465 def loadCamera(butler: Butler, dataId: DataId, *, collections: Any =
None) -> Tuple[Camera, bool]:
466 """Attempt to load versioned camera geometry from a butler, but fall back
467 to obtaining a nominal camera from the `Instrument` class if that fails.
471 butler : `lsst.daf.butler.Butler`
472 Butler instance to attempt to query for and load a ``camera`` dataset
474 dataId : `dict` or `DataCoordinate`
475 Data ID that identifies at least the ``instrument`` and ``exposure``
477 collections : Any, optional
478 Collections to be searched, overriding ``self.butler.collections``.
479 Can be any of the types supported by the ``collections`` argument
480 to butler construction.
484 camera : `lsst.afw.cameraGeom.Camera`
487 If `True`, the camera was obtained from the butler and should represent
488 a versioned camera from a calibration repository. If `False`, no
489 camera datasets were found, and the returned camera was produced by
490 instantiating the appropriate `Instrument` class and calling
491 `Instrument.getCamera`.
493 if collections
is None:
494 collections = butler.collections
499 dataId = butler.registry.expandDataId(dataId, graph=butler.registry.dimensions[
"exposure"].graph)
500 cameraRefs =
list(butler.registry.queryDatasets(
"camera", dataId=dataId, collections=collections,
503 assert len(cameraRefs) == 1,
"Should be guaranteed by deduplicate=True above."
504 return butler.getDirect(cameraRefs[0]),
True
505 instrument = Instrument.fromName(dataId[
"instrument"], butler.registry)
506 return instrument.getCamera(),
False