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

53 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-23 04:03 -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__ = ("Ap12PsfSkyPlot", "PsfApRatio") 

24 

25from ..actions.plot.histPlot import HistPanel, HistPlot 

26from ..actions.plot.skyPlot import SkyPlot 

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

28from ..actions.vector import ( 

29 CoaddPlotFlagSelector, 

30 DivideVector, 

31 ExtinctionCorrectedMagDiff, 

32 LoadVector, 

33 SnSelector, 

34 StarSelector, 

35) 

36from ..interfaces import AnalysisTool 

37 

38 

39class Ap12PsfSkyPlot(AnalysisTool): 

40 def setDefaults(self): 

41 super().setDefaults() 

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

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

44 # the plot is being made in. 

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

46 

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

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

49 self.prep.selectors.snSelector.threshold = 300 

50 

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

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

53 

54 # TODO: Can we make these defaults somewhere? 

55 self.process.buildActions.xStars = LoadVector() 

56 self.process.buildActions.xStars.vectorKey = "coord_ra" 

57 self.process.buildActions.yStars = LoadVector() 

58 self.process.buildActions.yStars.vectorKey = "coord_dec" 

59 self.process.buildActions.starStatMask = SnSelector() 

60 self.process.buildActions.starStatMask.fluxType = "{band}_psfFlux" 

61 

62 self.process.buildActions.zStars = ExtinctionCorrectedMagDiff() 

63 self.process.buildActions.zStars.magDiff.col1 = "{band}_ap12Flux" 

64 self.process.buildActions.zStars.magDiff.col2 = "{band}_psfFlux" 

65 

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

67 self.process.calculateActions.median.vectorKey = "zStars" 

68 

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

70 self.process.calculateActions.mean.vectorKey = "zStars" 

71 

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

73 self.process.calculateActions.sigmaMad.vectorKey = "zStars" 

74 

75 self.produce.plot = SkyPlot() 

76 self.produce.plot.plotTypes = ["stars"] 

77 self.produce.plot.plotName = "{band}_ap12-psf" 

78 self.produce.plot.xAxisLabel = "R.A. (degrees)" 

79 self.produce.plot.yAxisLabel = "Dec. (degrees)" 

80 self.produce.plot.zAxisLabel = "Ap 12 - PSF [mag]" 

81 self.produce.plot.plotOutlines = False 

82 

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

84 

85 self.produce.metric.newNames = { 

86 "median": "{band}_ap12-psf_median", 

87 "mean": "{band}_ap12-psf_mean", 

88 "sigmaMad": "{band}_ap12-psf_sigmaMad", 

89 } 

90 

91 

92class PsfApRatio(AnalysisTool): 

93 """Base class for plots or metrics which use PSF/Aperture Ratios.""" 

94 

95 def setDefaults(self): 

96 super().setDefaults() 

97 self.process.buildActions.loadVectorPsf = LoadVector() 

98 self.process.buildActions.loadVectorAp = LoadVector() 

99 

100 # assign keys for PSF and AP Flux 

101 self.process.buildActions.loadVectorPsf.vectorKey = "psFlux" 

102 self.process.buildActions.loadVectorAp.vectorKey = "apFlux" 

103 

104 self.process.calculateActions.fluxRatio = DivideVector( 

105 actionA=self.process.buildActions.loadVectorPsf, actionB=self.process.buildActions.loadVectorAp 

106 ) 

107 

108 self.produce.plot = HistPlot() 

109 

110 self.produce.panels["panel_flux"] = HistPanel() 

111 self.produce.panels["panel_flux"].label = "Psf/Ap Ratio" 

112 self.produce.panels["panel_flux"].hists = dict(fluxRatioMetric="Ratio")