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
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
lsst::afw::detection::FootprintMergeList Class Reference

List of Merged Footprints. More...

#include <FootprintMerge.h>

Classes

struct  KeyTuple
 

Public Member Functions

 FootprintMergeList (afw::table::Schema &sourceSchema, std::vector< std::string > const &filterList, afw::table::Schema const &initialPeakSchema)
 
 FootprintMergeList (afw::table::Schema &sourceSchema, std::vector< std::string > const &filterList)
 
afw::table::Schema getPeakSchema () const
 Return the schema for PeakRecords in the merged footprints. More...
 
void addCatalog (boost::shared_ptr< afw::table::SourceTable > sourceTable, afw::table::SourceCatalog const &inputCat, std::string const &filter, float minNewPeakDist=-1., bool doMerge=true, float maxSamePeakDist=-1.)
 Add objects from a SourceCatalog in the specified filter. More...
 
void clearCatalog ()
 Clear entries in the current vector. More...
 
void getFinalSources (afw::table::SourceCatalog &outputCat, bool doNorm=true)
 Get SourceCatalog with entries that contain the final Footprint and SourceRecord for each entry. More...
 

Private Types

typedef afw::table::Key
< afw::table::Flag > 
FlagKey
 
typedef std::vector
< boost::shared_ptr
< FootprintMerge > > 
FootprintMergeVec
 
typedef std::map< std::string,
KeyTuple
FilterMap
 

Private Member Functions

void _initialize (afw::table::Schema &sourceSchema, std::vector< std::string > const &filterList)
 

Private Attributes

FootprintMergeVec _mergeList
 
FilterMap _filterMap
 
afw::table::SchemaMapper _peakSchemaMapper
 
boost::shared_ptr< PeakTable_peakTable
 

Friends

class FootprintMerge
 

Detailed Description

List of Merged Footprints.

Stores a vector of FootprintMerges and SourceRecords that contain the union of different footprints and which filters it was detected in. Individual Footprints from a SourceCatalog can be added to the vector (note that any SourceRecords with parent!=0 will be skipped). If a Footprint overlaps an existing FootprintMerge, the Footprint will be added to it. If not, then a new FootprintMerge will be created and added to the vector.

The search algorithm uses a brute force approach over the current list. This should be fine if we are operating on smallish number of objects, such as at the tract level.

Definition at line 54 of file FootprintMerge.h.

Member Typedef Documentation

typedef std::map<std::string,KeyTuple> lsst::afw::detection::FootprintMergeList::FilterMap
private

Definition at line 138 of file FootprintMerge.h.

Definition at line 130 of file FootprintMerge.h.

typedef std::vector<boost::shared_ptr< FootprintMerge > > lsst::afw::detection::FootprintMergeList::FootprintMergeVec
private

Definition at line 137 of file FootprintMerge.h.

Constructor & Destructor Documentation

lsst::afw::detection::FootprintMergeList::FootprintMergeList ( afw::table::Schema sourceSchema,
std::vector< std::string > const &  filterList,
afw::table::Schema const &  initialPeakSchema 
)

Initialize the merge with a custom initial peak schema

Parameters
[in,out]sourceSchemaInput schema for SourceRecords to be merged, modified on return to include 'merge_footprint_<filter>' Flag fields that will indicate the origin of the source.
[in]filterListSequence of filter names to be used in Flag fields.
[in]initialPeakSchemaInput schema of PeakRecords in Footprints to be merged.

The output schema for PeakRecords will include additional 'merge_peak_<filter>' Flag fields that indicate the origin of peaks. This can be accessed by getPeakSchema().

Definition at line 215 of file FootprintMerge.cc.

219  : _peakSchemaMapper(initialPeakSchema) {
220  _initialize(sourceSchema, filterList);
221 }
void _initialize(afw::table::Schema &sourceSchema, std::vector< std::string > const &filterList)
afw::table::SchemaMapper _peakSchemaMapper
lsst::afw::detection::FootprintMergeList::FootprintMergeList ( afw::table::Schema sourceSchema,
std::vector< std::string > const &  filterList 
)

Initialize the merge with the default peak schema

