Skip to content

Commit 5022aff

Browse files
authored
Merge pull request #136 from lsst/tickets/DM-38974
DM-38974: Move photometric repeatability metrics from faro to analysis_tools
2 parents a493cff + 7f4b1b1 commit 5022aff

File tree

8 files changed

+66
-14
lines changed

8 files changed

+66
-14
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repos:
1313
# supported by your project here, or alternatively use
1414
# pre-commit's default_language_version, see
1515
# https://pre-commit.com/#top_level-default_language_version
16-
language_version: "python3.10"
16+
language_version: "python3.11"
1717
- repo: https://github.com/pycqa/isort
1818
rev: 5.12.0
1919
hooks:

pipelines/matchedVisitQualityCore.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,53 @@ tasks:
2323
atools.stellarAstrometricRepeatability3.process.calculateActions.rms.threshAD: 30
2424
python: |
2525
from lsst.analysis.tools.atools import *
26+
analyzeMatchedVisitExtended:
27+
class: lsst.analysis.tools.tasks.AssociatedSourcesTractAnalysisTask
28+
config:
29+
connections.outputName: matchedVisitExtended
30+
atools.modelPhotRepStarSn5to10: StellarPhotometricRepeatability
31+
atools.modelPhotRepStarSn5to10.fluxType: gaussianFlux
32+
atools.modelPhotRepStarSn5to10.process.filterActions.perGroupStdevFiltered.selectors.sn.minimum: 5
33+
atools.modelPhotRepStarSn5to10.process.filterActions.perGroupStdevFiltered.selectors.sn.maximum: 10
34+
atools.modelPhotRepStarSn5to10.produce.plot: NoPlot
35+
36+
atools.modelPhotRepStarSn10to20: StellarPhotometricRepeatability
37+
atools.modelPhotRepStarSn10to20.fluxType: gaussianFlux
38+
atools.modelPhotRepStarSn10to20.process.filterActions.perGroupStdevFiltered.selectors.sn.minimum: 10
39+
atools.modelPhotRepStarSn10to20.process.filterActions.perGroupStdevFiltered.selectors.sn.maximum: 20
40+
atools.modelPhotRepStarSn10to20.produce.plot: NoPlot
41+
42+
atools.modelPhotRepStarSn20to40: StellarPhotometricRepeatability
43+
atools.modelPhotRepStarSn20to40.fluxType: gaussianFlux
44+
atools.modelPhotRepStarSn20to40.process.filterActions.perGroupStdevFiltered.selectors.sn.minimum: 20
45+
atools.modelPhotRepStarSn20to40.process.filterActions.perGroupStdevFiltered.selectors.sn.maximum: 40
46+
atools.modelPhotRepStarSn20to40.produce.plot: NoPlot
47+
48+
atools.modelPhotRepStarSn40to80: StellarPhotometricRepeatability
49+
atools.modelPhotRepStarSn40to80.fluxType: gaussianFlux
50+
atools.modelPhotRepStarSn40to80.process.filterActions.perGroupStdevFiltered.selectors.sn.minimum: 40
51+
atools.modelPhotRepStarSn40to80.process.filterActions.perGroupStdevFiltered.selectors.sn.maximum: 80
52+
atools.modelPhotRepStarSn40to80.produce.plot: NoPlot
53+
54+
atools.psfPhotRepStarSn5to10: StellarPhotometricRepeatability
55+
atools.psfPhotRepStarSn5to10.process.filterActions.perGroupStdevFiltered.selectors.sn.minimum: 5
56+
atools.psfPhotRepStarSn5to10.process.filterActions.perGroupStdevFiltered.selectors.sn.maximum: 10
57+
atools.psfPhotRepStarSn5to10.produce.plot: NoPlot
58+
59+
atools.psfPhotRepStarSn10to20: StellarPhotometricRepeatability
60+
atools.psfPhotRepStarSn10to20.process.filterActions.perGroupStdevFiltered.selectors.sn.minimum: 10
61+
atools.psfPhotRepStarSn10to20.process.filterActions.perGroupStdevFiltered.selectors.sn.maximum: 20
62+
atools.psfPhotRepStarSn10to20.produce.plot: NoPlot
63+
64+
atools.psfPhotRepStarSn20to40: StellarPhotometricRepeatability
65+
atools.psfPhotRepStarSn20to40.process.filterActions.perGroupStdevFiltered.selectors.sn.minimum: 20
66+
atools.psfPhotRepStarSn20to40.process.filterActions.perGroupStdevFiltered.selectors.sn.maximum: 40
67+
atools.psfPhotRepStarSn20to40.produce.plot: NoPlot
68+
69+
atools.psfPhotRepStarSn40to80: StellarPhotometricRepeatability
70+
atools.psfPhotRepStarSn40to80.process.filterActions.perGroupStdevFiltered.selectors.sn.minimum: 40
71+
atools.psfPhotRepStarSn40to80.process.filterActions.perGroupStdevFiltered.selectors.sn.maximum: 80
72+
atools.psfPhotRepStarSn40to80.produce.plot: NoPlot
73+
python: |
74+
from lsst.analysis.tools.atools import *
75+
from lsst.analysis.tools.interfaces import *

