From 4656e76380a25515aa98652d0c58dbe5c8a0c7f9 Mon Sep 17 00:00:00 2001 From: Merlin Fisher-Levine Date: Thu, 15 Aug 2024 07:30:55 -0700 Subject: [PATCH 1/4] Fix crash when nothing is plotted --- python/lsst/summit/utils/nightReport.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/python/lsst/summit/utils/nightReport.py b/python/lsst/summit/utils/nightReport.py index 8f8243a4..2806e96b 100644 --- a/python/lsst/summit/utils/nightReport.py +++ b/python/lsst/summit/utils/nightReport.py @@ -736,8 +736,13 @@ def makeAltAzCoveragePlot( objects = self.stars objects = ensure_iterable(objects) + if not objects: # there's genuinely nothing now + self.log.info("No objects to plot") + return None + fig = plt.figure(figsize=(16, 12)) + ax = None for obj in objects: if obj in CALIB_VALUES: continue @@ -757,6 +762,11 @@ def makeAltAzCoveragePlot( ax = self._makePolarPlot( azes, zens, marker=marker, title=None, makeFig=False, color=color, objName=obj ) + + if ax is None: + self.log.info("Only calibs taken so far, nothing to plot") + return None + lgnd = ax.legend(bbox_to_anchor=(1.05, 1), prop={"size": 15}, loc="upper left") ax.set_title("Axial coverage - azimuth (theta, deg) vs zenith angle (r, deg)", size=20) From 40043904a1fb71d274cdc5fece7f5619db55a33b Mon Sep 17 00:00:00 2001 From: Merlin Fisher-Levine Date: Sat, 12 Oct 2024 06:10:07 -0700 Subject: [PATCH 2/4] Annotate new return type --- python/lsst/summit/utils/nightReport.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/lsst/summit/utils/nightReport.py b/python/lsst/summit/utils/nightReport.py index 2806e96b..ce45e754 100644 --- a/python/lsst/summit/utils/nightReport.py +++ b/python/lsst/summit/utils/nightReport.py @@ -711,7 +711,7 @@ def _makePolarPlot( def makeAltAzCoveragePlot( self, objects: Iterable[str] | None = None, withLines: bool = False, saveFig: str = "" - ) -> matplotlib.figure.Figure: + ) -> matplotlib.figure.Figure | None: """Make a polar plot of the azimuth and zenith angle for each object. Plots the azimuth on the theta axis, and zenith angle (not altitude!) @@ -729,8 +729,8 @@ def makeAltAzCoveragePlot( Return ------ - fig : `matplotlib.figure.Figure` - The figure object. + fig : `matplotlib.figure.Figure` or `None` + The figure object, or `None` if nothing was plotted. """ if not objects: objects = self.stars From 8dee06bf0dceb13fd28712bad22938422903e320 Mon Sep 17 00:00:00 2001 From: Merlin Fisher-Levine Date: Tue, 15 Oct 2024 13:47:07 -0700 Subject: [PATCH 3/4] Make plotPerObjectAirMass behave in the same way --- python/lsst/summit/utils/nightReport.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python/lsst/summit/utils/nightReport.py b/python/lsst/summit/utils/nightReport.py index ce45e754..959b0143 100644 --- a/python/lsst/summit/utils/nightReport.py +++ b/python/lsst/summit/utils/nightReport.py @@ -611,7 +611,7 @@ def getExposureMidpoint(self, seqNum: int) -> datetime.datetime: def plotPerObjectAirMass( self, objects: Iterable[str] | None = None, airmassOneAtTop: bool = True, saveFig: str = "" - ) -> matplotlib.figure.Figure: + ) -> matplotlib.figure.Figure | None: """Plot the airmass for objects observed over the course of the night. Parameters @@ -626,12 +626,16 @@ def plotPerObjectAirMass( Return ------ - fig : `matplotlib.figure.Figure` - The figure object. + fig : `matplotlib.figure.Figure` or `None` + The figure object or `None` if nothing was plotted. """ if not objects: objects = self.stars + if not objects: # there's genuinely nothing now + self.log.info("No objects to plot") + return None + objects = ensure_iterable(objects) fig = plt.figure(figsize=(16, 12)) From 70df1e45fdfc28a9d1b1543d4c743cd167587d3a Mon Sep 17 00:00:00 2001 From: Merlin Fisher-Levine Date: Tue, 15 Oct 2024 13:47:27 -0700 Subject: [PATCH 4/4] Explicitly declare the package as typed --- python/lsst/summit/utils/py.typed | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 python/lsst/summit/utils/py.typed diff --git a/python/lsst/summit/utils/py.typed b/python/lsst/summit/utils/py.typed new file mode 100644 index 00000000..e69de29b