0
wavelength_one=target[60].wavelength.value
flux_one=target[60].flux.value


wavelength_two=target[61].wavelength.value
flux_two=target[61].flux.value

f,ax=plt.subplots(figsize=(15,10))
ax.plot(wavelength_one,flux_one,color='green')
ax.plot(wavelength_two,flux_two,color='black')
ax.grid(True)

the plot

I have the following code that plots two spectrum with wavelength as the x-axis and flux as the y-axis. I want to find the first point of intersection between these graphs. How would I be able to find the index for the flux value where they intersect for the first time? The flux values are in a numpy array. I want to find the index of the first overlapping flux value and the corresponding wavelength associated with the intersection.

user14676394
  • 39
  • 1
  • 4

1 Answers1

0

You can try this code snippet:

from math import isclose
For i in range(len(flux_one)):
   if flux_one[i] == flux_two[i] and isclose(wavelength_one, wavelength_two):
      print(flux_one[i], flux_two[i]) 
SuperStar518
  • 2,814
  • 2
  • 20
  • 35