Skip to content

Commit

Permalink
Merge pull request #124 from lsst-sitcom/tickets/DM-45796
Browse files Browse the repository at this point in the history
DM-45796: Stop night report crashing when nothing observed
  • Loading branch information
mfisherlevine authored Oct 15, 2024
2 parents f901ca4 + 70df1e4 commit fc75cfb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions python/lsst/summit/utils/nightReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down Expand Up @@ -711,7 +715,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!)
Expand All @@ -729,15 +733,20 @@ 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
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
Expand All @@ -757,6 +766,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)

Expand Down
Empty file.

0 comments on commit fc75cfb

Please sign in to comment.