desihub / fastspecfit

Fast spectral synthesis and emission-line fitting of DESI spectra.
https://fastspecfit.readthedocs.org
BSD 3-Clause "New" or "Revised" License
13 stars 2 forks source link

Line integrated flux is overestimated in dichroic regions #156

Closed ashodkh closed 9 months ago

ashodkh commented 10 months ago

The integrated fluxes for lines that are in the dichroic region (where two cameras overlap) are significantly overestimated for some reason. Here are examples for when Halpha is in that region (these plots are rest-frame).

Screenshot 2023-10-13 at 6 56 46 PM
moustakas commented 10 months ago

Thanks for the bug report @ashodkh. I'm pretty certain the problem is here, where I take the pixel size to be constant over the integration window rathan than taking into account that it varies where the cameras overlap: https://github.com/desihub/fastspecfit/blob/main/py/fastspecfit/emlines.py#L1139

stephjuneau commented 10 months ago

Following @ashodkh's bug report, I made some plots showing the running median of the line flux and of the line flux error (from FLUX_IVAR) as I was curious if all typical emission lines behaved the same way. This is is expected from @moustakas suspicion that this is due to pixel size is correct. However, I thought it could still be informative to look at the values to spot other trends.

Here are some results for SV3-bright (top plot) then for SV3-dark (bottom two). For the line fluxes, I apply S/N>3 and then take a running median with size=251. For the line flux errors, I apply S/N>1 instead. These figures could be adapted to show the line flux sensitivity. I'd be interested in a temporary fix such as scaling the line fluxes by the appropriate value (seems that a fixed factor would be a close approximation on average).

image

image image
moustakas commented 10 months ago

Thank you @stephjuneau. Are these spectra from Fuji or Iron?

stephjuneau commented 10 months ago

Thank you @stephjuneau. Are these spectra from Fuji or Iron?

Fuji

stephjuneau commented 10 months ago

@moustakas EDIT: Differences in the line fluxes are very small between Iron and Fuji (phew!)

image
moustakas commented 10 months ago

I have a tentative fix for this bug in #157.

moustakas commented 10 months ago

Here are the results for around 0.5M objects in sv3/{bright,dark,backup} with #157 (right-hand side) vs main (left-hand side). It looks like there still might be some issues with the two fainter lines I'm highlighting ([NII] 6584 and [NeIII] 3869), although for [NeIII] it may just be a statistical fluctuation and for [NII] it may be related to the difficulty of deblending the line from Halpha in the (noisier) dichroic region.

Note that the dichroic wavelength overlaps I'm drawing here are [5760, 5800] and [7520, 7620], which are the actual extraction wavelengths (and much narrower than in Abareshi+22 or Guy+23, both of which list the instrument design wavelengths).

Regardless, it's clear that I've fixed the primary problem, but @ashodkh @stephjuneau please let me know how you'd like to proceed.

image

ashodkh commented 10 months ago

Thanks for the quick fix @moustakas. There's no urgency on my end, so please proceed as you see fit.

stephjuneau commented 10 months ago

The fixed results look good! Timing wise, I'm using Fuji-SV3 (brignt+dark) for the BGS AGN paper, which is almost complete as a draft but it still needs to go through the collaboration review + refereeing process. Raga's paper is based on Fuji+Guadalupe and it still needs a bit more work. I'm not sure what the best solution is but if there is a way to deal with Fuji first, it could be useful. For the moment, I applied an approximate correction to the values I'm using to get the results "close enough" for the purpose of writing the text of the paper. Q: does the fix just affect a small fraction of galaxies or would you need to re-run everything?

moustakas commented 10 months ago

Refitting all of Fuji takes about 2 hours, which I'd like to do since this really was a silly bug. The only question is: are there any other issues that we should fix before generating a v3.1 VAC?