Coverage for python/lsst/analysis/tools/atools/propertyMap.py: 71%

21 statements  

« prev     ^ index     » next       coverage.py v7.5.1, created at 2024-05-10 11:04 +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__ = ("PropertyMapTool",) 

24 

25from typing import Any, Dict, Iterable, MutableMapping 

26 

27from healsparse.healSparseMap import HealSparseMap 

28from lsst.pex.config import Field 

29 

30from ..actions.plot.propertyMapPlot import PropertyMapPlot 

31from ..interfaces import AnalysisAction, AnalysisTool 

32 

33 

34class LoadHealSparseMap(AnalysisAction): 

35 """Load a selection of HealSparseMaps configured for plotting.""" 

36 

37 mapsKey = Field[str]( 

38 doc="The key used to access the dictionary of requested HealSparseMap objects to be loaded." 

39 ) 

40 

41 def getInputSchema(self) -> Iterable[tuple[str, Dict]]: 

42 return [(self.mapsKey, Dict[str, HealSparseMap])] 

43 

44 def __call__( 

45 self, data: MutableMapping[str, Dict[str, HealSparseMap]], **kwds: Any 

46 ) -> Dict[str, HealSparseMap]: 

47 return data[self.mapsKey] 

48 

49 

50class PropertyMapTool(AnalysisTool): 

51 """An `AnalysisTool` for plotting property maps.""" 

52 

53 # Make the getOutputNames() method in the plot action config-aware. 

54 dynamicOutputNames: bool = True 

55 

56 # Do not iterate over multiple bands in a parameterized manner. 

57 parameterizedBand: bool = False 

58 

59 def setDefaults(self): 

60 super().setDefaults() 

61 self.process.buildActions.data = LoadHealSparseMap() 

62 self.process.buildActions.data.mapsKey = "maps" 

63 self.produce.plot = PropertyMapPlot()