Skip to content

Commit

Permalink
Merge pull request #2384 from desihub/tiles-specstatus-compatibility
Browse files Browse the repository at this point in the history
specstatus compatibility fix
  • Loading branch information
sbailey authored Oct 9, 2024
2 parents d8630a4 + 513774a commit 6fc2673
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions bin/desi_tsnr_afterburner
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,6 @@ def main():
"EFFTIME_BRIGHT_GFA": efftime_bright,
"EFFTIME_BACKUP_GFA": efftime_backup}
goaltype = tsnr2_expid_table["GOALTYPE"][jj]
efftime_gfa = tsnr2_expid_table["GOALTYPE"][jj]
for col in efftime_columns:
if col not in tsnr2_expid_table.colnames:
tsnr2_expid_table[col] = np.zeros(len(tsnr2_expid_table), dtype=float)
Expand All @@ -1235,7 +1234,7 @@ def main():
else:
# tsnr2_expid_table["EFFTIME_GFA"][goaltype == "backup"] = tsnr2_expid_table["EFFTIME_BACKUP_GFA"][goaltype == "backup"]
efftime_gfa[goaltype == "backup"] = expid_values[goaltype == "backup"]
tsnr2_expid_table["GOALTYPE"][jj] = efftime_gfa
tsnr2_expid_table["EFFTIME_GFA"][jj] = efftime_gfa

gfa_nights = np.unique(np.array(gfa_nights))
#
Expand Down
2 changes: 2 additions & 0 deletions doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ Other
* Add "UPDATED" timestamp column to tiles file (PR `#2373`_).
* Support reading old zbest files (now redrock) (PR `#2374`_).
* Add script to update processing tabel column layout (PR `#2376`_).
* Fix column incompatibility in :func:`desispec.specstatus.update_specstatus` (PR `#2384`_).

.. _`#2365`: https://github.com/desihub/desispec/pull/2365
.. _`#2373`: https://github.com/desihub/desispec/pull/2373
.. _`#2374`: https://github.com/desihub/desispec/pull/2374
.. _`#2376`: https://github.com/desihub/desispec/pull/2376
.. _`#2377`: https://github.com/desihub/desispec/pull/2377
.. _`#2384`: https://github.com/desihub/desispec/pull/2384

0.66.3 (2024-09-13)
-------------------
Expand Down
8 changes: 8 additions & 0 deletions py/desispec/specstatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def update_specstatus(specstatus, tiles, update_only=False,
Args:
specstatus: astropy Table from surveyops/ops/tiles-specstatus.ecsv
tiles: astropy Table from spectro/redux/daily/tiles.csv
update_only: bool don't change entries for tiles that have no new data.
clear_qa: bool indicating whether QA data should be cleared
Returns: updated specstatus table, sorted by TILEID
Expand All @@ -44,6 +45,10 @@ def update_specstatus(specstatus, tiles, update_only=False,
if 'PROGRAM' in tiles.colnames:
tiles.remove_column('PROGRAM')

# Quick and dirty fix to keep the tiles file compatible with the specstatus file.
if 'UPDATED' in tiles.colnames:
tiles.remove_column('UPDATED')

#- Confirm that they have the same columns except QA-specific ones
tilecol = set(tiles.colnames) | set(['USER', 'QA', 'OVERRIDE', 'ZDONE', 'QANIGHT', 'ARCHIVEDATE'])
if tilecol != set(specstatus.colnames):
Expand Down Expand Up @@ -82,13 +87,16 @@ def update_specstatus(specstatus, tiles, update_only=False,
#- Note: there is probably a more efficient way of doing this in bulk,
#- but let's favor obvious over clever unless efficiency is needed
num_updatedtiles = 0
log.debug('Checking for differences between tiles file and specstatus file')
for i, tileid in enumerate(tiles['TILEID']):
j = np.where(specstatus['TILEID'] == tileid)[0][0]
if not update_only or tiles['LASTNIGHT'][i] > specstatus['LASTNIGHT'][j]:
different = False
for col in specstatus.colnames:
if col not in qacols:
if tiles[col][i] != specstatus[col][j]:
log.debug('Tile %d updating %s %s -> %s',
tileid, col, str(specstatus[col][j]), str(tiles[col][i]))
different = True
if not different and not clear_qa:
continue
Expand Down

0 comments on commit 6fc2673

Please sign in to comment.