LSSTApplications  18.1.0
LSSTDataManagementBasePackage
Classes | Functions
lsst.pipe.drivers.constructCalibs Namespace Reference

Classes

class  BiasConfig
 
class  BiasTask
 
class  CalibArgumentParser
 
class  CalibCombineConfig
 
class  CalibCombineTask
 
class  CalibConfig
 
class  CalibIdAction
 
class  CalibStatsConfig
 
class  CalibStatsTask
 
class  CalibTask
 Base class for constructing calibs. More...
 
class  CalibTaskRunner
 
class  DarkConfig
 
class  DarkTask
 
class  FlatConfig
 
class  FlatTask
 
class  FringeConfig
 
class  FringeTask
 
class  SkyConfig
 
class  SkyTask
 

Functions

def getSize (dimList)
 
def dictToTuple (dict_, keys)
 Return a tuple of specific values from a dict. More...
 
def getCcdIdListFromExposures (expRefList, level="sensor", ccdKeys=["ccd"])
 Determine a list of CCDs from exposure references. More...
 
def mapToMatrix (pool, func, ccdIdLists, args, kwargs)
 

Function Documentation

◆ dictToTuple()

def lsst.pipe.drivers.constructCalibs.dictToTuple (   dict_,
  keys 
)

Return a tuple of specific values from a dict.

This provides a hashable representation of the dict from certain keywords. This can be useful for creating e.g., a tuple of the values in the DataId that identify the CCD.

Parameters
dict_dict to parse
keyskeys to extract (order is important)
Returns
tuple of values

Definition at line 189 of file constructCalibs.py.

189 def dictToTuple(dict_, keys):
190  """!Return a tuple of specific values from a dict
191 
192  This provides a hashable representation of the dict from certain keywords.
193  This can be useful for creating e.g., a tuple of the values in the DataId
194  that identify the CCD.
195 
196  @param dict_ dict to parse
197  @param keys keys to extract (order is important)
198  @return tuple of values
199  """
200  return tuple(dict_[k] for k in keys)
201 
202 
def dictToTuple(dict_, keys)
Return a tuple of specific values from a dict.

◆ getCcdIdListFromExposures()

def lsst.pipe.drivers.constructCalibs.getCcdIdListFromExposures (   expRefList,
  level = "sensor",
  ccdKeys = ["ccd"] 
)

Determine a list of CCDs from exposure references.

This essentially inverts the exposure-level references (which provides a list of CCDs for each exposure), by providing a dataId list for each CCD. Consider an input list of exposures [e1, e2, e3], and each exposure has CCDs c1 and c2. Then this function returns:

{(c1,): [e1c1, e2c1, e3c1], (c2,): [e1c2, e2c2, e3c2]}

This is a dict whose keys are tuples of the identifying values of a CCD (usually just the CCD number) and the values are lists of dataIds for that CCD in each exposure. A missing dataId is given the value None.

Parameters
expRefListList of data references for exposures
levelLevel for the butler to generate CCDs
ccdKeysDataId keywords that identify a CCD
Returns
dict of data identifier lists for each CCD; keys are values of ccdKeys in order

Definition at line 203 of file constructCalibs.py.

