Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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!
parejkoj committed Mar 26, 2024
1 parent 8cc82d0 commit 7e452ec
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
@@ -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)
@@ -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()

0 comments on commit 7e452ec

Please sign in to comment.