eph_bpn 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4d07b61557d0bb30302432031cd6526f1f82976
4
- data.tar.gz: d192b7b989e391566db05373926a3b66e0bd018f
3
+ metadata.gz: ce2a6c63fbd4c5e300b97012910cc1af06e96424
4
+ data.tar.gz: f6215f760899fcae728d33480d286bca5940991a
5
5
  SHA512:
6
- metadata.gz: 2928724a4faa216e325f8d01984f5a3d3af3b56205d43e0383677852c7fb5a3be9f91751fb4674da812932eb15770ed67c81194a1273b26277c3d0f4da81d0c6
7
- data.tar.gz: be8ebf09bad30b1497b1849e87b0add08134537cf8ee3e405dcdc4585176a37b5a7e968e0006e68a4fa54ff7b5198d766722e7622f23425a6e5c0dc1e815f403
6
+ metadata.gz: c9bdb24ffe144f3f937b4a8d549a800de8bd07cffd5fd35ec3b41b045d7d05a6701674af21cd5b827b686eca230071a5e21d4d355ca954403d6c8b96883c9247
7
+ data.tar.gz: 972c9eaefaddc8a2644066954235395eac478254a7f9b6557f246e3b987f166d8a997e85f45a610a57ca2566cb92507903c76052e3f111cc9f7878ef7de373a0
data/README.md CHANGED
@@ -35,20 +35,39 @@ Or install it yourself as:
35
35
 
36
36
  ### Calculation
37
37
 
38
- pos_g = [-0.50787065, 0.80728228, 0.34996714] # GCRS Coordinate
39
- pos_b = e.apply_bias(pos_g) # Apply Bias
40
- pos_p = e.apply_prec(pos_b) # Apply Precession
41
- pos_n = e.apply_nut(pos_p) # Apply Nutation
42
- pos_bp = e.apply_bias_prec(pos_g) # Apply Bias + Precession
43
- puts "TDB: #{e.tdb}" #=> TDB: 2016-07-23 00:00:00 +0000
44
- puts " JD: #{e.jd}" #=> JD: 2457592.5
45
- puts " JC: #{e.jc}" #=> JC: 0.16557152635181382
46
- puts "EPS: #{e.eps}" #=> EPS: 0.40905500411767176
47
- p pos_g #=> [-0.50787065, 0.80728228, 0.34996714]
48
- p pos_b #=> [-0.507870315369686, 0.8072824634004779, 0.34996720255697145]
49
- p pos_p #=> [-0.5114180771311418, 0.8053955471104202, 0.34914730256926324]
50
- p pos_n #=> [-0.5114180757959449, 0.8053955495119587, 0.34914729898526137]
51
- p pos_bp #=> [-0.5114184398598124, 0.805395337986056, 0.3491472536550768]
38
+ pos_g = [-0.50787065, 0.80728228, 0.34996714] # GCRS Coordinate
39
+ pos_b = e.apply_bias(pos_g) # Apply Bias
40
+ pos_bp = e.apply_bias_prec(pos_g) # Apply Bias & Precession
41
+ pos_bpn = e.apply_bias_prec_nut(pos_g) # Apply Bias & Precession & Nutation
42
+ pos_p = e.apply_prec(pos_b) # Apply Precession
43
+ pos_pn = e.apply_prec_nut(pos_b) # Apply Precession & Nutation
44
+ pos_n = e.apply_nut(pos_p) # Apply Nutation
45
+ puts "TDB: #{e.tdb}" #=> TDB: 2016-07-23 00:00:00 +0000
46
+ puts " JD: #{e.jd}" #=> JD: 2457592.5
47
+ puts " JC: #{e.jc}" #=> JC: 0.16557152635181382
48
+ puts "EPS: #{e.eps}" #=> EPS: 0.40905500411767176
49
+ p e.r_bias # Rotation matrix for Bias
50
+ p e.r_bias_prec # Rotation matrix for Bias & Precession
51
+ p e.r_bias_prec_nut # Rotation matrix for Bias & Precession & Nutation
52
+ p e.r_prec # Rotation matrix for Precession
53
+ p e.r_prec_nut # Rotation matrix for Precession & Nutation
54
+ p e.r_nut # Rotation matrix for Nutation
55
+ puts "SRC: #{pos_g}" #=> [-0.50787065, 0.80728228, 0.34996714]
56
+ puts " B: #{pos_b}" #=> [-0.507870315369686, 0.8072824634004779, 0.34996720255697145]
57
+ puts " BP: #{pos_bp}" #=> [-0.5114184398598124, 0.805395337986056, 0.3491472536550768]
58
+ puts "BPN: #{pos_bpn}" #=> [-0.5114038678325663, 0.8054186649898355, 0.3491147860877318]
59
+ puts " P: #{pos_p}" #=> [-0.5114180771311418, 0.8053955471104202, 0.34914730256926324]
60
+ puts " PN: #{pos_pn}" #=> [-0.5114035051003876, 0.8054188741108519, 0.34911483499021656]
61
+ puts " N: #{pos_n}" #=> [-0.5114035051003876, 0.8054188741108514, 0.34911483499021656]
62
+
63
+ About alias:
64
+
65
+ * `apply_bias` => apply_b`
66
+ * `apply_bias_prec` => apply_bp`
67
+ * `apply_bias_prec_nut` => apply_bpn`
68
+ * `apply_prec` => apply_p`
69
+ * `apply_prec_nut` => apply_pn`
70
+ * `apply_nut` => apply_n`
52
71
 
