Skip to content

Commit

Permalink
add workaround for zbest files
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Sep 3, 2024
1 parent 33d11ac commit f54fdbc
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions py/desispec/scripts/zcatalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,14 @@ def read_redrock(rrfile, group=None, recoadd_fibermap=False, minimal=False, pert
log.warning("Skipping {} with SPGRP {} != group {}".format(
rrfile, hdr['SPGRP'], group))
return None

redshifts = fx['REDSHIFTS'].read()
try:
redshifts = fx['REDSHIFTS'].read()
except IOError:
#
# zbest files do not have an EXP_FIBERMAP HDU, so force a recoadd.
#
redshifts = fx['ZBEST'].read()
recoadd_fibermap = True

if recoadd_fibermap:
spectra_filename = checkgzip(replace_prefix(rrfile, 'redrock', 'spectra'))
Expand All @@ -132,7 +138,14 @@ def read_redrock(rrfile, group=None, recoadd_fibermap=False, minimal=False, pert
fibermap = Table(fx['FIBERMAP'].read())
expfibermap = fx['EXP_FIBERMAP'].read()

tsnr2 = fx['TSNR2'].read()
try:
tsnr2 = fx['TSNR2'].read()
except IOError:
#
# zbest files do not have a TSNR2 HDU. For now just skip.
#
tsnr2 = None

assert np.all(redshifts['TARGETID'] == fibermap['TARGETID'])
assert np.all(redshifts['TARGETID'] == tsnr2['TARGETID'])

Expand Down

0 comments on commit f54fdbc

Please sign in to comment.