24 Tasks for transforming raw measurement outputs to calibrated quantities.
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')
55 """!Transform a SourceCatalog containing raw measurements to calibrated form.
57 Given a set of measurement algorithms with their associated configuration,
58 the table of source measurements they have produced, and information about
59 an associated WCS and calibration, transform the raw measurement output to
62 Transformations are defined on a per-measurement-plugin basis. In
63 addition, a configurable set of fields may be simply copied from the input
64 to the output catalog.
66 ConfigClass = TransformConfig
67 _DefaultName =
"transform"
69 def __init__(self, measConfig, pluginRegistry, inputSchema, *args, **kwargs):
70 """!Initialize TransformTask.
72 @param[in] measConfig Configuration for the measurement task which
73 produced the measurments being transformed.
74 @param[in] pluginRegistry A PluginRegistry which maps plugin names to measurement algorithms.
75 @param[in] inputSchema The schema of the input catalog.
76 @param[in] *args Passed through to pipeBase.Task.__init__()
77 @param[in] *kwargs Passed through to pipeBase.Task.__init__()
79 pipeBase.Task.__init__(self, *args, **kwargs)
83 for field
in self.config.copyFields:
84 self.mapper.addMapping(inputSchema.find(field).key)
90 for name
in measConfig.plugins.names:
91 config = measConfig.plugins.get(name)
92 transformClass = pluginRegistry.get(name).PluginClass.getTransformClass()
93 self.transforms.append(transformClass(config, name, self.
mapper))
96 """!Return a dict containing an empty catalog representative of this task's output."""
98 return {
'transformedSrc': transformedSrc}
100 def run(self, inputCat, wcs, calib):
101 """!Transform raw source measurements to calibrated quantities.
103 @param[in] inputCat SourceCatalog of sources to transform.
104 @param[in] wcs The world coordinate system under which transformations will take place.
105 @param[in] calib The calibration under which transformations will take place.
107 @return A BaseCatalog containing the transformed measurements.
110 outputCat.extend(inputCat, mapper=self.
mapper)
118 transform(inputCat, outputCat, wcs, calib)
123 """!Configuration for RunTransformTask."""
124 transform = pexConfig.ConfigurableField(
125 doc=
"Subtask which performs transformations",
128 measConfig = pexConfig.Field(
130 doc=
"Dataset type of measurement operation configuration",
131 default=
"processCcd_config"
133 measType = pexConfig.ChoiceField(
135 doc=
"Type of measurement operation performed",
136 default=
"SingleFrame",
138 "SingleFrame":
"Single frame measurement",
139 "Forced":
"Forced measurement"
145 """!Basic interface for TransformTask.
147 Provide a command-line task which can be used to run TransformTask.
149 - Loads a plugin registry based on configuration;
150 - Loads configuration for the measurement task which was applied from a repository;
151 - Loads the SourceCatalog input schema from a repository;
152 - For each input dataRef, reads the SourceCatalog, WCS and calibration from the
153 repository and executes TransformTask.
155 This can be sub-tasked to support whatever dataset types or sources for
156 the WCS and calibration information are required.
158 ConfigClass = RunTransformConfig
159 RunnerClass = pipeBase.ButlerInitializedTaskRunner
160 _DefaultName =
"transformMeasurement"
163 pipeBase.CmdLineTask.__init__(self, *args, config=kwargs[
'config'], log=kwargs[
'log'])
164 if self.config.measType ==
"SingleFrame":
165 pluginRegistry = measBase.sfm.SingleFramePlugin.registry
166 elif self.config.measType ==
"Forced":
167 pluginRegistry = measBase.forcedMeasurement.ForcedPlugin.registry
168 self.makeSubtask(
'transform', pluginRegistry=pluginRegistry,
169 measConfig=kwargs[
'butler'].get(self.config.measConfig).measurement.value,
170 inputSchema=kwargs[
'butler'].get(
"src_schema").schema)
174 """!Transform the source catalog referred to by dataRef.
176 The result is both returned and written as dataset type "transformedSrc"
177 to the provided dataRef.
179 @param[in] dataRef Data reference for source catalog (src) &
180 calibrated exposure (calexp).
182 @returns A BaseCatalog containing the transformed measurements.
184 inputCat = dataRef.get(
'src')
185 wcs = dataRef.get(
'calexp').getWcs()
186 calib = dataRef.get(
'calexp').getCalib()
187 outputCat = self.transform.run(inputCat, wcs, calib)
188 dataRef.put(outputCat,
"transformedSrc")
A custom container class for records, based on std::vector.
A mapping between the keys of two Schemas, used to copy data between them.