53
72
  ## Development
54
73
 
@@ -3,22 +3,28 @@
3
3
  require "eph_bpn"
4
4
 
5
5
  e = EphBpn.new(ARGV[0])
6
- pos_g = [-0.50787065, 0.80728228, 0.34996714] # GCRS Coordinate
7
- pos_b = e.apply_bias(pos_g) # Apply Bias
8
- pos_p = e.apply_prec(pos_b) # Apply Precession
9
- pos_n = e.apply_nut(pos_p) # Apply Nutation
10
- pos_bp = e.apply_bias_prec(pos_g) # Apply Bias + Precession
11
- puts "TDB: #{e.tdb}" #=> TDB: 2016-07-23 00:00:00 +0000
12
- puts " JD: #{e.jd}" #=> JD: 2457592.5
13
- puts " JC: #{e.jc}" #=> JC: 0.16557152635181382
14
- puts "EPS: #{e.eps}" #=> EPS: 0.40905500411767176
15
- p e.r_bias # Rotation matrix for Bias
16
- p e.r_prec # Rotation matrix for Precession
17
- p e.r_nut # Rotation matrix for Nutation
18
- p e.r_bias_prec # Rotation matrix for Bias & precession
19
- p pos_g #=> [-0.50787065, 0.80728228, 0.34996714]
20
- p pos_b #=> [-0.507870315369686, 0.8072824634004779, 0.34996720255697145]
21
- p pos_p #=> [-0.5114180771311418, 0.8053955471104202, 0.34914730256926324]
22
- p pos_n #=> [-0.5114180757959449, 0.8053955495119587, 0.34914729898526137]
23
- p pos_bp #=> [-0.5114184398598124, 0.805395337986056, 0.3491472536550768]
6
+ pos_g = [-0.50787065, 0.80728228, 0.34996714] # GCRS Coordinate
7
+ pos_b = e.apply_bias(pos_g) # Apply Bias
8
+ pos_bp = e.apply_bias_prec(pos_g) # Apply Bias & Precession
9
+ pos_bpn = e.apply_bias_prec_nut(pos_g) # Apply Bias & Precession & Nutation
10
+ pos_p = e.apply_prec(pos_b) # Apply Precession
11
+ pos_pn = e.apply_prec_nut(pos_b) # Apply Precession & Nutation
12
+ pos_n = e.apply_nut(pos_p) # Apply Nutation
13
+ puts "TDB: #{e.tdb}" #=> TDB: 2016-07-23 00:00:00 +0000
14
+ puts " JD: #{e.jd}" #=> JD: 2457592.5
15
+ puts " JC: #{e.jc}" #=> JC: 0.16557152635181382
16
+ puts "EPS: #{e.eps}" #=> EPS: 0.40905500411767176
17
+ p e.r_bias # Rotation matrix for Bias
18
+ p e.r_bias_prec # Rotation matrix for Bias & Precession
19
+ p e.r_bias_prec_nut # Rotation matrix for Bias & Precession & Nutation
20
+ p e.r_prec # Rotation matrix for Precession
21
+ p e.r_prec_nut # Rotation matrix for Precession & Nutation
22
+ p e.r_nut # Rotation matrix for Nutation
23
+ puts "SRC: #{pos_g}" #=> [-0.50787065, 0.80728228, 0.34996714]
24
+ puts " B: #{pos_b}" #=> [-0.507870315369686, 0.8072824634004779, 0.34996720255697145]
25
+ puts " BP: #{pos_bp}" #=> [-0.5114184398598124, 0.805395337986056, 0.3491472536550768]
26
+ puts "BPN: #{pos_bpn}" #=> [-0.5114038678325663, 0.8054186649898355, 0.3491147860877318]
27
+ puts " P: #{pos_p}" #=> [-0.5114180771311418, 0.8053955471104202, 0.34914730256926324]
28
+ puts " PN: #{pos_pn}" #=> [-0.5114035051003876, 0.8054188741108519, 0.34911483499021656]
29
+ puts " N: #{pos_n}" #=> [-0.5114035051003876, 0.8054188741108514, 0.34911483499021656]
24
30
 
