LSST Applications  21.0.0+75b29a8a7f,21.0.0+e70536a077,21.0.0-1-ga51b5d4+62c747d40b,21.0.0-10-gbfb87ad6+3307648ee3,21.0.0-15-gedb9d5423+47cba9fc36,21.0.0-2-g103fe59+fdf0863a2a,21.0.0-2-g1367e85+d38a93257c,21.0.0-2-g45278ab+e70536a077,21.0.0-2-g5242d73+d38a93257c,21.0.0-2-g7f82c8f+e682ffb718,21.0.0-2-g8dde007+d179fbfa6a,21.0.0-2-g8f08a60+9402881886,21.0.0-2-ga326454+e682ffb718,21.0.0-2-ga63a54e+08647d4b1b,21.0.0-2-gde069b7+26c92b3210,21.0.0-2-gecfae73+0445ed2f95,21.0.0-2-gfc62afb+d38a93257c,21.0.0-27-gbbd0d29+ae871e0f33,21.0.0-28-g5fc5e037+feb0e9397b,21.0.0-3-g21c7a62+f4b9c0ff5c,21.0.0-3-g357aad2+57b0bddf0b,21.0.0-3-g4be5c26+d38a93257c,21.0.0-3-g65f322c+3f454acf5d,21.0.0-3-g7d9da8d+75b29a8a7f,21.0.0-3-gaa929c8+9e4ef6332c,21.0.0-3-ge02ed75+4b120a55c4,21.0.0-4-g3300ddd+e70536a077,21.0.0-4-g591bb35+4b120a55c4,21.0.0-4-gc004bbf+4911b9cd27,21.0.0-4-gccdca77+f94adcd104,21.0.0-4-ge8fba5a+2b3a696ff9,21.0.0-5-gb155db7+2c5429117a,21.0.0-5-gdf36809+637e4641ee,21.0.0-6-g00874e7+c9fd7f7160,21.0.0-6-g4e60332+4b120a55c4,21.0.0-7-gc8ca178+40eb9cf840,21.0.0-8-gfbe0b4b+9e4ef6332c,21.0.0-9-g2fd488a+d83b7cd606,w.2021.05
LSST Data Management Base Package
Public Member Functions | Public Attributes | List of all members
lsst.obs.base.mapping.CalibrationMapping Class Reference
Inheritance diagram for lsst.obs.base.mapping.CalibrationMapping:
lsst.obs.base.mapping.Mapping

Public Member Functions

def __init__ (self, datasetType, policy, registry, calibRegistry, calibRoot, dataRoot=None, **kwargs)
 
def map (self, mapper, dataId, write=False)
 
def lookup (self, properties, dataId)
 
def standardize (self, mapper, item, dataId)
 
def template (self)
 
def keys (self)
 
def have (self, properties, dataId)
 
def need (self, properties, dataId)
 

Public Attributes

 reference
 
 refCols
 
 refRegistry
 
 dataRoot
 
 range
 
 columns
 
 setFilter
 
 metadataKeys
 
 datasetType
 
 registry
 
 rootStorage
 
 keyDict
 
 python
 
 persistable
 
 storage
 
 level
 
 tables
 
 obsTimeName
 
 recipe
 

Detailed Description

CalibrationMapping is a Mapping subclass for calibration-type products.

The difference is that data properties in the query or template
can be looked up using a reference Mapping in addition to this one.

CalibrationMapping Policies can contain the following:

reference (string, optional)
    a list of tables for finding missing dataset
    identifier components (including the observation time, if a validity
    range is required) in the exposure registry; note that the "tables"
    entry refers to the calibration registry

refCols (string, optional)
    a list of dataset properties required from the
    reference tables for lookups in the calibration registry

validRange (bool)
    true if the calibration dataset has a validity range
    specified by a column in the tables of the reference dataset in the
    exposure registry) and two columns in the tables of this calibration
    dataset in the calibration registry)

obsTimeName (string, optional)
    the name of the column in the reference
    dataset tables containing the observation time (default "taiObs")

