Skip to content

Commit

Permalink
read zbest if redrock not found
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Sep 3, 2024
1 parent 5cc344c commit a6355e9
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions py/specprodDB/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,20 +295,31 @@ def load_redshift(tile, spgrp='cumulative'):
readonly=True, return_exists=True)
if redrock_exists:
redrock_files.append(redrock_file)
else:
zbest_file = redrock_file.replace('redrock', 'zbest')
if os.path.exists(zbest_file):
db.log.info('Using %s instead of %s.',
os.path.basename(zbest_file),
os.path.basename(redrock_file))
redrock_files.append(zbest_file)
if len(redrock_files) == 0:
db.log.warning("No %s redrock files found for tile %d!", spgrp, tile.tileid)
db.log.warning("No %s redrock or zbest files found for tile %d!", spgrp, tile.tileid)
return []
load_ztile = list()
for rr in redrock_files:
redrock_table, expfibermap = read_redrock(rr, group=spgrp,
recoadd_fibermap=True,
pertile=True)
assert (expfibermap['TILEID'] == tile.tileid).all()
firstnight = np.unique(expfibermap['NIGHT']).tolist()
assert len(firstnight) == 1
#
# In non-daily specprod, firstnight is a minimum over all petals.
# However here, we are doing a minimum over one petal.
# Compare the FIRSTNIGHT calculation in desispec.scripts.zcatalog.
#
firstnight = np.min(expfibermap['NIGHT']).tolist()
row_index = no_sky(redrock_table)
load_ztile += db.Ztile.convert(redrock_table, tile.survey, tile.program,
tile.tileid, firstnight[0],
tile.tileid, firstnight,
row_index=row_index)
if len(load_ztile) > 0:
db.dbSession.add_all(load_ztile)
Expand Down

0 comments on commit a6355e9

Please sign in to comment.