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
Public Member Functions | Public Attributes | Static Public Attributes | Static Private Attributes | List of all members
lsst.pipe.tasks.multiBand.MergeMeasurementsTask Class Reference
Inheritance diagram for lsst.pipe.tasks.multiBand.MergeMeasurementsTask:
lsst.pipe.tasks.multiBand.MergeSourcesTask

Public Member Functions

def __init__
 
def mergeCatalogs
 
- Public Member Functions inherited from lsst.pipe.tasks.multiBand.MergeSourcesTask
def getInputSchema
 
def __init__
 
def run
 
def readCatalog
 
def mergeCatalogs
 
def write
 
def writeMetadata
 

Public Attributes

 schemaMapper
 
 flagKeys
 
 schema
 

Static Public Attributes

string inputDataset = "meas"
 
string outputDataset = "ref"
 
tuple getSchemaCatalogs = _makeGetSchemaCatalogs("ref")
 
- Static Public Attributes inherited from lsst.pipe.tasks.multiBand.MergeSourcesTask
 ConfigClass = MergeSourcesConfig
 
 RunnerClass = MergeSourcesRunner
 
 inputDataset = None
 
 outputDataset = None
 
 getSchemaCatalogs = None
 

Static Private Attributes

string _DefaultName = "mergeCoaddMeasurements"
 

Detailed Description

Measure measurements from multiple bands

Definition at line 651 of file multiBand.py.

Constructor & Destructor Documentation

def lsst.pipe.tasks.multiBand.MergeMeasurementsTask.__init__ (   self,
  butler = None,
  schema = None,
  kwargs 
)
Initialize the task.

Additional keyword arguments (forwarded to MergeSourcesTask.__init__):
 - schema: the schema of the detection catalogs used as input to this one
 - butler: a butler used to read the input schema from disk, if schema is None

The task will set its own self.schema attribute to the schema of the output merged catalog.

Definition at line 658 of file multiBand.py.

659  def __init__(self, butler=None, schema=None, **kwargs):
660  """Initialize the task.
661 
662  Additional keyword arguments (forwarded to MergeSourcesTask.__init__):
663  - schema: the schema of the detection catalogs used as input to this one
664  - butler: a butler used to read the input schema from disk, if schema is None
665 
666  The task will set its own self.schema attribute to the schema of the output merged catalog.
667  """
668  MergeSourcesTask.__init__(self, butler=butler, schema=schema, **kwargs)
669  inputSchema = self.getInputSchema(butler=butler, schema=schema)
670  self.schemaMapper = afwTable.SchemaMapper(inputSchema, True)
671  self.schemaMapper.addMinimalSchema(inputSchema, True)
672  self.flagKeys = {}
673  for band in self.config.priorityList:
674  short = getShortFilterName(band)
675  outputKey = self.schemaMapper.editOutputSchema().addField(
676  "merge_measurement_%s" % short,
677  type="Flag",
678  doc="Flag field set if the measurements here are from the %s filter" % band
679  )
680  peakKey = inputSchema.find("merge_peak_%s" % short).key
681  footprintKey = inputSchema.find("merge_footprint_%s" % short).key
682  self.flagKeys[band] = Struct(peak=peakKey, footprint=footprintKey, output=outputKey)
683  self.schema = self.schemaMapper.getOutputSchema()
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:19

Member Function Documentation

def lsst.pipe.tasks.multiBand.MergeMeasurementsTask.mergeCatalogs (   self,
  catalogs,
  patchRef 
)
Merge measurement catalogs to create a single reference catalog for forced photometry

For parent sources, we choose the first band in config.priorityList for which the
merge_footprint flag for that band is is True.

For child sources, the logic is the same, except that we use the merge_peak flags.

Definition at line 684 of file multiBand.py.

685  def mergeCatalogs(self, catalogs, patchRef):
686  """Merge measurement catalogs to create a single reference catalog for forced photometry
687 
688  For parent sources, we choose the first band in config.priorityList for which the
689  merge_footprint flag for that band is is True.
690 
691  For child sources, the logic is the same, except that we use the merge_peak flags.
692  """
693  # Put catalogs, filters in priority order
694  orderedCatalogs = [catalogs[band] for band in self.config.priorityList if band in catalogs.keys()]
695  orderedKeys = [self.flagKeys[band] for band in self.config.priorityList if band in catalogs.keys()]
696 
697  mergedCatalog = afwTable.SourceCatalog(self.schema)
698  mergedCatalog.reserve(len(orderedCatalogs[0]))
699 
700  idKey = orderedCatalogs[0].table.getIdKey()
701  for catalog in orderedCatalogs[1:]:
702  if numpy.any(orderedCatalogs[0].get(idKey) != catalog.get(idKey)):
703  raise ValueError("Error in inputs to MergeCoaddMeasurements: source IDs do not match")
704 
705  # This first zip iterates over all the catalogs simultaneously, yielding a sequence of one
706  # record for each band, in order.
707  for n, orderedRecords in enumerate(zip(*orderedCatalogs)):
708  # Now we iterate over those record-band pairs, until we find the one with the right flag set.
709  for inputRecord, flagKeys in zip(orderedRecords, orderedKeys):
710  bestParent = (inputRecord.getParent() == 0 and inputRecord.get(flagKeys.footprint))
711  bestChild = (inputRecord.getParent() != 0 and inputRecord.get(flagKeys.peak))
712  if bestParent or bestChild:
713  outputRecord = mergedCatalog.addNew()
714  outputRecord.assign(inputRecord, self.schemaMapper)
715  outputRecord.set(flagKeys.output, True)
716  break
717  else: # if we didn't break (i.e. didn't find any record with right flag set)
718  raise ValueError("Error in inputs to MergeCoaddMeasurements: no valid reference for %s" %
719  inputRecord.getId())
720 
721  # more checking for sane inputs, since zip silently iterates over the smallest sequence
722  for inputCatalog in orderedCatalogs:
723  if len(mergedCatalog) != len(inputCatalog):
724  raise ValueError("Mismatch between catalog sizes: %s != %s" %
725  (len(mergedCatalog), len(orderedCatalogs)))
726 
727  return mergedCatalog
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
Definition: fwd.h:55

Member Data Documentation

string lsst.pipe.tasks.multiBand.MergeMeasurementsTask._DefaultName = "mergeCoaddMeasurements"
staticprivate

Definition at line 653 of file multiBand.py.

lsst.pipe.tasks.multiBand.MergeMeasurementsTask.flagKeys

Definition at line 671 of file multiBand.py.

tuple lsst.pipe.tasks.multiBand.MergeMeasurementsTask.getSchemaCatalogs = _makeGetSchemaCatalogs("ref")
static

Definition at line 656 of file multiBand.py.

string lsst.pipe.tasks.multiBand.MergeMeasurementsTask.inputDataset = "meas"
static

Definition at line 654 of file multiBand.py.

string lsst.pipe.tasks.multiBand.MergeMeasurementsTask.outputDataset = "ref"
static

Definition at line 655 of file multiBand.py.

lsst.pipe.tasks.multiBand.MergeMeasurementsTask.schema

Definition at line 682 of file multiBand.py.

lsst.pipe.tasks.multiBand.MergeMeasurementsTask.schemaMapper

Definition at line 669 of file multiBand.py.


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