Coverage for tests/test_statisticsMasked.py : 97%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
|
# # LSST Data Management System # Copyright 2008, 2009, 2010 LSST Corporation. # # This product includes software developed by the # LSST Project (http://www.lsst.org/). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the LSST License Statement and # the GNU General Public License along with this program. If not, # see <http://www.lsstcorp.org/LegalNotices/>. #
Tests for statisticsMasked
Run with: ./statisticsMasked.py or python >>> import statisticsMasked; statisticsMasked.run() """
"""A test case to check that special values (NaN and Masks) are begin handled in Statistics"""
lsst.geom.Point2I(self.nRow//2 - 1, self.nCol - 1)) lsst.geom.Point2I(self.nRow - 1, self.nCol - 1))
# create masked images and set the left side to valL, and right to valR lsst.geom.Extent2I(self.nRow, self.nCol)) self.mimg, self.bboxL, afwImage.LOCAL) self.mimg, self.bboxR, afwImage.LOCAL)
# Verify that NaN values are being ignored # (by default, StatisticsControl.useNanSafe = True) # We'll set the L and R sides of an image to two different values and verify mean and stdev # ... then set R-side to NaN and try again ... we should get mean,stdev for L-side
# get the stats for the image with two values self.mimg, afwMath.NPOINT | afwMath.MEAN | afwMath.STDEV) self.mimgR.getHeight() (self.valR - mean)**2)/(nL + nR - 1))**0.5
# set the right side to NaN and stats should be just for the left side
self.mimg, afwMath.NPOINT | afwMath.MEAN | afwMath.STDEV)
# Verify that Masked pixels are being ignored according to the andMask # (by default, StatisticsControl.andMask = 0x0) # We'll set the L and R sides of an image to two different values and verify mean and stdev # ... then set R-side Mask and the andMask to 0x1 and try again ... we should get mean,stdev for L-side
# get the stats for the image with two values self.mimg, afwMath.NPOINT | afwMath.MEAN | afwMath.STDEV) self.mimgR.getHeight() (self.valR - mean)**2)/(nL + nR - 1))**0.5
# set the right side Mask and the StatisticsControl andMask to 0x1 # Stats should be just for the left side!
self.mimg, afwMath.NPOINT | afwMath.MEAN | afwMath.STDEV, sctrl)
# Verify that pixels are being weighted according to the variance plane (1/var) # We'll set the L and R sides of an image to two different values and verify mean # ... then set R-side Variance to equal the Image value, and set 'weighted' and try again ...
self.mimg, afwMath.NPOINT | afwMath.MEAN | afwMath.STDEV, sctrl) self.mimgR.getHeight()
# get the stats for the image with two values
mimg, afwMath.NPOINT | afwMath.MEAN | afwMath.STDEV, sctrl)
# original estimate; just a rewrite of the usual n/(n - 1) correction (vsum**2)/(wsum**2*(1.0-1.0/n)))**0.5 # # The correct formula:
# get the stats for the image with two values
lsst.utils.tests.init() unittest.main() |