Skip to content

Commit

Permalink
Fix flake8 warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
isullivan committed Feb 16, 2018
1 parent 3937da6 commit fff3f55
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions python/lsst/pipe/tasks/dcrAssembleCoadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ def run(self, dataRef, selectDataList=[]):
for subfilter, coaddExposure in enumerate(retStruct.dcrCoadds):
if self.config.doWrite:
self.writeDcrCoadd(dataRef, coaddExposure, subfilter)

return pipeBase.Struct(coaddExposure=retStruct.coaddExposure, nImage=retStruct.nImage)

def writeDcrCoadd(self, dataRef, coaddExposure, subfilter, nImage=None):
Expand Down Expand Up @@ -318,7 +317,9 @@ def dcrAssembleSubregion(self, dcrModels, bbox, tempExpRefList, imageScalerList,
visitInfo = exposure.getInfo().getVisitInfo()
wcs = exposure.getInfo().getWcs()
maskedImage = exposure.getMaskedImage()
templateImage = self.buildMatchedTemplate(dcrModels, visitInfo, statsFlags, statsCtrl, bbox_grow, wcs)
templateImage = self.buildMatchedTemplate(dcrModels, visitInfo,
statsFlags, statsCtrl,
bbox_grow, wcs)
if exposure.getWcs().pixelScale() != self.pixelScale:
self.log.warn("Incompatible pixel scale for %s %s", tempExpName, tempExpRef.dataId)
imageScaler.scaleMaskedImage(maskedImage)
Expand Down Expand Up @@ -393,7 +394,7 @@ def clampModel(residual, oldModel, bbox, useNonNegative=False, clamp=2.):
newImage[highInds] = oldImage[highInds]*clamp
newVariance[highInds] = oldVariance[highInds]*clamp
lowInds = ((numpy.abs(newImage) < numpy.abs(oldImage/clamp))*
(numpy.abs(newVariance) < numpy.abs(oldVariance/clamp)))
(numpy.abs(newVariance) < numpy.abs(oldVariance/clamp)))
newImage[lowInds] = oldImage[lowInds]/clamp
newVariance[lowInds] = oldVariance[lowInds]/clamp
return newModel
Expand Down Expand Up @@ -426,7 +427,7 @@ def calculateConvergence(self, dcrModels, bbox, tempExpRefList, imageScalerList,
templateImage = self.buildMatchedTemplate(dcrModels, visitInfo, statsFlags, statsCtrl, bbox, wcs)
templateVals = templateImage.getImage().getArray()
diffVals = numpy.abs(refVals - templateVals)*modelVals
refVals = numpy.abs(refVals)*modelVals
refVals = numpy.abs(refVals)*modelVals

finiteInds = (numpy.isfinite(refVals))*(numpy.isfinite(diffVals))
goodMaskInds = (refImage.getMask().getArray() & convergeMask) == convergeMask
Expand Down Expand Up @@ -464,7 +465,6 @@ def stackCoadd(dcrCoadds):
mimage += coadd.getMaskedImage()
return coaddExposure


def fillCoadd(self, dcrModels, skyInfo, tempExpRefList, weightList):
dcrCoadds = []
for model in dcrModels:
Expand Down Expand Up @@ -515,21 +515,22 @@ def dcrShiftCalculate(visitInfo, wcs, lambdaEff, filterWidth, dcrNSubbands):
for wl0, wl1 in wavelengthGenerator(lambdaEff, filterWidth, dcrNSubbands):
# Note that refract_amp can be negative, since it's relative to the midpoint of the full band
diffRefractAmp0 = differentialRefraction(wl0, lambdaEff,
elevation=visitInfo.getBoresightAzAlt().getLatitude(),
observatory=visitInfo.getObservatory(),
weather=visitInfo.getWeather())
elevation=visitInfo.getBoresightAzAlt().getLatitude(),
observatory=visitInfo.getObservatory(),
weather=visitInfo.getWeather())
diffRefractAmp1 = differentialRefraction(wl1, lambdaEff,
elevation=visitInfo.getBoresightAzAlt().getLatitude(),
observatory=visitInfo.getObservatory(),
weather=visitInfo.getWeather())
elevation=visitInfo.getBoresightAzAlt().getLatitude(),
observatory=visitInfo.getObservatory(),
weather=visitInfo.getWeather())
diffRefractAmp = (diffRefractAmp0 + diffRefractAmp1)/2.
diffRefractPix = diffRefractAmp.asArcseconds()/wcs.pixelScale().asArcseconds()
dcrShift.append(dcr(dx=diffRefractPix*numpy.cos(rotation.asRadians()),
dy=diffRefractPix*numpy.sin(rotation.asRadians())))
return dcrShift

def buildMatchedTemplate(self, dcrModels, visitInfo, statsFlags, statsCtrl, bbox, wcs):
dcrShift = self.dcrShiftCalculate(visitInfo, wcs, self.lambdaEff, self.filterWidth, self.config.dcrNSubbands)
dcrShift = self.dcrShiftCalculate(visitInfo, wcs, self.lambdaEff,
self.filterWidth, self.config.dcrNSubbands)
weightList = [1.0]*self.config.dcrNSubbands
maskedImageList = [self.convolveDcrModelPlane(model[bbox, afwImage.PARENT],
dcr, useFFT=self.config.useFFT)
Expand All @@ -541,9 +542,12 @@ def buildMatchedTemplate(self, dcrModels, visitInfo, statsFlags, statsCtrl, bbox
return templateImage

def dcrResiduals(self, dcrModels, residualImageIn, visitInfo, bbox, wcs):
dcrShift = self.dcrShiftCalculate(visitInfo, wcs, self.lambdaEff, self.filterWidth, self.config.dcrNSubbands)
dcrShift = self.dcrShiftCalculate(visitInfo, wcs, self.lambdaEff,
self.filterWidth, self.config.dcrNSubbands)
for dcr in dcrShift:
yield self.convolveDcrModelPlane(residualImageIn, dcr, useInverse=True, useFFT=self.config.useFFT)
yield self.convolveDcrModelPlane(residualImageIn, dcr,
useInverse=True,
useFFT=self.config.useFFT)


def wavelengthGenerator(lambdaEff, filterWidth, dcrNSubbands):
Expand Down

0 comments on commit fff3f55

Please sign in to comment.