37 doDeblend = pexConfig.Field(dtype=bool, default=
True, doc =
"Deblend sources?")
38 doMeasurement = pexConfig.Field(dtype=bool, default=
True, doc =
"Measure sources?")
39 doWriteSources = pexConfig.Field(dtype=bool, default=
True, doc =
"Write sources?")
40 doWriteHeavyFootprintsInSources = pexConfig.Field(dtype=bool, default=
False,
41 doc =
"Include HeavyFootprint data in source table?")
43 sourceOutputFile = pexConfig.Field(dtype=str, default=
None, doc=
"Write sources to given filename (default: use butler)", optional=
True)
45 deblend = pexConfig.ConfigurableField(
46 target = SourceDeblendTask,
47 doc =
"Split blended sources into their components",
49 measurement = pexConfig.ConfigurableField(
50 target = SourceMeasurementTask,
51 doc =
"Final source measurement on low-threshold detections",
56 ConfigClass = DeblendAndMeasureConfig
57 _DefaultName =
"deblendAndMeasure"
63 pipeBase.CmdLineTask.__init__(self, **kwargs)
66 def run(self, dataRef):
67 self.log.info(
"Processing %s" % (dataRef.dataId))
68 calexp = dataRef.get(
'calexp')
69 srcs = dataRef.get(
'src')
70 print 'Calexp:', calexp
79 mapper.addMinimalSchema(srcs.getSchema(),
True)
80 schema = mapper.getOutputSchema()
82 if self.config.doDeblend:
83 self.makeSubtask(
"deblend", schema=schema)
84 if self.config.doMeasurement:
85 self.makeSubtask(
"measurement", schema=schema, algMetadata=self.
algMetadata)
90 if src.getParent() == 0:
94 outsources.reserve(len(parents))
95 outsources.extend(parents, mapper=mapper)
97 print len(srcs),
'sources before deblending'
99 if self.config.doDeblend:
100 self.deblend.run(calexp, srcs, calexp.getPsf())
102 if self.config.doMeasurement:
103 self.measurement.run(calexp, srcs)
105 if srcs
is not None and self.config.doWriteSources:
106 sourceWriteFlags = (0
if self.config.doWriteHeavyFootprintsInSources
107 else afwTable.SOURCE_IO_NO_HEAVY_FOOTPRINTS)
108 print 'Writing "src" outputs'
109 if self.config.sourceOutputFile:
110 srcs.writeFits(self.config.sourceOutputFile, flags=sourceWriteFlags)
112 dataRef.put(srcs,
'src', flags=sourceWriteFlags)
114 if __name__ ==
'__main__':
115 DeblendAndMeasureTask.parseAndRun()
Class for storing ordered metadata with comments.
A mapping between the keys of two Schemas, used to copy data between them.
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
algMetadata
FIXME – this whole mapping business is very fragile – it seems to fail, eg, if you don't set "-c do...