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 .sysEngVals import SysEngVals 

3 

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

5 

6 

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

8 tauCloud=0, baseExpTime=15): 

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

10 

11 Parameters 

12 ---------- 

13 expTime : float 

14 Exposure time (in seconds) for each exposure 

15 nexp : int 

16 Number of exposures 

17 airmass : float 

18 Airmass of the observation 

19 FWHMeff : np.ndarray or pd.DataFrame 

20 FWHM (in arcseconds) per filter 

21 musky : np.ndarray or pd.DataFrame 

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

23 darkSkyMag : np.ndarray or pd.DataFrame 

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

25 Cm : np.ndarray or pd.DataFrame 

26 Cm value for the throughputs per filter 

27 dCm_infinity : np.ndarray or pd.DataFrame 

28 dCm_infinity values for the throughputs, per filter 

29 kAtm : np.ndarray or pd.DataFrame 

30 Atmospheric extinction values, per filter 

31 tauCloud : float, opt 

32 Extinction due to clouds 

33 baseExpTime : float, opt 

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

35 This is the individual exposure exposure time. 

36 

37 Returns 

38 ------- 

39 np.ndarray or pd.DataFrame 

40 m5 values scaled for the visit conditions 

41 

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

43 the makeM5 function in lsst.syseng.throughputs. 

44 """ 

45 # Calculate adjustment if readnoise is significant for exposure time 

46 # (see overview paper, equation 7) 

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

48 dCm = 0. 

49 dCm += dCm_infinity 

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

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

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

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

54 if nexp > 1: 

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

56 return m5 

57 

58 

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

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

61 

62 Parameters 

63 ---------- 

64 visitFilter : str 

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

66 musky : float 

67 Surface brightness of the sky in mag/sq arcsec 

68 FWHMeff : float 

69 The seeing effective FWHM (arcsec) 

70 expTime : float 

71 Exposure time for each exposure in the visit. 

72 airmass : float 

73 Airmass of the observation (unitless) 

74 nexp : int, opt 

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

76 tauCloud : float (0.) 

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

78 

79 Output 

80 ------ 

81 m5 : float 

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

83 """ 

84 

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

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

87 # 

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

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

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

91 

92 # Only define the dicts once on initial call 

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

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

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

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

97 # for a more in-depth evaluation. 

98 sev = SysEngVals() 

99 

100 m5_flat_sed.baseExpTime = sev.exptime 

101 m5_flat_sed.Cm = sev.Cm 

102 m5_flat_sed.dCm_infinity = sev.dCm_infinity 

103 m5_flat_sed.kAtm = sev.kAtm 

104 m5_flat_sed.msky = sev.skyMag 

105 # Calculate adjustment if readnoise is significant for exposure time 

106 # (see overview paper, equation 7) 

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

108 dCm = 0. 

109 dCm += m5_flat_sed.dCm_infinity[visitFilter] 

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

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

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

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

114 # Then combine with coadd if >1 exposure 

115 if nexp > 1: 

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

117 return m5