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

Tickets/dm-36246 #33

Merged
merged 1 commit into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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",
Comment on lines +22 to +27
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these need to be "flx" or could you write out "flux"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As it turns out, flux is not a valid unit and would have to be added as a custom unit to work. flx, or STflux are valid units. I did test it out with flux and it broke the code.

}
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):
bsmartradio marked this conversation as resolved.
Show resolved Hide resolved
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")
bsmartradio marked this conversation as resolved.
Show resolved Hide resolved