Skip to content

Commit

Permalink
Adapt to upstream API changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
TallJimbo committed Nov 20, 2023
1 parent c2a5f67 commit 479a661
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
6 changes: 3 additions & 3 deletions python/lsst/obs/base/_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ class attribute for curated calibrations corresponding to the
# by putting them in the ``runs`` set that was passed in.
camera = self.getCamera()
filters = set(self.filterDefinitions.physical_to_band.keys())
calib_dimensions: list[Any]
calib_dimensions: list[str]
if datasetType.name in StandardCuratedCalibrationDatasetTypes:
calib_dimensions = list(StandardCuratedCalibrationDatasetTypes[datasetType.name]["dimensions"])
else:
Expand All @@ -503,7 +503,7 @@ class attribute for curated calibrations corresponding to the
"Unknown curated calibration type %s. Attempting to use supplied definition.",
datasetType.name,
)
calib_dimensions = list(datasetType.dimensions)
calib_dimensions = list(datasetType.dimensions.names)

calibsDict, calib_type = read_all(calibPath, camera, calib_class, calib_dimensions, filters)

Expand Down Expand Up @@ -667,7 +667,7 @@ def loadCamera(butler: Butler, dataId: DataId, *, collections: Any = None) -> tu
# to ensure it only happens once.
# This will also catch problems with the data ID not having keys we need.
try:
dataId = butler.registry.expandDataId(dataId, graph=butler.dimensions["exposure"].graph)
dataId = butler.registry.expandDataId(dataId, dimensions=butler.dimensions["exposure"].minimal_group)
except DataIdError as exc:
raise LookupError(str(exc)) from exc
try:
Expand Down
14 changes: 3 additions & 11 deletions python/lsst/obs/base/defineVisits.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,7 @@

import lsst.geom
from lsst.afw.cameraGeom import FOCAL_PLANE, PIXELS
from lsst.daf.butler import (
Butler,
DataCoordinate,
DataId,
DimensionGraph,
DimensionRecord,
Progress,
Timespan,
)
from lsst.daf.butler import Butler, DataCoordinate, DataId, DimensionRecord, Progress, Timespan
from lsst.geom import Box2D
from lsst.pex.config import Config, Field, makeRegistry, registerConfigurable
from lsst.pipe.base import Instrument, Task
Expand Down Expand Up @@ -664,9 +656,9 @@ def run(
"""
# Normalize, expand, and deduplicate data IDs.
self.log.info("Preprocessing data IDs.")
dimensions = DimensionGraph(self.universe, names=["exposure"])
dimensions = self.universe.conform(["exposure"])
data_id_set: set[DataCoordinate] = {
self.butler.registry.expandDataId(d, graph=dimensions) for d in dataIds
self.butler.registry.expandDataId(d, dimensions=dimensions) for d in dataIds
}
if not data_id_set:
raise RuntimeError("No exposures given.")
Expand Down
10 changes: 5 additions & 5 deletions python/lsst/obs/base/formatters/fitsExposure.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def getImageCompressionSettings(self, recipeName):
recipe = self.writeRecipes[recipeName]

# Set the seed based on dataId
seed = hash(tuple(self.dataId.items())) % 2**31
seed = hash(tuple(self.dataId.required.items())) % 2**31
for plane in ("image", "mask", "variance"):
if plane in recipe and "scaling" in recipe[plane]:
scaling = recipe[plane]["scaling"]
Expand Down Expand Up @@ -599,20 +599,20 @@ def _fixFilterLabels(self, file_filter_label, should_be_standardized=None):
missing = []
band = None
physical_filter = None
if "band" in self.dataId.graph.dimensions.names:
if "band" in self.dataId.dimensions.names:
band = self.dataId.get("band")
# band isn't in the data ID; is that just because this data ID
# hasn't been filled in with everything the Registry knows, or
# because this dataset is never associated with a band?
if band is None and not self.dataId.hasFull() and "band" in self.dataId.graph.implied.names:
if band is None and not self.dataId.hasFull() and "band" in self.dataId.dimensions.implied:
missing.append("band")
if "physical_filter" in self.dataId.graph.dimensions.names:
if "physical_filter" in self.dataId.dimensions.names:
physical_filter = self.dataId.get("physical_filter")
# Same check as above for band, but for physical_filter.
if (
physical_filter is None
and not self.dataId.hasFull()
and "physical_filter" in self.dataId.graph.implied.names
and "physical_filter" in self.dataId.dimensions.implied
):
missing.append("physical_filter")
if should_be_standardized is None:
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/obs/base/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,8 @@ def expandDataIds(self, data: RawExposureData) -> RawExposureData:
for file in data.files:
for dataset in file.datasets:
dataset.dataId = self.butler.registry.expandDataId(
dataset.dataId, records=data.dataId.records
dataset.dataId,
records={k: data.dataId.records[k] for k in data.dataId.dimensions.elements},
)
return data

Expand Down

0 comments on commit 479a661

Please sign in to comment.