python/lsst/analysis/tools/actions/vector/calcBinnedStats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def __call__(self, data: KeyedData, **kwargs) -> KeyedData:
105105
for name, value in action(data, **kwargs).items():
106106
results[getattr(self, f"name_{name}").format(**kwargs_format)] = value
107107

108-
values = cast(Vector, data[self.selector_range.key][mask]) # type: ignore
108+
values = cast(Vector, data[self.selector_range.vectorKey][mask]) # type: ignore
109109
valid = np.sum(np.isfinite(values)) > 0
110110

111111
results[self.name_select_maximum.format(**kwargs_format)] = cast(

python/lsst/analysis/tools/actions/vector/selectors.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ def setDefaults(self):
187187
class RangeSelector(VectorAction):
188188
"""Selects rows within a range, inclusive of min/exclusive of max."""
189189

190-
key = Field[str](doc="Key to select from data")
190+
vectorKey = Field[str](doc="Key to select from data")
191191
maximum = Field[float](doc="The maximum value", default=np.Inf)
192192
minimum = Field[float](doc="The minimum value", default=np.nextafter(-np.Inf, 0.0))
193193

194194
def getInputSchema(self) -> KeyedDataSchema:
195-
yield self.key, Vector
195+
yield self.vectorKey, Vector
196196

197197
def __call__(self, data: KeyedData, **kwargs) -> Vector:
198198
"""Return a mask of rows with values within the specified range.
@@ -206,10 +206,10 @@ def __call__(self, data: KeyedData, **kwargs) -> Vector:
206206
result : `Vector`
207207
A mask of the rows with values within the specified range.
208208
"""
209-
values = cast(Vector, data[self.key])
209+
values = cast(Vector, data[self.vectorKey])
210210
mask = (values >= self.minimum) & (values < self.maximum)
211211

212-
return np.array(mask)
212+
return cast(Vector, mask)
213213

214214

215215
class SnSelector(SelectorBase):

python/lsst/analysis/tools/atools/astrometricRepeatability.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ def setDefaults(self):
231231

232232
# Select only sources with magnitude between 17 and 21.5
233233
self.process.filterActions.coord_ra = DownselectVector(vectorKey="coord_ra")
234-
self.process.filterActions.coord_ra.selector = RangeSelector(key="mags", minimum=17, maximum=21.5)
234+
self.process.filterActions.coord_ra.selector = RangeSelector(
235+
vectorKey="mags", minimum=17, maximum=21.5
236+
)
235237
self.process.filterActions.coord_dec = DownselectVector(
236238
vectorKey="coord_dec", selector=self.process.filterActions.coord_ra.selector
237239
)

python/lsst/analysis/tools/atools/diffMatched.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def configureMetrics(
146146
for minimum in range(self._mag_low_min, self._mag_low_max + 1):
147147
action = getattr(self.process.calculateActions, f"{name}{minimum}")
148148
action.selector_range = RangeSelector(
149-
key=x_key,
149+
vectorKey=x_key,
150150
minimum=minimum,
151151
maximum=minimum + self._mag_interval,
152152
)
@@ -180,7 +180,7 @@ def setDefaults(self):
180180
CalcBinnedStatsAction(
181181
key_vector=key,
182182
selector_range=RangeSelector(
183-
key=key,
183+
vectorKey=key,
184184
minimum=minimum,
185185
maximum=minimum + self._mag_interval,
186186
),

python/lsst/analysis/tools/atools/photometricRepeatability.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
LoadVector,
3737
MultiCriteriaDownselectVector,
3838
PerGroupStatistic,
39+
RangeSelector,
3940
ResidualWithPerGroupStatistic,
4041
SnSelector,
4142
ThresholdSelector,
@@ -93,10 +94,9 @@ def setDefaults(self):
9394
op="ge",
9495
threshold=3,
9596
)
96-
self.process.filterActions.perGroupStdevFiltered.selectors.sn = ThresholdSelector(
97+
self.process.filterActions.perGroupStdevFiltered.selectors.sn = RangeSelector(
9798
vectorKey="perGroupSn",
98-
op="ge",
99-
threshold=200,
99+
minimum=200,
100100
)
101101
self.process.filterActions.perGroupStdevFiltered.selectors.extendedness = ThresholdSelector(
102102
vectorKey="perGroupExtendedness",

tests/test_actions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def _checkSchema(self, action, truth):
145145
# VectorActions with their own files
146146

147147
def testCalcBinnedStats(self):
148-
selector = RangeSelector(key="r_vector", minimum=0, maximum=self.size)
148+
selector = RangeSelector(vectorKey="r_vector", minimum=0, maximum=self.size)
149149
prefix = "a_"
150150
stats = CalcBinnedStatsAction(name_prefix=prefix, selector_range=selector, key_vector="r_vector")
151151
result = stats(self.data)
@@ -489,7 +489,7 @@ def testCoaddPlotFlagSelector(self):
489489
np.testing.assert_array_equal(result, truth)
490490

491491
def testRangeSelector(self):
492-
selector = RangeSelector(key="r_psfFlux", minimum=np.nextafter(20, 30), maximum=50)
492+
selector = RangeSelector(vectorKey="r_psfFlux", minimum=np.nextafter(20, 30), maximum=50)
493493
self._checkSchema(selector, ["r_psfFlux"])
494494
result = self.data["r_psfFlux"][selector(self.data)]
495495
truth = [30, 40]

0 commit comments

Comments
 (0)