I tried to coadd two 1d spectra that partially overlap. The resulted spectrum had a twice bigger error at wavelengths for which only one spectrum has data.
Here is one simple example for which I do not get accurate results:
from pypeit.core import coadd as coadd
from linetools.spectra import utils as ltsu
from linetools.spectra.xspectrum1d import XSpectrum1D
import numpy as np
from astropy import units as u
wa = np.asarray(np.arange(3000, 7000.1, 100))
fl = np.ones_like(wa)
sig = np.ones_like(fl) 0.1
sp00 = XSpectrum1D.from_tuple((wau.AA, fl, sig), verbose=False)
wa = np.asarray(np.arange(5000, 9000.1, 100)) +50.
fl = np.ones_like(wa)
sig = np.ones_like(fl) 0.2
sp01 = XSpectrum1D.from_tuple((wau.AA, fl, sig), verbose=False)
spects = np.asarray([sp01,sp00,sp01])
spects = np.asarray([sp01,sp00]) # also not accurate results, but in a different way
Output: coaddsp has an error in flux 0.25394154 at wavelengths < ~5000, however, the only available data at these wavelengths are in sp00, with the error in flux 0.1.
If, instead of 0.2, the errors in the flux in sp01 are 10, the results are 0.1, which is accurate.
Happy to try to debug it, however it would be helpful if someone already has some ideas why this is happening, and/or how we could address it. Maybe @feigewang ?
I tried to coadd two 1d spectra that partially overlap. The resulted spectrum had a twice bigger error at wavelengths for which only one spectrum has data. Here is one simple example for which I do not get accurate results:
from pypeit.core import coadd as coadd from linetools.spectra import utils as ltsu from linetools.spectra.xspectrum1d import XSpectrum1D import numpy as np from astropy import units as u
wa = np.asarray(np.arange(3000, 7000.1, 100)) fl = np.ones_like(wa) sig = np.ones_like(fl) 0.1 sp00 = XSpectrum1D.from_tuple((wau.AA, fl, sig), verbose=False)
wa = np.asarray(np.arange(5000, 9000.1, 100)) +50. fl = np.ones_like(wa) sig = np.ones_like(fl) 0.2 sp01 = XSpectrum1D.from_tuple((wau.AA, fl, sig), verbose=False)
spects = np.asarray([sp01,sp00,sp01])
spects = np.asarray([sp01,sp00]) # also not accurate results, but in a different way
mspec = ltsu.collate(spects) coaddsp = coadd.coadd_spectra(mspec)
Output: coaddsp has an error in flux 0.25394154 at wavelengths < ~5000, however, the only available data at these wavelengths are in sp00, with the error in flux 0.1.
If, instead of 0.2, the errors in the flux in sp01 are 10, the results are 0.1, which is accurate.
Happy to try to debug it, however it would be helpful if someone already has some ideas why this is happening, and/or how we could address it. Maybe @feigewang ?