Skip to content

Commit

Permalink
Solve PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristobal Pio Garcia authored and mfisherlevine committed May 16, 2024
1 parent c3c2294 commit 64f8475
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 26 deletions.
2 changes: 1 addition & 1 deletion config/quickLookIsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
config.doSaturationInterpolation = True
config.overscan.fitType = "MEDIAN_PER_ROW"
config.overscan.doParallelOverscan = True
# config.brighterFatterMaxIter = 2 # Uncomment this to remove test warning
config.brighterFatterMaxIter = 2 # Uncomment this to remove test warning
2 changes: 1 addition & 1 deletion python/lsst/summit/utils/butlerUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def _assureDict(dataId: dict | dafButler.dimensions.DataCoordinate | dafButler.D
return {str(k): v for k, v in dataId.mapping.items()}
elif hasattr(dataId, "items"): # dafButler.dimensions.DataCoordinate
return {str(k): v for k, v in dataId.items()} # str() required due to full names
elif hasattr(dataId, "dataId"): # dafButler.dimensions.DimensionRecord
elif hasattr(dataId, "dataId"): # dafButler.DimensionRecord
return {str(k): v for k, v in dataId.dataId.mapping.items()}
else:
raise RuntimeError(f"Failed to coerce {type(dataId)} to dict")
Expand Down
10 changes: 7 additions & 3 deletions python/lsst/summit/utils/imageExaminer.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,15 @@ def plotCurveOfGrowth(self, ax: matplotlib.axes.Axes | None = None) -> None:
if plotDirect:
plt.show()

def plot(self) -> None:
def plot(self) -> matplotlib.figure.Figure:
"""Plot all the subplots together, including the stats box.
Image is saved if ``savefig`` was set.
Return
------
fig : `matplotlib.figure.Figure`
The figure object.
"""
figsize = 6
fig = plt.figure(figsize=(figsize * 3, figsize * 2))
Expand Down Expand Up @@ -732,8 +737,7 @@ def plot(self) -> None:
if self.savePlots:
print(f"Plot saved to {self.savePlots}")
fig.savefig(self.savePlots)
plt.show()
plt.close("all")
return fig

@staticmethod
def translateStats(imStats: pipeBase.Struct, mappingDict: dict[str, str]) -> list[str]:
Expand Down
24 changes: 16 additions & 8 deletions python/lsst/summit/utils/nightReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ def getExposureMidpoint(self, seqNum: int) -> datetime.datetime:

def plotPerObjectAirMass(
self, objects: Iterable[str] | None = None, airmassOneAtTop: bool = True, saveFig: str = ""
) -> None:
) -> matplotlib.figure.Figure:
"""Plot the airmass for objects observed over the course of the night.
Parameters
Expand All @@ -621,13 +621,18 @@ def plotPerObjectAirMass(
expect.
saveFig : `str`, optional
Save the figure to this file path?
Return
------
fig : `matplotlib.figure.Figure`
The figure object.
"""
if not objects:
objects = self.stars

objects = ensure_iterable(objects)

plt.figure(figsize=(16, 12))
fig = plt.figure(figsize=(16, 12))
for star in objects:
if star in CALIB_VALUES:
continue
Expand All @@ -654,8 +659,7 @@ def plotPerObjectAirMass(
plt.tight_layout()
if saveFig:
plt.savefig(saveFig)
plt.show()
plt.close()
return fig

def _makePolarPlot(
self,
Expand Down Expand Up @@ -703,7 +707,7 @@ def _makePolarPlot(

def makeAltAzCoveragePlot(
self, objects: Iterable[str] | None = None, withLines: bool = False, saveFig: str = ""
) -> None:
) -> matplotlib.figure.Figure:
"""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 @@ -718,12 +722,17 @@ def makeAltAzCoveragePlot(
Connect the points with lines?
saveFig : `str`, optional
Save the figure to this file path?
Return
------
fig : `matplotlib.figure.Figure`
The figure object.
"""
if not objects:
objects = self.stars
objects = ensure_iterable(objects)

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

for obj in objects:
if obj in CALIB_VALUES:
Expand Down Expand Up @@ -755,5 +764,4 @@ def makeAltAzCoveragePlot(
plt.tight_layout()
if saveFig:
plt.savefig(saveFig)
plt.show()
plt.close()
return fig
13 changes: 0 additions & 13 deletions tests/test_butlerUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
from collections.abc import Mapping
from typing import Iterable

import matplotlib.pyplot as plt

import lsst.daf.butler as dafButler
import lsst.utils.tests
from lsst.daf.butler import DatasetRef
Expand Down Expand Up @@ -66,17 +64,6 @@
)


def custom_show(*args, **kwargs):
pass


# Override the show function with our custom one
# to avoid getting the next Warning:
# UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
# plt.show()
plt.show = custom_show


class ButlerUtilsTestCase(lsst.utils.tests.TestCase):
"""A test case for testing sky position offsets for exposures."""

Expand Down

0 comments on commit 64f8475

Please sign in to comment.