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 

2 

3__all__ = ['m5_flat_sed', 'm5_scale'] 

4 

5 

6def m5_scale(expTime, nexp, airmass, FWHMeff, musky, darkSkyMag, Cm, dCm_infinity, kAtm, 

7 tauCloud=0, baseExpTime=15): 

8 """ Return m5 (scaled) value for all filters. 

9 

10 Parameters 

11 ---------- 

12 expTime : float 

13 Exposure time (in seconds) for each exposure 

14 nexp : int 

15 Number of exposures 

16 airmass : float 

17 Airmass of the observation 

18 FWHMeff : np.ndarray or pd.DataFrame 

19 FWHM (in arcseconds) per filter 

20 musky : np.ndarray or pd.DataFrame 

21 Sky background (in magnitudes/sq arcsecond) per filter of the observation 

22 darkSkyMag : np.ndarray or pd.DataFrame 

23 Dark Sky, zenith magnitude/sq arcsecond - to scale musky. per filter 

24 Cm : np.ndarray or pd.DataFrame 

25 Cm value for the throughputs per filter 

26 dCm_infinity : np.ndarray or pd.DataFrame 

27 dCm_infinity values for the throughputs, per filter 

28 kAtm : np.ndarray or pd.DataFrame 

29 Atmospheric extinction values, per filter 

30 tauCloud : float, opt 

31 Extinction due to clouds 

32 baseExpTime : float, opt 

33 The exposure time used to calculate Cm / dCm_infinity. Used to scale expTime. 

34 This is the individual exposure exposure time. 

35 

36 Returns 

37 ------- 

38 np.ndarray or pd.DataFrame 

39 m5 values scaled for the visit conditions 

40 

41 Note: The columns required as input for m5_scale can be calculated using 

42 the makeM5 function in lsst.syseng.throughputs. 

43 """ 

44 # Calculate adjustment if readnoise is significant for exposure time 

45 # (see overview paper, equation 7) 

46 Tscale = expTime / baseExpTime * np.power(10.0, -0.4 * (musky - darkSkyMag)) 

47 dCm = 0. 

48 dCm += dCm_infinity 

49 dCm -= 1.25 * np.log10(1 + (10**(0.8 * dCm_infinity) - 1)/Tscale) 

50 # Calculate m5 for 1 exp - constants here come from definition of Cm/dCm_infinity 

51 m5 = (Cm + dCm + 0.50 * (musky - 21.0) + 2.5 * np.log10(0.7 / FWHMeff) + 

52 1.25 * np.log10(expTime / 30.0) - kAtm * (airmass - 1.0) - 1.1 * tauCloud) 

53 if nexp > 1: 

54 m5 = 1.25 * np.log10(nexp * 10**(0.8 * m5)) 

55 return m5 

56 

57 

58def m5_flat_sed(visitFilter, musky, FWHMeff, expTime, airmass, nexp=1, tauCloud=0): 

59 """Calculate the m5 value, using photometric scaling. Note, does not include shape of the object SED. 

60 

61 Parameters 

62 ---------- 

63 visitFilter : str 

64 One of u,g,r,i,z,y 

65 musky : float 

66 Surface brightness of the sky in mag/sq arcsec 

67 FWHMeff : float 

68 The seeing effective FWHM (arcsec) 

69 expTime : float 

70 Exposure time for each exposure in the visit. 

71 airmass : float 

72 Airmass of the observation (unitless) 

73 nexp : int, opt 

74 The number of exposures. Default 1. (total on-sky time = expTime * nexp) 

75 tauCloud : float (0.) 

76 Any extinction from clouds in magnitudes (positive values = more extinction) 

77 

78 Output 

79 ------ 

80 m5 : float 

81 The five-sigma limiting depth of a point source observed in the given conditions. 

82 """ 

83 

84 # Set up expected extinction (kAtm) and m5 normalization values (Cm) for each filter. 

85 # The Cm values must be changed when telescope and site parameters are updated. 

86 # 

87 # These values are calculated using $SYSENG_THROUGHPUTS/python/calcM5.py. 

88 # This set of values are calculated using v1.2 of the SYSENG_THROUGHPUTS repo. 

89 # The exposure time scaling depends on knowing the value of the exposure time used to calculate Cm/etc. 

90 

91 # Only define the dicts once on initial call 

92 if not hasattr(m5_flat_sed, 'Cm'): 

93 # Using Cm / dCm_infinity values calculated for a 1x30s visit. 

94 # This results in an error of about 0.01 mag in u band for 2x15s visits (< in other bands) 

95 # See https://github.com/lsst-pst/survey_strategy/blob/master/fbs_1.3/m5FlatSed%20update.ipynb 

96 # for a more in-depth evaluation. 

97 m5_flat_sed.baseExpTime = 30. 

98 m5_flat_sed.Cm = {'u': 23.283, 

99 'g': 24.493, 

100 'r': 24.483, 

101 'i': 24.358, 

102 'z': 24.180, 

103 'y': 23.747} 

104 m5_flat_sed.dCm_infinity = {'u': 0.414, 

105 'g': 0.100, 

106 'r': 0.052, 

107 'i': 0.038, 

108 'z': 0.026, 

109 'y': 0.019} 

110 m5_flat_sed.kAtm = {'u': 0.492, 

111 'g': 0.213, 

112 'r': 0.126, 

113 'i': 0.096, 

114 'z': 0.069, 

115 'y': 0.170} 

116 m5_flat_sed.msky = {'u': 22.989, 

117 'g': 22.256, 

118 'r': 21.196, 

119 'i': 20.478, 

120 'z': 19.600, 

121 'y': 18.612} 

122 # Calculate adjustment if readnoise is significant for exposure time 

123 # (see overview paper, equation 7) 

124 Tscale = expTime / m5_flat_sed.baseExpTime * np.power(10.0, -0.4 * (musky - m5_flat_sed.msky[visitFilter])) 

125 dCm = 0. 

126 dCm += m5_flat_sed.dCm_infinity[visitFilter] 

127 dCm -= 1.25 * np.log10(1 + (10**(0.8 * m5_flat_sed.dCm_infinity[visitFilter]) - 1) / Tscale) 

128 # Calculate m5 for 1 exp - 30s and other constants here come from definition of Cm/dCm_infinity 

129 m5 = (m5_flat_sed.Cm[visitFilter] + dCm + 0.50 * (musky - 21.0) + 2.5 * np.log10(0.7 / FWHMeff) + 

130 1.25 * np.log10(expTime / 30.0) - m5_flat_sed.kAtm[visitFilter] * (airmass - 1.0) - 1.1 * tauCloud) 

131 # Then combine with coadd if >1 exposure 

132 if nexp > 1: 

133 m5 = 1.25 * np.log10(nexp * 10**(0.8 * m5)) 

134 return m5