LSSTApplications  18.0.0+112,18.0.0+52,19.0.0,19.0.0+1,19.0.0+14,19.0.0+15,19.0.0+17,19.0.0+22,19.0.0+3,19.0.0-1-g20d9b18+8,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+8,19.0.0-1-g6fe20d0+2,19.0.0-1-g7011481+13,19.0.0-1-g8c57eb9+8,19.0.0-1-gdc0e4a7+13,19.0.0-1-ge272bc4+8,19.0.0-1-ge3aa853+1,19.0.0-12-g296864c0+2,19.0.0-15-g85ac9ad,19.0.0-2-g0d9f9cd+15,19.0.0-2-g5037de4+1,19.0.0-2-g9b11441+2,19.0.0-2-gb96a1c4+9,19.0.0-2-gd955cfd+21,19.0.0-3-g97e0e8e9+1,19.0.0-4-g41ffa1d+1,19.0.0-4-g725f80e+17,19.0.0-4-ga8eba22,19.0.0-4-gad373c5+8,19.0.0-5-gb9a06e236+1,19.0.0-5-gfe96e6c+6,19.0.0-7-gea0a0fe+4,w.2020.02
LSSTDataManagementBasePackage
Public Member Functions | Public Attributes | List of all members
lsst.obs.base.gen2to3.dataIdExtractor.DataIdExtractor Class Reference

Public Member Functions

def __init__
 
def apply
 

Public Attributes

 filePathParser
 
 translator
 
 datasetType
 

Detailed Description

A class that extracts Gen3 data IDs from Gen2 filenames for a
particular dataset type.

Parameters
----------
datasetTypeName : `str`
    Name of the dataset type the object will process.
storageClass : `str` or `lsst.daf.butler.StorageClass`
    Gen3 storage class of the dataset type.
universe : `lsst.daf.butler.DimensionUniverse`
    Object containing all dimension definitions.
instrument : `str`
    Name of the Gen3 instrument for output data IDs that include that
    dimension.
filePathParser : `FilePathParser`, optional
    Object responsible for reading a Gen2 data ID from a filename.  Will
    be created from ``mapper`` if not provided.
translator : `Translator`, optional
    Object responsible for converting a Gen2 data ID into a Gen3 data ID.
    Will be created if not provided.
mapping : `lsst.obs.base.Mapper`, optional
    Object that defines a Gen2 dataset type.  Must be provided if
    ``filePathParser`` is not.
skyMap : `lsst.skymap.BaseSkyMap`, optional
    SkyMap that defines tracts and patches.  Must be provided for datasets
    with a ``patch`` key in their data IDs.
skyMapName: `str`, optional
    Name of the Gen3 skymap for output data IDs that include that
    dimension.

Raises
------
RuntimeError
    Raised if the given mapping has no template.

Definition at line 33 of file dataIdExtractor.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.obs.base.gen2to3.dataIdExtractor.DataIdExtractor.__init__ (   self,
  datasetTypeName 
)

Definition at line 70 of file dataIdExtractor.py.

70  def __init__(self, datasetTypeName: str, storageClass: Union[str, StorageClass], *,
71  universe: DimensionUniverse,
72  instrument: str,
73  filePathParser: Optional[FilePathParser] = None,
74  translator: Optional[Translator] = None,
75  mapping: Optional[Mapping] = None,
76  skyMap: Optional[BaseSkyMap] = None,
77  skyMapName: Optional[str] = None):
78  if filePathParser is None:
79  filePathParser = FilePathParser.fromMapping(mapping)
80  self.filePathParser = filePathParser
81  if translator is None:
82  translator = Translator.makeMatching(datasetTypeName, filePathParser.keys,
83  instrument=instrument, skyMap=skyMap, skyMapName=skyMapName)
84  self.translator = translator
85  self.datasetType = DatasetType(datasetTypeName, dimensions=self.translator.dimensionNames,
86  storageClass=storageClass, universe=universe)
87 

Member Function Documentation

◆ apply()

def lsst.obs.base.gen2to3.dataIdExtractor.DataIdExtractor.apply (   self,
  fileNameInRoot 
)

Definition at line 88 of file dataIdExtractor.py.

88  def apply(self, fileNameInRoot: str) -> Optional[DataCoordinate]:
89  """Extract a Gen3 data ID from the given filename,
90 
91  Parameters
92  ----------
93  fileNameInRoot : `str`
94  Filename relative to a Gen2 data repository root.
95 
96  Returns
97  -------
98  dataId : `lsst.daf.butler.DataCoordinate` or `None`
99  The Gen3 data ID, or `None` if the file was not recognized as an
100  instance of the extractor's dataset type.
101  """
102  gen2id = self.filePathParser(fileNameInRoot)
103  if gen2id is None:
104  return None
105  return DataCoordinate.standardize(self.translator(gen2id), graph=self.datasetType.dimensions)
106 

Member Data Documentation

◆ datasetType

lsst.obs.base.gen2to3.dataIdExtractor.DataIdExtractor.datasetType

Definition at line 85 of file dataIdExtractor.py.

◆ filePathParser

lsst.obs.base.gen2to3.dataIdExtractor.DataIdExtractor.filePathParser

Definition at line 80 of file dataIdExtractor.py.

◆ translator

lsst.obs.base.gen2to3.dataIdExtractor.DataIdExtractor.translator

Definition at line 84 of file dataIdExtractor.py.


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