From 73b3a12cd8f5bc97e56ac8698f1082dd40d1bb79 Mon Sep 17 00:00:00 2001 From: Merlin Fisher-Levine Date: Tue, 30 Jan 2024 09:50:15 -0800 Subject: [PATCH] Check rotPa and rotAzEl are finite when adding compass --- .../lsst/summit/utils/astrometry/plotting.py | 75 ++++++++++--------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/python/lsst/summit/utils/astrometry/plotting.py b/python/lsst/summit/utils/astrometry/plotting.py index 38e23133..2f48f441 100644 --- a/python/lsst/summit/utils/astrometry/plotting.py +++ b/python/lsst/summit/utils/astrometry/plotting.py @@ -93,46 +93,49 @@ def plot(exp, icSrc=None, filteredSources=None, saveAs=None, plt.plot(filteredSources['base_SdssCentroid_x'], filteredSources['base_SdssCentroid_y'], **markerStyle) - plt.arrow(compassCenter[0], - compassCenter[1], - -compassSize*np.sin(rotpa), - compassSize*np.cos(rotpa), - color='green', width=20) - plt.text(compassCenter[0] - textDistance*np.sin(rotpa), - compassCenter[1] + textDistance*np.cos(rotpa), - 'N', - color='green', fontsize=fontsize, weight='bold') - plt.arrow(compassCenter[0], - compassCenter[1], - compassSize*np.cos(rotpa), - compassSize*np.sin(rotpa), - color='green', width=20) - plt.text(compassCenter[0] + textDistance*np.cos(rotpa), - compassCenter[1] + textDistance*np.sin(rotpa), - 'E', - color='green', fontsize=fontsize, weight='bold') + + if np.isfinite(rotpa): # need a rotation angle for the compass + plt.arrow(compassCenter[0], + compassCenter[1], + -compassSize*np.sin(rotpa), + compassSize*np.cos(rotpa), + color='green', width=20) + plt.text(compassCenter[0] - textDistance*np.sin(rotpa), + compassCenter[1] + textDistance*np.cos(rotpa), + 'N', + color='green', fontsize=fontsize, weight='bold') + plt.arrow(compassCenter[0], + compassCenter[1], + compassSize*np.cos(rotpa), + compassSize*np.sin(rotpa), + color='green', width=20) + plt.text(compassCenter[0] + textDistance*np.cos(rotpa), + compassCenter[1] + textDistance*np.sin(rotpa), + 'E', + color='green', fontsize=fontsize, weight='bold') sinTheta = np.cos(AUXTEL_LOCATION.lat)/np.cos(dec)*np.sin(az) theta = Angle(np.arcsin(sinTheta)) rotAzEl = rotpa - theta - Angle(90.0 * u.deg) - plt.arrow(compassAzElCent[0], - compassAzElCent[1], - -compassSize*np.sin(rotAzEl), - compassSize*np.cos(rotAzEl), - color='cyan', width=20) - plt.text(compassAzElCent[0] - textDistance*np.sin(rotAzEl), - compassAzElCent[1] + textDistance*np.cos(rotAzEl), - 'EL', - color='cyan', fontsize=fontsize, weight='bold') - plt.arrow(compassAzElCent[0], - compassAzElCent[1], - compassSize*np.cos(rotAzEl), - compassSize*np.sin(rotAzEl), - color='cyan', width=20) - plt.text(compassAzElCent[0] + textDistance*np.cos(rotAzEl), - compassAzElCent[1] + textDistance*np.sin(rotAzEl), - 'AZ', - color='cyan', fontsize=fontsize, weight='bold') + if np.isfinite(rotAzEl): # need a rotation angle for the compass + plt.arrow(compassAzElCent[0], + compassAzElCent[1], + -compassSize*np.sin(rotAzEl), + compassSize*np.cos(rotAzEl), + color='cyan', width=20) + plt.text(compassAzElCent[0] - textDistance*np.sin(rotAzEl), + compassAzElCent[1] + textDistance*np.cos(rotAzEl), + 'EL', + color='cyan', fontsize=fontsize, weight='bold') + plt.arrow(compassAzElCent[0], + compassAzElCent[1], + compassSize*np.cos(rotAzEl), + compassSize*np.sin(rotAzEl), + color='cyan', width=20) + plt.text(compassAzElCent[0] + textDistance*np.cos(rotAzEl), + compassAzElCent[1] + textDistance*np.sin(rotAzEl), + 'AZ', + color='cyan', fontsize=fontsize, weight='bold') plt.ylim(0, height) plt.tight_layout()