Skip to content

Commit b4bc485

Browse files
committed
Simplify dayobs handling
1 parent 3c2fa4b commit b4bc485

1 file changed

Lines changed: 7 additions & 17 deletions

File tree

rubin_sim/maf/chimera_progress.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,20 @@
2222
from rubin_sim.maf.stackers.date_stackers import DayObsStacker
2323
from rubin_sim.maf.utils.opsim_utils import get_sim_data
2424

25-
# ---------------------------------------------------------------------------
26-
# DayObs helpers
27-
# DayObs is an integer YYYYMMDD in UTC-12, so it doesn't roll over mid-night.
28-
# ---------------------------------------------------------------------------
29-
30-
31-
def _dayobs_to_date(dayobs: int) -> datetime.date:
32-
"""Convert an integer YYYYMMDD dayobs to a datetime.date."""
33-
s = f"{int(dayobs):08d}"
34-
return datetime.date(int(s[:4]), int(s[4:6]), int(s[6:]))
35-
36-
37-
def _date_to_dayobs(d: datetime.date) -> int:
38-
"""Convert a datetime.date to an integer YYYYMMDD dayobs."""
39-
return int(d.strftime("%Y%m%d"))
40-
4125

4226
def _dayobs_range(start_dayobs: int, end_dayobs: int, step: int = 1) -> list[int]:
4327
"""Return a list of integer dayobs values from start to end (inclusive)."""
28+
29+
def _dayobs_to_date(dayobs: int) -> datetime.date:
30+
s = f"{int(dayobs):08d}"
31+
return datetime.date(int(s[:4]), int(s[4:6]), int(s[6:]))
32+
4433
current = _dayobs_to_date(start_dayobs)
4534
end_date = _dayobs_to_date(end_dayobs)
4635
result = []
4736
while current <= end_date:
48-
result.append(_date_to_dayobs(current))
37+
dayobs = int(current.strftime("%Y%m%d"))
38+
result.append(dayobs)
4939
current += datetime.timedelta(days=step)
5040
return result
5141

0 commit comments

Comments
 (0)