Coverage for python / lsst / analysis / tools / atools / diaObjectPlot.py: 33%

30 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-18 09:19 +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__ = ("DiaObjectPlot",) 

24 

25from ..actions.plot.calculateRange import MinMax 

26from ..actions.plot.skyPlot import SkyPlot 

27from ..actions.vector import DownselectVector, LoadVector 

28from ..actions.vector.selectors import FiniteSelector, ThresholdSelector 

29from ..interfaces import AnalysisTool 

30 

31 

32class DiaObjectPlot(AnalysisTool): 

33 """Make a plot of DiaObjects on the sky.""" 

34 

35 parameterizedBand: bool = False 

36 

37 def setDefaults(self): 

38 super().setDefaults() 

39 self.process.buildActions.x = LoadVector(vectorKey="ra") 

40 self.process.buildActions.y = LoadVector(vectorKey="dec") 

41 self.process.buildActions.z = LoadVector(vectorKey="nDiaSources") 

42 

43 # statMask is required for SkyPlot 

44 # it computes the nanMedian and nanSigmaMad for the z array, 

45 # with some selector applied 

46 self.process.buildActions.statMask = FiniteSelector(vectorKey="nDiaSources") 

47 

48 # only plot diaObjects composed of 5 or fewer diaSources 

49 self.process.filterActions.z = DownselectVector(vectorKey="z") 

50 self.process.filterActions.z.selector = ThresholdSelector( 

51 vectorKey="nDiaSources", op="le", threshold=5 

52 ) 

53 self.process.filterActions.x = DownselectVector( 

54 vectorKey="x", selector=self.process.filterActions.z.selector 

55 ) 

56 self.process.filterActions.y = DownselectVector( 

57 vectorKey="y", selector=self.process.filterActions.z.selector 

58 ) 

59 

60 self.produce.plot = SkyPlot() 

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

62 self.produce.plot.plotName = "DiaObjects with 5 or fewer DiaSources" 

63 

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

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

66 self.produce.plot.zAxisLabel = "Number of associated DiaSources" 

67 

68 self.produce.plot.colorbarRange = MinMax 

69 self.produce.plot.plotOutlines = True 

70 self.produce.plot.doBinning = False 

71 self.produce.plot.alpha = 0.2 

72 self.produce.plot.scatPtSize = 3