Parameters
[in,out]sourceSchemaInput schema for SourceRecords to be merged, modified on return to include 'merge_footprint_<filter>' Flag fields that will indicate the origin of the source.
[in]filterListSequence of filter names to be used in Flag fields.
[in]initialPeakSchemaInput schema of PeakRecords in Footprints to be merged.

The output schema for PeakRecords will include additional 'merge_peak_<filter>' Flag fields that indicate the origin of peaks. This can be accessed by getPeakSchema().

Definition at line 223 of file FootprintMerge.cc.

227  _initialize(sourceSchema, filterList);
228 }
static afw::table::Schema makeMinimalSchema()
Return a minimal schema for Peak tables and records.
Definition: Peak.h:116
void _initialize(afw::table::Schema &sourceSchema, std::vector< std::string > const &filterList)
afw::table::SchemaMapper _peakSchemaMapper

Member Function Documentation

void lsst::afw::detection::FootprintMergeList::_initialize ( afw::table::Schema sourceSchema,
std::vector< std::string > const &  filterList 
)
private

Definition at line 230 of file FootprintMerge.cc.

233  {
235  // Add Flags for the filters
236  for (
237  std::vector<std::string>::const_iterator iter=filterList.begin();
238  iter != filterList.end();
239  ++iter
240  ) {
241  KeyTuple & keys = _filterMap[*iter];
242  keys.footprint = sourceSchema.addField<afw::table::Flag>(
243  "merge_footprint_" + *iter,
244  "Detection footprint overlapped with a detection from filter " + *iter
245  );
246  keys.peak = _peakSchemaMapper.editOutputSchema().addField<afw::table::Flag>(
247  "merge_peak_" + *iter,
248  "Peak detected in filter " + *iter
249  );
250  }
252 }
int iter
Schema const getOutputSchema() const
Return the output schema (copy-on-write).
Definition: SchemaMapper.h:26
Schema const getInputSchema() const
Return the input schema (copy-on-write).
Definition: SchemaMapper.h:23
static boost::shared_ptr< PeakTable > make(afw::table::Schema const &schema, bool forceNew=false)
Obtain a table that can be used to create records with given schema.
Definition: Peak.cc:154
Key< T > addField(Field< T > const &field, bool doReplace=false)
Add a new field to the Schema, and return the associated Key.
Schema & editOutputSchema()
Return a reference to the output schema that allows it to be modified in place.
Definition: SchemaMapper.h:29
void addMinimalSchema(Schema const &minimal, bool doMap=true)
Add the given minimal schema to the output schema.
boost::shared_ptr< PeakTable > _peakTable
afw::table::SchemaMapper _peakSchemaMapper
void lsst::afw::detection::FootprintMergeList::addCatalog ( boost::shared_ptr< afw::table::SourceTable sourceTable,
afw::table::SourceCatalog const &  inputCat,
std::string const &  filter,
float  minNewPeakDist = -1.,
bool  doMerge = true,
float  maxSamePeakDist = -1. 
)

Add objects from a SourceCatalog in the specified filter.

Iterate over all objects that have not been deblendend and search for an overlapping FootprintMerge in _mergeList. If it overlaps, then it will be added to it, otherwise it will create a new one. If minNewPeakDist < 0, then new peaks will not be added to existing footprints. If minNewPeakDist >= 0, then new peaks will be added that are farther away than minNewPeakDist to the nearest existing peak.

The SourceTable is used to create new SourceRecords that store the filter information.

Definition at line 254 of file FootprintMerge.cc.

