Skip to content

Commit

Permalink
Merge pull request #318 from lsst/tickets/DM-27321
Browse files Browse the repository at this point in the history
DM-27321: Add day_obs and seq_num to exposure record
  • Loading branch information
timj committed Nov 2, 2020
2 parents 0c7b7f8 + 3214404 commit 8e8467f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion python/lsst/obs/base/_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ def makeExposureRecordFromObsInfo(obsInfo, universe):
return dimension.RecordClass(
instrument=obsInfo.instrument,
id=obsInfo.exposure_id,
name=obsInfo.observation_id,
obs_id=obsInfo.observation_id,
group_name=obsInfo.exposure_group,
group_id=obsInfo.visit_id,
datetime_begin=obsInfo.datetime_begin,
Expand All @@ -742,6 +742,8 @@ def makeExposureRecordFromObsInfo(obsInfo, universe):
dark_time=obsInfo.dark_time.to_value("s") if obsInfo.dark_time is not None else None,
observation_type=obsInfo.observation_type,
observation_reason=obsInfo.observation_reason,
day_obs=obsInfo.observing_day,
seq_num=obsInfo.observation_counter,
physical_filter=obsInfo.physical_filter,
science_program=obsInfo.science_program,
target_name=obsInfo.object,
Expand Down
7 changes: 6 additions & 1 deletion python/lsst/obs/base/defineVisits.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ def _buildVisitRecords(self, definition: VisitDefinitionData, *,
(e.target_name for e in definition.exposures))
science_program = _reduceOrNone(lambda a, b: a if a == b else None,
(e.science_program for e in definition.exposures))

# observing day for a visit is defined by the earliest observation
# of the visit
observing_day = _reduceOrNone(min, (e.day_obs for e in definition.exposures))
observation_reason = _reduceOrNone(lambda a, b: a if a == b else None,
(e.observation_reason for e in definition.exposures))
if observation_reason is None:
Expand All @@ -393,6 +397,7 @@ def _buildVisitRecords(self, definition: VisitDefinitionData, *,
target_name=target_name,
science_program=science_program,
observation_reason=observation_reason,
day_obs=observing_day,
zenith_angle=zenith_angle,
visit_system=self.groupExposures.getVisitSystem()[0],
exposure_time=exposure_time,
Expand Down Expand Up @@ -594,7 +599,7 @@ def group(self, exposures: List[DimensionRecord]) -> Iterable[VisitDefinitionDat
yield VisitDefinitionData(
instrument=exposure.instrument,
id=exposure.id,
name=exposure.name,
name=exposure.obs_id,
exposures=[exposure],
)

Expand Down
6 changes: 3 additions & 3 deletions python/lsst/obs/base/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,14 +536,14 @@ def run(self, files, *, pool: Optional[Pool] = None, processes: int = 1, run: Op

self.log.debug("Attempting to ingest %d file%s from exposure %s:%s",
len(exposure.files), "" if len(exposure.files) == 1 else "s",
exposure.record.instrument, exposure.record.name)
exposure.record.instrument, exposure.record.obs_id)

try:
self.butler.registry.syncDimensionData("exposure", exposure.record)
except Exception as e:
n_exposures_failed += 1
self.log.warning("Exposure %s:%s could not be registered: %s",
exposure.record.instrument, exposure.record.name, e)
exposure.record.instrument, exposure.record.obs_id, e)
continue

# Override default run if nothing specified explicitly
Expand All @@ -568,7 +568,7 @@ def run(self, files, *, pool: Optional[Pool] = None, processes: int = 1, run: Op
# Success for this exposure
n_exposures += 1
self.log.info("Exposure %s:%s ingested successfully",
exposure.record.instrument, exposure.record.name)
exposure.record.instrument, exposure.record.obs_id)

had_failure = False

Expand Down

0 comments on commit 8e8467f

Please sign in to comment.