Skip to content

Commit

Permalink
Merge branch 'tickets/DM-39004'
Browse files Browse the repository at this point in the history
  • Loading branch information
leeskelvin committed May 3, 2023
2 parents d9d683f + d7c555b commit 38c477b
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 18 deletions.
2 changes: 2 additions & 0 deletions python/lsst/analysis/tools/actions/plot/barPlots.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@


class BarPanel(Config):
"""A configurable class describing a panel in a bar plot."""

label = Field[str](
doc="Panel x-axis label.",
default="label",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@


class MultiVisitCoveragePlot(PlotAction):
"""Plot the coverage for a set of visits."""

plotName = Field[str](
doc="The name for the plot.",
optional=False,
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/analysis/tools/actions/scalar/scalarActions.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __call__(self, data: KeyedData, **kwargs) -> Scalar:


class CountAction(ScalarAction):
"""Returns the number of non nan entries in the given column,"""
"""Returns the number of non-NaN entries in the given column."""

vectorKey = Field[str]("Key of Vector to count")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def validate(self):


class CalcRhoStatistics(KeyedDataAction):
r"""Calculate rho statistics
r"""Calculate rho statistics.
Rho statistics refer to a collection of correlation functions involving
PSF ellipticity and size residuals. They quantify the contribution from PSF
Expand Down
10 changes: 5 additions & 5 deletions python/lsst/analysis/tools/actions/vector/selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _addValueToPlotInfo(self, value, **kwargs):


class FlagSelector(VectorAction):
"""The base flag selector to use to select valid sources for QA"""
"""The base flag selector to use to select valid sources for QA."""

selectWhenFalse = ListField[str](
doc="Names of the flag columns to select on when False", optional=False, default=[]
Expand Down Expand Up @@ -213,7 +213,7 @@ def __call__(self, data: KeyedData, **kwargs) -> Vector:


class SnSelector(SelectorBase):
"""Selects points that have S/N > threshold in the given flux type"""
"""Selects points that have S/N > threshold in the given flux type."""

fluxType = Field[str](doc="Flux type to calculate the S/N in.", default="{band}_psfFlux")
threshold = Field[float](doc="The S/N threshold to remove sources with.", default=500.0)
Expand Down Expand Up @@ -272,7 +272,7 @@ def __call__(self, data: KeyedData, **kwargs) -> Vector:


class SkyObjectSelector(FlagSelector):
"""Selects sky objects in the given band(s)"""
"""Selects sky objects in the given band(s)."""

bands = ListField[str](
doc="The bands to apply the flags in, takes precedence if band supplied in kwargs",
Expand Down Expand Up @@ -310,7 +310,7 @@ def setDefaults(self):


class SkySourceSelector(FlagSelector):
"""Selects sky sources from sourceTables"""
"""Selects sky sources from sourceTables."""

def getInputSchema(self) -> KeyedDataSchema:
yield from super().getInputSchema()
Expand All @@ -332,7 +332,7 @@ def setDefaults(self):


class GoodDiaSourceSelector(FlagSelector):
"""Selects good DIA sources from diaSourceTables"""
"""Selects good DIA sources from diaSourceTables."""

def getInputSchema(self) -> KeyedDataSchema:
yield from super().getInputSchema()
Expand Down
10 changes: 5 additions & 5 deletions python/lsst/analysis/tools/actions/vector/vectorActions.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def __call__(self, data: KeyedData, **kwargs) -> Vector:


class FractionalDifference(VectorAction):
"""Calculate (A-B)/B"""
"""Calculate (A-B)/B."""

actionA = ConfigurableActionField[VectorAction](doc="Action which supplies vector A")
actionB = ConfigurableActionField[VectorAction](doc="Action which supplies vector B")
Expand All @@ -136,7 +136,7 @@ def __call__(self, data: KeyedData, **kwargs) -> Vector:


class Sn(VectorAction):
"""Compute signal-to-noise in the given flux type"""
"""Compute signal-to-noise in the given flux type."""

fluxType = Field[str](doc="Flux type to calculate the S/N in.", default="{band}_psfFlux")
uncertaintySuffix = Field[str](
Expand Down Expand Up @@ -168,7 +168,7 @@ def __call__(self, data: KeyedData, **kwargs) -> Vector:


class ConstantValue(VectorAction):
"""Return a constant scalar value"""
"""Return a constant scalar value."""

value = Field[float](doc="A single constant value", optional=False)

Expand All @@ -180,7 +180,7 @@ def __call__(self, data: KeyedData, **kwargs) -> Vector:


class SubtractVector(VectorAction):
"""Calculate (A-B)"""
"""Calculate (A-B)."""

actionA = ConfigurableActionField[VectorAction](doc="Action which supplies vector A")
actionB = ConfigurableActionField[VectorAction](doc="Action which supplies vector B")
Expand Down Expand Up @@ -212,7 +212,7 @@ def __call__(self, data: KeyedData, **kwargs) -> Vector:


class LoadVector(VectorAction):
"""Load and return a Vector from KeyedData"""
"""Load and return a Vector from KeyedData."""

vectorKey = Field[str](doc="Key of vector which should be loaded")

Expand Down
6 changes: 6 additions & 0 deletions python/lsst/analysis/tools/atools/coveragePlots.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@


class BaseMultiVisitCoveragePlot(AnalysisTool):
"""Base class for multi-visit coverage plots."""

parameterizedBand: bool = False

def setDefaults(self):
Expand All @@ -46,13 +48,17 @@ def updateLoadList(self):


class FocalPlaneMultiVisitCoveragePlot(BaseMultiVisitCoveragePlot):
"""Multi-visit coverage plot in focal plane coordinates."""

def setDefaults(self):
super().setDefaults()
self.produce.plot.projection = "focalPlane"
self.produce.plot.plotName = "focalPlaneMultiVisitCoverage"


class RaDecMultiVisitCoveragePlot(BaseMultiVisitCoveragePlot):
"""Multi-visit coverage plot in RA/Dec coordinates."""

def setDefaults(self):
super().setDefaults()
self.produce.plot.plotName = "raDecMultiVisitCoverage"
6 changes: 5 additions & 1 deletion python/lsst/analysis/tools/interfaces/_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,17 @@ class NoMetric(MetricAction):

@dataclass
class JointResults:
"""The `JointResults` dataclass is a container for the results of a
`JointAction`.
"""

plot: PlotResultType | None
metric: MetricResultType | None


class JointAction(AnalysisAction):
"""A `JointAction` is an `AnalysisAction` that is a composite of a
`PlotAction` and a `MetricAction`
`PlotAction` and a `MetricAction`.
"""

metric = ConfigurableActionField[MetricAction](doc="Action to run that will produce one or more metrics")
Expand Down
9 changes: 5 additions & 4 deletions python/lsst/analysis/tools/interfaces/_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __init__(self) -> None:


ScalarType = type[Scalar]
"""A type alias for the Scalar interface."""

Vector = NDArray
"""A Vector is an abstraction around the NDArray interface, things that 'quack'
Expand All @@ -88,14 +89,14 @@ def __init__(self) -> None:
"""

PlotTypes = Figure
"""An interface that represents the various plot types analysis tools supports
"""An interface that represents the various plot types analysis tools supports.
"""

KeyedResults = Mapping[str, PlotTypes | Measurement]
"""A mapping of the return types for an analysisTool
"""
"""A mapping of the return types for an analysisTool."""

MetricResultType: TypeAlias = Mapping[str, Measurement] | Measurement

"""A type alias for the return type of a MetricAction."""

PlotResultType: TypeAlias = Mapping[str, PlotTypes] | PlotTypes
"""A type alias for the return type of a PlotAction."""
8 changes: 8 additions & 0 deletions python/lsst/analysis/tools/interfaces/_stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@


class BasePrep(KeyedDataAction):
"""Base class for actions which prepare data for processing."""

vectorKeys = ListField[str](doc="Keys to extract from KeyedData and return", default=[])

selectors = ConfigurableActionStructField[VectorAction](
Expand Down Expand Up @@ -80,6 +82,8 @@ def addInputSchema(self, inputSchema: KeyedDataSchema) -> None:


class BaseProcess(KeyedDataAction):
"""Base class for actions which process data."""

buildActions = ConfigurableActionStructField[VectorAction | KeyedDataAction](
doc="Actions which compute a Vector which will be added to results"
)
Expand Down Expand Up @@ -158,6 +162,8 @@ def __call__(self, data: KeyedData, **kwargs) -> KeyedData:


class BaseMetricAction(MetricAction):
"""Base class for actions which compute metrics."""

units = DictField[str, str](doc="Mapping of scalar key to astropy unit string", default={})
newNames = DictField[str, str](
doc="Mapping of key to new name if needed prior to creating metric",
Expand Down Expand Up @@ -185,6 +191,8 @@ def __call__(self, data: KeyedData, **kwargs) -> MetricResultType:


class BaseProduce(JointAction):
"""Base class for actions which produce data."""

def setDefaults(self):
super().setDefaults()
self.metric = BaseMetricAction()
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/analysis/tools/interfaces/_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def __init__(self, *, config: AnalysisBaseConfig = None): # type: ignore


class AnalysisBaseConfig(PipelineTaskConfig, pipelineConnections=AnalysisBaseConnections):
"""Base class for all configs used to define an `AnalysisPipelineTask`
"""Base class for all configs used to define an `AnalysisPipelineTask`.
This base class defines two fields that should be used in all subclasses,
atools, and bands.
Expand Down

0 comments on commit 38c477b

Please sign in to comment.