validStartName (string, optional)
    the name of the column in the
    calibration dataset tables containing the start of the validity range
    (default "validStart")

validEndName (string, optional)
    the name of the column in the
    calibration dataset tables containing the end of the validity range
    (default "validEnd")

Parameters
----------
datasetType : `str`
    Butler dataset type to be mapped.
policy : `daf_persistence.Policy`
    Mapping Policy.
registry : `lsst.obs.base.Registry`
    Registry for metadata lookups
calibRegistry : `lsst.obs.base.Registry`
    Registry for calibration metadata lookups.
calibRoot : `str`
    Path of calibration root directory.
dataRoot : `str`
    Path of data root directory; used for outputs only.

Definition at line 389 of file mapping.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.obs.base.mapping.CalibrationMapping.__init__ (   self,
  datasetType,
  policy,
  registry,
  calibRegistry,
  calibRoot,
  dataRoot = None,
**  kwargs 
)

Definition at line 443 of file mapping.py.

443  def __init__(self, datasetType, policy, registry, calibRegistry, calibRoot, dataRoot=None, **kwargs):
444  Mapping.__init__(self, datasetType, policy, calibRegistry, calibRoot, **kwargs)
445  self.reference = policy.asArray("reference") if "reference" in policy else None
446  self.refCols = policy.asArray("refCols") if "refCols" in policy else None
447  self.refRegistry = registry
448  self.dataRoot = dataRoot
449  if "validRange" in policy and policy["validRange"]:
450  self.range = ("?", policy["validStartName"], policy["validEndName"])
451  if "columns" in policy:
452  self.columns = policy.asArray("columns")
453  if "filter" in policy:
454  self.setFilter = policy["filter"]
455  self.metadataKeys = None
456  if "metadataKey" in policy:
457  self.metadataKeys = policy.asArray("metadataKey")
458 

Member Function Documentation

◆ have()

def lsst.obs.base.mapping.Mapping.have (   self,
  properties,
  dataId 
)
inherited
Returns whether the provided data identifier has all
the properties in the provided list.

