Skip to content

Commit

Permalink
Add timespan calculation for day_obs on ingest
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Feb 15, 2024
1 parent 2dcdcfc commit a2f1a5f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions python/lsst/obs/base/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
FileDataset,
Formatter,
Progress,
Timespan,
)
from lsst.pex.config import ChoiceField, Config, Field
from lsst.pipe.base import Instrument, Task
Expand Down Expand Up @@ -306,6 +307,12 @@ def __init__(
# have all the relevant metadata translators loaded.
Instrument.importAll(self.butler.registry)

# Read all the instrument records into a cache since they will be
# needed later to calculate day_obs timespans, if appropriate.
self._instrument_records = {
rec.name: rec for rec in butler.registry.queryDimensionRecords("instrument")
}

def _reduce_kwargs(self) -> dict[str, Any]:
# Add extra parameters to pickle.
return dict(
Expand Down Expand Up @@ -856,9 +863,12 @@ def makeDependencyRecords(
instrument=obsInfo.instrument,
)
if "day_obs" in exposure.implied:
instrument_record = self._instrument_records[obsInfo.instrument]
offset = instrument_record.day_obs_offset
records["day_obs"] = universe["day_obs"].RecordClass(
instrument=obsInfo.instrument,
id=obsInfo.observing_day,
timespan=Timespan.from_day_obs(obsInfo.observing_day, offset),
)
return records

Expand Down
3 changes: 3 additions & 0 deletions python/lsst/obs/base/instrument_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ def register(self, registry, update=False):
"visit_max": 1_000_000,
"exposure_max": 1_000_000,
}
if "day_obs_offset" in registry.dimensions["instrument"].metadata:
dataId["day_obs_offset"] = self.day_obs_offset

with registry.transaction():
registry.syncDimensionData("instrument", dataId, update=update)
self._registerFilters(registry, update=update)
Expand Down

0 comments on commit a2f1a5f

Please sign in to comment.