@@ -116,6 +116,54 @@ module EphBpn
116
116
  raise
117
117
  end
118
118
 
119
+ #=========================================================================
120
+ # Bias + Precession 変換行列
121
+ #
122
+ # * IAU 2006 (Fukushima-Williams 4-angle formulation) 理論
123
+ #
124
+ # @param: <none>
125
+ # @return: r (変換行列)
126
+ #=========================================================================
127
+ def comp_r_bias_prec
128
+ gamma = comp_gamma_bp
129
+ phi = comp_phi_bp
130
+ psi = comp_psi_bp
131
+ r = r_z(gamma)
132
+ r = r_x(phi, r)
133
+ r = r_z(-psi, r)
134
+ r = r_x(-@eps, r)
135
+ return r
136
+ rescue => e
137
+ raise
138
+ end
139
+
140
+ #=========================================================================
141
+ # Bias + Precession + Nutation 変換行列
142
+ #
143
+ # * IAU 2006 (Fukushima-Williams 4-angle formulation) 理論
144
+ #
145
+ # @param: <none>
146
+ # @return: r (変換行列)
147
+ #=========================================================================
148
+ def comp_r_bias_prec_nut
149
+ gamma = comp_gamma_bp
150
+ phi = comp_phi_bp
151
+ psi = comp_psi_bp
152
+ fj2 = -2.7774e-6 * @jc
153
+ dpsi_ls, deps_ls = compute_lunisolar
154
+ dpsi_pl, deps_pl = compute_planetary
155
+ dpsi, deps = dpsi_ls + dpsi_pl, deps_ls + deps_pl
156
+ dpsi += dpsi * (0.4697e-6 + fj2)
157
+ deps += deps * fj2
158
+ r = r_z(gamma)
159
+ r = r_x(phi, r)
160
+ r = r_z(-psi - dpsi, r)
161
+ r = r_x(-@eps - deps, r)
162
+ return r
163
+ rescue => e
164
+ raise
165
+ end
166
+
119
167
  #=========================================================================
120
168
  # precession(歳差)変換行列(J2000.0 用)
121
169
  #
@@ -142,25 +190,9 @@ module EphBpn
142
190
  # @return: r (変換行列)
143
191
  #=========================================================================
144
192
  def comp_r_prec
