-
Notifications
You must be signed in to change notification settings - Fork 0
/
corrections.py
272 lines (245 loc) · 10.3 KB
/
corrections.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
from numpy import arange, sqrt
from skyfield.earthlib import refraction
def inc_sun(m, s):
"GHA increment of sun"
h = (m + s / 60) / 60
return h * 15
def inc_aries(m, s):
"GHA increment of Aries"
h = (m + s / 60) / 60
return h * (15 + 2.46 / 60)
def inc_moon(m, s):
"GHA increment of moon"
h = (m + s / 60) / 60
return h * (14 + 19 / 60)
def v_corr(m, s, v):
"v/d correction"
h = (m + s / 60) / 60
return v * h
def ft(m):
"meters to feet"
return 3.280839 * m
def dip(h, feet=0):
"dip in minutes from height in meters or feet"
return (0.971 if feet else 1.765) * sqrt(h)
def idip(d, n=1, feet=0):
"min. height in meters for dip in minutes"
d = round(d, n)
for h in arange(0, 300, 10 ** -n):
h = round(h, n)
if round(dip(h, feet), n) >= d:
return h
_alt_corr10 = (
# alitude sun winter sun summer planets
# deg min lower upper lower upper stars
(0, 0, -17.5, -49.8, -17.8, -49.6, -33.8),
(0, 3, -16.9, -49.2, -17.2, -49.0, -33.2),
(0, 6, -16.3, -48.6, -16.6, -48.4, -32.6),
(0, 9, -15.7, -48.0, -16.0, -47.8, -32.0),
(0, 12, -15.2, -47.5, -15.5, -47.3, -31.5),
(0, 15, -14.6, -46.9, -14.9, -46.7, -30.9),
(0, 18, -14.1, -46.4, -14.4, -46.2, -30.4),
(0, 21, -13.5, -45.8, -13.8, -45.6, -29.8),
(0, 24, -13.0, -45.3, -13.3, -45.1, -29.3),
(0, 27, -12.5, -44.8, -12.8, -44.6, -28.8),
(0, 30, -12.0, -44.3, -12.3, -44.1, -28.3),
(0, 33, -11.6, -43.9, -11.9, -43.7, -27.9),
(0, 36, -11.1, -43.4, -11.4, -43.2, -27.4),
(0, 39, -10.6, -42.9, -10.9, -42.7, -26.9),
(0, 42, -10.2, -42.5, -10.5, -42.3, -26.5),
(0, 45, -9.8, -42.1, -10.1, -41.9, -26.1),
(0, 48, -9.4, -41.7, -9.7, -41.5, -25.7),
(0, 51, -9.0, -41.3, -9.3, -41.1, -25.3),
(0, 54, -8.6, -40.9, -8.9, -40.7, -24.9),
(0, 57, -8.2, -40.5, -8.5, -40.3, -24.5),
(1, 0, -7.8, -40.1, -8.1, -39.9, -24.1),
(1, 3, -7.4, -39.7, -7.7, -39.5, -23.7),
(1, 6, -7.1, -39.4, -7.4, -39.2, -23.4),
(1, 9, -6.7, -39.0, -7.0, -38.8, -23.0),
(1, 12, -6.4, -38.7, -6.7, -38.5, -22.7),
(1, 15, -6.0, -38.3, -6.3, -38.1, -22.3),
(1, 18, -5.7, -38.0, -6.0, -37.8, -22.0),
(1, 21, -5.4, -37.7, -5.7, -37.5, -21.7),
(1, 24, -5.1, -37.4, -5.4, -37.2, -21.4),
(1, 27, -4.8, -37.1, -5.1, -36.9, -21.1),
(1, 30, -4.5, -36.8, -4.8, -36.6, -20.8),
(1, 35, -4.0, -36.3, -4.3, -36.1, -20.3),
(1, 40, -3.6, -35.9, -3.9, -35.7, -19.9),
(1, 45, -3.1, -35.4, -3.4, -35.2, -19.4),
(1, 50, -2.7, -35.0, -3.0, -34.8, -19.0),
(1, 55, -2.3, -34.6, -2.6, -34.4, -18.6),
(2, 0, -1.9, -34.2, -2.2, -34.0, -18.2),
(2, 5, -1.5, -33.8, -1.8, -33.6, -17.8),
(2, 10, -1.1, -33.4, -1.4, -33.2, -17.4),
(2, 15, -0.8, -33.1, -1.1, -32.9, -17.1),
(2, 20, -0.4, -32.7, -0.7, -32.5, -16.7),
(2, 25, -0.1, -32.4, -0.4, -32.2, -16.4),
(2, 30, 0.2, -32.1, -0.1, -31.9, -16.1),
(2, 35, 0.5, -31.8, 0.2, -31.6, -15.8),
(2, 40, 0.9, -31.4, 0.6, -31.2, -15.4),
(2, 45, 1.1, -31.2, 0.8, -31.0, -15.2),
(2, 50, 1.4, -30.9, 1.1, -30.7, -14.9),
(2, 55, 1.7, -30.6, 1.4, -30.4, -14.6),
(3, 0, 2.0, -30.3, 1.7, -30.1, -14.3),
(3, 5, 2.2, -30.1, 1.9, -29.9, -14.1),
(3, 10, 2.5, -29.8, 2.2, -29.6, -13.8),
(3, 15, 2.7, -29.6, 2.4, -29.4, -13.6),
(3, 20, 2.9, -29.4, 2.6, -29.2, -13.4),
(3, 25, 3.2, -29.1, 2.9, -28.9, -13.1),
(3, 30, 3.4, -28.9, 3.1, -28.7, -12.9),
(3, 35, 3.6, -28.7, 3.3, -28.5, -12.7),
(3, 40, 3.8, -28.5, 3.5, -28.3, -12.5),
(3, 45, 4.0, -27.9, 3.8, -28.0, -12.3),
(3, 50, 4.2, -28.1, 3.9, -27.9, -12.1),
(3, 55, 4.4, -27.9, 4.1, -27.7, -11.9),
(4, 0, 4.6, -27.7, 4.3, -27.5, -11.7),
(4, 5, 4.8, -27.5, 4.5, -27.3, -11.5),
(4, 10, 4.9, -27.4, 4.6, -27.2, -11.4),
(4, 15, 5.1, -27.2, 4.8, -27.0, -11.2),
(4, 20, 5.3, -27.0, 5.0, -26.8, -11.0),
(4, 25, 5.4, -26.9, 5.1, -26.7, -10.9),
(4, 30, 5.6, -26.7, 5.3, -26.5, -10.7),
(4, 35, 5.7, -26.6, 5.4, -26.4, -10.6),
(4, 40, 5.9, -26.4, 5.6, -26.2, -10.4),
(4, 45, 6.0, -26.3, 5.7, -26.1, -10.3),
(4, 50, 6.2, -26.1, 5.9, -25.9, -10.1),
(4, 55, 6.3, -26.0, 6.0, -25.8, -10.0),
(5, 0, 6.5, -25.8, 6.2, -25.6, -9.8),
(5, 5, 6.6, -25.7, 6.3, -25.5, -9.7),
(5, 10, 6.7, -25.6, 6.4, -25.4, -9.6),
(5, 15, 6.8, -25.5, 6.5, -25.3, -9.5),
(5, 20, 7.0, -25.3, 6.7, -25.1, -9.3),
(5, 25, 7.1, -25.2, 6.8, -25.0, -9.2),
(5, 30, 7.2, -25.1, 6.9, -24.9, -9.1),
(5, 35, 7.3, -25.0, 7.0, -24.8, -9.0),
(5, 40, 7.4, -24.9, 7.1, -24.7, -8.9),
(5, 45, 7.5, -24.8, 7.2, -24.6, -8.8),
(5, 50, 7.6, -24.7, 7.3, -24.5, -8.7),
(5, 55, 7.7, -24.6, 7.4, -24.4, -8.6),
(6, 0, 7.8, -24.5, 7.5, -24.3, -8.5),
(6, 10, 8.0, -24.3, 7.7, -24.1, -8.3),
(6, 20, 8.2, -24.1, 7.9, -23.9, -8.1),
(6, 30, 8.4, -23.9, 8.1, -23.7, -7.9),
(6, 40, 8.6, -23.7, 8.3, -23.5, -7.7),
(6, 50, 8.7, -23.6, 8.4, -23.4, -7.6),
(7, 0, 8.9, -23.4, 8.6, -23.2, -7.4),
(7, 10, 9.1, -23.2, 8.8, -23.0, -7.2),
(7, 20, 9.2, -23.1, 8.9, -22.9, -7.1),
(7, 30, 9.4, -22.9, 9.1, -22.7, -6.9),
(7, 40, 9.5, -22.8, 9.2, -22.6, -6.8),
(7, 50, 9.6, -22.7, 9.3, -22.5, -6.7),
(8, 0, 9.7, -22.6, 9.4, -22.4, -6.6),
(8, 10, 9.9, -22.4, 9.6, -22.2, -6.4),
(8, 20, 10.0, -22.3, 9.7, -22.1, -6.3),
(8, 30, 10.1, -22.2, 9.8, -22.0, -6.2),
(8, 40, 10.2, -22.1, 9.9, -21.9, -6.1),
(8, 50, 10.3, -22.0, 10.0, -21.8, -6.0),
(9, 0, 10.4, -21.9, 10.1, -21.7, -5.9),
(9, 10, 10.5, -21.8, 10.2, -21.6, -5.8),
(9, 20, 10.6, -21.7, 10.3, -21.5, -5.7),
(9, 30, 10.7, -21.6, 10.4, -21.4, -5.6),
(9, 40, 10.8, -21.5, 10.5, -21.3, -5.5),
(9, 50, 10.9, -21.4, 10.6, -21.2, -5.4),
(10, 0, 11.0, -21.3, 10.7, -21.1, -5.3),
)
_alt_corr90 = (
# sun winter sun summer stars
# d, m, L, U, d, m, L, U, d, m, c
(9, 33, 10.8, -21.5, 9, 39, 10.6, -21.2, 9, 55, -5.3),
(9, 45, 10.9, -21.4, 9, 50, 10.7, -21.1, 10, 7, -5.2),
(9, 56, 11.0, -21.3, 10, 2, 10.8, -21.0, 10, 20, -5.1),
(10, 8, 11.1, -21.2, 10, 14, 10.9, -20.9, 10, 32, -5.0),
(10, 20, 11.2, -21.1, 10, 27, 11.0, -20.8, 10, 46, -4.9),
(10, 33, 11.3, -21.0, 10, 40, 11.1, -20.7, 10, 59, -4.8),
(10, 46, 11.4, -20.9, 10, 53, 11.2, -20.6, 11, 14, -4.7),
(11, 0, 11.5, -20.8, 11, 7, 11.3, -20.5, 11, 29, -4.6),
(11, 15, 11.6, -20.7, 11, 22, 11.4, -20.4, 11, 44, -4.5),
(11, 30, 11.7, -20.6, 11, 37, 11.5, -20.3, 12, 0, -4.4),
(11, 45, 11.8, -20.5, 11, 53, 11.6, -20.2, 12, 17, -4.3),
(12, 1, 11.9, -20.4, 12, 10, 11.7, -20.1, 12, 35, -4.2),
(12, 18, 12.0, -20.3, 12, 27, 11.8, -20.0, 12, 53, -4.1),
(12, 36, 12.1, -20.2, 12, 45, 11.9, -19.9, 13, 12, -4.0),
(12, 54, 12.2, -20.1, 13, 4, 12.0, -19.8, 13, 32, -3.9),
(13, 14, 12.3, -20.0, 13, 24, 12.1, -19.7, 13, 53, -3.8),
(13, 34, 12.4, -19.9, 13, 44, 12.2, -19.6, 14, 16, -3.7),
(13, 55, 12.5, -19.8, 14, 6, 12.3, -19.5, 14, 39, -3.6),
(14, 17, 12.6, -19.7, 14, 29, 12.4, -19.4, 15, 3, -3.5),
(14, 41, 12.7, -19.6, 14, 53, 12.5, -19.3, 15, 29, -3.4),
(15, 5, 12.8, -19.5, 15, 18, 12.6, -19.2, 15, 56, -3.3),
(15, 31, 12.9, -19.4, 15, 45, 12.7, -19.1, 16, 25, -3.2),
(15, 59, 13.0, -19.3, 16, 13, 12.8, -19.0, 16, 55, -3.1),
(16, 27, 13.1, -19.2, 16, 43, 12.9, -18.9, 17, 27, -3.0),
(16, 58, 13.2, -19.1, 17, 14, 13.0, -18.8, 18, 1, -2.9),
(17, 30, 13.3, -19.0, 17, 47, 13.1, -18.7, 18, 37, -2.8),
(18, 5, 13.4, -18.9, 18, 23, 13.2, -18.6, 19, 16, -2.7),
(18, 41, 13.5, -18.8, 19, 0, 13.3, -18.5, 19, 56, -2.6),
(19, 20, 13.6, -18.7, 19, 41, 13.4, -18.4, 20, 40, -2.5),
(20, 2, 13.7, -18.6, 20, 24, 13.5, -18.3, 21, 27, -2.4),
(20, 46, 13.8, -18.5, 21, 10, 13.6, -18.2, 22, 17, -2.3),
(21, 34, 13.9, -18.4, 21, 59, 13.7, -18.1, 23, 11, -2.2),
(22, 25, 14.0, -18.3, 22, 52, 13.8, -18.0, 24, 9, -2.1),
(23, 20, 14.1, -18.2, 23, 49, 13.9, -17.9, 25, 12, -2.0),
(24, 20, 14.2, -18.1, 24, 51, 14.0, -17.8, 26, 20, -1.9),
(25, 24, 14.3, -18.0, 25, 58, 14.1, -17.7, 27, 34, -1.8),
(26, 34, 14.4, -17.9, 27, 11, 14.2, -17.6, 28, 54, -1.7),
(27, 50, 14.5, -17.8, 28, 31, 14.3, -17.5, 30, 22, -1.6),
(29, 13, 14.6, -17.7, 29, 58, 14.4, -17.4, 31, 58, -1.5),
(30, 44, 14.7, -17.6, 31, 33, 14.5, -17.3, 33, 43, -1.4),
(32, 24, 14.8, -17.5, 33, 18, 14.6, -17.2, 35, 38, -1.3),
(34, 15, 14.9, -17.4, 35, 15, 14.7, -17.1, 37, 45, -1.2),
(36, 17, 15.0, -17.3, 37, 24, 14.8, -17.0, 40, 6, -1.1),
(38, 34, 15.1, -17.2, 39, 48, 14.9, -16.9, 42, 42, -1.0),
(41, 6, 15.2, -17.1, 42, 28, 15.0, -16.8, 45, 34, -0.9),
(43, 56, 15.3, -17.0, 45, 29, 15.1, -16.7, 48, 45, -0.8),
(47, 7, 15.4, -16.9, 48, 52, 15.2, -16.6, 52, 16, -0.7),
(50, 43, 15.5, -16.8, 52, 41, 15.3, -16.5, 56, 9, -0.6),
(54, 46, 15.6, -16.7, 56, 59, 15.4, -16.4, 60, 26, -0.5),
(59, 21, 15.7, -16.6, 61, 50, 15.5, -16.3, 65, 6, -0.4),
(64, 28, 15.8, -16.5, 67, 15, 15.6, -16.2, 70, 9, -0.3),
(70, 10, 15.9, -16.4, 73, 14, 15.7, -16.1, 75, 32, -0.2),
(76, 24, 16.0, -16.3, 79, 42, 15.8, -16.0, 81, 12, -0.1),
(83, 5, 16.1, -16.2, 86, 31, 15.9, -15.9, 87, 3, 0.0),
)
def corr_tab10(a, summer=0, upper=0):
assert 0 <= a <= 10, a
i = 2 + 2 * summer + upper
t = _alt_corr10
e0 = t[0]
a0 = e0[0] + e0[1] / 60
for k in range(1, len(t)):
e1 = t[k]
a1 = e1[0] + e1[1] / 60
if a0 <= a <= a1:
c0, c1 = e0[i], e1[i]
x = (a - a0) / (a1 - a0)
d = (c1 - c0)
return c0 + (a - a0) / (a1 - a0) * (c1 - c0)
e0, a0 = e1, a1
def corr_tab90(a, summer=0, upper=0):
t = _alt_corr90
d = 4 * summer
m = d + 1
v = d + 2 + upper
assert t[0][d] + t[0][m] / 60 <= a <= 90, (t[0][d] + t[0][m] / 60, a)
c = t[0][v]
for r in t:
a0 = r[d] + r[m] / 60
if a < a0: break
c = r[v]
return c
def corr_tab(a, summer=0, upper=0):
try:
return corr_tab90(a, summer, upper)
except:
return corr_tab10(a, summer, upper)
def corr(a, SD=0, tab=1):
if tab:
return corr_tab(a, abs(SD) < 16 if SD else 2, SD < 0)
return SD - 60 * refraction(a, 10, 1010)
def icorr(c, m=0, n=1, *args, **kwargs):
c = round(c, n)
for am in arange(0, 90 * 60, 10 ** -m):
a = round(am, m) / 60
if round(corr(a, *args, **kwargs), n) >= c:
return a
return 90