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

1import numpy as np 

2from .baseMetric import BaseMetric 

3from .exgalM5 import ExgalM5 

4 

5__all__ = ['ExgalM5_with_cuts', 'WeakLensingNvisits'] 

6 

7 

8class ExgalM5_with_cuts(BaseMetric): 

9 """ 

10 Calculate co-added five-sigma limiting depth, but apply dust extinction and depth cuts. 

11 This means that places on the sky that don't meet the dust extinction, coadded depth, or filter coverage 

12 cuts will have masked values on those places. 

13 

14 This metric is useful for DESC static science and weak lensing metrics. 

15 In particular, it is required as input for the StaticProbesFoMEmulatorMetricSimple 

16 (a summary metric to emulate a 3x2pt FOM). 

17 

18 Note: this metric calculates the depth after dust extinction in band 'lsstFilter', but because 

19 it looks for coverage in all bands, there should generally be no filter-constraint on the sql query. 

20 """ 

21 def __init__(self, m5Col='fiveSigmaDepth', filterCol='filter', 

22 metricName='ExgalM5_with_cuts', units='mag', 

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

24 extinction_cut=0.2, depth_cut=25.9, nFilters=6, **kwargs): 

25 self.m5Col = m5Col 

26 self.filterCol = filterCol 

27 self.extinction_cut = extinction_cut 

28 self.depth_cut = depth_cut 

29 self.nFilters = nFilters 

30 self.lsstFilter = lsstFilter 

31 # I thought about inheriting from ExGalM5 instead, but the columns specification is more complicated 

32 self.exgalM5 = ExgalM5(m5Col=m5Col, units=units, lsstFilter=self.lsstFilter, 

33 wavelen_min=wavelen_min, wavelen_max=wavelen_max) 

34 super().__init__(col=[self.m5Col, self.filterCol], metricName=metricName, units=units, 

35 maps=self.exgalM5.maps, **kwargs) 

36 

37 def run(self, dataSlice, slicePoint): 

38 # check to make sure there is at least some coverage in the required number of bands 

39 nFilters = len(set(dataSlice[self.filterCol])) 

40 if nFilters < self.nFilters: 

41 return self.badval 

42 

43 # exclude areas with high extinction 

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

45 return self.badval 

46 

47 # if coverage and dust criteria are valid, move forward with only lsstFilter-band visits 

48 dS = dataSlice[dataSlice[self.filterCol] == self.lsstFilter] 

49 # calculate the lsstFilter-band coadded depth 

50 dustdepth = self.exgalM5.run(dS, slicePoint) 

51 

52 # exclude areas that are shallower than the depth cut 

53 if dustdepth < self.depth_cut: 

54 return self.badval 

55 else: 

56 return dustdepth 

57 

58 

59class WeakLensingNvisits(BaseMetric): 

60 """A proxy metric for WL systematics. Higher values indicate better systematics mitigation. 

61 

62 Weak Lensing systematics metric : Computes the average number of visits per point on a HEALPix grid 

63 after a maximum E(B-V) cut and a minimum co-added depth cut. 

64 Intended to be used with a single filter. 

65 """ 

66 def __init__(self, m5Col='fiveSigmaDepth', expTimeCol='visitExposureTime', 

67 lsstFilter='i', 

68 depthlim=24.5, 

69 ebvlim=0.2, min_expTime=15, 

70 **kwargs): 

71 # First set up the ExgalM5 metric (this will also add the dustmap as a map attribute) 

72 self.ExgalM5 = ExgalM5(m5Col=m5Col, lsstFilter=lsstFilter) 

73 self.m5Col = m5Col 

74 self.expTimeCol = expTimeCol 

75 self.depthlim = depthlim 

76 self.ebvlim = ebvlim 

77 self.min_expTime = min_expTime 

78 super().__init__(col=[self.m5Col, self.expTimeCol], maps=self.ExgalM5.maps, **kwargs) 

79 

80 def run(self, dataSlice, slicePoint): 

81 if slicePoint['ebv'] > self.ebvlim: 

82 return self.badval 

83 dustdepth = self.ExgalM5.run(dataSlice=dataSlice, slicePoint=slicePoint) 

84 if dustdepth < self.depthlim: 

85 return self.badval 

86 nvisits = len(np.where(dataSlice[self.expTimeCol] > self.min_expTime)[0]) 

87 return nvisits