-
Notifications
You must be signed in to change notification settings - Fork 7
/
etc.py
131 lines (118 loc) · 3.67 KB
/
etc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# author: Igor Andreoni <[email protected].>
# Formulae from https://smtn-002.lsst.io/v/OPSIM-1134/index.html
import numpy as np
params = {
"u": {"Cm": 22.97,
"dCm_inf": 0.54,
"zp": 26.52,
"fwhm": 0.92,
"m_darksky": 23.05,
"k_atm": 0.47
},
"g": {"Cm": 24.58,
"dCm_inf": 0.09,
"zp": 28.51,
"fwhm": 0.87,
"m_darksky": 22.25,
"k_atm": 0.21
},
"r": {"Cm": 24.6,
"dCm_inf": 0.04,
"zp": 28.36,
"fwhm": 0.83,
"m_darksky": 21.2,
"k_atm": 0.13
},
"i": {"Cm": 24.54,
"dCm_inf": 0.03,
"zp": 28.17,
"fwhm": 0.80,
"m_darksky": 20.46,
"k_atm": 0.10
},
"z": {"Cm": 24.37,
"dCm_inf": 0.02,
"zp": 27.78,
"fwhm": 0.78,
"m_darksky": 19.61,
"k_atm": 0.07
},
"y": {"Cm": 23.84,
"dCm_inf": 0.02,
"zp": 26.82,
"fwhm": 0.76,
"m_darksky": 18.6,
"k_atm": 0.17
}
}
def get_exptime(m5, filt, X=1.):
"""
Given a certain depth, return the exposure time
Parameters
----------
m5 float
depth 5sigma (mag)
filt str
filter (one of ugrizy)
X float
airmass
Returns
-------
exptime float
exposure time to reach limiting magnitude
"""
# assign the parameters to variables
Cm = params[filt]["Cm"]
k_atm = params[filt]["k_atm"]
fwhm = params[filt]["fwhm"]
m_darksky = params[filt]["m_darksky"]
# Important: assuming darksky
m_sky = m_darksky
# FIXME approximation dCm=0 (fine within 0.3s for 30s exposures)
# dCm_inf = params[filt]["dCm_inf"]
# Tscale = exptime / 30. * 10**(-1 * 0.4 * (m_sky - m_darksky))
# dCm = dCm_inf - 1.25 * np.log10(1 + (10**(0.8 * dCm_inf) - 1) / Tscale)
dCm = 0
# Calculate the exposure time
exptime = 30 * 10 ** ((1 / 1.25) * (m5 - Cm - dCm - 0.5 * (m_sky - 21.) -
2.5 * np.log10(0.7 / fwhm) +
k_atm*(X - 1.0)))
return exptime
def get_m5(exptime, filt, X=1.):
"""
Given a certain exposure time return 5sigma depth
Parameters
----------
exptime int or float
exposure time
filt str
filter (one of ugrizy)
X float
airmass
Returns
-------
m5 float
5sigma limiting magnitude
"""
# assign the parameters to variables
Cm = params[filt]["Cm"]
dCm_inf = params[filt]["dCm_inf"]
k_atm = params[filt]["k_atm"]
fwhm = params[filt]["fwhm"]
m_darksky = params[filt]["m_darksky"]
# Important: assuming darksky
m_sky = m_darksky
# Calculate m5
Tscale = exptime / 30. * 10**(-1 * 0.4 * (m_sky - m_darksky))
dCm = dCm_inf - 1.25 * np.log10(1 + (10**(0.8 * dCm_inf) - 1) / Tscale)
m5 = Cm + dCm + 0.5 * (m_sky - 21.) + 2.5 * np.log10(0.7 / fwhm) + \
1.25 * np.log10(exptime / 30.) - k_atm*(X - 1.0)
return m5
if __name__ == "__main__":
# Testing getting exptime given a list of mag limits
m5s = [23.70, 24.97, 24.52, 24.13, 23.56, 22.55]
for m5, filt in zip(m5s, "ugrizy"):
# m5_out = get_m5(exptime, filt, X=1.)
exptime_out = get_exptime(m5, filt, X=1.)
# print('{:.2f}'.format(m5_out))
print('{:.2f}'.format(exptime_out))