Skip to content

Commit

Permalink
Fix debug logging and display2dArray
Browse files Browse the repository at this point in the history
We want the debug logs to appear if the loglevel is DEBUG.
Plot display was broken because `show()` never got called!
  • Loading branch information
parejkoj committed Mar 26, 2024
1 parent e96ca8e commit 8bfe439
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions python/lsst/ip/diffim/dipoleFitTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,12 @@ def makeModel(self, x, flux, xcenPos, ycenPos, xcenNeg, ycenNeg, fluxNeg=None,
if fluxNeg is None:
fluxNeg = flux

if self.debug:
self.log.debug('%.2f %.2f %.2f %.2f %.2f %.2f',
flux, fluxNeg, xcenPos, ycenPos, xcenNeg, ycenNeg)
if x1 is not None:
self.log.debug(' %.2f %.2f %.2f', b, x1, y1)
if xy is not None:
self.log.debug(' %.2f %.2f %.2f', xy, x2, y2)
self.log.debug('flux: %.2f fluxNeg: %.2f x+: %.2f x-: %.2f y+: %.2f y-: %.2f ',
flux, fluxNeg, xcenPos, xcenNeg, ycenPos, ycenNeg)
if x1 is not None:
self.log.debug(' b: %.2f x1: %.2f y1: %.2f', b, x1, y1)
if xy is not None:
self.log.debug(' xy: %.2f x2: %.2f y2: %.2f', xy, x2, y2)

posIm = self.makeStarModel(bbox, psf, xcenPos, ycenPos, flux)
negIm = self.makeStarModel(bbox, psf, xcenNeg, ycenNeg, fluxNeg)
Expand Down Expand Up @@ -937,24 +936,22 @@ def display2dArray(arr, title='Data', extent=None):
bbox = footprint.getBBox()
extent = (bbox.getBeginX(), bbox.getEndX(), bbox.getBeginY(), bbox.getEndY())
if z.shape[0] == 3:
fig = plt.figure(figsize=(8, 8))
plt.figure(figsize=(8, 8))
for i in range(3):
plt.subplot(3, 3, i*3+1)
display2dArray(z[i, :], 'Data', extent=extent)
plt.subplot(3, 3, i*3+2)
display2dArray(fit[i, :], 'Model', extent=extent)
plt.subplot(3, 3, i*3+3)
display2dArray(z[i, :] - fit[i, :], 'Residual', extent=extent)
return fig
else:
fig = plt.figure(figsize=(8, 2.5))
plt.figure(figsize=(8, 2.5))
plt.subplot(1, 3, 1)
display2dArray(z, 'Data', extent=extent)
plt.subplot(1, 3, 2)
display2dArray(fit, 'Model', extent=extent)
plt.subplot(1, 3, 3)
display2dArray(z - fit, 'Residual', extent=extent)
return fig

plt.show()

Expand Down

0 comments on commit 8bfe439

Please sign in to comment.