145
- gamma = ((10.556403 + \
146
- (0.4932044 + \
147
- (-0.00031238 + \
148
- (-0.000002788 + \
149
- (0.0000000260) \
150
- * @jc) * @jc) * @jc) * @jc) * @jc) * Const::AS2R
151
- phi = (84381.406000 + \
152
- ( -46.811015 + \
153
- ( 0.0511269 + \
154
- ( 0.00053289 + \
155
- ( -0.000000440 + \
156
- ( -0.0000000176) \
157
- * @jc) * @jc) * @jc) * @jc) * @jc) * Const::AS2R
158
- psi = (( 5038.481507 + \
159
- ( 1.5584176 + \
160
- ( -0.00018522 + \
161
- ( -0.000026452 + \
162
- ( -0.0000000148) \
163
- * @jc) * @jc) * @jc) * @jc) * @jc) * Const::AS2R
193
+ gamma = comp_gamma_p
194
+ phi = comp_phi_p
195
+ psi = comp_psi_p
164
196
  r = r_z(gamma)
165
197
  r = r_x(phi, r)
166
198
  r = r_z(-psi, r)
@@ -171,39 +203,27 @@ module EphBpn
171
203
  end
172
204
 
173
205
  #=========================================================================
174
- # Bias + Precession 変換行列
206
+ # Precession + Nutation 変換行列
175
207
  #
176
- # * IAU 2006 (Fukushima-Williams 4-angle formulation) 理論
208
+ # * IAU 2000A nutation with adjustments to match the IAU 2006 precession.
177
209
  #
178
210
  # @param: <none>
179
211
  # @return: r (変換行列)
180
212
  #=========================================================================
181
- def comp_r_bias_prec
182
- gamma = (-0.052928 + \
183
- (10.556378 + \
184
- ( 0.4932044 + \
185
- (-0.00031238 + \
186
- (-0.000002788 + \
187
- ( 0.0000000260) \
188
- * @jc) * @jc) * @jc) * @jc) * @jc) * Const::AS2R
189
- phi = (84381.412819 + \
190
- ( -46.811016 + \
191
- ( 0.0511268 + \
192
- ( 0.00053289 + \
193
- ( -0.000000440 + \
194
- ( -0.0000000176) \
195
- * @jc) * @jc) * @jc) * @jc) * @jc) * Const::AS2R
196
- psi = ( -0.041775 + \
197
- (5038.481484 + \
198
- ( 1.5584175 + \
199
- ( -0.00018522 + \
200
- ( -0.000026452 + \
201
- ( -0.0000000148) \
202
- * @jc) * @jc) * @jc) * @jc) * @jc) * Const::AS2R
213
+ def comp_r_prec_nut
214
+ gamma = comp_gamma_p
215
+ phi = comp_phi_p
216
+ psi = comp_psi_p
217
+ fj2 = -2.7774e-6 * @jc
218
+ dpsi_ls, deps_ls = compute_lunisolar
219
+ dpsi_pl, deps_pl = compute_planetary
220
+ dpsi, deps = dpsi_ls + dpsi_pl, deps_ls + deps_pl
221
+ dpsi += dpsi * (0.4697e-6 + fj2)
222
+ deps += deps * fj2
203
223
  r = r_z(gamma)
204
- r = r_x(phi, r)
205
- r = r_z(-psi, r)
206
- r = r_x(-@eps, r)
224
+ r = r_x(phi, r)
225
+ r = r_z(-psi - dpsi, r)
226
+ r = r_x(-@eps - deps, r)
207
227
  return r
208
228
  rescue => e
209
229
  raise
@@ -232,6 +252,112 @@ module EphBpn
232
252
  raise
233
253
  end
234
254
 
