LSST Applications  21.0.0+04719a4bac,21.0.0-1-ga51b5d4+f5e6047307,21.0.0-10-g17396bd+0db626c9d4,21.0.0-11-ga42c5b2+8e919b1fde,21.0.0-11-gf32158d+0ebe75d2c4,21.0.0-12-g21f7bf3+5457518a9a,21.0.0-12-g9de0849+524af766c8,21.0.0-14-gbfe4b77+9a33cf3f69,21.0.0-16-g0fb55c1+2e80f2f4c5,21.0.0-19-g4cded4ca+da87cab2e2,21.0.0-2-g103fe59+7aa255a7ca,21.0.0-2-g45278ab+04719a4bac,21.0.0-2-g5242d73+7df4c6fa3d,21.0.0-2-g7f82c8f+0b5b78a3be,21.0.0-2-g8f08a60+06509c8b61,21.0.0-2-g8faa9b5+616205b9df,21.0.0-2-ga326454+0b5b78a3be,21.0.0-2-gde069b7+5e4aea9c2f,21.0.0-2-gecfae73+632ec57a44,21.0.0-2-gfc62afb+7df4c6fa3d,21.0.0-25-g1d57be3cd+e9f70389b0,21.0.0-3-g357aad2+3b365e1178,21.0.0-3-g4a4ce7f+7df4c6fa3d,21.0.0-3-g4be5c26+7df4c6fa3d,21.0.0-3-g65f322c+79dc209d58,21.0.0-3-g7d9da8d+616205b9df,21.0.0-3-ge02ed75+0db626c9d4,21.0.0-4-g591bb35+0db626c9d4,21.0.0-4-g65b4814+2e80f2f4c5,21.0.0-4-gccdca77+0de219a2bc,21.0.0-4-ge8a399c+7b7c27da6e,21.0.0-5-gd00fb1e+52bf7bf9f3,21.0.0-6-gc675373+7df4c6fa3d,21.0.0-61-ge77b8116+a869d0a5a5,21.0.0-7-g04766d7+5bf495eb54,21.0.0-7-g98eecf7+d1bd76f71f,21.0.0-7-gdf92d54+04719a4bac,master-gac4afde19b+0db626c9d4,w.2021.13
LSST Data Management Base Package
Public Member Functions | Public Attributes | List of all members
lsst.pipe.tasks.postprocess.VisitDataIdContainer Class Reference
Inheritance diagram for lsst.pipe.tasks.postprocess.VisitDataIdContainer:
lsst.pipe.base.argumentParser.DataIdContainer

Public Member Functions

def makeDataRefList (self, namespace)
 
def setDatasetType (self, datasetType)
 
def castDataIds (self, butler)
 

Public Attributes

 refList
 
 datasetType
 
 level
 
 idList
 

Detailed Description

DataIdContainer that groups sensor-level id's by visit

Definition at line 1072 of file postprocess.py.

Member Function Documentation

◆ castDataIds()

def lsst.pipe.base.argumentParser.DataIdContainer.castDataIds (   self,
  butler 
)
inherited
Validate data IDs and cast them to the correct type
(modify idList in place).

This code casts the values in the data IDs dicts in `dataIdList`
to the type required by the butler. Data IDs are read from the
command line as `str`, but the butler requires some values to be
other types. For example "visit" values should be `int`.

Parameters
----------
butler : `lsst.daf.persistence.Butler`
    Data butler.

Definition at line 133 of file argumentParser.py.

