Skip to content

Commit

Permalink
Run black
Browse files Browse the repository at this point in the history
  • Loading branch information
isullivan committed Mar 27, 2024
1 parent 6b27080 commit 9d27563
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 39 deletions.
23 changes: 8 additions & 15 deletions python/lsst/analysis/tools/actions/plot/interpolateDetectorPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@


class InterpolateDetectorMetricPlot(PlotAction):
"""Returns a fixed array size with interpolation of metric in the detector
"""
"""Interpolate metrics evaluated at locations across a detector."""

xAxisLabel = Field[str](doc="Label to use for the x axis.", default="x (pixel)", optional=True)
yAxisLabel = Field[str](doc="Label to use for the y axis.", default="y (pixel)", optional=True)
Expand All @@ -60,32 +59,26 @@ def getInputSchema(self) -> KeyedDataSchema:
return base

def __call__(self, data: KeyedData, **kwargs) -> Mapping[str, Figure] | Figure:
# self._validateInput(data, **kwargs)
return self.makePlot(data, **kwargs)

def makePlot(
self,
data: KeyedData,
plotInfo: Optional[Mapping[str, str]] = None,
**kwargs
) -> Figure:
def makePlot(self, data: KeyedData, plotInfo: Optional[Mapping[str, str]] = None, **kwargs) -> Figure:

X = np.linspace(-self.gridMargin, self.xCoordSize+self.gridMargin, self.nGridPoints)
Y = np.linspace(-self.gridMargin, self.yCoordSize+self.gridMargin, self.nGridPoints)
X = np.linspace(-self.gridMargin, self.xCoordSize + self.gridMargin, self.nGridPoints)
Y = np.linspace(-self.gridMargin, self.yCoordSize + self.gridMargin, self.nGridPoints)
meshgridX, meshgridY = np.meshgrid(X, Y) # 2D grid for interpolation

interp = CloughTocher2DInterpolator(list(zip(data["x"], data["y"])), data["metricValues"])
Z = interp(meshgridX, meshgridY)

fig, ax = plt.subplots(1, 1, figsize=(8, 6))
pc = ax.pcolormesh(X, Y, Z, shading='auto')
ax.scatter(data['x'], data['y'], s=5, c="black")
pc = ax.pcolormesh(X, Y, Z, shading="auto")
ax.scatter(data["x"], data["y"], s=5, c="black")
cbar = fig.colorbar(pc)
cbar.set_label(self.zAxisLabel, rotation=270)
ax.set_xlabel(self.xAxisLabel)
ax.set_ylabel(self.yAxisLabel)
ax.set_aspect('equal', 'box')
ax.set_aspect("equal", "box")

# add general plot info
if plotInfo is not None:
fig = addPlotInfo(fig, plotInfo)
Expand Down
35 changes: 15 additions & 20 deletions python/lsst/analysis/tools/atools/diaMetricsPlots.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is part of analysis_ap.
# This file is part of analysis_tools.
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
Expand All @@ -18,7 +18,6 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

__all__ = ("DiffimMetricsHistPlot", "DiffimMetricsInterpolatePlot")

from lsst.pex.config import Field
Expand All @@ -30,32 +29,28 @@


class DiffimMetricsHistPlot(AnalysisTool):
"""Create histograms of the fraction of pixels with certain mask planes set.
"""Create histograms of the fraction of pixels with certain mask planes
set.
"""

parameterizedBand: bool = False

def setDefaults(self):
super().setDefaults()

self.process.buildActions.bad_mask_fraction = LoadVector(
vectorKey="bad_mask_fraction")
self.process.buildActions.cr_mask_fraction = LoadVector(
vectorKey="cr_mask_fraction")
self.process.buildActions.detected_mask_fraction = LoadVector(
vectorKey="detected_mask_fraction")
self.process.buildActions.bad_mask_fraction = LoadVector(vectorKey="bad_mask_fraction")
self.process.buildActions.cr_mask_fraction = LoadVector(vectorKey="cr_mask_fraction")
self.process.buildActions.detected_mask_fraction = LoadVector(vectorKey="detected_mask_fraction")
self.process.buildActions.detected_negative_mask_fraction = LoadVector(
vectorKey="detected_negative_mask_fraction")
self.process.buildActions.intrp_mask_fraction = LoadVector(
vectorKey="intrp_mask_fraction")
self.process.buildActions.no_data_mask_fraction = LoadVector(
vectorKey="no_data_mask_fraction")
self.process.buildActions.sat_mask_fraction = LoadVector(
vectorKey="sat_mask_fraction")
vectorKey="detected_negative_mask_fraction"
)
self.process.buildActions.intrp_mask_fraction = LoadVector(vectorKey="intrp_mask_fraction")
self.process.buildActions.no_data_mask_fraction = LoadVector(vectorKey="no_data_mask_fraction")
self.process.buildActions.sat_mask_fraction = LoadVector(vectorKey="sat_mask_fraction")
self.process.buildActions.sat_template_mask_fraction = LoadVector(
vectorKey="sat_template_mask_fraction")
self.process.buildActions.streak_mask_fraction = LoadVector(
vectorKey="streak_mask_fraction")
vectorKey="sat_template_mask_fraction"
)
self.process.buildActions.streak_mask_fraction = LoadVector(vectorKey="streak_mask_fraction")

self.produce.plot = HistPlot()

Expand All @@ -64,7 +59,7 @@ def setDefaults(self):
self.produce.plot.panels["panel_flags"].bins = 20
self.produce.plot.panels["panel_flags"].rangeType = "fixed"
self.produce.plot.panels["panel_flags"].lowerRange = 0
self.produce.plot.panels["panel_flags"].upperRange = 1.
self.produce.plot.panels["panel_flags"].upperRange = 1.0
self.produce.plot.panels["panel_flags"].hists = dict(
no_data_mask_fraction="No data",
sat_mask_fraction="Saturated",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
class DiffimDetectorVisitAnalysisPlotsConnections(
AnalysisBaseConnections,
dimensions=("visit", "band", "detector"),
defaultTemplates={"coaddName": "goodSeeing",
"fakesType": ""}
defaultTemplates={"coaddName": "goodSeeing", "fakesType": ""},
):
data = connectionTypes.Input(
doc="QA metrics evaluated in locations throughout the difference image.",
Expand All @@ -57,12 +56,12 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):
inputs = butlerQC.get(inputRefs)
dataId = butlerQC.quantum.dataId
plotInfo = self.parsePlotInfo(inputs, dataId)
plotInfo['tableName'] += f", detector: {plotInfo['detector']}"
plotInfo["tableName"] += f", detector: {plotInfo['detector']}"
data = self.loadData(inputs["data"])

outputs = self.run(
data=data,
plotInfo=plotInfo,
bands=plotInfo['band'],
bands=plotInfo["band"],
)
butlerQC.put(outputs, outputRefs)

0 comments on commit 9d27563

Please sign in to comment.