255
+ #=========================================================================
256
+ # 歳差変換行列用 gamma 計算
257
+ #
258
+ # @param: <none>
259
+ # @return: gamma
260
+ #=========================================================================
261
+ def comp_gamma_p
262
+ return ((10.556403 + \
263
+ ( 0.4932044 + \
264
+ (-0.00031238 + \
265
+ (-0.000002788 + \
266
+ ( 0.0000000260) \
267
+ * @jc) * @jc) * @jc) * @jc) * @jc) * Const::AS2R
268
+ rescue => e
269
+ raise
270
+ end
271
+
272
+ #=========================================================================
273
+ # 歳差変換行列用 phi 計算
274
+ #
275
+ # @param: <none>
276
+ # @return: phi
277
+ #=========================================================================
278
+ def comp_phi_p
279
+ return (84381.406000 + \
280
+ ( -46.811015 + \
281
+ ( 0.0511269 + \
282
+ ( 0.00053289 + \
283
+ ( -0.000000440 + \
284
+ ( -0.0000000176) \
285
+ * @jc) * @jc) * @jc) * @jc) * @jc) * Const::AS2R
286
+ rescue => e
287
+ raise
288
+ end
289
+
290
+ #=========================================================================
291
+ # 歳差変換行列用 psi 計算
292
+ #
293
+ # @param: <none>
294
+ # @return: psi
295
+ #=========================================================================
296
+ def comp_psi_p
297
+ return (( 5038.481507 + \
298
+ ( 1.5584176 + \
299
+ ( -0.00018522 + \
300
+ ( -0.000026452 + \
301
+ ( -0.0000000148) \
302
+ * @jc) * @jc) * @jc) * @jc) * @jc) * Const::AS2R
303
+ rescue => e
304
+ raise
305
+ end
306
+
307
+ #=========================================================================
308
+ # バイアス&歳差変換行列用 gamma 計算
309
+ #
310
+ # @param: <none>
311
+ # @return: gamma
312
+ #=========================================================================
313
+ def comp_gamma_bp
314
+ gamma = (-0.052928 + \
315
+ (10.556378 + \
316
+ ( 0.4932044 + \
317
+ (-0.00031238 + \
318
+ (-0.000002788 + \
319
+ ( 0.0000000260) \
320
+ * @jc) * @jc) * @jc) * @jc) * @jc) * Const::AS2R
321
+ rescue => e
322
+ raise
323
+ end
324
+
325
+ #=========================================================================
326
+ # バイアス&歳差変換行列用 phi 計算
327
+ #
328
+ # @param: <none>
329
+ # @return: phi
330
+ #=========================================================================
331
+ def comp_phi_bp
332
+ phi = (84381.412819 + \
333
+ ( -46.811016 + \
334
+ ( 0.0511268 + \
335
+ ( 0.00053289 + \
336
+ ( -0.000000440 + \
337
+ ( -0.0000000176) \
338
+ * @jc) * @jc) * @jc) * @jc) * @jc) * Const::AS2R
339
+ rescue => e
340
+ raise
341
+ end
342
+
343
+ #=========================================================================
344
+ # バイアス&歳差変換行列用 psi 計算
345
+ #
346
+ # @param: <none>
347
+ # @return: psi
348
+ #=========================================================================
349
+ def comp_psi_bp
350
+ psi = ( -0.041775 + \
351
+ (5038.481484 + \
352
+ ( 1.5584175 + \
353
+ ( -0.00018522 + \
354
+ ( -0.000026452 + \
355
+ ( -0.0000000148) \
356
+ * @jc) * @jc) * @jc) * @jc) * @jc) * Const::AS2R
357
+ rescue => e
358
+ raise
359
+ end
360
+
235
361
  #=========================================================================
236
362
  # 日月章動(luni-solar nutation)の計算
237
363
  #
@@ -1,18 +1,22 @@
1
1
  module EphBpn
2
+
2
3
  class Ephemeris
3
4
  attr_reader :tdb, :jd, :jc, :eps,
4
- :r_bias, :r_prec, :r_nut, :r_bias_prec
5
+ :r_bias, :r_bias_prec, :r_bias_prec_nut,
6
+ :r_prec, :r_prec_nut, :r_nut
5
7
  include Compute
6
8
 
7
9
  def initialize(tdb)
