26from lsst.utils.timer
import timeMethod
28__all__ = [
"ExampleSigmaClippedStatsConfig",
"ExampleSigmaClippedStatsTask",
"ExampleSimpleStatsTask"]
44 """!Configuration for ExampleSigmaClippedStatsTask
46 badMaskPlanes = pexConfig.ListField(
48 doc="Mask planes that, if set, indicate the associated pixel should "
49 "not be included when the calculating statistics.",
52 numSigmaClip = pexConfig.Field(
53 doc=
"number of sigmas at which to clip data",
57 numIter = pexConfig.Field(
58 doc=
"number of iterations of sigma clipping",
66 Example task to compute sigma-clipped mean and standard deviation of an image
68 \section pipeTasks_ExampleSigmaClippedStatsTask_Contents Contents
70 - \ref pipeTasks_ExampleSigmaClippedStatsTask_Purpose
71 - \ref pipeTasks_ExampleSigmaClippedStatsTask_Config
72 - \ref pipeTasks_ExampleSigmaClippedStatsTask_Debug
73 - \ref pipeTasks_ExampleSigmaClippedStatsTask_Example
75 \section pipeTasks_ExampleSigmaClippedStatsTask_Purpose Description
77 \copybrief ExampleSigmaClippedStatsTask
79 This
is a simple example task designed to be run
as a subtask by ExampleCmdLineTask.
80 See also ExampleSimpleStatsTask
as a variant that
is even simpler.
82 The main method
is \ref ExampleSigmaClippedStatsTask.run
"run".
84 \section pipeTasks_ExampleSigmaClippedStatsTask_Config Configuration parameters
86 See \ref ExampleSigmaClippedStatsConfig
88 \section pipeTasks_ExampleSigmaClippedStatsTask_Debug Debug variables
90 This task has no debug variables.
92 \section pipeTasks_ExampleSigmaClippedStatsTask_Example A complete example
93 of using ExampleSigmaClippedStatsTask
95 This code
is in examples/exampleStatsTask.py (this one example runs both
96 ExampleSigmaClippedStatsTask
and ExampleSimpleStatsTask),
and can be run
as:
98 examples/exampleStatsTask.py [fitsFile]
101 ConfigClass = ExampleSigmaClippedStatsConfig
102 _DefaultName = "exampleSigmaClippedStats"
105 """!Construct an ExampleSigmaClippedStatsTask
107 The init method may compute anything that that does not require data.
108 In this case we create a statistics control object using the config
109 (which cannot change once the task
is created).
111 pipeBase.Task.__init__(self, *args, **kwargs)
113 self._badPixelMask_badPixelMask = afwImage.Mask.getPlaneBitMask(self.config.badMaskPlanes)
116 self._statsControl_statsControl.setNumSigmaClip(self.config.numSigmaClip)
117 self._statsControl_statsControl.setNumIter(self.config.numIter)
121 def run(self, maskedImage):
122 """!Compute and return statistics for a masked image
124 @param[
in] maskedImage: masked image (an lsst::afw::MaskedImage)
125 @return a pipeBase Struct containing:
126 - mean: mean of image plane
127 - meanErr: uncertainty
in mean
128 - stdDev: standard deviation of image plane
129 - stdDevErr: uncertainty
in standard deviation
133 mean, meanErr = statObj.getResult(afwMath.MEANCLIP)
134 stdDev, stdDevErr = statObj.getResult(afwMath.STDEVCLIP)
135 self.log.info("clipped mean=%0.2f; meanErr=%0.2f; stdDev=%0.2f; stdDevErr=%0.2f",
136 mean, meanErr, stdDev, stdDevErr)
137 return pipeBase.Struct(
147 Example task to compute mean and standard deviation of an image
149 \section pipeTasks_ExampleSimpleStatsTask_Contents Contents
151 - \ref pipeTasks_ExampleSimpleStatsTask_Purpose
152 - \ref pipeTasks_ExampleSimpleStatsTask_Config
153 - \ref pipeTasks_ExampleSimpleStatsTask_Debug
154 - \ref pipeTasks_ExampleSimpleStatsTask_Example
156 \section pipeTasks_ExampleSimpleStatsTask_Purpose Description
158 \copybrief ExampleSimpleStatsTask
160 This was designed to be run
as a subtask by ExampleCmdLineTask.
161 It
is about
as simple
as a task can be; it has no configuration parameters
and requires no special
162 initialization. See also ExampleSigmaClippedStatsTask
as a variant that
is slightly more complicated.
164 The main method
is \ref ExampleSimpleTask.run
"run".
166 \section pipeTasks_ExampleSimpleStatsTask_Config Configuration parameters
168 This task has no configuration parameters.
170 \section pipeTasks_ExampleSimpleStatsTask_Debug Debug variables
172 This task has no debug variables.
174 \section pipeTasks_ExampleSimpleStatsTask_Example A complete example of using ExampleSimpleStatsTask
176 This code
is in examples/exampleStatsTask.py (this one example runs both
177 ExampleSigmaClippedStatsTask
and ExampleSimpleStatsTask),
and can be run
as:
179 examples/exampleStatsTask.py [fitsFile]
183 ConfigClass = pexConfig.Config
188 _DefaultName =
"exampleSimpleStats"
195 def run(self, maskedImage):
196 """!Compute and return statistics for a masked image
198 @param[
in] maskedImage: masked image (an lsst::afw::MaskedImage)
199 @return a pipeBase Struct containing:
200 - mean: mean of image plane
201 - meanErr: uncertainty
in mean
202 - stdDev: standard deviation of image plane
203 - stdDevErr: uncertainty
in standard deviation
208 mean, meanErr = statObj.getResult(afwMath.MEAN)
209 stdDev, stdDevErr = statObj.getResult(afwMath.STDEV)
210 self.log.info("simple mean=%0.2f; meanErr=%0.2f; stdDev=%0.2f; stdDevErr=%0.2f",
211 mean, meanErr, stdDev, stdDevErr)
213 return pipeBase.Struct(
Pass parameters to a Statistics object.
Configuration for ExampleSigmaClippedStatsTask.
Example task to compute sigma-clipped mean and standard deviation of an image.
def run(self, maskedImage)
Compute and return statistics for a masked image.
def __init__(self, *args, **kwargs)
Construct an ExampleSigmaClippedStatsTask.
Example task to compute mean and standard deviation of an image.
def run(self, maskedImage)
Compute and return statistics for a masked image.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a watered-down front-end to the constructor (no variance)