23 Tasks for transforming raw measurement outputs to calibrated quantities. 26 import lsst.pex.config
as pexConfig
31 """!Return a version of the input catalog which is contiguous in memory.""" 32 if not catalog.isContiguous():
33 return catalog.copy(deep=
True)
39 """!Configuration for TransformTask.""" 40 copyFields = pexConfig.ListField(
42 doc=
"Fields to copy from input to output catalog without transformation",
43 default=(
'id',
'coord_ra',
'coord_dec')
56 \anchor TransformTask_ 58 \brief Transform a SourceCatalog containing raw measurements to calibrated form. 60 \section pipe_tasks_transform_Contents Contents 62 - \ref pipe_tasks_transform_purpose 63 - \ref pipe_tasks_transform_initialize 64 - \ref pipe_tasks_transform_invoke 66 \section pipe_tasks_transform_purpose Description 68 Given a set of measurement algorithms with their associated configuration, 69 the table of source measurements they have produced, and information about 70 an associated WCS and calibration, transform the raw measurement output to 73 Transformations are defined on a per-measurement-plugin basis. In 74 addition, a configurable set of fields may be simply copied from the input 75 to the output catalog. 77 This task operates on an input SourceCatalog and returns a BaseCatalog 78 containing the transformed results. It requires that the caller supply 79 information on the configuration of the measurement task which produced 80 the input data as well as the world coordinate system and calibration 81 under which the transformation will take place. It provides no 82 functionality for reading or writing data from a Butler: rather, 83 per-dataset-type command line tasks are provided to obtain the appropriate 84 information from a Butler (or elsewhere) and then delegate to this task. 86 \section pipe_tasks_transform_initialize Task initialization 90 \section pipe_tasks_transform_invoke Task invocation 94 ConfigClass = TransformConfig
95 _DefaultName =
"transform" 97 def __init__(self, measConfig, inputSchema, outputDataset, *args, **kwargs):
98 """!Initialize TransformTask. 100 @param[in] measConfig Configuration for the measurement task which 101 produced the measurments being transformed. 102 @param[in] inputSchema The schema of the input catalog. 103 @param[in] outputDataset The butler dataset type of the output catalog. 104 @param[in] *args Passed through to pipeBase.Task.__init__() 105 @param[in] *kwargs Passed through to pipeBase.Task.__init__() 107 pipeBase.Task.__init__(self, *args, **kwargs)
115 for field
in self.config.copyFields:
116 self.
mapper.addMapping(inputSchema.find(field).key)
121 for name
in measConfig.plugins.names:
122 config = measConfig.plugins.get(name)
123 transformClass = measConfig.plugins.registry.get(name).PluginClass.getTransformClass()
127 """!Return a dict containing an empty catalog representative of this task's output.""" 131 def run(self, inputCat, wcs, photoCalib):
132 """!Transform raw source measurements to calibrated quantities. 134 @param[in] inputCat SourceCatalog of sources to transform. 135 @param[in] wcs The world coordinate system under which transformations will take place. 136 @param[in] photoCalib The calibration under which transformations will take place. 138 @return A BaseCatalog containing the transformed measurements. 141 outputCat.extend(inputCat, mapper=self.
mapper)
149 transform(inputCat, outputCat, wcs, photoCalib)
154 """!Configuration for RunTransformTaskBase derivatives.""" 155 transform = pexConfig.ConfigurableField(
156 doc=
"Subtask which performs transformations",
159 inputConfigType = pexConfig.Field(
161 doc=
"Dataset type of measurement operation configuration",
167 \anchor RunTransformTaskBase_ 169 \brief Command line interface for TransformTask. 171 \section pipe_tasks_transform_Contents Contents 173 - \ref pipe_tasks_runtransform_purpose 174 - \ref pipe_tasks_runtransform_invoke 176 \section pipe_tasks_runtransform_purpose Description 178 Provides a command-line task which can be used to run TransformTask. 180 - Loads a plugin registry based on configuration; 181 - Loads configuration for the measurement task which was applied from a repository; 182 - Loads the SourceCatalog input schema from a repository; 183 - For each input dataRef, reads the SourceCatalog, WCS and calibration from the 184 repository and executes TransformTask. 186 This is not a fully-fledged command line task: it requires specialization to a particular 187 source type by defining the variables indicated below. 189 \section pipe_tasks_runtransform_invoke Task invocation 193 RunnerClass = pipeBase.ButlerInitializedTaskRunner
194 ConfigClass = RunTransformConfig
211 The Butler dataset type for the schema of the input source catalog. 213 By default, we append `_schema` to the input source type. Subclasses may customize 221 The Butler dataset type for the schema of the output catalog. 223 By default, we prepend `transformed_` to the input source type. Subclasses may 224 customize if required. 231 The configuration of the measurement operation used to generate the input catalog. 233 By default we look for `measurement` under the root configuration of the 234 generating task. Subclasses may customize this (e.g. to `calibrate.measurement`) 237 return self.
butler.get(self.config.inputConfigType).measurement.value
240 pipeBase.CmdLineTask.__init__(self, *args, config=kwargs[
'config'], log=kwargs[
'log'])
248 """!Transform the source catalog referred to by dataRef. 250 The result is both returned and written as dataset type "transformed_" + the input 251 source dataset type to the provided dataRef. 253 @param[in] dataRef Data reference for source catalog & calibrated exposure. 255 @returns A BaseCatalog containing the transformed measurements. 259 photoCalib = dataRef.get(self.
calexpType).getPhotoCalib()
260 outputCat = self.transform.
run(inputCat, wcs, photoCalib)
274 \anchor SrcTransformTask_ 276 \brief Transform ``src`` measuremenents to calibrated form. 278 This is a specialization of \ref RunTransformTaskBase_ "RunTransformTaskBase" which 279 operates on ``src`` measurements. Refer to the parent documentation for details. 281 _DefaultName =
"transformSrcMeasurement" 283 calexpType =
'calexp' 287 return self.
butler.get(self.config.inputConfigType).calibrate.measurement.value
299 \anchor ForcedSrcTransformTask_ 301 \brief Transform ``forced_src`` measuremenents to calibrated form. 303 This is a specialization of \ref RunTransformTaskBase_ "RunTransformTaskBase" which 304 operates on ``forced_src`` measurements. Refer to the parent documentation for details. 306 _DefaultName =
"transformForcedSrcMeasurement" 307 sourceType =
'forced_src' 308 calexpType =
'calexp' 320 \anchor CoaddSrcTransformTask_ 322 \brief Transform measuremenents made on coadds to calibrated form. 324 This is a specialization of \ref RunTransformTaskBase_ "RunTransformTaskBase" which 325 operates on measurements made on coadds. Refer to the parent documentation for details. 327 _DefaultName =
"transformCoaddSrcMeasurement" 331 return self.
butler.get(self.config.inputConfigType).coaddName
341 def _getConfigName(self):
342 return "%s_transformCoaddSrcMeasurement_config" % (self.
coaddName,)
344 def _getMetaDataName(self):
345 return "%s_transformCoaddSrcMeasurement_metadata" % (self.
coaddName,)
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, skyInfo, tempExpRefList, imageScalerList, weightList, altMaskList=None, mask=None, supplementaryData=None)