LSSTApplications  20.0.0
LSSTDataManagementBasePackage
Classes | Functions | Variables
lsst.obs.base._instrument Namespace Reference

Classes

class  Instrument
 

Functions

def makeExposureRecordFromObsInfo (obsInfo, universe)
 
def addUnboundedCalibrationLabel (registry, instrumentName)
 
Tuple[Camera, bool] loadCamera (Butler butler, DataId dataId, *Any collections=None)
 

Variables

dictionary StandardCuratedCalibrationDatasetTypes
 

Function Documentation

◆ addUnboundedCalibrationLabel()

def lsst.obs.base._instrument.addUnboundedCalibrationLabel (   registry,
  instrumentName 
)
Add a special 'unbounded' calibration_label dimension entry for the
given camera that is valid for any exposure.

If such an entry already exists, this function just returns a `DataId`
for the existing entry.

Parameters
----------
registry : `Registry`
    Registry object in which to insert the dimension entry.
instrumentName : `str`
    Name of the instrument this calibration label is associated with.

Returns
-------
dataId : `DataId`
    New or existing data ID for the unbounded calibration.

Definition at line 434 of file _instrument.py.

434 def addUnboundedCalibrationLabel(registry, instrumentName):
435  """Add a special 'unbounded' calibration_label dimension entry for the
436  given camera that is valid for any exposure.
437 
438  If such an entry already exists, this function just returns a `DataId`
439  for the existing entry.
440 
441  Parameters
442  ----------
443  registry : `Registry`
444  Registry object in which to insert the dimension entry.
445  instrumentName : `str`
446  Name of the instrument this calibration label is associated with.
447 
448  Returns
449  -------
450  dataId : `DataId`
451  New or existing data ID for the unbounded calibration.
452  """
453  d = dict(instrument=instrumentName, calibration_label="unbounded")
454  try:
455  return registry.expandDataId(d)
456  except LookupError:
457  pass
458  entry = d.copy()
459  entry["datetime_begin"] = TIMESPAN_MIN
460  entry["datetime_end"] = TIMESPAN_MAX
461  registry.insertDimensionData("calibration_label", entry)
462  return registry.expandDataId(d)
463 
464 

◆ loadCamera()

Tuple[Camera, bool] lsst.obs.base._instrument.loadCamera ( Butler  butler,
DataId  dataId,
*Any   collections = None 
)
Attempt to load versioned camera geometry from a butler, but fall back
to obtaining a nominal camera from the `Instrument` class if that fails.

Parameters
----------
butler : `lsst.daf.butler.Butler`
    Butler instance to attempt to query for and load a ``camera`` dataset
    from.
dataId : `dict` or `DataCoordinate`
    Data ID that identifies at least the ``instrument`` and ``exposure``
    dimensions.
collections : Any, optional
    Collections to be searched, overriding ``self.butler.collections``.
    Can be any of the types supported by the ``collections`` argument
    to butler construction.

Returns
-------
camera : `lsst.afw.cameraGeom.Camera`
    Camera object.
versioned : `bool`
    If `True`, the camera was obtained from the butler and should represent
    a versioned camera from a calibration repository.  If `False`, no
    camera datasets were found, and the returned camera was produced by
    instantiating the appropriate `Instrument` class and calling
    `Instrument.getCamera`.

Definition at line 465 of file _instrument.py.

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.
468 
469  Parameters
470  ----------
471  butler : `lsst.daf.butler.Butler`
472  Butler instance to attempt to query for and load a ``camera`` dataset
473  from.
474  dataId : `dict` or `DataCoordinate`
475  Data ID that identifies at least the ``instrument`` and ``exposure``
476  dimensions.
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.
481 
482  Returns
483  -------
484  camera : `lsst.afw.cameraGeom.Camera`
485  Camera object.
486  versioned : `bool`
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`.
492  """
493  if collections is None:
494  collections = butler.collections
495  # Registry would do data ID expansion internally if we didn't do it first,
496  # but we might want an expanded data ID ourselves later, so we do it here
497  # to ensure it only happens once.
498  # This will also catch problems with the data ID not having keys we need.
499  dataId = butler.registry.expandDataId(dataId, graph=butler.registry.dimensions["exposure"].graph)
500  cameraRefs = list(butler.registry.queryDatasets("camera", dataId=dataId, collections=collections,
501  deduplicate=True))
502  if cameraRefs:
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

◆ makeExposureRecordFromObsInfo()

def lsst.obs.base._instrument.makeExposureRecordFromObsInfo (   obsInfo,
  universe 
)
Construct an exposure DimensionRecord from
`astro_metadata_translator.ObservationInfo`.

Parameters
----------
obsInfo : `astro_metadata_translator.ObservationInfo`
    A `~astro_metadata_translator.ObservationInfo` object corresponding to
    the exposure.
universe : `DimensionUniverse`
    Set of all known dimensions.

Returns
-------
record : `DimensionRecord`
    A record containing exposure metadata, suitable for insertion into
    a `Registry`.

Definition at line 400 of file _instrument.py.

400 def makeExposureRecordFromObsInfo(obsInfo, universe):
401  """Construct an exposure DimensionRecord from
402  `astro_metadata_translator.ObservationInfo`.
403 
404  Parameters
405  ----------
406  obsInfo : `astro_metadata_translator.ObservationInfo`
407  A `~astro_metadata_translator.ObservationInfo` object corresponding to
408  the exposure.
409  universe : `DimensionUniverse`
410  Set of all known dimensions.
411 
412  Returns
413  -------
414  record : `DimensionRecord`
415  A record containing exposure metadata, suitable for insertion into
416  a `Registry`.
417  """
418  dimension = universe["exposure"]
419  return dimension.RecordClass.fromDict({
420  "instrument": obsInfo.instrument,
421  "id": obsInfo.exposure_id,
422  "name": obsInfo.observation_id,
423  "group_name": obsInfo.exposure_group,
424  "group_id": obsInfo.visit_id,
425  "datetime_begin": obsInfo.datetime_begin,
426  "datetime_end": obsInfo.datetime_end,
427  "exposure_time": obsInfo.exposure_time.to_value("s"),
428  "dark_time": obsInfo.dark_time.to_value("s"),
429  "observation_type": obsInfo.observation_type,
430  "physical_filter": obsInfo.physical_filter,
431  })
432 
433 

Variable Documentation

◆ StandardCuratedCalibrationDatasetTypes

dictionary lsst.obs.base._instrument.StandardCuratedCalibrationDatasetTypes
Initial value:
1 = {
2  "defects": {"dimensions": ("instrument", "detector", "calibration_label"),
3  "storageClass": "Defects"},
4  "qe_curve": {"dimensions": ("instrument", "detector", "calibration_label"),
5  "storageClass": "QECurve"},
6 }

Definition at line 41 of file _instrument.py.

lsst.obs.base._instrument.loadCamera
Tuple[Camera, bool] loadCamera(Butler butler, DataId dataId, *Any collections=None)
Definition: _instrument.py:465
lsst.obs.base._instrument.addUnboundedCalibrationLabel
def addUnboundedCalibrationLabel(registry, instrumentName)
Definition: _instrument.py:434
lsst.obs.base._instrument.makeExposureRecordFromObsInfo
def makeExposureRecordFromObsInfo(obsInfo, universe)
Definition: _instrument.py:400
list
daf::base::PropertyList * list
Definition: fits.cc:913