26from lsst.utils.timer
import timeMethod
30 """Configuration for ExampleSigmaClippedStatsTask
32 badMaskPlanes = pexConfig.ListField(
34 doc="Mask planes that, if set, indicate the associated pixel should "
35 "not be included when the calculating statistics.",
38 numSigmaClip = pexConfig.Field(
39 doc=
"number of sigmas at which to clip data",
43 numIter = pexConfig.Field(
44 doc=
"number of iterations of sigma clipping",
51 """Example task to compute sigma-clipped mean and standard deviation of an image.
53 This is a simple example task designed to be run
as a subtask by
54 ExampleCmdLineTask. See also ExampleSimpleStatsTask
as a variant that
is
59 pipeTasks_ExampleSigmaClippedStatsTask_Example A complete example
60 of using ExampleSigmaClippedStatsTask
62 This code
is in examples/exampleStatsTask.py (this one example runs both
63 ExampleSigmaClippedStatsTask
and ExampleSimpleStatsTask),
and can be run
64 as: examples/exampleStatsTask.py [fitsFile]
66 The init method may compute anything that that does
not require data.
67 In this case we create a statistics control object using the config
68 (which cannot change once the task
is created).
70 ConfigClass = ExampleSigmaClippedStatsConfig
71 _DefaultName = "exampleSigmaClippedStats"
74 pipeBase.Task.__init__(self, *args, **kwargs)
76 self.
_badPixelMask = afwImage.Mask.getPlaneBitMask(self.config.badMaskPlanes)
84 def run(self, maskedImage):
85 """Compute and return statistics for a masked image.
90 Masked image to compute statistics on.
94 stats : `lsst.pipe.base.Struct`
95 Statistics as a struct
with attributes:
98 Mean of image plane (`float`).
100 Uncertainty
in mean (`float`).
102 Standard deviation of image plane (`float`).
104 Uncertainty
in standard deviation (`float`).
106 statObj = afwMath.makeStatistics(maskedImage, afwMath.MEANCLIP | afwMath.STDEVCLIP | afwMath.ERRORS,
108 mean, meanErr = statObj.getResult(afwMath.MEANCLIP)
109 stdDev, stdDevErr = statObj.getResult(afwMath.STDEVCLIP)
110 self.log.info("clipped mean=%0.2f; meanErr=%0.2f; stdDev=%0.2f; stdDevErr=%0.2f",
111 mean, meanErr, stdDev, stdDevErr)
112 return pipeBase.Struct(
121 """Example task to compute mean and standard deviation of an image.
123 This was designed to be run as a subtask by ExampleCmdLineTask.
124 It
is about
as simple
as a task can be; it has no configuration parameters
125 and requires no special initialization. See also
126 ExampleSigmaClippedStatsTask
as a variant that
is slightly more
129 The main method
is ExampleSimpleTask.run
"run".
131 pipeTasks_ExampleSimpleStatsTask_Config Configuration parameters
133 This task has no configuration parameters.
135 pipeTasks_ExampleSimpleStatsTask_Debug Debug variables
137 This task has no debug variables.
139 pipeTasks_ExampleSimpleStatsTask_Example A complete example of using
140 ExampleSimpleStatsTask
142 This code
is in examples/exampleStatsTask.py (this one example runs both
143 ExampleSigmaClippedStatsTask
and ExampleSimpleStatsTask),
and can be run
144 as: examples/exampleStatsTask.py [fitsFile]
147 ConfigClass = pexConfig.Config
153 _DefaultName =
"exampleSimpleStats"
161 def run(self, maskedImage):
162 """Compute and return statistics for a masked image.
166 maskedImage : `lsst.afw.MaskedImage`
167 Masked image to compute statistics on.
171 stats : `lsst.pipe.base.Struct`
172 Statistics as a struct
with attributes:
175 Mean of image plane (`float`).
177 Uncertainty
in mean (`float`).
179 Standard deviation of image plane (`float`).
181 Uncertainty
in standard deviation (`float`).
184 statObj = afwMath.makeStatistics(maskedImage, afwMath.MEAN | afwMath.STDEV | afwMath.ERRORS,
186 mean, meanErr = statObj.getResult(afwMath.MEAN)
187 stdDev, stdDevErr = statObj.getResult(afwMath.STDEV)
188 self.log.info("simple mean=%0.2f; meanErr=%0.2f; stdDev=%0.2f; stdDevErr=%0.2f",
189 mean, meanErr, stdDev, stdDevErr)
191 return pipeBase.Struct(
def run(self, maskedImage)
def __init__(self, *args, **kwargs)
def run(self, maskedImage)