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

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
1import numpy as np
2from .baseMetric import BaseMetric
3from .simpleMetrics import Coaddm5Metric
4from lsst.sims.photUtils import Sed, Bandpass
6__all__ = ['ExgalM5']
9class ExgalM5(BaseMetric):
10 """
11 Calculate co-added five-sigma limiting depth after dust extinction.
13 Uses photUtils to calculate dust extinction.
15 Parameters
16 ----------
17 m5Col : str, opt
18 Column name for five sigma depth. Default 'fiveSigmaDepth'.
19 unit : str, opt
20 Label for units. Default 'mag'.
21 lsstFilter : str, opt
22 Filter name for which to calculate m5 depth. Default 'r'.
23 This is used to set the wavelength range over which to calculate dust extinction.
24 Overrides wavelen_min/wavelen_max/wavelen_step if specified.
25 wavelen_min : float, opt
26 If lsstFilter is not specified, this can be used to set the minimum wavelength for dust extinction.
27 wavelen_max : float, opt
28 If lsstFilter is not specified, this can be used to set the maximum wavelength for dust extinction.
29 """
30 def __init__(self, m5Col='fiveSigmaDepth', metricName='ExgalM5', units='mag',
31 lsstFilter='r', wavelen_min=None , wavelen_max=None , **kwargs):
32 # Set the name for the dust map to use. This is gathered into the MetricBundle.
33 maps = ['DustMap']
34 # Set the default wavelength limits for the lsst filters. These are approximately correct.
35 waveMins = {'u':330.,'g':403.,'r':552.,'i':691.,'z':818.,'y':950.}
36 waveMaxes = {'u':403.,'g':552.,'r':691.,'i':818.,'z':922.,'y':1070.}
37 if lsstFilter is not None:
38 wavelen_min = waveMins[lsstFilter]
39 wavelen_max = waveMaxes[lsstFilter]
41 self.m5Col = m5Col
42 super().__init__(col=[self.m5Col], maps=maps, metricName=metricName, units=units, **kwargs)
44 # Set up internal values for the dust extinction.
45 testsed = Sed()
46 testsed.setFlatSED(wavelen_min=wavelen_min, wavelen_max=wavelen_max, wavelen_step=1.0)
47 testbandpass = Bandpass(wavelen_min=wavelen_min, wavelen_max=wavelen_max, wavelen_step=1.0)
48 testbandpass.setBandpass(wavelen=testsed.wavelen,
49 sb=np.ones(len(testsed.wavelen)))
50 self.R_v = 3.1
51 self.ref_ebv = 1.0
52 # Calculate non-dust-extincted magnitude
53 flatmag = testsed.calcMag(testbandpass)
54 # Add dust
55 self.a, self.b = testsed.setupCCM_ab()
56 testsed.addDust(self.a, self.b, ebv=self.ref_ebv, R_v=self.R_v)
57 # Calculate difference due to dust when EBV=1.0 (m_dust = m_nodust - Ax, Ax > 0)
58 self.Ax1 = testsed.calcMag(testbandpass) - flatmag
59 # We will call Coaddm5Metric to calculate the coadded depth. Set it up here.
60 self.Coaddm5Metric = Coaddm5Metric(m5Col=m5Col)
62 def run(self, dataSlice, slicePoint):
63 """
64 Compute the co-added m5 depth and then apply dust extinction to that magnitude.
65 """
66 m5 = self.Coaddm5Metric.run(dataSlice)
67 # Total dust extinction along this line of sight. Correct default A to this EBV value.
68 A_x = self.Ax1 * slicePoint['ebv'] / self.ref_ebv
69 return m5 - A_x