23 Tasks for transforming raw measurement outputs to calibrated quantities.
30 """!Return a version of the input catalog which is contiguous in memory."""
31 if not catalog.isContiguous():
32 return catalog.copy(deep=
True)
38 """!Configuration for TransformTask."""
39 copyFields = pexConfig.ListField(
41 doc=
"Fields to copy from input to output catalog without transformation",
42 default=(
'id',
'coord_ra',
'coord_dec')
54 \anchor TransformTask_
56 \brief Transform a SourceCatalog containing raw measurements to calibrated form.
58 \section pipe_tasks_transform_Contents Contents
60 - \ref pipe_tasks_transform_purpose
61 - \ref pipe_tasks_transform_initialize
62 - \ref pipe_tasks_transform_invoke
64 \section pipe_tasks_transform_purpose Description
66 Given a set of measurement algorithms with their associated configuration,
67 the table of source measurements they have produced, and information about
68 an associated WCS and calibration, transform the raw measurement output to
71 Transformations are defined on a per-measurement-plugin basis. In
72 addition, a configurable set of fields may be simply copied from the input
73 to the output catalog.
75 This task operates on an input SourceCatalog and returns a BaseCatalog
76 containing the transformed results. It requires that the caller supply
77 information on the configuration of the measurement task which produced
78 the input data as well as the world coordinate system and calibration
79 under which the transformation will take place. It provides no
80 functionality for reading or writing data from a Butler: rather,
81 per-dataset-type command line tasks are provided to obtain the appropriate
82 information from a Butler (or elsewhere) and then delegate to this task.
84 \section pipe_tasks_transform_initialize Task initialization
88 \section pipe_tasks_transform_invoke Task invocation
92 ConfigClass = TransformConfig
93 _DefaultName =
"transform"
95 def __init__(self, measConfig, inputSchema, outputDataset, *args, **kwargs):
96 """!Initialize TransformTask.
98 @param[in] measConfig Configuration for the measurement task which
99 produced the measurments being transformed.
100 @param[in] inputSchema The schema of the input catalog.
101 @param[in] outputDataset The butler dataset type of the output catalog.
102 @param[in] *args Passed through to pipeBase.Task.__init__()
103 @param[in] *kwargs Passed through to pipeBase.Task.__init__()
105 pipeBase.Task.__init__(self, *args, **kwargs)
113 for field
in self.config.copyFields:
114 self.mapper.addMapping(inputSchema.find(field).key)
119 for name
in measConfig.plugins.names:
120 config = measConfig.plugins.get(name)
121 transformClass = measConfig.plugins.registry.get(name).PluginClass.getTransformClass()
122 self.transforms.append(transformClass(config, name, self.
mapper))
125 """!Return a dict containing an empty catalog representative of this task's output."""
129 def run(self, inputCat, wcs, calib):
130 """!Transform raw source measurements to calibrated quantities.
132 @param[in] inputCat SourceCatalog of sources to transform.
133 @param[in] wcs The world coordinate system under which transformations will take place.
134 @param[in] calib The calibration under which transformations will take place.
136 @return A BaseCatalog containing the transformed measurements.
139 outputCat.extend(inputCat, mapper=self.
mapper)
147 transform(inputCat, outputCat, wcs, calib)
152 """!Configuration for RunTransformTaskBase derivatives."""
153 transform = pexConfig.ConfigurableField(
154 doc=
"Subtask which performs transformations",
157 inputConfigType = pexConfig.Field(
159 doc=
"Dataset type of measurement operation configuration",
165 \anchor RunTransformTaskBase_
167 \brief Command line interface for TransformTask.
169 \section pipe_tasks_transform_Contents Contents
171 - \ref pipe_tasks_runtransform_purpose
172 - \ref pipe_tasks_runtransform_invoke
174 \section pipe_tasks_runtransform_purpose Description
176 Provides a command-line task which can be used to run TransformTask.
178 - Loads a plugin registry based on configuration;
179 - Loads configuration for the measurement task which was applied from a repository;
180 - Loads the SourceCatalog input schema from a repository;
181 - For each input dataRef, reads the SourceCatalog, WCS and calibration from the
182 repository and executes TransformTask.
184 This is not a fully-fledged command line task: it requires specialization to a particular
185 source type by defining the variables indicated below.
187 \section pipe_tasks_runtransform_invoke Task invocation
191 RunnerClass = pipeBase.ButlerInitializedTaskRunner
192 ConfigClass = RunTransformConfig
209 The Butler dataset type for the schema of the input source catalog.
211 By default, we append `_schema` to the input source type. Subclasses may customize
219 The Butler dataset type for the schema of the output catalog.
221 By default, we prepend `transformed_` to the input source type. Subclasses may
222 customize if required.
229 The configuration of the measurement operation used to generate the input catalog.
231 By default we look for `measurement` under the root configuration of the
232 generating task. Subclasses may customize this (e.g. to `calibrate.measurement`)
235 return self.butler.get(self.config.inputConfigType).measurement.value
238 pipeBase.CmdLineTask.__init__(self, *args, config=kwargs[
'config'], log=kwargs[
'log'])
246 """!Transform the source catalog referred to by dataRef.
248 The result is both returned and written as dataset type "transformed_" + the input
249 source dataset type to the provided dataRef.
251 @param[in] dataRef Data reference for source catalog & calibrated exposure.
253 @returns A BaseCatalog containing the transformed measurements.
257 calib = dataRef.get(self.
calexpType).getCalib()
258 outputCat = self.transform.run(inputCat, wcs, calib)
272 \anchor SrcTransformTask_
274 \brief Transform ``src`` measuremenents to calibrated form.
276 This is a specialization of \ref RunTransformTaskBase_ "RunTransformTaskBase" which
277 operates on ``src`` measurements. Refer to the parent documentation for details.
279 _DefaultName =
"transformSrcMeasurement"
281 calexpType =
'calexp'
285 return self.butler.get(self.config.inputConfigType).calibrate.measurement.value
297 \anchor ForcedSrcTransformTask_
299 \brief Transform ``forced_src`` measuremenents to calibrated form.
301 This is a specialization of \ref RunTransformTaskBase_ "RunTransformTaskBase" which
302 operates on ``forced_src`` measurements. Refer to the parent documentation for details.
304 _DefaultName =
"transformForcedSrcMeasurement"
305 sourceType =
'forced_src'
306 calexpType =
'calexp'
318 \anchor CoaddSrcTransformTask_
320 \brief Transform measuremenents made on coadds to calibrated form.
322 This is a specialization of \ref RunTransformTaskBase_ "RunTransformTaskBase" which
323 operates on measurements made on coadds. Refer to the parent documentation for details.
325 _DefaultName =
"transformCoaddSrcMeasurement"
329 return self.butler.get(self.config.inputConfigType).coaddName
340 return "%s_transformCoaddSrcMeasurement_config" % (self.
coaddName,)
343 return "%s_transformCoaddSrcMeasurement_metadata" % (self.
coaddName,)
A custom container class for records, based on std::vector.
A mapping between the keys of two Schemas, used to copy data between them.