smooth continuum is drastically changing flux in some cases
Closed this issue · 4 comments
I noticed that for some spectra the smooth continuum is drastically changing the flux (incorrectly) in some cases. This seems to be around H alpha but I haven't checked. As an example, https://fastspecfit.desi.lbl.gov/target/sv3-bright-26272-39627751547735909?index=1
This is the same spectrum without the smooth continuum:
another example:
https://fastspecfit.desi.lbl.gov/target/sv3-bright-26965-39627781696392988?index=1
Thanks for the ticket @ashodkh. The smooth continuum is critical for getting good line-flux measurements, especially in the presence of broad-line emission. However, in the two examples you've highlighted, it's clear that the code isn't behaving as expected.
I'll play around with the algorithm. One idea is to switch to this new "smooth spline" implementation in scipy
, but please let me know if you have any other thoughts:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.make_smoothing_spline.html
@ashodkh I took a look at this ticket to see if there was a quick fix that wouldn't break other parts of the line-fitting (particularly the broad-line modeling).
I still think this is an important area of improvement, but in the meantime I (in a branch):
- Increased the smoothing window width from 50 to 75 pixels;
- Increased the sliding window width from 10 to 25 pixels;
- Interpolate over line-masked pixels using a first-order B-spline rather than linear interpolation (which is why
39627751547735909
got messed up); - Increased the final median-smoothing kernel from 150 to 175 pixels.
- Mask the first and last (typically noisy) 10 pixels of the per-camera spectra (which is why
39627781696392988
was messed up).
In general, these changes reduce the high-frequency smooth-continuum corrections while still being able to adapt to (low-frequency) calibration errors and spectra which are not well-fit by SPS models (i.e.g, most QSO spectra).
With these changes, here's the fit to 39627751547735909
with main
and with my branch, respectively (note especially the region around Halpha). There's still lots of (statistically insignificant) funny business in the blue part of the spectrum, but the interpolation across the Ha+[NII] complex is much better behaved.
Here's 39627781696392988
(before and after---note the very noisy NIR camera; it's not perfect but arguably not wrong due to a low-level mis-calibration of the camera edges, especially around [SII]).
And here's one of @Ragadeepika-Pucha's low-mass AGN, as a null test to make sure that things are still reasonably well-behaved:
And finally one of @VFawcett's totally crazy red quasars. This fit was never good, but at least the code doesn't crash!
If you're happy with these changes I'll get them merged in.
@moustakas These look great! Thank you!