Skip to content

Commit

Permalink
Use astropy.time instead of datetime in day_obs calculation.
Browse files Browse the repository at this point in the history
For consistency with the observing day_obs, the value is defined based
on the TAI-12 date of processing start, not the UTC-12 date.
  • Loading branch information
kfindeisen committed Jan 26, 2024
1 parent 4f840cb commit 76ae49c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions python/activator/middleware_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
__all__ = ["get_central_butler", "make_local_repo", "MiddlewareInterface"]

import collections.abc
import datetime
import hashlib
import itertools
import logging
Expand Down Expand Up @@ -128,8 +127,8 @@ def make_local_repo(local_storage: str, central_butler: Butler, instrument: str)
return repo_dir


# Time zone used to define exposures' day_obs value.
_DAY_OBS_TZ = datetime.timezone(datetime.timedelta(hours=-12), name="day_obs")
# Offset used to define exposures' day_obs value.
_DAY_OBS_DELTA = astropy.time.TimeDelta(-12.0 * astropy.units.hour, scale="tai")


class MiddlewareInterface:
Expand Down Expand Up @@ -221,7 +220,7 @@ def __init__(self, central_butler: Butler, image_bucket: str, visit: FannedOutVi
self.instrument = lsst.obs.base.Instrument.from_string(visit.instrument, central_butler.registry)
self.pipelines = pipelines

self._day_obs = datetime.datetime.now(_DAY_OBS_TZ).strftime("%Y-%m-%d")
self._day_obs = (astropy.time.Time.now() + _DAY_OBS_DELTA).tai.to_value("iso", "date")

self._init_local_butler(local_repo, [self.instrument.makeUmbrellaCollectionName()], None)
self._prep_collections()
Expand Down

0 comments on commit 76ae49c

Please sign in to comment.