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

DM-42647: Add a psf - cmodel scatter plot #189

Merged
merged 1 commit into from
Jan 25, 2024
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
2 changes: 1 addition & 1 deletion pipelines/coaddQualityCore.yaml
Expand Up @@ -22,7 +22,7 @@ tasks:
atools.yPerpCModel: YPerpCModel
atools.skyObjectSky: SkyObjectSkyPlot
atools.skyObjectFlux: SkyObjectHistPlot
atools.psfCModelSky: PsfCModelSkyPlot
atools.psfCModelScatter: PsfCModelScatterPlot
python: |
from lsst.analysis.tools.atools import *
from lsst.analysis.tools.contexts import *
Expand Down
1 change: 1 addition & 0 deletions pipelines/coaddQualityExtended.yaml
Expand Up @@ -7,6 +7,7 @@ tasks:
connections.outputName: objectTableExtended
# set plots to run
atools.ap12PsfSky: Ap12PsfSkyPlot
atools.psfCModelSky: PsfCModelSkyPlot
atools.shapeSizeDetRadiusVsCmodelMag: SizeMagnitudePlot
atools.shapeSizeDetRadiusVsCmodelMag.size_type: "determinantRadius"
atools.shapeSizeDetRadiusVsCmodelMag.mag_x: "cmodel_err"
Expand Down
57 changes: 47 additions & 10 deletions python/lsst/analysis/tools/atools/photometry.py
Expand Up @@ -20,13 +20,15 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from __future__ import annotations

__all__ = ("Ap12PsfSkyPlot", "PsfCModelSkyPlot", "PsfApRatio")
__all__ = ("Ap12PsfSkyPlot", "PsfCModelSkyPlot", "PsfCModelScatterPlot", "PsfApRatio")

from ..actions.plot.histPlot import HistPanel, HistPlot
from ..actions.plot.scatterplotWithTwoHists import ScatterPlotStatsAction, ScatterPlotWithTwoHists
from ..actions.plot.skyPlot import SkyPlot
from ..actions.scalar.scalarActions import MeanAction, MedianAction, SigmaMadAction
from ..actions.vector import (
CoaddPlotFlagSelector,
ConvertFluxToMag,
DivideVector,
ExtinctionCorrectedMagDiff,
LoadVector,
Expand Down Expand Up @@ -117,15 +119,6 @@ def setDefaults(self):
self.process.buildActions.zStars.col1 = "{band}_psfFlux"
self.process.buildActions.zStars.col2 = "{band}_cModelFlux"

self.process.calculateActions.median = MedianAction()
self.process.calculateActions.median.vectorKey = "zStars"

self.process.calculateActions.mean = MeanAction()
self.process.calculateActions.mean.vectorKey = "zStars"

self.process.calculateActions.sigmaMad = SigmaMadAction()
self.process.calculateActions.sigmaMad.vectorKey = "zStars"

self.produce.plot = SkyPlot()
self.produce.plot.plotTypes = ["stars"]
self.produce.plot.plotName = "{band}_psf-cModel"
Expand All @@ -134,6 +127,50 @@ def setDefaults(self):
self.produce.plot.zAxisLabel = "PSF - cModel [mmag]"
self.produce.plot.plotOutlines = False


class PsfCModelScatterPlot(AnalysisTool):
"""Creates a scatterPlot showing the difference between
PSF and CModel mags"""

def setDefaults(self):
super().setDefaults()
self.prep.selectors.flagSelector = CoaddPlotFlagSelector()
self.prep.selectors.flagSelector.bands = []

self.prep.selectors.snSelector = SnSelector()
self.prep.selectors.snSelector.fluxType = "{band}_psfFlux"
self.prep.selectors.snSelector.threshold = 300

self.prep.selectors.starSelector = StarSelector()
self.prep.selectors.starSelector.vectorKey = "{band}_extendedness"

self.process.buildActions.xStars = ConvertFluxToMag()
self.process.buildActions.xStars.vectorKey = "{band}_psfFlux"
self.process.buildActions.yStars = MagDiff()
self.process.buildActions.yStars.col1 = "{band}_psfFlux"
self.process.buildActions.yStars.col2 = "{band}_cModelFlux"
self.process.buildActions.patch = LoadVector(vectorKey="patch")

self.process.calculateActions.stars = ScatterPlotStatsAction(vectorKey="yStars")
self.process.calculateActions.stars.lowSNSelector.fluxType = "{band}_psfFlux"
self.process.calculateActions.stars.highSNSelector.fluxType = "{band}_psfFlux"
self.process.calculateActions.stars.fluxType = "{band}_psfFlux"

self.process.calculateActions.median = MedianAction()
self.process.calculateActions.median.vectorKey = "yStars"

self.process.calculateActions.mean = MeanAction()
self.process.calculateActions.mean.vectorKey = "yStars"

self.process.calculateActions.sigmaMad = SigmaMadAction()
self.process.calculateActions.sigmaMad.vectorKey = "yStars"

self.produce.plot = ScatterPlotWithTwoHists()
self.produce.plot.plotTypes = ["stars"]
self.produce.plot.xAxisLabel = "PSF Magnitude (Mag)"
self.produce.plot.yAxisLabel = "PSF - cModel [mmag]"
self.produce.plot.magLabel = "PSF Magnitude (mag)"

self.produce.metric.units = {"median": "mmag", "sigmaMad": "mmag", "mean": "mmag"}

self.produce.metric.newNames = {
Expand Down