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 The init method may compute anything that that does
not require data.
60 In this case we create a statistics control object using the config
61 (which cannot change once the task
is created).
63 ConfigClass = ExampleSigmaClippedStatsConfig
64 _DefaultName = "exampleSigmaClippedStats"
67 pipeBase.Task.__init__(self, *args, **kwargs)
69 self.
_badPixelMask = afwImage.Mask.getPlaneBitMask(self.config.badMaskPlanes)
77 def run(self, maskedImage):
78 """Compute and return statistics for a masked image.
83 Masked image to compute statistics on.
87 stats : `lsst.pipe.base.Struct`
88 Statistics as a struct
with attributes:
91 Mean of image plane (`float`).
93 Uncertainty
in mean (`float`).
95 Standard deviation of image plane (`float`).
97 Uncertainty
in standard deviation (`float`).
99 statObj = afwMath.makeStatistics(maskedImage, afwMath.MEANCLIP | afwMath.STDEVCLIP | afwMath.ERRORS,
101 mean, meanErr = statObj.getResult(afwMath.MEANCLIP)
102 stdDev, stdDevErr = statObj.getResult(afwMath.STDEVCLIP)
103 self.log.info("clipped mean=%0.2f; meanErr=%0.2f; stdDev=%0.2f; stdDevErr=%0.2f",
104 mean, meanErr, stdDev, stdDevErr)
105 return pipeBase.Struct(
114 """Example task to compute mean and standard deviation of an image.
116 This was designed to be run as a subtask by ExampleCmdLineTask.
117 It
is about
as simple
as a task can be; it has no configuration parameters
118 and requires no special initialization. See also
119 ExampleSigmaClippedStatsTask
as a variant that
is slightly more
122 The main method
is ExampleSimpleTask.run
"run".
124 pipeTasks_ExampleSimpleStatsTask_Config Configuration parameters
126 This task has no configuration parameters.
128 pipeTasks_ExampleSimpleStatsTask_Debug Debug variables
130 This task has no debug variables.
133 ConfigClass = pexConfig.Config
139 _DefaultName =
"exampleSimpleStats"
147 def run(self, maskedImage):
148 """Compute and return statistics for a masked image.
152 maskedImage : `lsst.afw.MaskedImage`
153 Masked image to compute statistics on.
157 stats : `lsst.pipe.base.Struct`
158 Statistics as a struct
with attributes:
161 Mean of image plane (`float`).
163 Uncertainty
in mean (`float`).
165 Standard deviation of image plane (`float`).
167 Uncertainty
in standard deviation (`float`).
170 statObj = afwMath.makeStatistics(maskedImage, afwMath.MEAN | afwMath.STDEV | afwMath.ERRORS,
172 mean, meanErr = statObj.getResult(afwMath.MEAN)
173 stdDev, stdDevErr = statObj.getResult(afwMath.STDEV)
174 self.log.info("simple mean=%0.2f; meanErr=%0.2f; stdDev=%0.2f; stdDevErr=%0.2f",
175 mean, meanErr, stdDev, stdDevErr)
177 return pipeBase.Struct(
def __init__(self, *args, **kwargs)