desihub / redrock

Redshift fitting for spectroperfectionism
BSD 3-Clause "New" or "Revised" License
21 stars 13 forks source link

Default to a special template for ZWARN of NODATA cases #294

Closed geordie666 closed 2 months ago

geordie666 commented 2 months ago

This PR sets ZWARN of NODATA cases to a z=0, GALAXY with blank SUBTYPE and zero coefficients.

It should address #224.

Example output files processed via:

rrdesi -i /global/cfs/cdirs/desi/spectro/redux/daily/tiles/cumulative/3351/20230905/coadd-1-3351-thru20230905.fits --outfile $SCRATCH/new.fits --ntargets 15

are at:

/pscratch/sd/a/adamyers/old.fits (before this PR) /pscratch/sd/a/adamyers/new.fits (after this PR)

Test of the desired outcome:

import fitsio
a = fitsio.read("/pscratch/sd/a/adamyers/old.fits")
b = fitsio.read("/pscratch/sd/a/adamyers/new.fits")
print(a[[5, 14]][["ZWARN", "COEFF", "SPECTYPE", "SUBTYPE"]])
print(b[[5, 14]][["ZWARN", "COEFF", "SPECTYPE", "SUBTYPE"]])

[(516, [ 6.13320718e+01, -7.90512496e+01,  4.09394471e+01, -4.52058606e+01,  2.58237348e+00,  2.92976339e+00,  1.51155349e+01,  1.33815240e-01, -4.78952134e+00,  8.33736341e+00], 'GALAXY', '')
 (516, [-2.85894625e-02,  8.61347220e+02,  1.78825596e+00, -2.12392741e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00], 'QSO', 'LOZ')]
[(516, [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], 'GALAXY', '')
 (516, [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], 'GALAXY', '')]
geordie666 commented 2 months ago

This is still a work in progress while we determine whether we need more special-casing (as described in #224).

coveralls commented 2 months ago

Coverage Status

coverage: 38.547% (+0.2%) from 38.311% when pulling 0b43353234d1845580db4500d4d7d495ac6c97d3 on ADM-null-template into 1b9f888c226ca0b95538dbe232fd8b81d59a5361 on main.

sbailey commented 2 months ago

Thanks, looks good. I will merge this and close the issues, but we can re-open them and reconsider a custom NODATA template if we find ourselves still tripping on these.