Coverage for python/lsst/sims/maf/metrics/exgalM5.py : 16%

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
5__all__ = ['ExgalM5', 'ExgalM5_cut']
7class ExgalM5(BaseMetric):
8 """
9 Calculate co-added five-sigma limiting depth after dust extinction.
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.}
29 if lsstFilter is not None:
30 wavelen_min = waveMins[lsstFilter]
31 wavelen_max = waveMaxes[lsstFilter]
33 self.m5Col = m5Col
34 super(ExgalM5, self).__init__(col=[self.m5Col],
35 maps=maps, units=units, **kwargs)
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)
45 def run(self, dataSlice, slicePoint=None):
46 """
47 Compute the co-added m5 depth and then apply extinction to that magnitude.
49 Args:
50 dataSlice (np.array):
51 slicePoint (dict):
52 Returns:
53 float that is the dust atennuated co-added m5-depth.
54 """
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
62class ExgalM5_cut(BaseMetric):
63 """
64 Calculate co-added five-sigma limiting depth after dust extinction
65 and depth cuts
67 A copy of ExgalM5 for use of FoMEmulator as a Summary Metric on this.
68 """
69 def __init__(self, m5Col='fiveSigmaDepth', filterCol='filter', units='mag',
70 lsstFilter='i', wavelen_min=None, wavelen_max=None,
71 wavelen_step=1., extinction_cut=0.2, depth_cut=25.9, **kwargs):
72 """
73 Args:
74 m5Col (str): Column name that ('fiveSigmaDepth')
75 filterCol (str): Filter column name, default is 'filter'
76 units (str): units of the metric ('mag')
77 lsstFilter (str): Which LSST filter to calculate m5 for
78 wavelen_min (float): Minimum wavength of your filter (None)
79 wavelen_max (float): (None)
80 wavelen_step (float): (1.)
81 **kwargs:
82 """
83 maps = ['DustMap']
84 waveMins={'u':330., 'g':403., 'r':552., 'i':691., 'z':818., 'y':950.}
85 waveMaxes={'u':403., 'g':552., 'r':691., 'i':818., 'z':922., 'y':1070.}
87 if lsstFilter is not None:
88 wavelen_min = waveMins[lsstFilter]
89 wavelen_max = waveMaxes[lsstFilter]
91 self.m5Col = m5Col
92 self.filterCol = filterCol
93 super(ExgalM5_cut, self).__init__(col=[self.m5Col, self.filterCol],
94 maps=maps,
95 units=units,
96 **kwargs
97 )
99 testsed = Sed()
100 testsed.setFlatSED(wavelen_min=wavelen_min,
101 wavelen_max=wavelen_max,
102 wavelen_step=1)
103 self.a,self.b = testsed.setupCCM_ab()
104 self.R_v = 3.1
105 self.Coaddm5Metric = Coaddm5Metric(m5Col=m5Col)
107 self.extinction_cut = extinction_cut
108 self.depth_cut = depth_cut
111 def run(self, dataSlice, slicePoint=None):
112 """
113 Compute the co-added m5 depth and then apply extinction cut
114 and depth cut to that magnitude.
116 Args:
117 dataSlice (ndarray): Values passed to metric by the slicer,
118 which the metric will use to calculate metric values
119 at each slicePoint.
120 slicePoint (Dict): Dictionary of slicePoint metadata passed
121 to each metric.
122 Returns:
123 float: the dust atennuated co-added m5-depth.
124 """
125 # check to make sure there is at least some coverage in all bands
126 if set(dataSlice[self.filterCol]) != set(('u','g','r','i','z','y')):
127 return self.badval
129 # if coverage criteria is valid, move forward with only i-band visits
130 dataSlice = dataSlice[dataSlice[self.filterCol] == 'i']
132 # exclude areas with bad extinction
133 if slicePoint['ebv'] > self.extinction_cut:
134 return self.badval
136 # calculate the i-band coadded depth
137 m5 = self.Coaddm5Metric.run(dataSlice)
138 A_x = (self.a[0] + self.b[0]/self.R_v) * (self.R_v*slicePoint['ebv'])
139 result = m5-A_x
141 # exclude areas that are shallower than the depth cut
142 if result < self.depth_cut:
143 return self.badval
144 else:
145 return result