Skip to content

Commit

Permalink
Merge pull request #33 from lsst/tickets/DM-36246
Browse files Browse the repository at this point in the history
Tickets/dm-36246: Create metrics for mean, median for psf/ap flux. Add plot for psf/ap ratio.
  • Loading branch information
bsmartradio committed Oct 26, 2022
2 parents cb12d04 + c2524ce commit b56a9a1
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
28 changes: 28 additions & 0 deletions python/lsst/analysis/tools/analysisMetrics/fluxMetrics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from lsst.analysis.tools.actions.scalar import MeanAction, MedianAction
from lsst.analysis.tools.interfaces import AnalysisMetric


class CentralTendency(AnalysisMetric):
"""Metric for measuring mean and median of psf, ap,
and total flux.
"""

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

self.process.calculateActions.psFluxMedianMetric = MedianAction(vectorKey="psFlux")
self.process.calculateActions.apFluxMedianMetric = MedianAction(vectorKey="apFlux")
self.process.calculateActions.totFluxMedianMetric = MedianAction(vectorKey="totFlux")

self.process.calculateActions.psFluxMeanMetric = MeanAction(vectorKey="psFlux")
self.process.calculateActions.apFluxMeanMetric = MeanAction(vectorKey="apFlux")
self.process.calculateActions.totFluxMeanMetric = MeanAction(vectorKey="totFlux")

self.produce.units = {
"psFluxMeanMetric": "flx",
"apFluxMeanMetric": "flx",
"totFluxMeanMetric": "flx",
"psFluxMedianMetric": "flx",
"apFluxMedianMetric": "flx",
"totFluxMedianMetric": "flx",
}
19 changes: 19 additions & 0 deletions python/lsst/analysis/tools/analysisParts/baseFluxRatio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from lsst.analysis.tools.actions.vector import DivideVector, LoadVector
from lsst.analysis.tools.interfaces import AnalysisTool


class BasePsfApRatio(AnalysisTool):
"""Base class for plots or metrics which use PSF/Aperture Ratios."""

def setDefaults(self):
super().setDefaults()
self.process.buildActions.loadVectorPsf = LoadVector()
self.process.buildActions.loadVectorAp = LoadVector()

# assign keys for PSF and AP Flux
self.process.buildActions.loadVectorPsf.vectorKey = "psFlux"
self.process.buildActions.loadVectorAp.vectorKey = "apFlux"

self.process.calculateActions.fluxRatio = DivideVector(
actionA=self.process.buildActions.loadVectorPsf, actionB=self.process.buildActions.loadVectorAp
)
15 changes: 15 additions & 0 deletions python/lsst/analysis/tools/analysisPlots/analysisPlots.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

from ..actions.keyedData.stellarLocusFit import StellarLocusFitAction
from ..actions.plot.colorColorFitPlot import ColorColorFitPlot
from ..actions.plot.histPlot import HistPanel, HistPlot
from ..actions.plot.scatterplotWithTwoHists import ScatterPlotStatsAction, ScatterPlotWithTwoHists
from ..actions.plot.skyPlot import SkyPlot
from ..actions.scalar import ApproxFloor
Expand All @@ -48,6 +49,7 @@
StarSelector,
VectorSelector,
)
from ..analysisParts.baseFluxRatio import BasePsfApRatio
from ..analysisParts.genericPrep import CoaddPrep, VisitPrep
from ..analysisParts.shapeSizeFractional import BasePsfResidualMixin
from ..interfaces import AnalysisPlot
Expand Down Expand Up @@ -287,3 +289,16 @@ class TargetRefCatDeltaDecScatterPlot(TargetRefCatDelta):

def setDefaults(self):
super().setDefaults(coordinate="Dec")


class FluxRatioPlot(AnalysisPlot, BasePsfApRatio):
"""Plot a histogram of the PSF and AP flux ratios of sources."""

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

self.produce = HistPlot()

self.produce.panels["panel_flux"] = HistPanel()
self.produce.panels["panel_flux"].label = "Psf/Ap Ratio"
self.produce.panels["panel_flux"].hists = dict(fluxRatioMetric="Ratio")

0 comments on commit b56a9a1

Please sign in to comment.