Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-27350: Define mandatory properties for ObservationInfo #320

Merged
merged 2 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion python/lsst/obs/base/_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,8 @@ def makeExposureRecordFromObsInfo(obsInfo, universe):
datetime_begin=obsInfo.datetime_begin,
datetime_end=obsInfo.datetime_end,
exposure_time=obsInfo.exposure_time.to_value("s"),
dark_time=obsInfo.dark_time.to_value("s"),
# we are not mandating that dark_time be calculable
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,
physical_filter=obsInfo.physical_filter,
Expand Down
33 changes: 32 additions & 1 deletion python/lsst/obs/base/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,38 @@ def _calculate_dataset_info(self, header, filename):
The dataId, and observation information associated with this
dataset.
"""
obsInfo = ObservationInfo(header)
# To ensure we aren't slowed down for no reason, explicitly
# list here the properties we need for the schema
# Use a dict with values a boolean where True indicates
# that it is required that we calculate this property.
ingest_subset = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this using a dict just for its hashing? Would a set work instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A set is what we need in the end but I use a dict here so that I can specify the required keys here once without having to have a separate list of the properties to calculate and the required properties. You see a few lines below that I convert this dict into two sets for the ObservationInfo constructor.

"altaz_begin": False,
"boresight_rotation_coord": False,
"boresight_rotation_angle": False,
"dark_time": False,
"datetime_begin": True,
"datetime_end": True,
"detector_num": True,
"exposure_group": False,
"exposure_id": True,
"exposure_time": True,
"instrument": True,
"tracking_radec": False,
"object": False,
"observation_counter": False,
"observation_id": True,
"observation_reason": False,
"observation_type": True,
"observing_day": False,
"physical_filter": True,
"science_program": False,
"visit_id": False,
}

obsInfo = ObservationInfo(header, pedantic=False,
required={k for k in ingest_subset if ingest_subset[k]},
subset=set(ingest_subset))

dataId = DataCoordinate.standardize(instrument=obsInfo.instrument,
exposure=obsInfo.exposure_id,
detector=obsInfo.detector_num,
Expand Down