LSSTApplications  19.0.0-10-g920eed2,19.0.0-11-g48a0200+2,19.0.0-18-gfc4e62b+11,19.0.0-2-g3b2f90d+2,19.0.0-2-gd671419+5,19.0.0-20-g5a5a17ab+9,19.0.0-21-g2644856+11,19.0.0-22-gc5dc5b1+6,19.0.0-23-gdc29a50+3,19.0.0-24-g923e380+11,19.0.0-25-g6c8df7140,19.0.0-28-g9b887e2,19.0.0-3-g2b32d65+5,19.0.0-3-g8227491+10,19.0.0-3-g9c54d0d+10,19.0.0-3-gca68e65+6,19.0.0-3-gcfc5f51+5,19.0.0-3-ge110943+9,19.0.0-3-ge74d124,19.0.0-3-gfe04aa6+11,19.0.0-4-g06f5963+5,19.0.0-4-g3d16501+11,19.0.0-4-g4a9c019+5,19.0.0-4-g5a8b323,19.0.0-4-g66397f0+1,19.0.0-4-g8278b9b+1,19.0.0-4-g8557e14,19.0.0-4-g8964aba+11,19.0.0-4-ge404a01+10,19.0.0-5-g40f3a5a,19.0.0-5-g4db63b3,19.0.0-5-gfb03ce7+11,19.0.0-6-gbaebbfb+10,19.0.0-60-gafafd468+11,19.0.0-67-g3ab1e6e,19.0.0-7-g039c0b5+9,19.0.0-7-gbea9075+4,19.0.0-7-gc567de5+11,19.0.0-8-g3a3ce09+6,19.0.0-9-g463f923+10,w.2020.21
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 408 of file instrument.py.

408 def addUnboundedCalibrationLabel(registry, instrumentName):
409  """Add a special 'unbounded' calibration_label dimension entry for the
410  given camera that is valid for any exposure.
411 
412  If such an entry already exists, this function just returns a `DataId`
413  for the existing entry.
414 
415  Parameters
416  ----------
417  registry : `Registry`
418  Registry object in which to insert the dimension entry.
419  instrumentName : `str`
420  Name of the instrument this calibration label is associated with.
421 
422  Returns
423  -------
424  dataId : `DataId`
425  New or existing data ID for the unbounded calibration.
426  """
427  d = dict(instrument=instrumentName, calibration_label="unbounded")
428  try:
429  return registry.expandDataId(d)
430  except LookupError:
431  pass
432  entry = d.copy()
433  entry["datetime_begin"] = TIMESPAN_MIN
434  entry["datetime_end"] = TIMESPAN_MAX
435  registry.insertDimensionData("calibration_label", entry)
436  return registry.expandDataId(d)
437 
438 

◆ 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 439 of file instrument.py.

439 def loadCamera(butler: Butler, dataId: DataId, *, collections: Any = None) -> Tuple[Camera, bool]:
440  """Attempt to load versioned camera geometry from a butler, but fall back
441  to obtaining a nominal camera from the `Instrument` class if that fails.
442 
443  Parameters
444  ----------
445  butler : `lsst.daf.butler.Butler`
446  Butler instance to attempt to query for and load a ``camera`` dataset
447  from.
448  dataId : `dict` or `DataCoordinate`
449  Data ID that identifies at least the ``instrument`` and ``exposure``
450  dimensions.
451  collections : Any, optional
452  Collections to be searched, overriding ``self.butler.collections``.
453  Can be any of the types supported by the ``collections`` argument
454  to butler construction.
455 
456  Returns
457  -------
458  camera : `lsst.afw.cameraGeom.Camera`
459  Camera object.
460  versioned : `bool`
461  If `True`, the camera was obtained from the butler and should represent
462  a versioned camera from a calibration repository. If `False`, no
463  camera datasets were found, and the returned camera was produced by
464  instantiating the appropriate `Instrument` class and calling
465  `Instrument.getCamera`.
466  """
467  if collections is None:
468  collections = butler.collections
469  # Registry would do data ID expansion internally if we didn't do it first,
470  # but we might want an expanded data ID ourselves later, so we do it here
471  # to ensure it only happens once.
472  # This will also catch problems with the data ID not having keys we need.
473  dataId = butler.registry.expandDataId(dataId, graph=butler.registry.dimensions["exposure"].graph)
474  cameraRefs = list(butler.registry.queryDatasets("camera", dataId=dataId, collections=collections,
475  deduplicate=True))
476  if cameraRefs:
477  assert len(cameraRefs) == 1, "Should be guaranteed by deduplicate=True above."
478  return butler.getDirect(cameraRefs[0]), True
479  instrument = Instrument.fromName(dataId["instrument"], butler.registry)
480  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 374 of file instrument.py.

374 def makeExposureRecordFromObsInfo(obsInfo, universe):
375  """Construct an exposure DimensionRecord from
376  `astro_metadata_translator.ObservationInfo`.
377 
378  Parameters
379  ----------
380  obsInfo : `astro_metadata_translator.ObservationInfo`
381  A `~astro_metadata_translator.ObservationInfo` object corresponding to
382  the exposure.
383  universe : `DimensionUniverse`
384  Set of all known dimensions.
385 
386  Returns
387  -------
388  record : `DimensionRecord`
389  A record containing exposure metadata, suitable for insertion into
390  a `Registry`.
391  """
392  dimension = universe["exposure"]
393  return dimension.RecordClass.fromDict({
394  "instrument": obsInfo.instrument,
395  "id": obsInfo.exposure_id,
396  "name": obsInfo.observation_id,
397  "group_name": obsInfo.exposure_group,
398  "group_id": obsInfo.visit_id,
399  "datetime_begin": obsInfo.datetime_begin,
400  "datetime_end": obsInfo.datetime_end,
401  "exposure_time": obsInfo.exposure_time.to_value("s"),
402  "dark_time": obsInfo.dark_time.to_value("s"),
403  "observation_type": obsInfo.observation_type,
404  "physical_filter": obsInfo.physical_filter,
405  })
406 
407 

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 40 of file instrument.py.

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