Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1from .baseMetric import BaseMetric 

2from .simpleMetrics import Coaddm5Metric 

3from lsst.sims.photUtils import Sed 

4 

5__all__ = ['ExgalM5', 'ExgalM5_cut'] 

6 

7class ExgalM5(BaseMetric): 

8 """ 

9 Calculate co-added five-sigma limiting depth after dust extinction. 

10 

11 Uses photUtils 

12 """ 

13 def __init__(self, m5Col='fiveSigmaDepth', units='mag', 

14 lsstFilter='r', wavelen_min=None , wavelen_max=None , wavelen_step=1., **kwargs ): 

15 """ 

16 Args: 

17 m5Col (str): Column name that ('fiveSigmaDepth') 

18 units (str): units of the metric ('mag') 

19 lsstFilter (str): Which LSST filter to calculate m5 for 

20 wavelen_min (float): Minimum wavength of your filter (None) 

21 wavelen_max (float): (None) 

22 wavelen_step (float): (1.) 

23 **kwargs: 

24 """ 

25 maps = ['DustMap'] 

26 waveMins={'u':330.,'g':403.,'r':552.,'i':691.,'z':818.,'y':950.} 

27 waveMaxes={'u':403.,'g':552.,'r':691.,'i':818.,'z':922.,'y':1070.} 

28 

29 if lsstFilter is not None: 

30 wavelen_min = waveMins[lsstFilter] 

31 wavelen_max = waveMaxes[lsstFilter] 

32 

33 self.m5Col = m5Col 

34 super(ExgalM5, self).__init__(col=[self.m5Col], 

35 maps=maps, units=units, **kwargs) 

36 

37 testsed = Sed() 

38 testsed.setFlatSED(wavelen_min = wavelen_min, 

39 wavelen_max = wavelen_max, wavelen_step = 1) 

40 self.a,self.b = testsed.setupCCM_ab() 

41 self.R_v = 3.1 

42 self.Coaddm5Metric = Coaddm5Metric(m5Col=m5Col) 

43 

44 

45 def run(self, dataSlice, slicePoint=None): 

46 """ 

47 Compute the co-added m5 depth and then apply extinction to that magnitude. 

48 

49 Args: 

50 dataSlice (np.array): 

51 slicePoint (dict): 

52 Returns: 

53 float that is the dust atennuated co-added m5-depth. 

54 """ 

55 

56 m5 = self.Coaddm5Metric.run(dataSlice) 

57 A_x = (self.a[0]+self.b[0]/self.R_v)*(self.R_v*slicePoint['ebv']) 

58 result = m5-A_x 

59 return result 

60 

61 

62class ExgalM5_cut(BaseMetric): 

63 """ 

64 Calculate co-added five-sigma limiting depth after dust extinction  

65 and depth cuts 

66 

67 A copy of ExgalM5 for use of FoMEmulator as a Summary Metric on this. 

68 """ 

69 def __init__(self, m5Col='fiveSigmaDepth', units='mag', 

70 lsstFilter='i', wavelen_min=None, wavelen_max=None, 

71 wavelen_step=1., extinction_cut=0.2, depth_cut=26, **kwargs): 

72 """ 

73 Args:  

74 m5Col (str): Column name that ('fiveSigmaDepth') 

75 units (str): units of the metric ('mag') 

76 lsstFilter (str): Which LSST filter to calculate m5 for 

77 wavelen_min (float): Minimum wavength of your filter (None) 

78 wavelen_max (float): (None) 

79 wavelen_step (float): (1.) 

80 **kwargs: 

81 """ 

82 maps = ['DustMap'] 

83 waveMins={'u':330., 'g':403., 'r':552., 'i':691., 'z':818., 'y':950.} 

84 waveMaxes={'u':403., 'g':552., 'r':691., 'i':818., 'z':922., 'y':1070.} 

85 

86 if lsstFilter is not None: 

87 wavelen_min = waveMins[lsstFilter] 

88 wavelen_max = waveMaxes[lsstFilter] 

89 

90 self.m5Col = m5Col 

91 super(ExgalM5_cut, self).__init__(col=[self.m5Col], 

92 maps=maps, 

93 units=units, 

94 **kwargs 

95 ) 

96 

97 testsed = Sed() 

98 testsed.setFlatSED(wavelen_min=wavelen_min, 

99 wavelen_max=wavelen_max, 

100 wavelen_step=1) 

101 self.a,self.b = testsed.setupCCM_ab() 

102 self.R_v = 3.1 

103 self.Coaddm5Metric = Coaddm5Metric(m5Col=m5Col) 

104 

105 self.extinction_cut = extinction_cut 

106 self.depth_cut = depth_cut 

107 

108 

109 def run(self, dataSlice, slicePoint=None): 

110 """ 

111 Compute the co-added m5 depth and then apply extinction cut 

112 and depth cut to that magnitude. 

113  

114 Args: 

115 dataSlice (ndarray): Values passed to metric by the slicer,  

116 which the metric will use to calculate metric values  

117 at each slicePoint. 

118 slicePoint (Dict): Dictionary of slicePoint metadata passed 

119 to each metric. 

120 Returns: 

121 float: the dust atennuated co-added m5-depth. 

122 """ 

123 

124 if slicePoint['ebv'] > self.extinction_cut: 

125 return self.badval 

126 

127 m5 = self.Coaddm5Metric.run(dataSlice) 

128 A_x = (self.a[0] + self.b[0]/self.R_v) * (self.R_v*slicePoint['ebv']) 

129 result = m5-A_x 

130 if result < self.depth_cut: 

131 return self.badval 

132 else: 

133 return result 

134