26from lsst.utils.timer
import timeMethod
28__all__ = [
"ExampleSigmaClippedStatsConfig",
"ExampleSigmaClippedStatsTask",
"ExampleSimpleStatsTask"]
46 """!Configuration for ExampleSigmaClippedStatsTask
48 badMaskPlanes = pexConfig.ListField(
50 doc="Mask planes that, if set, indicate the associated pixel should "
51 "not be included when the calculating statistics.",
54 numSigmaClip = pexConfig.Field(
55 doc=
"number of sigmas at which to clip data",
59 numIter = pexConfig.Field(
60 doc=
"number of iterations of sigma clipping",
67 r"""Example task to compute sigma-clipped mean and standard deviation of an
70 This is a simple example task designed to be run
as a subtask by
71 ExampleCmdLineTask. See also ExampleSimpleStatsTask
as a variant that
is
74 The main method
is ExampleSigmaClippedStatsTask.run
"run".
76 pipeTasks_ExampleSigmaClippedStatsTask_Config Configuration parameters
78 See ExampleSigmaClippedStatsConfig
80 pipeTasks_ExampleSigmaClippedStatsTask_Debug Debug variables
82 This task has no debug variables.
84 pipeTasks_ExampleSigmaClippedStatsTask_Example A complete example
85 of using ExampleSigmaClippedStatsTask
87 This code
is in examples/exampleStatsTask.py (this one example runs both
88 ExampleSigmaClippedStatsTask
and ExampleSimpleStatsTask),
and can be run
89 as: examples/exampleStatsTask.py [fitsFile]
91 The init method may compute anything that that does
not require data.
92 In this case we create a statistics control object using the config
93 (which cannot change once the task
is created).
95 ConfigClass = ExampleSigmaClippedStatsConfig
96 _DefaultName = "exampleSigmaClippedStats"
99 pipeBase.Task.__init__(self, *args, **kwargs)
101 self.
_badPixelMask = afwImage.Mask.getPlaneBitMask(self.config.badMaskPlanes)
109 def run(self, maskedImage):
110 """Compute and return statistics for a masked image
114 maskedImage : `lsst.afw.MaskedImage`
119 retStruct : `~lsst.pipe.base.Struct`
120 A struct containing following attributes
121 - mean: mean of image plane
122 - meanErr: uncertainty in mean
123 - stdDev: standard deviation of image plane
124 - stdDevErr: uncertainty
in standard deviation
126 statObj = afwMath.makeStatistics(maskedImage, afwMath.MEANCLIP | afwMath.STDEVCLIP | afwMath.ERRORS,
128 mean, meanErr = statObj.getResult(afwMath.MEANCLIP)
129 stdDev, stdDevErr = statObj.getResult(afwMath.STDEVCLIP)
130 self.log.info("clipped mean=%0.2f; meanErr=%0.2f; stdDev=%0.2f; stdDevErr=%0.2f",
131 mean, meanErr, stdDev, stdDevErr)
132 return pipeBase.Struct(
142 Example task to compute mean and standard deviation of an image
144 This was designed to be run
as a subtask by ExampleCmdLineTask.
145 It
is about
as simple
as a task can be; it has no configuration parameters
146 and requires no special initialization. See also
147 ExampleSigmaClippedStatsTask
as a variant that
is slightly more
150 The main method
is ExampleSimpleTask.run
"run".
152 pipeTasks_ExampleSimpleStatsTask_Config Configuration parameters
154 This task has no configuration parameters.
156 pipeTasks_ExampleSimpleStatsTask_Debug Debug variables
158 This task has no debug variables.
160 pipeTasks_ExampleSimpleStatsTask_Example A complete example of using
161 ExampleSimpleStatsTask
163 This code
is in examples/exampleStatsTask.py (this one example runs both
164 ExampleSigmaClippedStatsTask
and ExampleSimpleStatsTask),
and can be run
165 as: examples/exampleStatsTask.py [fitsFile]
168 ConfigClass = pexConfig.Config
174 _DefaultName =
"exampleSimpleStats"
182 def run(self, maskedImage):
183 """Compute and return statistics for a masked image
187 maskedImage : `lsst.afw.MaskedImage`
192 retStruct : `~lsst.pipe.base.Struct`
193 A struct containing following attributes
194 - mean: mean of image plane
195 - meanErr: uncertainty in mean
196 - stdDev: standard deviation of image plane
197 - stdDevErr: uncertainty
in standard deviation
200 statObj = afwMath.makeStatistics(maskedImage, afwMath.MEAN | afwMath.STDEV | afwMath.ERRORS,
202 mean, meanErr = statObj.getResult(afwMath.MEAN)
203 stdDev, stdDevErr = statObj.getResult(afwMath.STDEV)
204 self.log.info("simple mean=%0.2f; meanErr=%0.2f; stdDev=%0.2f; stdDevErr=%0.2f",
205 mean, meanErr, stdDev, stdDevErr)
207 return pipeBase.Struct(
Configuration for ExampleSigmaClippedStatsTask.
def __init__(self, *args, **kwargs)