Skip to content

Commit

Permalink
Merge pull request #73 from lsst/tickets/DM-23173/meas_deblender
Browse files Browse the repository at this point in the history
DM-23173: Change W504 to W503 and fix flake8 warnings
  • Loading branch information
r-owen committed Apr 9, 2020
2 parents 8e6e14c + 99db964 commit 361aba8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
22 changes: 11 additions & 11 deletions examples/plotDeblendFamilies.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,11 @@ def getDebFlagString(kid):
# print 'valid', valid.shape, valid.dtype
# print 'rw[valid]:', rw[valid]

myresid = np.sum(kid.psfFitDebugValidPix *
kid.psfFitDebugRampWeight *
((kid.psfFitDebugStamp.getArray() -
kid.psfFitDebugPsfModel.getArray()) /
np.sqrt(kid.psfFitDebugVar.getArray()))**2)
myresid = np.sum(kid.psfFitDebugValidPix
* kid.psfFitDebugRampWeight
* ((kid.psfFitDebugStamp.getArray()
- kid.psfFitDebugPsfModel.getArray())
/ np.sqrt(kid.psfFitDebugVar.getArray()))**2)
print('myresid:', myresid)

plt.subplot(2, 4, 8)
Expand All @@ -418,8 +418,8 @@ def getDebFlagString(kid):
# plt.imshow(kid.psfFitDebugVar.getArray(), vmin=0, **ima)
# plt.colorbar()
plt.title('model+noise')
plt.imshow((kid.psfFitDebugPsfModel.getArray() +
sig * np.random.normal(size=sig.shape))*valid,
plt.imshow((kid.psfFitDebugPsfModel.getArray()
+ sig * np.random.normal(size=sig.shape))*valid,
vmin=0, vmax=mx, **ima)
plt.xticks([])
plt.yticks([])
Expand All @@ -439,10 +439,10 @@ def getDebFlagString(kid):
plt.yticks([])
plt.colorbar()

chi = (kid.psfFitDebugValidPix *
(kid.psfFitDebugStamp.getArray() -
kid.psfFitDebugPsfModel.getArray()) /
np.sqrt(kid.psfFitDebugVar.getArray()))
chi = (kid.psfFitDebugValidPix
* (kid.psfFitDebugStamp.getArray()
- kid.psfFitDebugPsfModel.getArray())
/ np.sqrt(kid.psfFitDebugVar.getArray()))

plt.subplot(2, 4, 6)
plt.title('fit psf chi')
Expand Down
20 changes: 10 additions & 10 deletions python/lsst/meas/deblender/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ def _fitPsf(fp, fmask, pk, pkF, pkres, fbb, peaks, peaksF, log, psf, psffwhm,
del inpsfy

def _overlap(xlo, xhi, xmin, xmax):
assert((xlo <= xmax) and (xhi >= xmin) and
(xlo <= xhi) and (xmin <= xmax))
assert((xlo <= xmax) and (xhi >= xmin)
and (xlo <= xhi) and (xmin <= xmax))
xloclamp = max(xlo, xmin)
Xlo = xloclamp - xlo
xhiclamp = min(xhi, xmax)
Expand Down Expand Up @@ -414,17 +414,17 @@ def _overlap(xlo, xhi, xmin, xmax):
# shifted-by-minus-one.
oldsx = (sx1, sx2, sx3, sx4)
sx1, sx2, sx3, sx4 = _overlap(xlo, xhi, px0+1, px1-1)
psfsub = (psfarr[psf_y_slice, sx3 - dpx0 + 1: sx4 - dpx0 + 1] -
psfarr[psf_y_slice, sx3 - dpx0 - 1: sx4 - dpx0 - 1])/2.
psfsub = (psfarr[psf_y_slice, sx3 - dpx0 + 1: sx4 - dpx0 + 1]
- psfarr[psf_y_slice, sx3 - dpx0 - 1: sx4 - dpx0 - 1])/2.
vsub = valid[sy1-ylo: sy2-ylo, sx1-xlo: sx2-xlo]
A[indx[valid], I_dx] = psfsub[vsub]
# revert x indices...
(sx1, sx2, sx3, sx4) = oldsx

# PSF dy
sy1, sy2, sy3, sy4 = _overlap(ylo, yhi, py0+1, py1-1)
psfsub = (psfarr[sy3 - dpy0 + 1: sy4 - dpy0 + 1, psf_x_slice] -
psfarr[sy3 - dpy0 - 1: sy4 - dpy0 - 1, psf_x_slice])/2.
psfsub = (psfarr[sy3 - dpy0 + 1: sy4 - dpy0 + 1, psf_x_slice]
- psfarr[sy3 - dpy0 - 1: sy4 - dpy0 - 1, psf_x_slice])/2.
vsub = valid[sy1-ylo: sy2-ylo, sx1-xlo: sx2-xlo]
A[indy[valid], I_dy] = psfsub[vsub]

Expand Down Expand Up @@ -587,8 +587,8 @@ def _overlap(xlo, xhi, xmin, xmax):
pkres.psfFit3 = (chisqb, dofb)

# Which one do we keep?
if (((ispsf1 and ispsf2) and (q2 < q1)) or
(ispsf2 and not ispsf1)):
if (((ispsf1 and ispsf2) and (q2 < q1))
or (ispsf2 and not ispsf1)):
Xpsf = X2
chisq = chisq2
dof = dof2
Expand Down Expand Up @@ -788,8 +788,8 @@ def rampFluxAtEdge(debResult, log, patchEdges=False):
dp.y0, dp.y1, dp.psf, pkres.peak,
dp.avgNoise, patchEdges)
except lsst.pex.exceptions.Exception as exc:
if (isinstance(exc, lsst.pex.exceptions.InvalidParameterError) and
"CoaddPsf" in str(exc)):
if (isinstance(exc, lsst.pex.exceptions.InvalidParameterError)
and "CoaddPsf" in str(exc)):
pkres.setOutOfBounds()
continue
raise
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[flake8]
max-line-length = 110
# TODO: remove E266 when Task documentation is converted to rst in DM-14207.
ignore = E133, E226, E228, N802, N803, N806, E266, N812, N815, N816, W504
ignore = E133, E226, E228, N802, N803, N806, E266, N812, N815, N816, W503
exclude = __init__.py

[tool:pytest]
addopts = --flake8
flake8-ignore = E133 E226 E228 N802 N803 N806 N812 N815 N816 W504
flake8-ignore = E133 E226 E228 N802 N803 N806 N812 N815 N816 W503
# TODO: remove E266 lines when Task documentation is converted to rst in DM-14207.
deblend.py E266

0 comments on commit 361aba8

Please sign in to comment.