259  {
260  FilterMap::const_iterator keyIter = _filterMap.find(filter);
261  if (keyIter == _filterMap.end()) {
262  throw LSST_EXCEPT(
263  pex::exceptions::LogicError,
264  (boost::format("Filter %s not in original list") % filter).str()
265  );
266  }
267 
268  // If list is empty don't check for any matches, just add all the objects
269  bool checkForMatches = (_mergeList.size() > 0);
270 
271  for (afw::table::SourceCatalog::const_iterator srcIter = inputCat.begin(); srcIter != inputCat.end();
272  ++srcIter) {
273 
274  // Only consider unblended objects
275  if (srcIter->getParent() != 0) continue;
276 
277  PTR(Footprint) foot = srcIter->getFootprint();
278 
279  // Empty pointer to account for the first match in the catalog. If there is more than one
280  // match, subsequent matches will be merged with this one
281  PTR(FootprintMerge) first = PTR(FootprintMerge)();
282 
283  if (checkForMatches) {
284  FootprintMergeVec::iterator iter = _mergeList.begin();
285  while (iter != _mergeList.end()) {
286  // Grow by one pixel to allow for touching
287  geom::Box2I box((**iter).getBBox());
288  box.grow(geom::Extent2I(1,1));
289  if (box.overlaps(foot->getBBox()) && (**iter).overlaps(*foot)) {
290  if (!first) {
291  first = *iter;
292  // Add Footprint to existing merge and set flag for this band
293  if (doMerge) {
294  first->add(foot, _peakSchemaMapper, keyIter->second, minNewPeakDist,
295  maxSamePeakDist);
296  }
297  } else {
298  // Add merged Footprint to first
299  if (doMerge) {
300  first->add(**iter, _filterMap, minNewPeakDist, maxSamePeakDist);
301  iter = _mergeList.erase(iter);
302  continue;
303  }
304  }
305  }
306  ++iter;
307  }
308  }
309 
310  if (!first) {
311  _mergeList.push_back(
312  boost::make_shared<FootprintMerge>(
313  foot, sourceTable, _peakTable, _peakSchemaMapper, keyIter->second
314  )
315  );
316  }
317  }
318 }
int iter
#define PTR(...)
Definition: base.h:41
An integer coordinate rectangle.
Definition: Box.h:53
if(width!=gim.getWidth()||height!=gim.getHeight()||x0!=gim.getX0()||y0!=gim.getY0())
Definition: saturated.cc:47
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
void grow(int buffer)
Increase the size of the box by the given buffer amount in all directions.
Definition: Box.h:193
Base::const_iterator const_iterator
Definition: SortedCatalog.h:49
boost::shared_ptr< PeakTable > _peakTable
lsst::afw::detection::Footprint Footprint
Definition: Source.h:61
afw::table::SchemaMapper _peakSchemaMapper
void lsst::afw::detection::FootprintMergeList::clearCatalog ( )
inline

Clear entries in the current vector.

Definition at line 118 of file FootprintMerge.h.

118 { _mergeList.clear(); }
void lsst::afw::detection::FootprintMergeList::getFinalSources ( afw::table::SourceCatalog outputCat,
bool  doNorm = true 
)

Get SourceCatalog with entries that contain the final Footprint and SourceRecord for each entry.

The resulting Footprints will be normalized, meaning that there peaks are sorted, and areas are calculated.

Definition at line 320 of file FootprintMerge.cc.

321 {
322  // Now set the merged footprint as the footprint of the SourceRecord
323  for (FootprintMergeVec::iterator iter = _mergeList.begin(); iter != _mergeList.end(); ++iter) {
324  if (doNorm) (**iter).getMergedFootprint()->normalize();
325  outputCat.push_back((**iter).getSource());
326  }
327 }
int iter
afw::table::Schema lsst::afw::detection::FootprintMergeList::getPeakSchema ( ) const
inline

Return the schema for PeakRecords in the merged footprints.

Definition at line 93 of file FootprintMerge.h.

93 { return _peakTable->getSchema(); }
boost::shared_ptr< PeakTable > _peakTable

Friends And Related Function Documentation

friend class FootprintMerge
friend

Definition at line 140 of file FootprintMerge.h.

Member Data Documentation

FilterMap lsst::afw::detection::FootprintMergeList::_filterMap
private

Definition at line 148 of file FootprintMerge.h.

FootprintMergeVec lsst::afw::detection::FootprintMergeList::_mergeList
private

Definition at line 147 of file FootprintMerge.h.

afw::table::SchemaMapper lsst::afw::detection::FootprintMergeList::_peakSchemaMapper
private

Definition at line 149 of file FootprintMerge.h.

boost::shared_ptr< PeakTable > lsst::afw::detection::FootprintMergeList::_peakTable
private

Definition at line 150 of file FootprintMerge.h.


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