pythonastropyspectra

How to divide two data sets (spectra) with different sizes?


Spectrum_3 = Spectrum_1/Spectrum_2, but they have different sizes. How could I proceed? Since I am dealing with spectra, my approach is to decrease the resolution of Spectrum_1 so that the data size matches (if you come from Astrophysics is this a correct approach?). Anyhow, I (think I) need to bin the data from Spectrum_1 in such a way that the size of it matches the size of Spectrum_2.

arr1.size is 313136
synth_spec2.size is 102888
arr1_new = arr1.reshape(-1,2).mean(axis=1) # should be the answer but 
# I don`t fully understand it. 

I need

len(arr1_new) == len(synth_spec2) #True

Solution

  • Generally you need to interpolate the two spectra onto a common wavelength grid, paying careful attention to the ends of the spectra if they don't overlap fully. I would suggest having looking at the synphot package and in particular the SourceSpectrum classes. Despite the name, it has support for a variety of spectra as synthetic photometry is normally done by assembling a suitable source spectrum, applying reddening/extinction etc to it and then multiplying by a filter bandpasses (which is also spectrum-like, being transmission against wavelength) and integrating to derive a flux.