LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Functions
lsst.pipe.tasks.coaddHelpers Namespace Reference

Functions

def groupDataRefs
 
def groupPatchExposures
 
def getGroupDataId
 
def getGroupDataRef
 

Function Documentation

def lsst.pipe.tasks.coaddHelpers.getGroupDataId (   groupTuple,
  keys 
)
Reconstitute a data identifier from a tuple and corresponding keys

@param groupTuple: Tuple with values specifying a group
@param keys: List of keys for group tuple
@return Data identifier dict

Definition at line 85 of file coaddHelpers.py.

85 
86 def getGroupDataId(groupTuple, keys):
87  """Reconstitute a data identifier from a tuple and corresponding keys
88 
89  @param groupTuple: Tuple with values specifying a group
90  @param keys: List of keys for group tuple
91  @return Data identifier dict
92  """
93  if len(groupTuple) != len(keys):
94  raise RuntimeError("Number of values (%d) and keys (%d) do not match" % (len(groupTuple), len(keys)))
95  return dict(zip(keys, groupTuple))
def lsst.pipe.tasks.coaddHelpers.getGroupDataRef (   butler,
  datasetType,
  groupTuple,
  keys 
)
Construct a data reference from a tuple and corresponding keys

@param butler: Data butler
@param datasetType: Name of dataset
@param groupTuple: Tuple with values specifying a group
@param keys: List of keys for group tuple
@return Data reference

Definition at line 96 of file coaddHelpers.py.

96 
97 def getGroupDataRef(butler, datasetType, groupTuple, keys):
98  """Construct a data reference from a tuple and corresponding keys
99 
100  @param butler: Data butler
101  @param datasetType: Name of dataset
102  @param groupTuple: Tuple with values specifying a group
103  @param keys: List of keys for group tuple
104  @return Data reference
105  """
106  dataId = getGroupDataId(groupTuple, keys)
107  return butler.dataRef(datasetType=datasetType, dataId=dataId)
def lsst.pipe.tasks.coaddHelpers.groupDataRefs (   keys,
  dataRefIterable 
)
Group data references by data identifier value-tuple.

Value-tuples are built from the values of the given keys.
The effect is that the data references in each group have the same
values for the provided keys.

@param keys: List of keys to consider when grouping (order is important)
@param dataRefIterable: Iterable of data references to group
@return Dict of <value-tuple>: <list of data references for group>

Definition at line 35 of file coaddHelpers.py.

35 
36 def groupDataRefs(keys, dataRefIterable):
37  """Group data references by data identifier value-tuple.
38 
39  Value-tuples are built from the values of the given keys.
40  The effect is that the data references in each group have the same
41  values for the provided keys.
42 
43  @param keys: List of keys to consider when grouping (order is important)
44  @param dataRefIterable: Iterable of data references to group
45  @return Dict of <value-tuple>: <list of data references for group>
46  """
47  groupDict = dict()
48  for dataRef in dataRefIterable:
49  dataId = dataRef.dataId
50  values = tuple(dataId[key] for key in keys) # NOT dataId.values() as we must preserve order
51  group = groupDict.get(values)
52  if group:
53  group.append(dataRef)
54  else:
55  groupDict[values] = [dataRef]
56 
57  return groupDict
def lsst.pipe.tasks.coaddHelpers.groupPatchExposures (   patchDataRef,
  calexpDataRefList,
  coaddDatasetType = "deepCoadd",
  tempExpDatasetType = "deepCoadd_tempExp" 
)
Group calibrated exposures overlapping a patch by the warped
(temporary) exposure they contribute to.

For example, if the instrument has a mosaic camera, each group would
consist of the subset of CCD exposures from a single camera exposure
that potentially overlap the patch.

@return Struct with:
- groups: Dict of <group tuple>: <list of data references for group>
- keys: List of keys for group tuple

Definition at line 59 of file coaddHelpers.py.

59 
60  tempExpDatasetType="deepCoadd_tempExp"):
61  """Group calibrated exposures overlapping a patch by the warped
62  (temporary) exposure they contribute to.
63 
64  For example, if the instrument has a mosaic camera, each group would
65  consist of the subset of CCD exposures from a single camera exposure
66  that potentially overlap the patch.
67 
68  @return Struct with:
69  - groups: Dict of <group tuple>: <list of data references for group>
70  - keys: List of keys for group tuple
71  """
72  butler = patchDataRef.getButler()
73  tempExpKeys = butler.getKeys(datasetType=tempExpDatasetType)
74  coaddKeys = sorted(butler.getKeys(datasetType=coaddDatasetType))
75  keys = sorted(set(tempExpKeys) - set(coaddKeys)) # Keys that will specify an exposure
76  patchId = patchDataRef.dataId
77  groups = groupDataRefs(keys, calexpDataRefList)
78 
79  # Supplement the groups with the coadd-specific information (e.g., tract, patch; these are constant)
80  coaddValues = tuple(patchId[k] for k in coaddKeys)
81  groups = dict((k + coaddValues, v) for k,v in groups.iteritems())
82  keys += tuple(coaddKeys)
83 
84  return Struct(groups=groups, keys=keys)