Coverage for python / lsst / analysis / tools / atools / columnMagnitudeScatterPlot.py: 46%
49 statements
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-16 01:15 -0700
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-16 01:15 -0700
1# This file is part of analysis_tools.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22from __future__ import annotations
24__all__ = ("ColumnMagnitudeScatterPlot",)
26import logging
28from deprecated.sphinx import deprecated
30from lsst.pex.config import Field
32from ..actions.vector import DownselectVector, LoadVector, Log10Vector
33from ..actions.vector.selectors import CoaddPlotFlagSelector, VectorSelector, VisitPlotFlagSelector
34from .genericProduce import MagnitudeScatterPlot
36logging.basicConfig()
37_LOG = logging.getLogger(__name__)
38_LOG.setLevel(logging.WARNING)
41class ColumnMagnitudeScatterPlot(MagnitudeScatterPlot):
42 """A MagnitudeScatterPlot with a single column value on the y axis."""
44 _parameterizedBand: bool = True
46 # TODO: Remove the getter and setting in DM-54864.
47 # Instead, just convert _parameterizedBand to parameterizedBand.
48 @property
49 def parameterizedBand(self) -> bool:
50 return self._parameterizedBand
52 @parameterizedBand.setter
53 def parameterizedBand(self, value: bool) -> None:
54 _LOG.info(
55 "Setting 'parameterizedBand' of a `ColumnMagnitudeScatterPlot' is a no-op. "
56 "If you see this message, it is likely because you are trying "
57 "to read older version of configs with newer versions of the "
58 "LSST Science Pipelines."
59 )
61 # TODO: Remove the getter and setter in DM-54864.
62 @property
63 @deprecated(reason="This is no longer used.", version="v31")
64 def extendedness(self) -> None:
65 """A config-like attribute for backward compatibility.
67 This does not do anything but enable reading old configs.
68 """
70 @extendedness.setter
71 def extendedness(self, value: str) -> None:
72 _LOG.info(
73 "Setting 'extendedness' of a `ColumnMagnitudeScatterPlot' is a no-op. "
74 "If you see this message, it is likely because you are trying "
75 "to read older version of configs with newer versions of the "
76 "LSST Science Pipelines."
77 )
79 key_y = Field[str](default=None, doc="Key of column to plot on the y axis")
80 log10_y = Field[bool](default=False, doc="Whether to plot log10 of the values on the y axis")
82 def coaddContext(self) -> None:
83 self.prep.selectors.flagSelector = CoaddPlotFlagSelector()
84 self.prep.selectors.flagSelector.bands = []
86 def visitContext(self) -> None:
87 self.prep.selectors.flagSelector = VisitPlotFlagSelector()
89 def finalize(self):
90 # A lazy check for whether finalize has already been called
91 classes = self.get_classes()
92 if hasattr(self.process.filterActions, self.get_name_attr_values(classes[0])):
93 return
94 super().finalize()
95 if not self.key_y:
96 raise ValueError("Must specify key to plot on y axis")
98 action = LoadVector(vectorKey=self.key_y)
99 if self.log10_y:
100 action = Log10Vector(action=action)
102 attr_column = f"get_{self.key_y}"
103 setattr(self.process.buildActions, attr_column, action)
105 classes = self.get_classes()
106 for object_class in classes:
107 setattr(
108 self.process.filterActions,
109 self.get_name_attr_values(object_class),
110 DownselectVector(
111 vectorKey=attr_column,
112 selector=VectorSelector(vectorKey=self.get_name_attr_selector(object_class)),
113 ),
114 )
116 if not self.produce.plot.yAxisLabel:
117 self.produce.plot.yAxisLabel = f"log10({self.key_y})" if self.log10_y else self.key_y