Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-34566: Fix deprecation warnings #225

Merged
merged 3 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions python/lsst/ip/diffim/dcrModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def regularizeModelFreq(self, modelImages, bbox, statsCtrl, regularizationFactor
# The noise should be lower in the smoothed image by
# sqrt(Nsmooth) ~ fwhm pixels
noiseLevel /= fwhm
smoothRef = ndimage.filters.gaussian_filter(referenceImage, filterWidth, mode='constant')
smoothRef = ndimage.gaussian_filter(referenceImage, filterWidth, mode='constant')
# Add a three sigma offset to both the reference and model to prevent
# dividing by zero. Note that this will also slightly suppress faint
# variations in color.
Expand All @@ -574,12 +574,12 @@ def regularizeModelFreq(self, modelImages, bbox, statsCtrl, regularizationFactor
highThreshold=highThreshold,
lowThreshold=lowThreshold,
regularizationWidth=regularizationWidth)
smoothModel = ndimage.filters.gaussian_filter(model.array, filterWidth, mode='constant')
smoothModel = ndimage.gaussian_filter(model.array, filterWidth, mode='constant')
smoothModel += 3.*noiseLevel
relativeModel = smoothModel/smoothRef
# Now sharpen the smoothed relativeModel using an alpha of 3.
alpha = 3.
relativeModel2 = ndimage.filters.gaussian_filter(relativeModel, filterWidth/alpha)
relativeModel2 = ndimage.gaussian_filter(relativeModel, filterWidth/alpha)
relativeModel += alpha*(relativeModel - relativeModel2)
model.array = relativeModel*referenceImage

Expand Down Expand Up @@ -653,13 +653,13 @@ def applyImageThresholds(self, image, highThreshold=None, lowThreshold=None, reg
highPixels = image > highThreshold
if regularizationWidth > 0:
# Erode and dilate ``highPixels`` to exclude noisy pixels.
highPixels = ndimage.morphology.binary_opening(highPixels, structure=filterStructure)
highPixels = ndimage.binary_opening(highPixels, structure=filterStructure)
image[highPixels] = highThreshold[highPixels]
if lowThreshold is not None:
lowPixels = image < lowThreshold
if regularizationWidth > 0:
# Erode and dilate ``lowPixels`` to exclude noisy pixels.
lowPixels = ndimage.morphology.binary_opening(lowPixels, structure=filterStructure)
lowPixels = ndimage.binary_opening(lowPixels, structure=filterStructure)
image[lowPixels] = lowThreshold[lowPixels]


Expand Down
2 changes: 1 addition & 1 deletion python/lsst/ip/diffim/dipoleFitTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ def dipoleModelFunctor(x, flux, xcenPos, ycenPos, xcenNeg, ycenNeg, fluxNeg=None
gmod.set_param_hint('y2Neg', value=bgParsNeg[5])

y, x = np.mgrid[bbox.getBeginY():bbox.getEndY(), bbox.getBeginX():bbox.getEndX()]
in_x = np.array([x, y]).astype(np.float)
in_x = np.array([x, y]).astype(np.float64)
in_x[0, :] -= in_x[0, :].mean() # center it!
in_x[1, :] -= in_x[1, :].mean()

Expand Down
8 changes: 4 additions & 4 deletions tests/test_dcrModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,11 @@ def testRegularizationSmallClamp(self):
np.max(model.array - templateImage))
highThreshold = templateImage*clampFrequency
highPix = model.array > highThreshold
highPix = ndimage.morphology.binary_opening(highPix, iterations=regularizationWidth)
highPix = ndimage.binary_opening(highPix, iterations=regularizationWidth)
self.assertFalse(np.all(highPix))
lowThreshold = templateImage/clampFrequency
lowPix = model.array < lowThreshold
lowPix = ndimage.morphology.binary_opening(lowPix, iterations=regularizationWidth)
lowPix = ndimage.binary_opening(lowPix, iterations=regularizationWidth)
self.assertFalse(np.all(lowPix))

def testRegularizationSidelobes(self):
Expand Down Expand Up @@ -517,11 +517,11 @@ def testRegularizeModelIter(self):
# Check that all of the outliers are clipped
highThreshold = oldModel.array*modelClampFactor
highPix = newModel.array > highThreshold
highPix = ndimage.morphology.binary_opening(highPix, iterations=regularizationWidth)
highPix = ndimage.binary_opening(highPix, iterations=regularizationWidth)
self.assertFalse(np.all(highPix))
lowThreshold = oldModel.array/modelClampFactor
lowPix = newModel.array < lowThreshold
lowPix = ndimage.morphology.binary_opening(lowPix, iterations=regularizationWidth)
lowPix = ndimage.binary_opening(lowPix, iterations=regularizationWidth)
self.assertFalse(np.all(lowPix))

def testIterateModel(self):
Expand Down
12 changes: 6 additions & 6 deletions tests/test_subtractTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,9 @@ def _run_and_check_images(doDecorrelation):

# check PSF, WCS, bbox, filterLabel, photoCalib, aperture correction
self._compare_apCorrMaps(apCorrMap, output.difference.info.getApCorrMap())
self.assertWcsAlmostEqualOverBBox(science.getWcs(), output.difference.getWcs(), science.getBBox())
self.assertEqual(science.getFilterLabel(), output.difference.getFilterLabel())
self.assertEqual(science.getPhotoCalib(), output.difference.getPhotoCalib())
self.assertWcsAlmostEqualOverBBox(science.wcs, output.difference.wcs, science.getBBox())
self.assertEqual(science.filter, output.difference.filter)
self.assertEqual(science.photoCalib, output.difference.photoCalib)
_run_and_check_images(doDecorrelation=True)
_run_and_check_images(doDecorrelation=False)

Expand Down Expand Up @@ -680,9 +680,9 @@ def _run_and_check_images(doDecorrelation):

# check PSF, WCS, bbox, filterLabel, photoCalib, aperture correction
self._compare_apCorrMaps(apCorrMap, output.difference.info.getApCorrMap())
self.assertWcsAlmostEqualOverBBox(science.getWcs(), output.difference.getWcs(), science.getBBox())
self.assertEqual(science.getFilterLabel(), output.difference.getFilterLabel())
self.assertEqual(science.getPhotoCalib(), output.difference.getPhotoCalib())
self.assertWcsAlmostEqualOverBBox(science.wcs, output.difference.wcs, science.getBBox())
self.assertEqual(science.filter, output.difference.filter)
self.assertEqual(science.photoCalib, output.difference.photoCalib)

_run_and_check_images(doDecorrelation=True)
_run_and_check_images(doDecorrelation=False)
Expand Down