Parameters
----------
properties : `list of `str`
    Properties required.
dataId : `dict`
    Dataset identifier.

Returns
-------
bool
    True if all properties are present.

Definition at line 275 of file mapping.py.

275  def have(self, properties, dataId):
276  """Returns whether the provided data identifier has all
277  the properties in the provided list.
278 
279  Parameters
280  ----------
281  properties : `list of `str`
282  Properties required.
283  dataId : `dict`
284  Dataset identifier.
285 
286  Returns
287  -------
288  bool
289  True if all properties are present.
290  """
291  for prop in properties:
292  if prop not in dataId:
293  return False
294  return True
295 

◆ keys()

def lsst.obs.base.mapping.Mapping.keys (   self)
inherited
Return the dict of keys and value types required for this mapping.

Definition at line 135 of file mapping.py.

135  def keys(self):
136  """Return the dict of keys and value types required for this mapping.
137  """
138  return self.keyDict
139 

◆ lookup()

def lsst.obs.base.mapping.CalibrationMapping.lookup (   self,
  properties,
  dataId 
)
Look up properties for in a metadata registry given a partial
dataset identifier.

Parameters
----------
properties : `list` of `str`
    Properties to look up.
dataId : `dict`
    Dataset identifier.

Returns
-------
`list` of `tuple`
    Values of properties.

Reimplemented from lsst.obs.base.mapping.Mapping.

Definition at line 466 of file mapping.py.

466  def lookup(self, properties, dataId):
467  """Look up properties for in a metadata registry given a partial
468  dataset identifier.
469 
470  Parameters
471  ----------
472  properties : `list` of `str`
473  Properties to look up.
474  dataId : `dict`
475  Dataset identifier.
476 
477  Returns
478  -------
479  `list` of `tuple`
480  Values of properties.
481  """
482 
483 # Either look up taiObs in reference and then all in calibRegistry
484 # Or look up all in registry
485 
486  newId = dataId.copy()
487  if self.reference is not None:
488  where = []
489  values = []
490  for k, v in dataId.items():
491  if self.refCols and k not in self.refCols:
492  continue
493  where.append(k)
494  values.append(v)
495 
496  # Columns we need from the regular registry
497  if self.columns is not None:
498  columns = set(self.columns)
499  for k in dataId.keys():
500  columns.discard(k)
501  else:
502  columns = set(properties)
503 
504  if not columns:
505  # Nothing to lookup in reference registry; continue with calib
506  # registry
507  return Mapping.lookup(self, properties, newId)
508 
509  lookupDataId = dict(zip(where, values))
510  lookups = self.refRegistry.lookup(columns, self.reference, lookupDataId)
511  if len(lookups) != 1:
512  raise RuntimeError("No unique lookup for %s from %s: %d matches" %
513  (columns, dataId, len(lookups)))
514  if columns == set(properties):
515  # Have everything we need
516  return lookups
517  for i, prop in enumerate(columns):
518  newId[prop] = lookups[0][i]
519  return Mapping.lookup(self, properties, newId)
520 
daf::base::PropertySet * set
Definition: fits.cc:912

◆ map()

def lsst.obs.base.mapping.CalibrationMapping.map (   self,
  mapper,
  dataId,
  write = False 
)
Standard implementation of map function.

Parameters
----------
mapper: `lsst.daf.persistence.Mapper`
    Object to be mapped.
dataId: `dict`
    Dataset identifier.

Returns
-------
lsst.daf.persistence.ButlerLocation
    Location of object that was mapped.

Reimplemented from lsst.obs.base.mapping.Mapping.

Definition at line 459 of file mapping.py.

459  def map(self, mapper, dataId, write=False):
460  location = Mapping.map(self, mapper, dataId, write=write)
461  # Want outputs to be in the output directory
462  if write and self.dataRoot:
463  location.storage = self.dataRoot
464  return location
465 

◆ need()

def lsst.obs.base.mapping.Mapping.need (   self,
  properties,
  dataId 
)
inherited
Ensures all properties in the provided list are present in
the data identifier, looking them up as needed.  This is only
possible for the case where the data identifies a single
exposure.

Parameters
----------
properties : `list` of `str`
    Properties required.
dataId : `dict`
    Partial dataset identifier

Returns
-------
`dict`
    Copy of dataset identifier with enhanced values.

Definition at line 296 of file mapping.py.

296  def need(self, properties, dataId):
297  """Ensures all properties in the provided list are present in
298  the data identifier, looking them up as needed. This is only
299  possible for the case where the data identifies a single
300  exposure.
301 
302  Parameters
303  ----------
304  properties : `list` of `str`
305  Properties required.
306  dataId : `dict`
307  Partial dataset identifier
308 
309  Returns
310  -------
311  `dict`
312  Copy of dataset identifier with enhanced values.
313  """
314  newId = dataId.copy()
315  newProps = [] # Properties we don't already have
316  for prop in properties:
317  if prop not in newId:
318  newProps.append(prop)
319  if len(newProps) == 0:
320  return newId
321 
322  lookups = self.lookup(newProps, newId)
323  if len(lookups) != 1:
324  raise NoResults("No unique lookup for %s from %s: %d matches" %
325  (newProps, newId, len(lookups)),
326  self.datasetType, dataId)
327  for i, prop in enumerate(newProps):
328  newId[prop] = lookups[0][i]
329  return newId
330 
331 

◆ standardize()

def lsst.obs.base.mapping.CalibrationMapping.standardize (   self,
  mapper,
  item,
  dataId 
)
Default standardization function for calibration datasets.

If the item is of a type that should be standardized, the base class
``standardizeExposure`` method is called, otherwise the item is
returned unmodified.

Parameters
----------
mapping : `lsst.obs.base.Mapping`
    Mapping object to pass through.
item : object
    Will be standardized if of type lsst.afw.image.Exposure,
    lsst.afw.image.DecoratedImage, lsst.afw.image.Image
    or lsst.afw.image.MaskedImage

dataId : `dict`
    Dataset identifier

Returns
-------
`lsst.afw.image.Exposure` or item
    The standardized object.

Definition at line 521 of file mapping.py.

521  def standardize(self, mapper, item, dataId):
522  """Default standardization function for calibration datasets.
523 
524  If the item is of a type that should be standardized, the base class
525  ``standardizeExposure`` method is called, otherwise the item is
526  returned unmodified.
527 
528  Parameters
529  ----------
530  mapping : `lsst.obs.base.Mapping`
531  Mapping object to pass through.
532  item : object
533  Will be standardized if of type lsst.afw.image.Exposure,
534  lsst.afw.image.DecoratedImage, lsst.afw.image.Image
535  or lsst.afw.image.MaskedImage
536 
537  dataId : `dict`
538  Dataset identifier
539 
540  Returns
541  -------
542  `lsst.afw.image.Exposure` or item
543  The standardized object.
544  """
545  if issubclass(doImport(self.python), (Exposure, MaskedImage, Image, DecoratedImage)):
546  return mapper._standardizeExposure(self, item, dataId, filter=self.setFilter)
547  return item
548 
549 

◆ template()

def lsst.obs.base.mapping.Mapping.template (   self)
inherited

Definition at line 128 of file mapping.py.

128  def template(self):
129  if self._template: # template must not be an empty string or None
130  return self._template
131  else:
132  raise RuntimeError(f"Template is not defined for the {self.datasetType} dataset type, "
133  "it must be set before it can be used.")
134 

Member Data Documentation

◆ columns

lsst.obs.base.mapping.CalibrationMapping.columns

Definition at line 452 of file mapping.py.

◆ dataRoot

lsst.obs.base.mapping.CalibrationMapping.dataRoot

Definition at line 448 of file mapping.py.

◆ datasetType

lsst.obs.base.mapping.Mapping.datasetType
inherited

Definition at line 89 of file mapping.py.

◆ keyDict

lsst.obs.base.mapping.Mapping.keyDict
inherited

Definition at line 102 of file mapping.py.

◆ level

lsst.obs.base.mapping.Mapping.level
inherited

Definition at line 117 of file mapping.py.

◆ metadataKeys

lsst.obs.base.mapping.CalibrationMapping.metadataKeys

Definition at line 455 of file mapping.py.

◆ obsTimeName

lsst.obs.base.mapping.Mapping.obsTimeName
inherited

Definition at line 124 of file mapping.py.

◆ persistable

lsst.obs.base.mapping.Mapping.persistable
inherited

Definition at line 114 of file mapping.py.

◆ python

lsst.obs.base.mapping.Mapping.python
inherited

Definition at line 113 of file mapping.py.

◆ range

lsst.obs.base.mapping.CalibrationMapping.range

Definition at line 450 of file mapping.py.

◆ recipe

lsst.obs.base.mapping.Mapping.recipe
inherited

Definition at line 125 of file mapping.py.

◆ refCols

lsst.obs.base.mapping.CalibrationMapping.refCols

Definition at line 446 of file mapping.py.

◆ reference

lsst.obs.base.mapping.CalibrationMapping.reference

Definition at line 445 of file mapping.py.

◆ refRegistry

lsst.obs.base.mapping.CalibrationMapping.refRegistry

Definition at line 447 of file mapping.py.

◆ registry

lsst.obs.base.mapping.Mapping.registry
inherited

Definition at line 90 of file mapping.py.

◆ rootStorage

lsst.obs.base.mapping.Mapping.rootStorage
inherited

Definition at line 91 of file mapping.py.

◆ setFilter

lsst.obs.base.mapping.CalibrationMapping.setFilter

Definition at line 454 of file mapping.py.

◆ storage

lsst.obs.base.mapping.Mapping.storage
inherited

Definition at line 115 of file mapping.py.

◆ tables

lsst.obs.base.mapping.Mapping.tables
inherited

Definition at line 119 of file mapping.py.


The documentation for this class was generated from the following file: