23Tasks for transforming raw measurement outputs to calibrated quantities.
28from lsst.utils.timer
import timeMethod
32 """!Return a version of the input catalog which is contiguous in memory."""
33 if not catalog.isContiguous():
34 return catalog.copy(deep=
True)
40 """!Configuration for TransformTask."""
41 copyFields = pexConfig.ListField(
43 doc=
"Fields to copy from input to output catalog without transformation",
44 default=(
'id',
'coord_ra',
'coord_dec')
57 \anchor TransformTask_
59 \brief Transform a SourceCatalog containing raw measurements to calibrated form.
61 \section pipe_tasks_transform_Contents Contents
63 - \ref pipe_tasks_transform_purpose
64 - \ref pipe_tasks_transform_initialize
65 - \ref pipe_tasks_transform_invoke
67 \section pipe_tasks_transform_purpose Description
69 Given a set of measurement algorithms with their associated configuration,
70 the table of source measurements they have produced,
and information about
71 an associated WCS
and calibration, transform the raw measurement output to
74 Transformations are defined on a per-measurement-plugin basis. In
75 addition, a configurable set of fields may be simply copied
from the input
76 to the output catalog.
78 This task operates on an input SourceCatalog
and returns a BaseCatalog
79 containing the transformed results. It requires that the caller supply
80 information on the configuration of the measurement task which produced
81 the input data
as well
as the world coordinate system
and calibration
82 under which the transformation will take place. It provides no
83 functionality
for reading
or writing data
from a Butler: rather,
84 per-dataset-type command line tasks are provided to obtain the appropriate
85 information
from a Butler (
or elsewhere)
and then delegate to this task.
87 \section pipe_tasks_transform_initialize Task initialization
91 \section pipe_tasks_transform_invoke Task invocation
95 ConfigClass = TransformConfig
96 _DefaultName = "transform"
98 def __init__(self, measConfig, inputSchema, outputDataset, *args, **kwargs):
99 """!Initialize TransformTask.
101 @param[
in] measConfig Configuration
for the measurement task which
102 produced the measurments being transformed.
103 @param[
in] inputSchema The schema of the input catalog.
104 @param[
in] outputDataset The butler dataset type of the output catalog.
105 @param[
in] *args Passed through to pipeBase.Task.__init__()
106 @param[
in] *kwargs Passed through to pipeBase.Task.__init__()
108 pipeBase.Task.__init__(self, *args, **kwargs)
116 for field
in self.config.copyFields:
117 self.
mappermapper.addMapping(inputSchema.find(field).key)
122 for name
in measConfig.plugins.names:
123 config = measConfig.plugins.get(name)
124 transformClass = measConfig.plugins.registry.get(name).PluginClass.getTransformClass()
128 """!Return a dict containing an empty catalog representative of this task's output."""
133 def run(self, inputCat, wcs, photoCalib):
134 """!Transform raw source measurements to calibrated quantities.
136 @param[
in] inputCat SourceCatalog of sources to transform.
137 @param[
in] wcs The world coordinate system under which transformations will take place.
138 @param[
in] photoCalib The calibration under which transformations will take place.
140 @return A BaseCatalog containing the transformed measurements.
143 outputCat.extend(inputCat, mapper=self.mappermapper)
151 transform(inputCat, outputCat, wcs, photoCalib)
156 """!Configuration for RunTransformTaskBase derivatives."""
157 transform = pexConfig.ConfigurableField(
158 doc=
"Subtask which performs transformations",
161 inputConfigType = pexConfig.Field(
163 doc=
"Dataset type of measurement operation configuration",
169 \anchor RunTransformTaskBase_
171 \brief Command line interface for TransformTask.
173 \section pipe_tasks_runtransform_Contents Contents
175 - \ref pipe_tasks_runtransform_purpose
176 - \ref pipe_tasks_runtransform_invoke
178 \section pipe_tasks_runtransform_purpose Description
180 Provides a command-line task which can be used to run TransformTask.
182 - Loads a plugin registry based on configuration;
183 - Loads configuration
for the measurement task which was applied
from a repository;
184 - Loads the SourceCatalog input schema
from a repository;
185 - For each input dataRef, reads the SourceCatalog, WCS
and calibration
from the
186 repository
and executes TransformTask.
188 This
is not a fully-fledged command line task: it requires specialization to a particular
189 source type by defining the variables indicated below.
191 \section pipe_tasks_runtransform_invoke Task invocation
195 RunnerClass = pipeBase.ButlerInitializedTaskRunner
196 ConfigClass = RunTransformConfig
213 The Butler dataset type for the schema of the input source catalog.
215 By default, we append `_schema` to the input source type. Subclasses may customize
223 The Butler dataset type for the schema of the output catalog.
225 By default, we prepend `transformed_` to the input source type. Subclasses may
226 customize
if required.
228 return 'transformed_' + self.
sourceTypesourceType
233 The configuration of the measurement operation used to generate the input catalog.
235 By default we look for `measurement` under the root configuration of the
236 generating task. Subclasses may customize this (e.g. to `calibrate.measurement`)
239 return self.
butlerbutler.get(self.config.inputConfigType).measurement.value
242 pipeBase.CmdLineTask.__init__(self, *args, config=kwargs[
'config'], log=kwargs[
'log'])
244 self.makeSubtask(
'transform', measConfig=self.
measurementConfigmeasurementConfig,
250 """!Transform the source catalog referred to by dataRef.
252 The result is both returned
and written
as dataset type
"transformed_" + the input
253 source dataset type to the provided dataRef.
255 @param[
in] dataRef Data reference
for source catalog & calibrated exposure.
257 @returns A BaseCatalog containing the transformed measurements.
259 inputCat = dataRef.get(self.sourceTypesourceType)
260 wcs = dataRef.get(self.calexpTypecalexpType).getWcs()
261 photoCalib = dataRef.get(self.calexpTypecalexpType).getPhotoCalib()
262 outputCat = self.transform.run(inputCat, wcs, photoCalib)
276 \anchor SrcTransformTask_
278 \brief Transform ``src`` measuremenents to calibrated form.
280 This is a specialization of \ref RunTransformTaskBase_
"RunTransformTaskBase" which
281 operates on ``src`` measurements. Refer to the parent documentation
for details.
283 _DefaultName = "transformSrcMeasurement"
285 calexpType =
'calexp'
289 return self.
butlerbutler.get(self.config.inputConfigType).calibrate.measurement.value
301 \anchor ForcedSrcTransformTask_
303 \brief Transform ``forced_src`` measuremenents to calibrated form.
305 This is a specialization of \ref RunTransformTaskBase_
"RunTransformTaskBase" which
306 operates on ``forced_src`` measurements. Refer to the parent documentation
for details.
308 _DefaultName = "transformForcedSrcMeasurement"
309 sourceType =
'forced_src'
310 calexpType =
'calexp'
322 \anchor CoaddSrcTransformTask_
324 \brief Transform measuremenents made on coadds to calibrated form.
326 This is a specialization of \ref RunTransformTaskBase_
"RunTransformTaskBase" which
327 operates on measurements made on coadds. Refer to the parent documentation
for details.
329 _DefaultName = "transformCoaddSrcMeasurement"
333 return self.
butlerbutler.get(self.config.inputConfigType).coaddName
337 return self.
coaddNamecoaddName +
"Coadd_meas"
341 return self.
coaddNamecoaddName +
"Coadd_calexp"
343 def _getConfigName(self):
344 return "%s_transformCoaddSrcMeasurement_config" % (self.
coaddNamecoaddName,)
346 def _getMetaDataName(self):
347 return "%s_transformCoaddSrcMeasurement_metadata" % (self.
coaddNamecoaddName,)
A mapping between the keys of two Schemas, used to copy data between them.
std::shared_ptr< FrameSet > append(FrameSet const &first, FrameSet const &second)
Construct a FrameSet that performs two transformations in series.
def run(self, coaddExposures, bbox, wcs, dataIds, **kwargs)