Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-45796: Stop night report crashing when nothing observed #124

Merged
merged 4 commits into from
Oct 15, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions python/lsst/summit/utils/nightReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand All @@ -729,15 +729,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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I think it will just return the empty plot in that case, but do you want to do the same check and bail with error message in plotPerObjectAirMass()? If just for consistency...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

fig = plt.figure(figsize=(16, 12))

ax = None
for obj in objects:
if obj in CALIB_VALUES:
continue
Expand All @@ -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)

Expand Down
Loading