Closed sbailey closed 7 years ago
code tested successfully (along with desispec branch cosmic_masking) on one cosmic ray spike (oak1 frame r0-00000006 fiber 413 wave 6519A). with new code, cosmic shows very large CHI2PIX value in frame, and is adequately flagged in MASK.
I defer to Julien's detailed testing on this...
These are good comments. I'm about to leave on vacation so I'm not going to try to fix them and merge in a rush and then disappear. Will wait for late August...
I added changes to address Julien's comments:
I updated the ipython notebook and re-tested the example shown in the original PR post (which still works fine...)
This PR adds several new outputs to the ex2d() spectral extractions:
These are provided as informational numbers that downstream steps could use for masking. A future specter improvement might use the pixel-level chi2 to identify and mask poorly fitting pixels (e.g. from cosmics) and then re-extract, potentially "saving" some flux bins that otherwise would have been lost as just bad extractions. But that iterative refit isn't included in this PR.
The ipython notebook in doc/nb/unmasked_cosmics.ipynb documents more details about how this works. The following figure shows an unmasked cosmic in the DESI oak simulations that was incorrectly identified as H-alpha; the upper plot shows the extracted spectrum and the wavelengths that would be masked by applying a cut on the PSF-weighted pixel-chi2.
Testing on the DESI oak-lite simulations (2 spectrographs, 3 exposures) using this with a conservative 10-sigma cut improved the ELG redshifts from 90% efficiency to 94%, and LRGs from 97% to 99%. Full disclosure: compared to oak (10 spectrographs, 9 exposures) the QSO efficiency went down, but the efficiencies were already so low (50-60%) something else is going on that needs to be debugged independent of this.
Ted and Julien: I had previously reported that this was blowing memory on edison batch jobs. That turned out to be a leftover of caching the results of every subpatch extraction for debugging. Removing that, the memory footprint is only modestly larger (1.5 vs. 1.4 GB).
I'll submit a PR on the desispec side to use these features.