eph_jcg 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +10 -0
- data/Guardfile +42 -0
- data/LICENSE.txt +21 -0
- data/README.md +95 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/eph_jcg.gemspec +33 -0
- data/exe/eph_jcg +38 -0
- data/lib/eph_jcg/argument.rb +37 -0
- data/lib/eph_jcg/coeffs.rb +478 -0
- data/lib/eph_jcg/constants.rb +18 -0
- data/lib/eph_jcg/ephemeris.rb +471 -0
- data/lib/eph_jcg/time_calculator.rb +75 -0
- data/lib/eph_jcg/version.rb +3 -0
- data/lib/eph_jcg.rb +15 -0
- metadata +106 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module EphJcg
|
|
2
|
+
JST_UTC_SEC = 32400 # JST - UTC (9 * 60 * 60 sec)
|
|
3
|
+
DIVS = [
|
|
4
|
+
"SUN_RA", "SUN_DEC","SUN_DIST",
|
|
5
|
+
"MOON_RA", "MOON_DEC", "MOON_HP",
|
|
6
|
+
"R", "EPS"
|
|
7
|
+
]
|
|
8
|
+
DELTA_T = {
|
|
9
|
+
2008 => 65, 2009 => 66, 2010 => 66, 2011 => 67, 2012 => 67,
|
|
10
|
+
2013 => 67, 2014 => 67, 2015 => 68, 2016 => 68
|
|
11
|
+
}
|
|
12
|
+
PI = 3.141592653589793238462 # 円周率
|
|
13
|
+
Y_MIN = DELTA_T.min { |a, b| a[0] <=> b[0] }[0]
|
|
14
|
+
Y_MAX = DELTA_T.max { |a, b| a[0] <=> b[0] }[0]
|
|
15
|
+
MSG_ERR_1 = "[ERROR] Format: YYYYMMDD or YYYYMMDDHHMMSS"
|
|
16
|
+
MSG_ERR_2 = "[ERROR] Invalid date-time!"
|
|
17
|
+
MSG_ERR_3 = "[ERROR] It should be between #{Y_MIN}0101090000 and #{Y_MAX + 1}0101085959."
|
|
18
|
+
end
|
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
module EphJcg
|
|
2
|
+
class Ephemeris
|
|
3
|
+
attr_reader :jst, :utc,
|
|
4
|
+
:sun_ra, :sun_dec, :sun_dist,
|
|
5
|
+
:moon_ra, :moon_dec, :moon_hp,
|
|
6
|
+
:r, :eps, :sun_h, :moon_h,
|
|
7
|
+
:sun_sd, :moon_sd,
|
|
8
|
+
:sun_lambda, :sun_beta,
|
|
9
|
+
:moon_lambda, :moon_beta,
|
|
10
|
+
:lambda_s_m
|
|
11
|
+
|
|
12
|
+
def initialize(jst)
|
|
13
|
+
@jst = jst
|
|
14
|
+
@utc = jst - JST_UTC_SEC
|
|
15
|
+
t = TimeCalculator.new(@utc)
|
|
16
|
+
t.calc
|
|
17
|
+
@year, @month, @day = t.year, t.month, t.day
|
|
18
|
+
@hour, @min, @sec = t.hour, t.min, t.sec
|
|
19
|
+
@t, @f, @dt, @tm, @tm_r = t.t, t.f, t.dt, t.tm, t.tm_r
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
#=========================================================================
|
|
23
|
+
# 計算(一括)
|
|
24
|
+
#=========================================================================
|
|
25
|
+
def calc_all
|
|
26
|
+
calc_sun_ra
|
|
27
|
+
calc_sun_dec
|
|
28
|
+
calc_sun_dist
|
|
29
|
+
calc_moon_ra
|
|
30
|
+
calc_moon_dec
|
|
31
|
+
calc_moon_hp
|
|
32
|
+
calc_r
|
|
33
|
+
calc_eps
|
|
34
|
+
@sun_h = calc_h(@f, @sun_ra, @r)
|
|
35
|
+
@moon_h = calc_h(@f, @moon_ra, @r)
|
|
36
|
+
@sun_sd = calc_sd_sun(@sun_dist)
|
|
37
|
+
@moon_sd = calc_sd_moon(@moon_hp)
|
|
38
|
+
@sun_lambda = calc_lambda(@sun_ra, @sun_dec, @eps)
|
|
39
|
+
@sun_beta = calc_beta(@sun_ra, @sun_dec, @eps)
|
|
40
|
+
@moon_lambda = calc_lambda(@moon_ra, @moon_dec, @eps)
|
|
41
|
+
@moon_beta = calc_beta(@moon_ra, @moon_dec, @eps)
|
|
42
|
+
@lambda_s_m = calc_lambda_sun_moon(@sun_lambda, @moon_lambda)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
#=========================================================================
|
|
46
|
+
# 計算 (SUN_RA)
|
|
47
|
+
#=========================================================================
|
|
48
|
+
def calc_sun_ra
|
|
49
|
+
@sun_ra = calc_cmn("SUN_RA", @year, @tm)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
#=========================================================================
|
|
53
|
+
# 計算 (SUN_DEC)
|
|
54
|
+
#=========================================================================
|
|
55
|
+
def calc_sun_dec
|
|
56
|
+
@sun_dec = calc_cmn("SUN_DEC", @year, @tm)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
#=========================================================================
|
|
60
|
+
# 計算 (SUN_DIST)
|
|
61
|
+
#=========================================================================
|
|
62
|
+
def calc_sun_dist
|
|
63
|
+
@sun_dist = calc_cmn("SUN_DIST", @year, @tm)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
#=========================================================================
|
|
67
|
+
# 計算 (MOON_RA)
|
|
68
|
+
#=========================================================================
|
|
69
|
+
def calc_moon_ra
|
|
70
|
+
@moon_ra = calc_cmn("MOON_RA", @year, @tm)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
#=========================================================================
|
|
74
|
+
# 計算 (MOON_DEC)
|
|
75
|
+
#=========================================================================
|
|
76
|
+
def calc_moon_dec
|
|
77
|
+
@moon_dec = calc_cmn("MOON_DEC", @year, @tm)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
#=========================================================================
|
|
81
|
+
# 計算 (MOON_HP)
|
|
82
|
+
#=========================================================================
|
|
83
|
+
def calc_moon_hp
|
|
84
|
+
@moon_hp = calc_cmn("MOON_HP", @year, @tm)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
#=========================================================================
|
|
88
|
+
# 計算 (R)
|
|
89
|
+
#=========================================================================
|
|
90
|
+
def calc_r
|
|
91
|
+
@r = calc_cmn("R", @year, @tm_r)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
#=========================================================================
|
|
95
|
+
# 計算 (EPS)
|
|
96
|
+
#=========================================================================
|
|
97
|
+
def calc_eps
|
|
98
|
+
@eps = calc_cmn("EPS", @year, @tm)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
#=========================================================================
|
|
102
|
+
# 計算 (SUN_H)
|
|
103
|
+
#=========================================================================
|
|
104
|
+
def calc_sun_h
|
|
105
|
+
calc_sun_ra
|
|
106
|
+
calc_r
|
|
107
|
+
@sun_h = calc_h(@f, @sun_ra, @r)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
#=========================================================================
|
|
111
|
+
# 計算 (MOON_H)
|
|
112
|
+
#=========================================================================
|
|
113
|
+
def calc_moon_h
|
|
114
|
+
calc_moon_ra
|
|
115
|
+
calc_r
|
|
116
|
+
@moon_h = calc_h(@f, @moon_ra, @r)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
#=========================================================================
|
|
120
|
+
# 計算 (SUN_SD)
|
|
121
|
+
#=========================================================================
|
|
122
|
+
def calc_sun_sd
|
|
123
|
+
calc_sun_dist
|
|
124
|
+
@sun_sd = calc_sd_sun(@sun_dist)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
#=========================================================================
|
|
128
|
+
# 計算 (MOON_SD)
|
|
129
|
+
#=========================================================================
|
|
130
|
+
def calc_moon_sd
|
|
131
|
+
calc_moon_hp
|
|
132
|
+
@moon_sd = calc_sd_moon(@moon_hp)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
#=========================================================================
|
|
136
|
+
# 計算 (SUN_LAMBDA)
|
|
137
|
+
#=========================================================================
|
|
138
|
+
def calc_sun_lambda
|
|
139
|
+
calc_sun_ra
|
|
140
|
+
calc_sun_dec
|
|
141
|
+
calc_eps
|
|
142
|
+
@sun_lambda = calc_lambda(@sun_ra, @sun_dec, @eps)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
#=========================================================================
|
|
146
|
+
# 計算 (SUN_BETA)
|
|
147
|
+
#=========================================================================
|
|
148
|
+
def calc_sun_beta
|
|
149
|
+
calc_sun_ra
|
|
150
|
+
calc_sun_dec
|
|
151
|
+
calc_eps
|
|
152
|
+
@sun_beta = calc_beta(@sun_ra, @sun_dec, @eps)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
#=========================================================================
|
|
156
|
+
# 計算 (MOON_LAMBDA)
|
|
157
|
+
#=========================================================================
|
|
158
|
+
def calc_moon_lambda
|
|
159
|
+
calc_moon_ra
|
|
160
|
+
calc_moon_dec
|
|
161
|
+
calc_eps
|
|
162
|
+
@moon_lambda = calc_lambda(@moon_ra, @moon_dec, @eps)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
#=========================================================================
|
|
166
|
+
# 計算 (MOON_BETA)
|
|
167
|
+
#=========================================================================
|
|
168
|
+
def calc_moon_beta
|
|
169
|
+
calc_moon_ra
|
|
170
|
+
calc_moon_dec
|
|
171
|
+
calc_eps
|
|
172
|
+
@moon_beta = calc_beta(@moon_ra, @moon_dec, @eps)
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
#=========================================================================
|
|
176
|
+
# 計算 (LAMBDA_S_M)
|
|
177
|
+
#=========================================================================
|
|
178
|
+
def calc_lambda_s_m
|
|
179
|
+
calc_sun_lambda
|
|
180
|
+
calc_moon_lambda
|
|
181
|
+
@lambda_s_m = calc_lambda_sun_moon(@sun_lambda, @moon_lambda)
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
#=========================================================================
|
|
185
|
+
# 99.999h -> 99h99m99s 変換
|
|
186
|
+
#
|
|
187
|
+
# @param: hour
|
|
188
|
+
# @return: "99 h 99 m 99.999 s"
|
|
189
|
+
#=========================================================================
|
|
190
|
+
def hour2hms(hour)
|
|
191
|
+
h = hour.to_i
|
|
192
|
+
h_r = hour - h
|
|
193
|
+
m = (h_r * 60).to_i
|
|
194
|
+
m_r = h_r * 60 - m
|
|
195
|
+
s = m_r * 60
|
|
196
|
+
return sprintf(" %3d h %02d m %06.3f s", h, m, s)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
#=========================================================================
|
|
200
|
+
# 99.999° -> 99°99′99″ 変換
|
|
201
|
+
#
|
|
202
|
+
# @param: deg
|
|
203
|
+
# @return: "99 ° 99 ′ 99.999 ″"
|
|
204
|
+
#=========================================================================
|
|
205
|
+
def deg2dms(deg)
|
|
206
|
+
pm = deg < 0 ? "-" : " "
|
|
207
|
+
deg *= -1 if deg < 0
|
|
208
|
+
d = deg.to_i
|
|
209
|
+
d_r = deg - d
|
|
210
|
+
m = (d_r * 60).to_i
|
|
211
|
+
m_r = d_r * 60 - m
|
|
212
|
+
s = m_r * 60
|
|
213
|
+
return sprintf("%4s ° %02d ′ %06.3f ″", "#{pm}#{d}", m, s)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
#=========================================================================
|
|
217
|
+
# 結果出力
|
|
218
|
+
#=========================================================================
|
|
219
|
+
def display_all
|
|
220
|
+
str = "[ JST: #{Time.at(@jst).strftime("%Y-%m-%d %H:%M:%S")},"
|
|
221
|
+
str << " UTC: #{Time.at(@utc).strftime("%Y-%m-%d %H:%M:%S")} ]\n"
|
|
222
|
+
str << sprintf(" SUN R.A. = %12.8f h", @sun_ra )
|
|
223
|
+
str << sprintf(" (= %s)\n", hour2hms(@sun_ra ))
|
|
224
|
+
str << sprintf(" SUN DEC. = %12.8f °", @sun_dec )
|
|
225
|
+
str << sprintf(" (= %s)\n", deg2dms(@sun_dec ))
|
|
226
|
+
str << sprintf(" SUN DIST. = %12.8f AU\n", @sun_dist )
|
|
227
|
+
str << sprintf(" SUN hG. = %12.8f h", @sun_h )
|
|
228
|
+
str << sprintf(" (= %s)\n", hour2hms(@sun_h ))
|
|
229
|
+
str << sprintf(" SUN S.D. = %12.8f ′", @sun_sd )
|
|
230
|
+
str << sprintf(" (= %s)\n", deg2dms(@sun_sd / 60.0 ))
|
|
231
|
+
str << sprintf(" MOON R.A. = %12.8f h", @moon_ra )
|
|
232
|
+
str << sprintf(" (= %s)\n", hour2hms(@moon_ra ))
|
|
233
|
+
str << sprintf(" MOON DEC. = %12.8f °", @moon_dec )
|
|
234
|
+
str << sprintf(" (= %s)\n", deg2dms(@moon_dec))
|
|
235
|
+
str << sprintf(" MOON H.P. = %12.8f °", @moon_hp )
|
|
236
|
+
str << sprintf(" (= %s)\n", deg2dms(@moon_hp ))
|
|
237
|
+
str << sprintf(" MOON hG. = %12.8f h", @moon_h )
|
|
238
|
+
str << sprintf(" (= %s)\n", hour2hms(@moon_h ))
|
|
239
|
+
str << sprintf(" MOON S.D. = %12.8f ′", @moon_sd )
|
|
240
|
+
str << sprintf(" (= %s)\n", deg2dms(@moon_sd / 60.0))
|
|
241
|
+
str << sprintf(" R = %12.8f h", @r )
|
|
242
|
+
str << sprintf(" (= %s)\n", hour2hms(@r ))
|
|
243
|
+
str << sprintf(" EPS. = %12.8f °", @eps )
|
|
244
|
+
str << sprintf(" (= %s)\n", deg2dms(@eps ))
|
|
245
|
+
str << " ---\n"
|
|
246
|
+
str << sprintf(" SUN LAMBDA =%13.8f °", @sun_lambda )
|
|
247
|
+
str << sprintf(" (=%s)\n", deg2dms(@sun_lambda ))
|
|
248
|
+
str << sprintf(" SUN BETA =%13.8f °", @sun_beta )
|
|
249
|
+
str << sprintf(" (=%s)\n", deg2dms(@sun_beta ))
|
|
250
|
+
str << sprintf(" MOON LAMBDA =%13.8f °", @moon_lambda )
|
|
251
|
+
str << sprintf(" (=%s)\n", deg2dms(@moon_lambda))
|
|
252
|
+
str << sprintf(" MOON BETA =%13.8f °", @moon_beta )
|
|
253
|
+
str << sprintf(" (=%s)\n", deg2dms(@moon_beta ))
|
|
254
|
+
str << sprintf(" DIFF LAMBDA =%13.8f °\n", @lambda_s_m )
|
|
255
|
+
puts str
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
private
|
|
259
|
+
|
|
260
|
+
#=========================================================================
|
|
261
|
+
# 共通計算
|
|
262
|
+
#
|
|
263
|
+
# * SUN_RA, SUN_DEC, SUN_DIST, MOON_RA, MOON_DEC, MOON_HP, R, EPS 用の計算
|
|
264
|
+
#
|
|
265
|
+
# @param: div (定数名)
|
|
266
|
+
# @param: year(年)
|
|
267
|
+
# @param: t (時刻引数)
|
|
268
|
+
# @return: val (計算結果)
|
|
269
|
+
#=========================================================================
|
|
270
|
+
def calc_cmn(div, year, t)
|
|
271
|
+
a, b, coeffs = get_coeffs(div, year, t)
|
|
272
|
+
theta = calc_theta(a, b, t)
|
|
273
|
+
val = calc_ft(theta, coeffs)
|
|
274
|
+
if div =~ /_RA$|^R$/
|
|
275
|
+
while val >= 24.0; val -= 24.0; end
|
|
276
|
+
while val <= 0.0; val += 24.0; end
|
|
277
|
+
end
|
|
278
|
+
return val
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
#=========================================================================
|
|
282
|
+
# 係数等の取得
|
|
283
|
+
#
|
|
284
|
+
# * 引数の文字列の定数配列から a, b, 係数配列を取得する。
|
|
285
|
+
#
|
|
286
|
+
# @param: div (定数名)
|
|
287
|
+
# @param: year(年)
|
|
288
|
+
# @param: t (時刻引数)
|
|
289
|
+
# @return: [a, b, 係数配列]
|
|
290
|
+
#=========================================================================
|
|
291
|
+
def get_coeffs(div, year, t)
|
|
292
|
+
a, b = 0, 0
|
|
293
|
+
coeffs = Array.new
|
|
294
|
+
Object.const_get("EphJcg::#{div}").each do |row|
|
|
295
|
+
next unless row[0] == year
|
|
296
|
+
if row[1][0] <= t.to_i && t.to_i <= row[1][1]
|
|
297
|
+
a, b = row[1]
|
|
298
|
+
coeffs = row[2]
|
|
299
|
+
break
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
return [a, b, coeffs]
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
#=========================================================================
|
|
306
|
+
# θ の計算
|
|
307
|
+
#
|
|
308
|
+
# * θ を次式により計算する。
|
|
309
|
+
# θ = cos^(-1)((2 * t - (a + b)) / (b - a))
|
|
310
|
+
# 但し、0°<= θ <= 180°
|
|
311
|
+
#
|
|
312
|
+
# @param: a (期間(開始))
|
|
313
|
+
# @param: b (期間(終了))
|
|
314
|
+
# @param: t (時刻引数)
|
|
315
|
+
# @return: theta(単位: °)
|
|
316
|
+
#=========================================================================
|
|
317
|
+
def calc_theta(a, b, t)
|
|
318
|
+
b = t if b < t # 年末のΔT秒分も計算可能とするための応急処置
|
|
319
|
+
theta = (2 * t - (a + b)) / (b - a).to_f
|
|
320
|
+
return Math.acos(theta) * 180 / PI
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
#=========================================================================
|
|
324
|
+
# 所要値の計算
|
|
325
|
+
#
|
|
326
|
+
# * θ, 係数配列から次式により所要値を計算する。
|
|
327
|
+
# f(t) = C_0 + C_1 * cos(θ) + C_2 * cos(2θ) + ... + C_N * cos(Nθ)
|
|
328
|
+
#
|
|
329
|
+
# @param: theta (θ)
|
|
330
|
+
# @param: coeffs(係数配列)
|
|
331
|
+
# @return: ft (所要値)
|
|
332
|
+
#=========================================================================
|
|
333
|
+
def calc_ft(theta, coeffs)
|
|
334
|
+
ft = 0.0
|
|
335
|
+
coeffs.each_with_index do |c, i|
|
|
336
|
+
ft += c * Math.cos(theta * i * PI / 180.0)
|
|
337
|
+
end
|
|
338
|
+
return ft
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
#=========================================================================
|
|
342
|
+
# グリニジ時角の計算
|
|
343
|
+
#
|
|
344
|
+
# * 次式によりグリニジ時角を計算する。
|
|
345
|
+
# h = E + UT
|
|
346
|
+
# (但し、E = R - R.A.)
|
|
347
|
+
#
|
|
348
|
+
# @param: R.A.(視赤経)
|
|
349
|
+
# @return: h (単位: h)
|
|
350
|
+
#=========================================================================
|
|
351
|
+
def calc_h(f, ra, r) # グリニジ時角の計算
|
|
352
|
+
return r - ra + f * 24
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
#=========================================================================
|
|
356
|
+
# 視半径(太陽)の計算
|
|
357
|
+
#
|
|
358
|
+
# * 次式により視半径を計算する。
|
|
359
|
+
# S.D.= 16.02 ′/ Dist.
|
|
360
|
+
#
|
|
361
|
+
# @param: Dist(地心距離(太陽))
|
|
362
|
+
# @return: sd (単位: ′)
|
|
363
|
+
#=========================================================================
|
|
364
|
+
def calc_sd_sun(sun_dist)
|
|
365
|
+
return 16.02 / sun_dist
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
#=========================================================================
|
|
369
|
+
# 視半径(月)の計算
|
|
370
|
+
#
|
|
371
|
+
# * 次式により視半径を計算する。
|
|
372
|
+
# S.D.= sin^(-1) (0.2725 * sin(H.P.))
|
|
373
|
+
#
|
|
374
|
+
# @param: H.P.(地平視差(月))
|
|
375
|
+
# @return: sd (単位: ′)
|
|
376
|
+
#=========================================================================
|
|
377
|
+
def calc_sd_moon(moon_hp)
|
|
378
|
+
sd = Math.asin(0.2725 * Math.sin(moon_hp * PI / 180.0))
|
|
379
|
+
return sd * 60.0 * 180.0 / PI
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
#=========================================================================
|
|
383
|
+
# 視黄経の計算
|
|
384
|
+
#
|
|
385
|
+
# * 次式により視黄経を計算する
|
|
386
|
+
# λ = arctan(sin δ sin ε + cos δ sin α cos ε / cos δ cos α)
|
|
387
|
+
# (α : 視赤経、δ : 視赤緯、 ε : 黄道傾斜角)
|
|
388
|
+
#
|
|
389
|
+
# @param: alpha (視赤経, R.A.)
|
|
390
|
+
# @param: delta (視赤緯, Dec.)
|
|
391
|
+
# @return: lambda(視黄経)
|
|
392
|
+
#=========================================================================
|
|
393
|
+
def calc_lambda(alpha, delta, eps)
|
|
394
|
+
alpha = alpha * 15 * PI / 180.0
|
|
395
|
+
delta = delta * PI / 180.0
|
|
396
|
+
eps = eps * PI / 180.0
|
|
397
|
+
lambda = Math.sin(delta) * Math.sin(eps) \
|
|
398
|
+
+ Math.cos(delta) * Math.sin(alpha) * Math.cos(eps)
|
|
399
|
+
lambda /= Math.cos(delta) * Math.cos(alpha)
|
|
400
|
+
lambda = Math.atan(lambda) * 180 / PI
|
|
401
|
+
lambda += 180.0 if lambda < 0
|
|
402
|
+
return lambda
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
#=========================================================================
|
|
406
|
+
# 視黄緯の計算
|
|
407
|
+
#
|
|
408
|
+
# * 次式により視黄経を計算する
|
|
409
|
+
# β = arcsin(sin δ cos ε − cos δ sin α sin ε)
|
|
410
|
+
# (α : 視赤経、δ : 視赤緯、 ε : 黄道傾斜角)
|
|
411
|
+
#
|
|
412
|
+
# @param: alpha(視赤経, R.A.)
|
|
413
|
+
# @param: delta(視赤緯, Dec.)
|
|
414
|
+
# @return: beta (視黄緯)
|
|
415
|
+
#=========================================================================
|
|
416
|
+
def calc_beta(alpha, delta, eps)
|
|
417
|
+
alpha = alpha * 15 * PI / 180.0
|
|
418
|
+
delta = delta * PI / 180.0
|
|
419
|
+
eps = eps * PI / 180.0
|
|
420
|
+
beta = Math.sin(delta) * Math.cos(eps) \
|
|
421
|
+
- Math.cos(delta) * Math.sin(alpha) * Math.sin(eps)
|
|
422
|
+
return Math.asin(beta) * 180 / PI
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
#=========================================================================
|
|
426
|
+
# 視黄経差(太陽 - 月)の計算
|
|
427
|
+
#
|
|
428
|
+
# * SUN_LAMBDA - MOON_LAMBDA
|
|
429
|
+
#
|
|
430
|
+
# @param: SUN LAMBDA
|
|
431
|
+
# @param: MOON LAMBDA
|
|
432
|
+
# @return: 視黄経差(太陽 - 月)
|
|
433
|
+
#=========================================================================
|
|
434
|
+
def calc_lambda_sun_moon(sun_lambda, moon_lambda)
|
|
435
|
+
return sun_lambda - moon_lambda
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
# #=========================================================================
|
|
439
|
+
# # 99.999h -> 99h99m99s 変換
|
|
440
|
+
# #
|
|
441
|
+
# # @param: hour
|
|
442
|
+
# # @return: "99 h 99 m 99.999 s"
|
|
443
|
+
# #=========================================================================
|
|
444
|
+
# def hour2hms(hour)
|
|
445
|
+
# h = hour.to_i
|
|
446
|
+
# h_r = hour - h
|
|
447
|
+
# m = (h_r * 60).to_i
|
|
448
|
+
# m_r = h_r * 60 - m
|
|
449
|
+
# s = m_r * 60
|
|
450
|
+
# return sprintf(" %3d h %02d m %06.3f s", h, m, s)
|
|
451
|
+
# end
|
|
452
|
+
|
|
453
|
+
# #=========================================================================
|
|
454
|
+
# # 99.999° -> 99°99′99″ 変換
|
|
455
|
+
# #
|
|
456
|
+
# # @param: deg
|
|
457
|
+
# # @return: "99 ° 99 ′ 99.999 ″"
|
|
458
|
+
# #=========================================================================
|
|
459
|
+
# def deg2dms(deg)
|
|
460
|
+
# pm = deg < 0 ? "-" : " "
|
|
461
|
+
# deg *= -1 if deg < 0
|
|
462
|
+
# d = deg.to_i
|
|
463
|
+
# d_r = deg - d
|
|
464
|
+
# m = (d_r * 60).to_i
|
|
465
|
+
# m_r = d_r * 60 - m
|
|
466
|
+
# s = m_r * 60
|
|
467
|
+
# return sprintf("%4s ° %02d ′ %06.3f ″", "#{pm}#{d}", m, s)
|
|
468
|
+
# end
|
|
469
|
+
end
|
|
470
|
+
end
|
|
471
|
+
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
module EphJcg
|
|
2
|
+
class TimeCalculator
|
|
3
|
+
attr_reader :year, :month, :day, :hour, :min, :sec,
|
|
4
|
+
:t, :f, :dt, :tm, :tm_r
|
|
5
|
+
|
|
6
|
+
def initialize(utc)
|
|
7
|
+
@utc = utc
|
|
8
|
+
tm = Time.at(utc)
|
|
9
|
+
@year, @month, @day = tm.year, tm.month, tm.day
|
|
10
|
+
@hour, @min, @sec = tm.hour, tm.min, tm.sec
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def calc
|
|
14
|
+
@t = calc_t
|
|
15
|
+
@f = calc_f
|
|
16
|
+
@dt = get_delta_t
|
|
17
|
+
@tm, @tm_r = calc_tm(@t, @f, @dt)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
#=========================================================================
|
|
23
|
+
# 通日 T の計算
|
|
24
|
+
#
|
|
25
|
+
# * 通日 T は1月0日を第0日とした通算日数で、次式により求める。
|
|
26
|
+
# T = 30 * P + Q * (S - Y) + P * (1 - Q) + 日
|
|
27
|
+
# 但し、
|
|
28
|
+
# P = 月 - 1, Q = [(月 + 7) / 10]
|
|
29
|
+
# Y = [(年 / 4) - [(年 / 4)] + 0.77]
|
|
30
|
+
# S = [P * 0.55 - 0.33]
|
|
31
|
+
# で、[] は整数部のみを抜き出すことを意味する。
|
|
32
|
+
#=========================================================================
|
|
33
|
+
def calc_t
|
|
34
|
+
p = @month - 1
|
|
35
|
+
q = ((@month + 7) / 10.0).to_i
|
|
36
|
+
y = ((@year / 4.0) - (@year / 4.0).to_i + 0.77).to_i
|
|
37
|
+
s = (p * 0.55 - 0.33).to_i
|
|
38
|
+
return 30 * p + q * (s - y) + p * (1 - q) + @day
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
#=========================================================================
|
|
42
|
+
# 世界時 UT(時・分・秒) の端数計算
|
|
43
|
+
#
|
|
44
|
+
# * 次式により求める。
|
|
45
|
+
# F = 時 / 24 + 分 / 1440 + 秒 / 86400
|
|
46
|
+
#=========================================================================
|
|
47
|
+
def calc_f
|
|
48
|
+
utc = Time.at(@utc)
|
|
49
|
+
return utc.hour / 24.0 + utc.min / 1440.0 + utc.sec / 86400.0
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
#=========================================================================
|
|
53
|
+
# ΔT(世界時 - 地球時)の取得
|
|
54
|
+
#
|
|
55
|
+
# * あらかじめ予測されている ΔT の値を取得る。
|
|
56
|
+
#=========================================================================
|
|
57
|
+
def get_delta_t
|
|
58
|
+
return DELTA_T[@year]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
#=========================================================================
|
|
62
|
+
# 計算用時刻引数 tm の計算
|
|
63
|
+
#
|
|
64
|
+
# * 次式により求める。
|
|
65
|
+
# (R 計算用は tm_r, その他は tm)
|
|
66
|
+
# tm = T + F + ΔT / 86400
|
|
67
|
+
# tm_r = T + F
|
|
68
|
+
#=========================================================================
|
|
69
|
+
def calc_tm(t, f, dt)
|
|
70
|
+
tm_r = t + f
|
|
71
|
+
tm = tm_r + dt / 86400.0
|
|
72
|
+
return [tm, tm_r]
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
data/lib/eph_jcg.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require "date"
|
|
2
|
+
require "eph_jcg/version"
|
|
3
|
+
require "eph_jcg/argument"
|
|
4
|
+
require "eph_jcg/coeffs"
|
|
5
|
+
require "eph_jcg/constants"
|
|
6
|
+
require "eph_jcg/ephemeris"
|
|
7
|
+
require "eph_jcg/time_calculator"
|
|
8
|
+
|
|
9
|
+
module EphJcg
|
|
10
|
+
def self.new(args = ARGV)
|
|
11
|
+
jst = EphJcg::Argument.new(args).get_jst
|
|
12
|
+
return if jst == 0
|
|
13
|
+
return EphJcg::Ephemeris.new(jst)
|
|
14
|
+
end
|
|
15
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: eph_jcg
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- komasaru
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-06-05 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.11'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.11'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
description: EphJcg is a ephemeris calculation tool by JCG method.
|
|
56
|
+
email:
|
|
57
|
+
- masaru@mk-mode.com
|
|
58
|
+
executables:
|
|
59
|
+
- eph_jcg
|
|
60
|
+
extensions: []
|
|
61
|
+
extra_rdoc_files: []
|
|
62
|
+
files:
|
|
63
|
+
- ".gitignore"
|
|
64
|
+
- ".rspec"
|
|
65
|
+
- ".travis.yml"
|
|
66
|
+
- Gemfile
|
|
67
|
+
- Guardfile
|
|
68
|
+
- LICENSE.txt
|
|
69
|
+
- README.md
|
|
70
|
+
- Rakefile
|
|
71
|
+
- bin/console
|
|
72
|
+
- bin/setup
|
|
73
|
+
- eph_jcg.gemspec
|
|
74
|
+
- exe/eph_jcg
|
|
75
|
+
- lib/eph_jcg.rb
|
|
76
|
+
- lib/eph_jcg/argument.rb
|
|
77
|
+
- lib/eph_jcg/coeffs.rb
|
|
78
|
+
- lib/eph_jcg/constants.rb
|
|
79
|
+
- lib/eph_jcg/ephemeris.rb
|
|
80
|
+
- lib/eph_jcg/time_calculator.rb
|
|
81
|
+
- lib/eph_jcg/version.rb
|
|
82
|
+
homepage: https://github.com/komasaru/EphJcg
|
|
83
|
+
licenses:
|
|
84
|
+
- MIT
|
|
85
|
+
metadata: {}
|
|
86
|
+
post_install_message:
|
|
87
|
+
rdoc_options: []
|
|
88
|
+
require_paths:
|
|
89
|
+
- lib
|
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - ">="
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '0'
|
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
|
+
requirements:
|
|
97
|
+
- - ">="
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: '0'
|
|
100
|
+
requirements: []
|
|
101
|
+
rubyforge_project:
|
|
102
|
+
rubygems_version: 2.6.4
|
|
103
|
+
signing_key:
|
|
104
|
+
specification_version: 4
|
|
105
|
+
summary: Ephemeris calculation tool by JCG method.
|
|
106
|
+
test_files: []
|