Skip to content

Commit

Permalink
Move countMaskedPixels to ip_isr.
Browse files Browse the repository at this point in the history
  • Loading branch information
czwa committed Sep 9, 2022
1 parent 104f198 commit d59c43c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 114 deletions.
3 changes: 1 addition & 2 deletions python/lsst/cp/pipe/defects.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
from lsst.afw import cameraGeom
from lsst.geom import Box2I, Point2I
from lsst.meas.algorithms import SourceDetectionTask
from lsst.ip.isr import Defects
from .utils import countMaskedPixels
from lsst.ip.isr import Defects, countMaskedPixels

from ._lookupStaticCalibration import lookupStaticCalibration

Expand Down
22 changes: 1 addition & 21 deletions python/lsst/cp/pipe/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#

__all__ = ['countMaskedPixels', 'ddict2dict', 'CovFastFourierTransform']
__all__ = ['ddict2dict', 'CovFastFourierTransform']

import numpy as np
from scipy.optimize import leastsq
Expand Down Expand Up @@ -180,26 +180,6 @@ def makeMockFlats(expTime, gain=1.0, readNoiseElectrons=5, fluxElectrons=1000,
return flatExp1, flatExp2


def countMaskedPixels(maskedIm, maskPlane):
"""Count the number of pixels in a given mask plane.
Parameters
----------
maskedIm : `~lsst.afw.image.MaskedImage`
Masked image to examine.
maskPlane : `str`
Name of the mask plane to examine.
Returns
-------
nPix : `int`
Number of pixels in the requested mask plane.
"""
maskBit = maskedIm.mask.getPlaneBitMask(maskPlane)
nPix = np.where(np.bitwise_and(maskedIm.mask.array, maskBit))[0].flatten().size
return nPix


def irlsFit(initialParams, dataX, dataY, function, weightsY=None, weightType='Cauchy', scaleResidual=True):
"""Iteratively reweighted least squares fit.
Expand Down
6 changes: 3 additions & 3 deletions tests/test_defects.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import lsst.ip.isr as ipIsr
import lsst.cp.pipe as cpPipe
from lsst.ip.isr import isrMock
from lsst.ip.isr import isrMock, countMaskedPixels
from lsst.geom import Box2I, Point2I, Extent2I


Expand Down Expand Up @@ -627,7 +627,7 @@ def test_edgeMasking(self):
testImage = self.flatExp.clone()
mi = testImage.maskedImage

self.assertEqual(cpPipe.utils.countMaskedPixels(mi, 'EDGE'), 0)
self.assertEqual(countMaskedPixels(mi, 'EDGE'), 0)
self.defaultTask._setEdgeBits(mi)

hEdge = self.defaultConfig.nPixBorderLeftRight
Expand All @@ -636,7 +636,7 @@ def test_edgeMasking(self):

nEdge = xSize*vEdge*2 + ySize*hEdge*2 - hEdge*vEdge*4

self.assertEqual(cpPipe.utils.countMaskedPixels(mi, 'EDGE'), nEdge)
self.assertEqual(countMaskedPixels(mi, 'EDGE'), nEdge)


class TestMemory(lsst.utils.tests.MemoryTestCase):
Expand Down
88 changes: 0 additions & 88 deletions tests/test_utils.py

This file was deleted.

0 comments on commit d59c43c

Please sign in to comment.