Coverage for python/lsst/pipe/tasks/multiBandUtils.py: 68%

15 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2022-09-30 10:43 +0000

1# This file is part of pipe_tasks. 

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/>. 

21 

22__all__ = ["CullPeaksConfig"] 

23 

24import lsst.afw.table as afwTable 

25 

26from lsst.pex.config import Config, RangeField 

27 

28 

29def _makeGetSchemaCatalogs(datasetSuffix): 

30 """Construct a getSchemaCatalogs instance method 

31 

32 These are identical for most of the classes here, so we'll consolidate 

33 the code. 

34 

35 datasetSuffix: Suffix of dataset name, e.g., "src" for "deepCoadd_src" 

36 """ 

37 

38 def getSchemaCatalogs(self): 

39 """Return a dict of empty catalogs for each catalog dataset produced by this task.""" 

40 src = afwTable.SourceCatalog(self.schema) 

41 if hasattr(self, "algMetadata"): 

42 src.getTable().setMetadata(self.algMetadata) 

43 return {self.config.coaddName + "Coadd_" + datasetSuffix: src} 

44 return getSchemaCatalogs 

45 

46 

47class CullPeaksConfig(Config): 

48 """Configuration for culling garbage peaks after merging footprints. 

49 

50 Peaks may also be culled after detection or during deblending; this configuration object 

51 only deals with culling after merging Footprints. 

52 

53 These cuts are based on three quantities: 

54 - nBands: the number of bands in which the peak was detected 

55 - peakRank: the position of the peak within its family, sorted from brightest to faintest. 

56 - peakRankNormalized: the peak rank divided by the total number of peaks in the family. 

57 

58 The formula that identifie peaks to cull is: 

59 

60 nBands < nBandsSufficient 

61 AND (rank >= rankSufficient) 

62 AND (rank >= rankConsider OR rank >= rankNormalizedConsider) 

63 

64 To disable peak culling, simply set nBandsSufficient=1. 

65 """ 

66 nBandsSufficient = RangeField(dtype=int, default=2, min=1, 

67 doc="Always keep peaks detected in this many bands") 

68 rankSufficient = RangeField(dtype=int, default=20, min=1, 

69 doc="Always keep this many peaks in each family") 

70 rankConsidered = RangeField(dtype=int, default=30, min=1, 

71 doc=("Keep peaks with less than this rank that also match the " 

72 "rankNormalizedConsidered condition.")) 

73 rankNormalizedConsidered = RangeField(dtype=float, default=0.7, min=0.0, 

74 doc=("Keep peaks with less than this normalized rank that" 

75 " also match the rankConsidered condition."))