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

44 statements  

« prev     ^ index     » next       coverage.py v7.2.5, created at 2023-05-05 04:41 -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.vector import ( 

28 CoaddPlotFlagSelector, 

29 DivideVector, 

30 ExtinctionCorrectedMagDiff, 

31 LoadVector, 

32 SnSelector, 

33 StarSelector, 

34) 

35from ..interfaces import AnalysisTool 

36 

37 

38class Ap12PsfSkyPlot(AnalysisTool): 

39 def setDefaults(self): 

40 super().setDefaults() 

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

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

43 # the plot is being made in. 

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

45 

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

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

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

49 

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

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

52 

53 # TODO: Can we make these defaults somewhere? 

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

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

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

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

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

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

60 

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

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

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

64 

65 self.produce.plot = SkyPlot() 

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

67 self.produce.plot.plotName = "ap12-psf_{band}" 

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

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

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

71 self.produce.plot.plotOutlines = False 

72 

73 

74class PsfApRatio(AnalysisTool): 

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

76 

77 def setDefaults(self): 

78 super().setDefaults() 

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

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

81 

82 # assign keys for PSF and AP Flux 

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

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

85 

86 self.process.calculateActions.fluxRatio = DivideVector( 

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

88 ) 

89 

90 self.produce.plot = HistPlot() 

91 

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

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

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