133  def castDataIds(self, butler):
134  """Validate data IDs and cast them to the correct type
135  (modify idList in place).
136 
137  This code casts the values in the data IDs dicts in `dataIdList`
138  to the type required by the butler. Data IDs are read from the
139  command line as `str`, but the butler requires some values to be
140  other types. For example "visit" values should be `int`.
141 
142  Parameters
143  ----------
144  butler : `lsst.daf.persistence.Butler`
145  Data butler.
146  """
147  if self.datasetType is None:
148  raise RuntimeError("Must call setDatasetType first")
149  try:
150  idKeyTypeDict = butler.getKeys(datasetType=self.datasetType, level=self.level)
151  except KeyError as e:
152  msg = f"Cannot get keys for datasetType {self.datasetType} at level {self.level}"
153  raise KeyError(msg) from e
154 
155  for dataDict in self.idList:
156  for key, strVal in dataDict.items():
157  try:
158  keyType = idKeyTypeDict[key]
159  except KeyError:
160  # OK, assume that it's a valid key and guess that it's a
161  # string
162  keyType = str
163 
164  log = lsstLog.Log.getDefaultLogger()
165  log.warn("Unexpected ID %s; guessing type is \"%s\"",
166  key, 'str' if keyType == str else keyType)
167  idKeyTypeDict[key] = keyType
168 
169  if keyType != str:
170  try:
171  castVal = keyType(strVal)
172  except Exception:
173  raise TypeError(f"Cannot cast value {strVal!r} to {keyType} for ID key {key}")
174  dataDict[key] = castVal
175 

◆ makeDataRefList()

def lsst.pipe.tasks.postprocess.VisitDataIdContainer.makeDataRefList (   self,
  namespace 
)
Make self.refList from self.idList

Generate a list of data references grouped by visit.

Parameters
----------
namespace : `argparse.Namespace`
    Namespace used by `lsst.pipe.base.CmdLineTask` to parse command line arguments

Reimplemented from lsst.pipe.base.argumentParser.DataIdContainer.

Definition at line 1076 of file postprocess.py.

1076  def makeDataRefList(self, namespace):
1077  """Make self.refList from self.idList
1078 
1079  Generate a list of data references grouped by visit.
1080 
1081  Parameters
1082  ----------
1083  namespace : `argparse.Namespace`
1084  Namespace used by `lsst.pipe.base.CmdLineTask` to parse command line arguments
1085  """
1086  # Group by visits
1087  visitRefs = defaultdict(list)
1088  for dataId in self.idList:
1089  if "visit" in dataId:
1090  visitId = dataId["visit"]
1091  # append all subsets to
1092  subset = namespace.butler.subset(self.datasetType, dataId=dataId)
1093  visitRefs[visitId].extend([dataRef for dataRef in subset])
1094 
1095  outputRefList = []
1096  for refList in visitRefs.values():
1097  existingRefs = [ref for ref in refList if ref.datasetExists()]
1098  if existingRefs:
1099  outputRefList.append(existingRefs)
1100 
1101  self.refList = outputRefList
1102 
1103 

◆ setDatasetType()

def lsst.pipe.base.argumentParser.DataIdContainer.setDatasetType (   self,
  datasetType 
)
inherited
Set actual dataset type, once it is known.

Parameters
----------
datasetType : `str`
    Dataset type.

Notes
-----
The reason ``datasetType`` is not a constructor argument is that
some subclasses do not know the dataset type until the command
is parsed. Thus, to reduce special cases in the code,
``datasetType`` is always set after the command is parsed.

Definition at line 116 of file argumentParser.py.

116  def setDatasetType(self, datasetType):
117  """Set actual dataset type, once it is known.
118 
119  Parameters
120  ----------
121  datasetType : `str`
122  Dataset type.
123 
124  Notes
125  -----
126  The reason ``datasetType`` is not a constructor argument is that
127  some subclasses do not know the dataset type until the command
128  is parsed. Thus, to reduce special cases in the code,
129  ``datasetType`` is always set after the command is parsed.
130  """
131  self.datasetType = datasetType
132 

Member Data Documentation

◆ datasetType

lsst.pipe.base.argumentParser.DataIdContainer.datasetType
inherited

Definition at line 98 of file argumentParser.py.

◆ idList

lsst.pipe.base.argumentParser.DataIdContainer.idList
inherited

Definition at line 104 of file argumentParser.py.

◆ level

lsst.pipe.base.argumentParser.DataIdContainer.level
inherited

Definition at line 101 of file argumentParser.py.

◆ refList

lsst.pipe.tasks.postprocess.VisitDataIdContainer.refList

Definition at line 1101 of file postprocess.py.


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