Skip to content

Commit 73e2451

Browse files
authored
Merge pull request #318 from sot/limit-stat-update-range
Limit stat update range to end of AOPCADMD data
2 parents 67a794e + 0e5ae6c commit 73e2451

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

mica/stats/update_acq_stats.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,23 @@ def calc_acq_stats(manvr, vals, times):
469469

470470

471471
def _get_obsids_to_update(check_missing=False):
472+
# Use the end of AOPCADMD data as the end of the time range for kadi obsids
473+
_, aopcadmd_end_time = fetch.get_time_range("AOPCADMD")
474+
475+
# There's some duplication below in how stop time is applied, but in both
476+
# cases the the kadi obsids are filtered on the stop time of the obsid as less than or equal to
477+
# the end of AOPCADMD data as available from the CXC archive.
478+
#
479+
# Note that the obsid event interval is the full interval of constant obsid.
480+
# Obsid commanding is normally in the maneuver between observations.
481+
# And note that the normal stop kwarg is inclusive and includes intervals that intersect with
482+
# that stop time.
483+
472484
if check_missing:
473485
last_tstart = "2007:271:12:00:00"
474-
kadi_obsids = events.obsids.filter(start=last_tstart)
486+
kadi_obsids = events.obsids.filter(
487+
start=last_tstart, stop__lte=aopcadmd_end_time
488+
)
475489
with tables.open_file(table_file, "r") as h5:
476490
tbl_data = h5.root.data[:]
477491
# get all obsids that aren't already in tbl
@@ -483,7 +497,9 @@ def _get_obsids_to_update(check_missing=False):
483497
last_tstart = tbl.cols.guide_tstart[tbl.colindexes["guide_tstart"][-1]]
484498
except Exception:
485499
last_tstart = "2002:012:12:00:00"
486-
kadi_obsids = events.obsids.filter(start=last_tstart)
500+
kadi_obsids = events.obsids.filter(
501+
start=last_tstart, stop__lte=aopcadmd_end_time
502+
)
487503
# Skip the first obsid (as we already have it in the table)
488504
obsids = [o.obsid for o in kadi_obsids][1:]
489505
return obsids

mica/stats/update_guide_stats.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,24 @@ def calc_gui_stats(data):
400400

401401

402402
def _get_obsids_to_update(check_missing=False, table_file=None, start=None, stop=None):
403+
# Use the end of AOPCADMD data or a supplied stop time.
404+
_, aopcadmd_end_time = fetch.get_time_range("AOPCADMD")
405+
stop = stop if stop is not None else aopcadmd_end_time
406+
407+
# There's some duplication below in how stop time is applied, but in both
408+
# cases the the kadi obsids are filtered on the stop time of the obsid as less than or equal to
409+
# the stop time defined above (the supplied stop time or the end of cxc archive
410+
# AOPCADMD data). The kadi obsid events may be complete past the end of
411+
# the AOPCADMD data, especially if kadi events are updated using MAUDE data.
412+
#
413+
# Note that the obsid event interval is the full interval of constant obsid.
414+
# Obsid commanding is normally in the maneuver between observations.
415+
# And note that the normal stop kwarg is inclusive and includes intervals that intersect with
416+
# that stop time.
417+
403418
if check_missing:
404419
last_tstart = start if start is not None else "2007:271:12:00:00"
405-
kadi_obsids = events.obsids.filter(start=last_tstart)
420+
kadi_obsids = events.obsids.filter(start=last_tstart, stop__lte=stop)
406421
with tables.open_file(table_file, "r") as h5:
407422
tbl_data = h5.root.data[:]
408423
# get all obsids that aren't already in tbl
@@ -416,7 +431,7 @@ def _get_obsids_to_update(check_missing=False, table_file=None, start=None, stop
416431
]
417432
except Exception:
418433
last_tstart = start if start is not None else "2002:012:12:00:00"
419-
kadi_obsids = events.obsids.filter(start=last_tstart, stop=stop)
434+
kadi_obsids = events.obsids.filter(start=last_tstart, stop__lte=stop)
420435
# Skip the first obsid (as we already have it in the table)
421436
obsids = [o.obsid for o in kadi_obsids][1:]
422437
return obsids

0 commit comments

Comments
 (0)