Coverage for python/lsst/analysis/tools/atools/coaddInputCount.py: 21%

43 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-10-10 02:34 -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/>. 

21from __future__ import annotations 

22 

23__all__ = ("CoaddInputCount",) 

24 

25from ..actions.plot.calculateRange import MinMax 

26from ..actions.plot.skyPlot import SkyPlot 

27from ..actions.scalar.scalarActions import MeanAction, MedianAction, SigmaMadAction 

28from ..actions.vector import CoaddPlotFlagSelector, LoadVector, SnSelector 

29from ..interfaces import AnalysisTool 

30 

31 

32class CoaddInputCount(AnalysisTool): 

33 """skyPlot and associated metrics indicating the number 

34 of exposures that have gone into creating a coadd. 

35 """ 

36 

37 def setDefaults(self): 

38 super().setDefaults() 

39 self.prep.selectors.flagSelector = CoaddPlotFlagSelector() 

40 # Set this to an empty list to look at the band 

41 # the plot is being made in. 

42 self.prep.selectors.flagSelector.bands = [] 

43 

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

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

46 self.prep.selectors.snSelector.threshold = 5 

47 

48 self.process.buildActions.x = LoadVector() 

49 self.process.buildActions.x.vectorKey = "coord_ra" 

50 self.process.buildActions.y = LoadVector() 

51 self.process.buildActions.y.vectorKey = "coord_dec" 

52 self.process.buildActions.statMask = SnSelector() 

53 self.process.buildActions.statMask.fluxType = "{band}_psfFlux" 

54 self.process.buildActions.statMask.threshold = 5 

55 

56 self.process.buildActions.z = LoadVector() 

57 self.process.buildActions.z.vectorKey = "{band}_inputCount" 

58 

59 self.process.buildActions.patch = LoadVector() 

60 self.process.buildActions.patch.vectorKey = "patch" 

61 

62 self.process.calculateActions.median = MedianAction() 

63 self.process.calculateActions.median.vectorKey = "z" 

64 

65 self.process.calculateActions.mean = MeanAction() 

66 self.process.calculateActions.mean.vectorKey = "z" 

67 

68 self.process.calculateActions.sigmaMad = SigmaMadAction() 

69 self.process.calculateActions.sigmaMad.vectorKey = "z" 

70 

71 # SkyPlot of number of contributing exposures across coadd: 

72 self.produce.plot = SkyPlot() 

73 self.produce.plot.plotTypes = ["any"] 

74 self.produce.plot.plotName = "{band}_inputCount" 

75 self.produce.plot.xAxisLabel = "R.A. (deg)" 

76 self.produce.plot.yAxisLabel = "Dec. (deg)" 

77 self.produce.plot.zAxisLabel = "Input Count" 

78 self.produce.plot.plotOutlines = True 

79 self.produce.plot.showExtremeOutliers = False 

80 self.produce.plot.colorbarRange = MinMax() 

81 

82 # Summary metrics for the whole coadd. 

83 self.produce.metric.units = {"median": "ct", "sigmaMad": "ct", "mean": "ct"} 

84 self.produce.metric.newNames = { 

85 "median": "{band}_inputCount_median", 

86 "mean": "{band}_inputCount_mean", 

87 "sigmaMad": "{band}_inputCount_sigmaMad", 

88 }