Skip to content

Commit

Permalink
Merge branch 'tickets/DM-36188'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophie Reed committed Sep 21, 2022
2 parents 2e543c4 + 335462c commit b9b489f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
11 changes: 7 additions & 4 deletions python/lsst/analysis/tools/actions/plot/colorColorFitPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ColorColorFitPlot(PlotAction):
plotTypes = ListField[str](
doc="Selection of types of objects to plot. Can take any combination of"
" stars, galaxies, unknown, mag, any.",
optional=False,
default=["stars"],
)

plotName = Field[str](doc="The name for the plot.", optional=False)
Expand Down Expand Up @@ -169,9 +169,12 @@ def makePlot(
ax = fig.add_axes([0.12, 0.25, 0.43, 0.60])
axContour = fig.add_axes([0.65, 0.11, 0.3, 0.31])
axHist = fig.add_axes([0.65, 0.51, 0.3, 0.31])
xs = cast(Vector, data["x"])
ys = cast(Vector, data["y"])
mags = data["mag"]

# Check for nans/infs
goodPoints = np.isfinite(data["x"]) & np.isfinite(data["y"]) & np.isfinite(data["mag"])
xs = cast(Vector, data["x"])[goodPoints]
ys = cast(Vector, data["y"])[goodPoints]
mags = cast(Vector, data["mag"])[goodPoints]

# TODO: Make a no data fig function and use here
if len(xs) == 0 or len(ys) == 0:
Expand Down
5 changes: 4 additions & 1 deletion python/lsst/analysis/tools/actions/plot/plotUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ def addPlotInfo(fig, plotInfo):
for band in plotInfo["bands"]:
bandText += band + ", "
bandsText = f", Bands: {bandText[:-2]}"
SNText = f", S/N: {plotInfo['SN']}"
try:
SNText = f", S/N: {plotInfo['SN']}"
except KeyError:
SNText = ", S/N: -"
infoText = f"\n{run}{datasetsUsed}{tableType}{dataIdText}{bandsText}{SNText}"
fig.text(0.01, 0.98, infoText, fontsize=7, transform=fig.transFigure, alpha=0.6, ha="left", va="top")

Expand Down
3 changes: 3 additions & 0 deletions python/lsst/analysis/tools/analysisPlots/analysisPlots.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ def setDefaults(self):
}

self.produce = ColorColorFitPlot()
self.produce.xAxisLabel = "g - r (PSF) [mags]"
self.produce.yAxisLabel = "r - i (PSF) [mags]"
self.produce.magLabel = "PSF Mag"
self.produce.plotName = "wPerp_psfFlux"


Expand Down
2 changes: 2 additions & 0 deletions python/lsst/analysis/tools/tasks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ def runPlots(self, data: KeyedData, **kwargs) -> Struct:
setattr(results, n, v)
case value:
setattr(results, name, value)
if "SN" not in kwargs["plotInfo"].keys():
kwargs["plotInfo"]["SN"] = "-"
return results

def runMetrics(self, data: KeyedData, **kwargs) -> Struct:
Expand Down
13 changes: 13 additions & 0 deletions tests/testPlots.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
description: |
A test pipeline that makes one plot of each plot type.
tasks:
analyzeObjectTableCore:
class: lsst.analysis.tools.tasks.ObjectTableTractAnalysisTask
config:
connections.outputName: objectTableCore
plots.shapeSizeFractionalDiffScatter: ShapeSizeFractionalDiffScatterPlot
plots.wPerpPSFPlot: WPerpPSFPlot
plots.ap12PsfSkyPlot: Ap12PsfSkyPlot
plots.skyObjectHistPlot: SkyObjectHistPlot
python: |
from lsst.analysis.tools.analysisPlots import *

0 comments on commit b9b489f

Please sign in to comment.