From 5ed898fb0737c36d833a6a58405bb06a9f8cbb64 Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Wed, 11 Sep 2024 17:13:27 -0700 Subject: [PATCH] fill missing zbest columns with zero --- py/desispec/scripts/zcatalog.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/py/desispec/scripts/zcatalog.py b/py/desispec/scripts/zcatalog.py index 0de2274a7..f1278398d 100755 --- a/py/desispec/scripts/zcatalog.py +++ b/py/desispec/scripts/zcatalog.py @@ -141,6 +141,9 @@ def read_redrock(rrfile, group=None, recoadd_fibermap=False, minimal=False, pert fibermap, expfibermap = coadd_fibermap(fibermap_orig, onetile=pertile) if zbest_file: fibermap.sort(['TARGETID']) + if 'MEAN_PSF_TO_FIBER_SPECFLUX' not in fibermap.colnames: + log.warning("Adding missing column MEAN_PSF_TO_FIBER_SPECFLUX to fibermap with dummy values.") + fibermap['MEAN_PSF_TO_FIBER_SPECFLUX'] = np.zeros((len(fibermap), ), dtype=np.float32) else: fibermap = Table(fx['FIBERMAP'].read()) expfibermap = fx['EXP_FIBERMAP'].read() @@ -167,6 +170,18 @@ def read_redrock(rrfile, group=None, recoadd_fibermap=False, minimal=False, pert if tsnr2 is not None: assert np.all(redshifts['TARGETID'] == tsnr2['TARGETID']) + # + # Fill missing columns with dummy values. + # + for band in ('B', 'R', 'Z', ''): + for targ in ('ELG', 'GPBBACKUP', 'GPBBRIGHT', 'GPBDARK', 'LYA', 'BGS', 'QSO', 'LRG'): + if band: + colname = f'TSNR2_{targ}_{band}' + else: + colname = f'TSNR2_{targ}' + if colname not in tsnr2.colnames: + log.warning("TSNR2 table is missing %s, filling with dummy values.", colname) + tsnr2[colname] = np.zeros((len(tsnr2), ), dtype=np.float32) if minimal: # basic set of target information