Skip to content

Commit

Permalink
Merge pull request #761 from desihub/ADM-ToO-time
Browse files Browse the repository at this point in the history
Add a TIMESTAMP to the Main Survey Target of Opportunity Ledgers
  • Loading branch information
geordie666 committed Aug 10, 2021
2 parents 015a3e1 + 9fe2719 commit 1903180
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ desitarget Change Log
1.2.3 (unreleased)
------------------

* No changes yet.
* Add a ``TIMESTAMP`` to the Main Survey ToO Ledgers [`PR #761`_].

.. _`PR #761`: https://github.com/desihub/desitarget/pull/761

1.2.2 (2021-07-08)
------------------
Expand Down
15 changes: 14 additions & 1 deletion py/desitarget/ToO.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from desiutil.log import get_logger

from desitarget import io
from desitarget.mtl import get_utc_date
# ADM the data model for ToO, similar to that of secondary targets...
from desitarget.secondary import indatamodel
from desitarget.secondary import outdatamodel
Expand All @@ -29,6 +30,8 @@
('CHECKER', '>U7'), ('TOO_TYPE', '>U5'),
('TOO_PRIO', '>U2'), ('OCLAYER', '>U6'),
('MJD_BEGIN', '>f8'), ('MJD_END', '>f8'), ('TOOID', '>i4')])
# ADM columns to only include in the output for Main Survey files.
msaddcols = np.array([], dtype=[('TIMESTAMP', 'U25')])

# ADM when using basic or csv ascii writes, specifying the formats of
# ADM float32 columns can make things easier on the eye.
Expand Down Expand Up @@ -400,8 +403,13 @@ def finalize_too(inledger, survey="main"):
A Table of targets generated from the ToO ledger, with the
necessary columns added for fiberassign to run.
"""
# ADM add extra columns that are just for the Main Survey.
dt = outdatamodel.dtype.descr
if survey == 'main':
dt += msaddcols.dtype.descr

# ADM create the output data table.
outdata = Table(np.zeros(len(inledger), dtype=outdatamodel.dtype))
outdata = Table(np.zeros(len(inledger), dtype=dt))
# ADM change column names to reflect the survey.
if survey[:2] == "sv":
bitcols = [col for col in outdata.dtype.names if "_TARGET" in col]
Expand Down Expand Up @@ -448,6 +456,11 @@ def finalize_too(inledger, survey="main"):
np.random.seed(616)
outdata["SUBPRIORITY"] = np.random.random(ntoo)

# ADM finally, add a processing timestamp.
# ADM I only remembered to do this starting with the Main Survey.
if survey == 'main':
outdata["TIMESTAMP"] = get_utc_date(survey="main")

return outdata


Expand Down

0 comments on commit 1903180

Please sign in to comment.