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

U/sullivan/demo pipeline #35

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pipelines/demoPipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
description: |
Test pipeline
tasks:
demoMetric1:
class: lsst.analysis.tools.tasks.DemoTask
config:
connections.outputName: demoOutput
bands: ['g']
metrics.demoMetric: DemoMetric
plots.demoPlot: DemoPlot
python: |
from lsst.analysis.tools.analysisMetrics import *
from lsst.analysis.tools.analysisPlots import *
1 change: 1 addition & 0 deletions python/lsst/analysis/tools/analysisMetrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@
from .photometricRepeatabilityMetrics import *
from .psfResidualMetrics import *
from .skyFluxStatisticMetrics import *
from .demoMetric import *
36 changes: 36 additions & 0 deletions python/lsst/analysis/tools/analysisMetrics/demoMetric.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

__all__ = (
"DemoMetric",
)


from ..interfaces import AnalysisMetric
from lsst.analysis.tools.actions.scalar import MedianAction
from lsst.analysis.tools.actions.vector import SnSelector


class DemoMetric(AnalysisMetric):
def setDefaults(self):
super().setDefaults()

# select on high signal to noise obejcts
# add in a signal to noise selector
self.prep.selectors.snSelector = SnSelector()

# set what key the selector should use when deciding SNR
self.prep.selectors.snSelector.fluxType = "psFlux"

# select what threshold value is desireable for the selector
self.prep.selectors.snSelector.threshold = 10

# the final name in the qualification is used as a key to insert
# the calculation into KeyedData
self.process.calculateActions.medianValueName = MedianAction(vectorKey="psFlux")

# tell the metic what the units are for the quantity
self.produce.units = {"medianValueName": "Jy"}

# Rename the quanity prior to producing the Metric
# (useful for resuable workflows that set a name toward
# the end of computation)
self.produce.newNames = {"medianValueName": "DemoMetric"}
22 changes: 22 additions & 0 deletions python/lsst/analysis/tools/analysisParts/demoPsfApRatio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from lsst.analysis.tools.interfaces import AnalysisTool
from lsst.analysis.tools.actions.vector import LoadVector, DivideVector


class DemoPsfApRatioBaseClass(AnalysisTool):
"""Base class for scatter plots of PSF residuals.
This is shared by size and ellipticity plots.
"""

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

self.process.filterActions.loadVectorPsf.vectorKey = "psFlux"
self.process.filterActions.loadVectorAp.vectorKey = "apFlux"

# the final name in the qualification is used as a key to insert
# the calculation into KeyedData
self.process.calculateActions.fluxRatioMetric = DivideVector(
actionA=self.process.filterActions.loadVectorPsf,
actionB=self.process.filterActions.loadVectorAp)
1 change: 1 addition & 0 deletions python/lsst/analysis/tools/analysisPlots/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .analysisPlots import *
from .skyObject import *
from .demoPlot import *
14 changes: 14 additions & 0 deletions python/lsst/analysis/tools/analysisPlots/demoPlot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from lsst.analysis.tools.actions.plot.histPlot import HistPlot, HistPanel
from lsst.analysis.tools.interfaces import AnalysisPlot
from ..analysisParts.demoPsfApRatio import DemoPsfApRatioBaseClass


class DemoPlot(AnalysisPlot, DemoPsfApRatioBaseClass):
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="fluxRatioMetric")
1 change: 1 addition & 0 deletions python/lsst/analysis/tools/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
from .diaSourceTableVisitAnalysis import *
from .objectTableTractAnalysis import *
from .sourceTableVisitAnalysis import *
from .demo import *
29 changes: 29 additions & 0 deletions python/lsst/analysis/tools/tasks/demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from __future__ import annotations

from lsst.pipe.base import connectionTypes as ct

from .base import AnalysisBaseConfig, AnalysisBaseConnections, AnalysisPipelineTask


class DemoConnections(
AnalysisBaseConnections,
dimensions=("visit", "band"),
defaultTemplates={"coaddName": "deep", "fakesType": "fakes_"},
):

data = ct.Input(
doc="CcdVisit-based DiaSource table to load from the butler",
name="{fakesType}{coaddName}Diff_assocDiaSrc",
storageClass="DataFrame",
dimensions=("visit", "band", "detector"),
deferLoad=True,
)


class DemoConfig(AnalysisBaseConfig, pipelineConnections=DemoConnections):
pass


class DemoTask(AnalysisPipelineTask):
ConfigClass = DemoConfig
_DefaultName = "DemoAnalysis"