22 from __future__
import absolute_import, division, print_function
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",
65 """!Example task to compute sigma-clipped mean and standard deviation of an image 67 \section pipeTasks_ExampleSigmaClippedStatsTask_Contents Contents 69 - \ref pipeTasks_ExampleSigmaClippedStatsTask_Purpose 70 - \ref pipeTasks_ExampleSigmaClippedStatsTask_Config 71 - \ref pipeTasks_ExampleSigmaClippedStatsTask_Debug 72 - \ref pipeTasks_ExampleSigmaClippedStatsTask_Example 74 \section pipeTasks_ExampleSigmaClippedStatsTask_Purpose Description 76 \copybrief ExampleSigmaClippedStatsTask 78 This is a simple example task designed to be run as a subtask by ExampleCmdLineTask. 79 See also ExampleSimpleStatsTask as a variant that is even simpler. 81 The main method is \ref ExampleSigmaClippedStatsTask.run "run". 83 \section pipeTasks_ExampleSigmaClippedStatsTask_Config Configuration parameters 85 See \ref ExampleSigmaClippedStatsConfig 87 \section pipeTasks_ExampleSigmaClippedStatsTask_Debug Debug variables 89 This task has no debug variables. 91 \section pipeTasks_ExampleSigmaClippedStatsTask_Example A complete example 92 of using ExampleSigmaClippedStatsTask 94 This code is in examples/exampleStatsTask.py (this one example runs both 95 ExampleSigmaClippedStatsTask and ExampleSimpleStatsTask), and can be run as: 97 examples/exampleStatsTask.py [fitsFile] 100 ConfigClass = ExampleSigmaClippedStatsConfig
101 _DefaultName =
"exampleSigmaClippedStats" 104 """!Construct an ExampleSigmaClippedStatsTask 106 The init method may compute anything that that does not require data. 107 In this case we create a statistics control object using the config 108 (which cannot change once the task is created). 110 pipeBase.Task.__init__(self, *args, **kwargs)
112 self.
_badPixelMask = afwImage.Mask.getPlaneBitMask(self.config.badMaskPlanes)
120 def run(self, maskedImage):
121 """!Compute and return statistics for a masked image 123 @param[in] maskedImage: masked image (an lsst::afw::MaskedImage) 124 @return a pipeBase Struct containing: 125 - mean: mean of image plane 126 - meanErr: uncertainty in mean 127 - stdDev: standard deviation of image plane 128 - stdDevErr: uncertainty in standard deviation 130 statObj = afwMath.makeStatistics(maskedImage, afwMath.MEANCLIP | afwMath.STDEVCLIP | afwMath.ERRORS,
132 mean, meanErr = statObj.getResult(afwMath.MEANCLIP)
133 stdDev, stdDevErr = statObj.getResult(afwMath.STDEVCLIP)
134 self.log.info(
"clipped mean=%0.2f; meanErr=%0.2f; stdDev=%0.2f; stdDevErr=%0.2f" %
135 (mean, meanErr, stdDev, stdDevErr))
136 return pipeBase.Struct(
145 """!Example task to compute mean and standard deviation of an image 147 \section pipeTasks_ExampleSimpleStatsTask_Contents Contents 149 - \ref pipeTasks_ExampleSimpleStatsTask_Purpose 150 - \ref pipeTasks_ExampleSimpleStatsTask_Config 151 - \ref pipeTasks_ExampleSimpleStatsTask_Debug 152 - \ref pipeTasks_ExampleSimpleStatsTask_Example 154 \section pipeTasks_ExampleSimpleStatsTask_Purpose Description 156 \copybrief ExampleSimpleStatsTask 158 This was designed to be run as a subtask by ExampleCmdLineTask. 159 It is about as simple as a task can be; it has no configuration parameters and requires no special 160 initialization. See also ExampleSigmaClippedStatsTask as a variant that is slightly more complicated. 162 The main method is \ref ExampleSimpleTask.run "run". 164 \section pipeTasks_ExampleSimpleStatsTask_Config Configuration parameters 166 This task has no configuration parameters. 168 \section pipeTasks_ExampleSimpleStatsTask_Debug Debug variables 170 This task has no debug variables. 172 \section pipeTasks_ExampleSimpleStatsTask_Example A complete example of using ExampleSimpleStatsTask 174 This code is in examples/exampleStatsTask.py (this one example runs both 175 ExampleSigmaClippedStatsTask and ExampleSimpleStatsTask), and can be run as: 177 examples/exampleStatsTask.py [fitsFile] 181 ConfigClass = pexConfig.Config
186 _DefaultName =
"exampleSimpleStats" 193 def run(self, maskedImage):
194 """!Compute and return statistics for a masked image 196 @param[in] maskedImage: masked image (an lsst::afw::MaskedImage) 197 @return a pipeBase Struct containing: 198 - mean: mean of image plane 199 - meanErr: uncertainty in mean 200 - stdDev: standard deviation of image plane 201 - stdDevErr: uncertainty in standard deviation 204 statObj = afwMath.makeStatistics(maskedImage, afwMath.MEAN | afwMath.STDEV | afwMath.ERRORS,
206 mean, meanErr = statObj.getResult(afwMath.MEAN)
207 stdDev, stdDevErr = statObj.getResult(afwMath.STDEV)
208 self.log.info(
"simple mean=%0.2f; meanErr=%0.2f; stdDev=%0.2f; stdDevErr=%0.2f" %
209 (mean, meanErr, stdDev, stdDevErr))
211 return pipeBase.Struct(
Example task to compute sigma-clipped mean and standard deviation of an image.
def __init__(self, args, kwargs)
Construct an ExampleSigmaClippedStatsTask.
def run(self, maskedImage)
Compute and return statistics for a masked image.
def run(self, maskedImage)
Compute and return statistics for a masked image.
Configuration for ExampleSigmaClippedStatsTask.
Example task to compute mean and standard deviation of an image.