389def plotApCorr(bbox, xx, yy, zzMeasure, field, title, doPause):
390 """Plot aperture correction fit residuals
391
392 There are two subplots: residuals against x and y.
393
394 Intended for debugging.
395
396 Parameters
397 ----------
398 bbox : `lsst.geom.Box2I`
399 Bounding box (for bounds)
400 xx, yy : `numpy.ndarray`, (N)
401 x and y coordinates
402 zzMeasure : `float`
403 Measured value of the aperture correction
404 field : `lsst.afw.math.ChebyshevBoundedField`
405 Fit aperture correction field
406 title : 'str'
407 Title for plot
408 doPause : `bool`
409 Pause to inspect the residuals plot? If
410 False, there will be a 4 second delay to
411 allow for inspection of the plot before
412 closing it and moving on.
413 """
414 import matplotlib.pyplot as plt
415
416 zzFit = field.evaluate(xx, yy)
417 residuals = zzMeasure - zzFit
418
419 fig, axes = plt.subplots(2, 1)
420
421 axes[0].scatter(xx, residuals, s=3, marker='o', lw=0, alpha=0.7)
422 axes[1].scatter(yy, residuals, s=3, marker='o', lw=0, alpha=0.7)
423 for ax in axes:
424 ax.set_ylabel("ApCorr Fit Residual")
425 ax.set_ylim(0.9*residuals.min(), 1.1*residuals.max())
426 axes[0].set_xlabel("x")
427 axes[0].set_xlim(bbox.getMinX(), bbox.getMaxX())
428 axes[1].set_xlabel("y")
429 axes[1].set_xlim(bbox.getMinY(), bbox.getMaxY())
430 plt.suptitle(title)
431
432 if not doPause:
433 try:
434 plt.pause(4)
435 plt.close()
436 except Exception:
437 print("%s: plt.pause() failed. Please close plots when done." % __name__)
438 plt.show()
439 else:
440 print("%s: Please close plots when done." % __name__)
441 plt.show()