8
- @tdb = tdb # 太陽系力学時
9
- @jd = gc2jd(@tdb) # TDB -> JD(ユリウス日)
10
- @jc = jd2jc(@jd) # ユリウス世紀
11
- @eps = compute_obliquity(@jc) # 平均黄道傾斜角
12
- @r_bias = comp_r_bias # 回転行列(バイアス)
13
- @r_prec = comp_r_prec # 回転行列(歳差)
14
- @r_nut = comp_r_nut # 回転行列(章動)
15
- @r_bias_prec = comp_r_bias_prec # 回転行列(バイアス&歳差)
10
+ @tdb = tdb # 太陽系力学時
11
+ @jd = gc2jd(@tdb) # TDB -> JD(ユリウス日)
12
+ @jc = jd2jc(@jd) # ユリウス世紀
13
+ @eps = compute_obliquity(@jc) # 平均黄道傾斜角
14
+ @r_bias = comp_r_bias # 回転行列(バイアス)
15
+ @r_bias_prec = comp_r_bias_prec # 回転行列(バイアス&歳差)
16
+ @r_bias_prec_nut = comp_r_bias_prec_nut # 回転行列(バイアス&歳差&章動)
17
+ @r_prec = comp_r_prec # 回転行列(歳差)
18
+ @r_prec_nut = comp_r_prec_nut # 回転行列(歳差&章動)
19
+ @r_nut = comp_r_nut # 回転行列(章動)
16
20
  end
17
21
 
18
22
  #=========================================================================
@@ -24,6 +28,29 @@ module EphBpn
24
28
  def apply_bias(pos)
25
29
  return rotate(@r_bias, pos)
26
30
  end
31
+ alias :apply_b :apply_bias
32
+
33
+ #=========================================================================
34
+ # Bias + Precession(歳差) 適用
35
+ #
36
+ # @param: pos (適用前直角座標)
37
+ # @return: pos_p (適用後直角座標)
38
+ #=========================================================================
39
+ def apply_bias_prec(pos)
40
+ return rotate(@r_bias_prec, pos)
41
+ end
42
+ alias :apply_bp :apply_bias_prec
43
+
44
+ #=========================================================================
45
+ # Bias + Precession(歳差) + Nutation(章動) 適用
46
+ #
47
+ # @param: pos (適用前直角座標)
48
+ # @return: pos_p (適用後直角座標)
49
+ #=========================================================================
50
+ def apply_bias_prec_nut(pos)
51
+ return rotate(@r_bias_prec_nut, pos)
52
+ end
53
+ alias :apply_bpn :apply_bias_prec_nut
27
54
 
28
55
  #=========================================================================
29
56
  # Precession(歳差) 適用
@@ -34,26 +61,29 @@ module EphBpn
34
61
  def apply_prec(pos)
35
62
  return rotate(@r_prec, pos)
36
63
  end
64
+ alias :apply_p :apply_prec
37
65
 
38
66
  #=========================================================================
39
- # Nutation(章動) 適用
67
+ # Precession(歳差) + Nutation(章動) 適用
40
68
  #
41
69
  # @param: pos (適用前直角座標)
42
- # @return: pos_n (適用後直角座標)
70
+ # @return: pos_p (適用後直角座標)
43
71
  #=========================================================================
44
- def apply_nut(pos)
45
- return rotate(@r_nut, pos)
72
+ def apply_prec_nut(pos)
73
+ return rotate(@r_prec_nut, pos)
46
74
  end
75
+ alias :apply_pn :apply_prec_nut
47
76
 
48
77
  #=========================================================================
49
- # Bias + Precession(歳差) 適用
78
+ # Nutation(章動) 適用
50
79
  #
51
80
  # @param: pos (適用前直角座標)
52
- # @return: pos_p (適用後直角座標)
81
+ # @return: pos_n (適用後直角座標)
53
82
  #=========================================================================
54
- def apply_bias_prec(pos)
55
- return rotate(@r_bias_prec, pos) # IAU 2006 (Fukushima-Williams) 理論
83
+ def apply_nut(pos)
84
+ return rotate(@r_nut, pos)
56
85
  end
86
+ alias :apply_n :apply_nut
57
87
  end
58
88
  end
59
89
 
@@ -1,3 +1,3 @@
1
1
  module EphBpn
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eph_bpn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - komasaru
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-06 00:00:00.000000000 Z
11
+ date: 2016-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler