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) 

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

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

35 

36 def run(self, dataSlice, slicePoint): 

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

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

39 if nFilters < self.nFilters: 

40 return self.badval 

41 

42 # exclude areas with high extinction 

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

44 return self.badval 

45 

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

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

48 # calculate the lsstFilter-band coadded depth 

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

50 

51 # exclude areas that are shallower than the depth cut 

52 if dustdepth < self.depth_cut: 

53 return self.badval 

54 else: 

55 return dustdepth 

56 

57 

58class WeakLensingNvisits(BaseMetric): 

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

60 

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

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

63 Intended to be used with a single filter. 

64 """ 

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

66 lsstFilter='i', filterCol='filter', 

67 depthlim=24.5, 

68 ebvlim=0.2, min_expTime=15, 

69 **kwargs): 

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

71 self.ExgalM5 = ExgalM5(m5Col=m5Col, filterCol=filterCol) 

72 self.m5Col = m5Col 

73 self.expTimeCol = expTimeCol 

74 self.depthlim = depthlim 

75 self.ebvlim = ebvlim 

76 self.min_expTime = min_expTime 

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

78 

79 def run(self, dataSlice, slicePoint): 

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

81 return self.badval 

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

83 if dustdepth < self.depthlim: 

84 return self.badval 

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

86 return nvisits