203 def getCcdIdListFromExposures(expRefList, level="sensor", ccdKeys=["ccd"]):
204  """!Determine a list of CCDs from exposure references
205 
206  This essentially inverts the exposure-level references (which
207  provides a list of CCDs for each exposure), by providing
208  a dataId list for each CCD. Consider an input list of exposures
209  [e1, e2, e3], and each exposure has CCDs c1 and c2. Then this
210  function returns:
211 
212  {(c1,): [e1c1, e2c1, e3c1], (c2,): [e1c2, e2c2, e3c2]}
213 
214  This is a dict whose keys are tuples of the identifying values of a
215  CCD (usually just the CCD number) and the values are lists of dataIds
216  for that CCD in each exposure. A missing dataId is given the value
217  None.
218 
219  @param expRefList List of data references for exposures
220  @param level Level for the butler to generate CCDs
221  @param ccdKeys DataId keywords that identify a CCD
222  @return dict of data identifier lists for each CCD;
223  keys are values of ccdKeys in order
224  """
225  expIdList = [[ccdRef.dataId for ccdRef in expRef.subItems(
226  level)] for expRef in expRefList]
227 
228  # Determine what additional keys make a CCD from an exposure
229  if len(ccdKeys) != len(set(ccdKeys)):
230  raise RuntimeError("Duplicate keys found in ccdKeys: %s" % ccdKeys)
231  ccdNames = set() # Set of tuples which are values for each of the CCDs in an exposure
232  for ccdIdList in expIdList:
233  for ccdId in ccdIdList:
234  name = dictToTuple(ccdId, ccdKeys)
235  ccdNames.add(name)
236 
237  # Turn the list of CCDs for each exposure into a list of exposures for
238  # each CCD
239  ccdLists = {}
240  for n, ccdIdList in enumerate(expIdList):
241  for ccdId in ccdIdList:
242  name = dictToTuple(ccdId, ccdKeys)
243  if name not in ccdLists:
244  ccdLists[name] = []
245  ccdLists[name].append(ccdId)
246 
247  for ccd in ccdLists:
248  # Sort the list by the dataId values (ordered by key)
249  ccdLists[ccd] = sorted(ccdLists[ccd], key=lambda dd: dictToTuple(dd, sorted(dd.keys())))
250 
251  return ccdLists
252 
253 
def getCcdIdListFromExposures(expRefList, level="sensor", ccdKeys=["ccd"])
Determine a list of CCDs from exposure references.
std::shared_ptr< FrameSet > append(FrameSet const &first, FrameSet const &second)
Construct a FrameSet that performs two transformations in series.
Definition: functional.cc:33
daf::base::PropertySet * set
Definition: fits.cc:884
def dictToTuple(dict_, keys)
Return a tuple of specific values from a dict.

◆ getSize()

def lsst.pipe.drivers.constructCalibs.getSize (   dimList)
Determine a consistent size, given a list of image sizes

Definition at line 180 of file constructCalibs.py.

180 def getSize(dimList):
181  """Determine a consistent size, given a list of image sizes"""
182  dim = set((w, h) for w, h in dimList)
183  dim.discard(None)
184  if len(dim) != 1:
185  raise RuntimeError("Inconsistent dimensions: %s" % dim)
186  return dim.pop()
187 
188 
daf::base::PropertySet * set
Definition: fits.cc:884

◆ mapToMatrix()

def lsst.pipe.drivers.constructCalibs.mapToMatrix (   pool,
  func,
  ccdIdLists,
  args,
  kwargs 
)
Generate a matrix of results using pool.map

The function should have the call signature:
    func(cache, dataId, *args, **kwargs)

We return a dict mapping 'ccd name' to a list of values for
each exposure.

@param pool  Process pool
@param func  Function to call for each dataId
@param ccdIdLists  Dict of data identifier lists for each CCD name
@return matrix of results

Definition at line 254 of file constructCalibs.py.

254 def mapToMatrix(pool, func, ccdIdLists, *args, **kwargs):
255  """Generate a matrix of results using pool.map
256 
257  The function should have the call signature:
258  func(cache, dataId, *args, **kwargs)
259 
260  We return a dict mapping 'ccd name' to a list of values for
261  each exposure.
262 
263  @param pool Process pool
264  @param func Function to call for each dataId
265  @param ccdIdLists Dict of data identifier lists for each CCD name
266  @return matrix of results
267  """
268  dataIdList = sum(ccdIdLists.values(), [])
269  resultList = pool.map(func, dataIdList, *args, **kwargs)
270  # Piece everything back together
271  data = dict((ccdName, [None] * len(expList)) for ccdName, expList in ccdIdLists.items())
272  indices = dict(sum([[(tuple(dataId.values()) if dataId is not None else None, (ccdName, expNum))
273  for expNum, dataId in enumerate(expList)]
274  for ccdName, expList in ccdIdLists.items()], []))
275  for dataId, result in zip(dataIdList, resultList):
276  if dataId is None:
277  continue
278  ccdName, expNum = indices[tuple(dataId.values())]
279  data[ccdName][expNum] = result
280  return data
281 
282 
def mapToMatrix(pool, func, ccdIdLists, args, kwargs)