Skip to content

Commit

Permalink
Use new lambdaMin and lambdaMax filter properties in dcrAssembleCoadd.
Browse files Browse the repository at this point in the history
  • Loading branch information
isullivan committed Apr 6, 2018
1 parent ce9d3b2 commit 6336f2d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 43 deletions.
59 changes: 21 additions & 38 deletions python/lsst/pipe/tasks/dcrAssembleCoadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,6 @@ class DcrAssembleCoaddConfig(CompareWarpAssembleCoaddConfig):
default=["DETECTED"],
doc="Mask planes to use to calculate convergence."
)
lambdaEff = pexConfig.Field(
dtype=float,
doc="Effective center wavelength of the filter, in nm. This will be replaced in DM-13668.",
default=478.,
)
filterWidth = pexConfig.Field(
dtype=float,
doc="Width of the filter, in nm. This will be replaced in DM-13668",
default=147.,
)

def setDefaults(self):
CompareWarpAssembleCoaddConfig.setDefaults(self)
Expand Down Expand Up @@ -230,6 +220,11 @@ def assemble(self, skyInfo, tempExpRefList, imageScalerList, weightList,
if altMaskList is None:
altMaskList = [None]*len(tempExpRefList)
baseMask = templateCoadd.mask
self.filterInfo = templateCoadd.getFilter()
if np.isnan(self.filterInfo.getFilterProperty().getLambdaMin()):
raise NotImplementedError("No minimum/maximum wavelength information found"
" in the filter definition! Please add lambdaMin and lambdaMax"
" to the Mapper class in your obs package.")
for subBBox in self._subBBoxIter(skyInfo.bbox, subregionSize):
modelIter = 0
convergenceMetric = self.calculateConvergence(subBandImages, subBBox, tempExpRefList,
Expand Down Expand Up @@ -720,17 +715,15 @@ def dcrShiftCalculate(self, visitInfo, wcs):
The 2D shift due to DCR, in pixels.
"""
rotation = self.calculateRotationAngle(visitInfo, wcs)

dcrShift = []
for wl0, wl1 in wavelengthGenerator(self.config.lambdaEff,
self.config.filterWidth,
self.config.dcrNumSubbands):
lambdaEff = self.filterInfo.getFilterProperty().getLambdaEff()
for wl0, wl1 in self.wavelengthGenerator():
# Note that diffRefractAmp can be negative, since it's relative to the midpoint of the full band
diffRefractAmp0 = differentialRefraction(wl0, self.config.lambdaEff,
diffRefractAmp0 = differentialRefraction(wl0, lambdaEff,
elevation=visitInfo.getBoresightAzAlt().getLatitude(),
observatory=visitInfo.getObservatory(),
weather=visitInfo.getWeather())
diffRefractAmp1 = differentialRefraction(wl1, self.config.lambdaEff,
diffRefractAmp1 = differentialRefraction(wl1, lambdaEff,
elevation=visitInfo.getBoresightAzAlt().getLatitude(),
observatory=visitInfo.getObservatory(),
weather=visitInfo.getWeather())
Expand Down Expand Up @@ -858,26 +851,16 @@ def shiftMask(self, mask, shift, useInverse=False):
retMask[bbox, afwImage.PARENT] |= mask[bboxBase, afwImage.PARENT]
return retMask

def wavelengthGenerator(self):
"""Iterate over the wavelength endpoints of subfilters.
def wavelengthGenerator(lambdaEff, filterWidth, dcrNumSubbands):
"""Iterate over the wavelength endpoints of subfilters.
Parameters
----------
lambdaEff : `float`
The effective wavelength of the full filter, in nm.
filterWidth : `float`
The full width of the filter, in nm.
dcrNumSubbands : `int`
The number of subfilters to divide the bandpass into.
Yields
------
Tuple of two `floats`
The next set of wavelength endpoints for a subfilter, in nm.
"""
wlStep = filterWidth/dcrNumSubbands
for wl in np.linspace(-filterWidth/2., filterWidth/2., dcrNumSubbands, endpoint=False):
wlStart = lambdaEff + wl
wlEnd = wlStart + wlStep
yield (wlStart, wlEnd)
Yields
------
Tuple of two `floats`
The next set of wavelength endpoints for a subfilter, in nm.
"""
lambdaMin = self.filterInfo.getFilterProperty().getLambdaMin()
lambdaMax = self.filterInfo.getFilterProperty().getLambdaMax()
wlStep = (lambdaMax - lambdaMin)/self.config.dcrNumSubfilters
for wl in np.linspace(lambdaMin, lambdaMax, self.config.dcrNumSubfilters, endpoint=False):
yield (wl, wl + wlStep)
13 changes: 8 additions & 5 deletions tests/test_dcrAssembleCoadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ class DcrAssembleCoaddTestTask(lsst.utils.tests.TestCase, DcrAssembleCoaddTask):

def setUp(self):
self.config = DcrAssembleCoaddConfig()
self.config.lambdaEff = 478.
self.config.filterWidth = 147.
lambdaEff = 476.31 # Use LSST g band values for the test.
lambdaMin = 405
lambdaMax = 552
afwImage.utils.defineFilter("gTest", lambdaEff, lambdaMin=lambdaMin, lambdaMax=lambdaMax)
self.filterInfo = afwImage.Filter("gTest")
self.config.dcrNumSubfilters = 3
badMaskPlanes = self.config.badMaskPlanes[:]
badMaskPlanes.append("CLIPPED")
Expand Down Expand Up @@ -154,9 +157,9 @@ def testDcrShiftCalculation(self):
visitInfo = self.makeDummyVisitInfo(azimuth, elevation)
wcs = self.makeDummyWcs(rotAngle, pixelScale, crval=visitInfo.getBoresightRaDec())
dcrShift = self.dcrShiftCalculate(visitInfo, wcs)
refShift = [afwGeom.Extent2D(-0.55832265311722795, -0.32306512577396451),
afwGeom.Extent2D(-0.018151534656568987, -0.010503116422151829),
afwGeom.Extent2D(0.36985291822812622, 0.21400990785188412)]
refShift = [afwGeom.Extent2D(-0.5363512808, -0.3103517169),
afwGeom.Extent2D(0.001887293861, 0.001092054612),
afwGeom.Extent2D(0.3886592703, 0.2248919247)]
for shiftOld, shiftNew in zip(refShift, dcrShift):
self.assertFloatsAlmostEqual(shiftOld.getX(), shiftNew.getX(), rtol=1e-6, atol=1e-8)
self.assertFloatsAlmostEqual(shiftOld.getY(), shiftNew.getY(), rtol=1e-6, atol=1e-8)
Expand Down

0 comments on commit 6336f2d

Please sign in to comment.