Coverage for python/lsst/analysis/tools/atools/limitingMagnitudeMetric.py: 38%

26 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-13 10:07 +0000

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/>. 

21from __future__ import annotations 

22 

23__all__ = ("FiveSigmaPointSourceDepthMetric",) 

24 

25from ..actions.scalar.scalarActions import MeanAction, MedianAction 

26from ..actions.vector.selectors import SnSelector, StarSelector 

27from ..actions.vector.vectorActions import ConvertFluxToMag 

28from ..interfaces import AnalysisTool 

29 

30 

31class FiveSigmaPointSourceDepthMetric(AnalysisTool): 

32 """Calculate the five-sigma point source depth of a visit, based on the 

33 PSF flux and its reported error. By default the calculation selects 

34 objects between 4.75 < S/N < 5.25, but these limits are configurable. 

35 The flux type to use for selection is also configurable. Both the median 

36 and mean 5-sigma depths are returned. 

37 """ 

38 

39 def coaddContext(self) -> None: 

40 

41 self.prep.selectors.starSelector.vectorKey = "{band}_extendedness" 

42 self.prep.selectors.snSelector.fluxType = "{band}_psfFlux" 

43 self.process.buildActions.mags = ConvertFluxToMag(vectorKey="{band}_psfFlux") 

44 

45 self.produce.metric.newNames = { 

46 "median5sigmaDepth": "{band}_median5sigmaDepth", 

47 "mean5sigmaDepth": "{band}_mean5sigmaDepth", 

48 } 

49 

50 def visitContext(self) -> None: 

51 self.parameterizedBand = False 

52 self.prep.selectors.starSelector.vectorKey = "extendedness" 

53 self.prep.selectors.snSelector.fluxType = "psfFlux" 

54 self.process.buildActions.mags = ConvertFluxToMag(vectorKey="psfFlux") 

55 

56 def setDefaults(self): 

57 super().setDefaults() 

58 

59 self.prep.selectors.starSelector = StarSelector() 

60 

61 self.prep.selectors.snSelector = SnSelector() 

62 # Select between 4.75 < SNR < 5.25 to get a decent sample: 

63 self.prep.selectors.snSelector.threshold = 4.75 

64 self.prep.selectors.snSelector.maxSN = 5.25 

65 

66 self.process.calculateActions.median5sigmaDepth = MedianAction(vectorKey="mags") 

67 self.process.calculateActions.mean5sigmaDepth = MeanAction(vectorKey="mags") 

68 

69 self.produce.metric.units = { # type: ignore 

70 "median5sigmaDepth": "mag", 

71 "mean5sigmaDepth": "mag", 

72 }