class EphJcg::Ephemeris
Attributes
eps[R]
jst[R]
lambda_s_m[R]
moon_beta[R]
moon_dec[R]
moon_h[R]
moon_hp[R]
moon_lambda[R]
moon_ra[R]
moon_sd[R]
r[R]
sun_beta[R]
sun_dec[R]
sun_dist[R]
sun_h[R]
sun_lambda[R]
sun_ra[R]
sun_sd[R]
utc[R]
Public Class Methods
new(jst)
click to toggle source
# File lib/eph_jcg/ephemeris.rb, line 12 def initialize(jst) @jst = jst @utc = jst - JST_UTC_SEC t = TimeCalculator.new(@utc) t.calc @year, @month, @day = t.year, t.month, t.day @hour, @min, @sec = t.hour, t.min, t.sec @t, @f, @dt, @tm, @tm_r = t.t, t.f, t.dt, t.tm, t.tm_r end
Public Instance Methods
calc_all()
click to toggle source
¶ ↑
計算(一括)
¶ ↑
# File lib/eph_jcg/ephemeris.rb, line 25 def calc_all calc_sun_ra calc_sun_dec calc_sun_dist calc_moon_ra calc_moon_dec calc_moon_hp calc_r calc_eps @sun_h = calc_h(@f, @sun_ra, @r) @moon_h = calc_h(@f, @moon_ra, @r) @sun_sd = calc_sd_sun(@sun_dist) @moon_sd = calc_sd_moon(@moon_hp) @sun_lambda = calc_lambda(@sun_ra, @sun_dec, @eps) @sun_beta = calc_beta(@sun_ra, @sun_dec, @eps) @moon_lambda = calc_lambda(@moon_ra, @moon_dec, @eps) @moon_beta = calc_beta(@moon_ra, @moon_dec, @eps) @lambda_s_m = calc_lambda_sun_moon(@sun_lambda, @moon_lambda) end
calc_eps()
click to toggle source
calc_lambda_s_m()
click to toggle source
calc_moon_beta()
click to toggle source
calc_moon_dec()
click to toggle source
calc_moon_h()
click to toggle source
calc_moon_hp()
click to toggle source
calc_moon_lambda()
click to toggle source
calc_moon_ra()
click to toggle source
calc_moon_sd()
click to toggle source
calc_r()
click to toggle source
calc_sun_beta()
click to toggle source
calc_sun_dec()
click to toggle source
calc_sun_dist()
click to toggle source
calc_sun_h()
click to toggle source
calc_sun_lambda()
click to toggle source
calc_sun_ra()
click to toggle source
calc_sun_sd()
click to toggle source
deg2dms(deg)
click to toggle source
¶ ↑
99.999° -> 99°99′99″ 変換 @param: deg @return: "99 ° 99 ′ 99.999 ″"
¶ ↑
# File lib/eph_jcg/ephemeris.rb, line 205 def deg2dms(deg) pm = deg < 0 ? "-" : " " deg *= -1 if deg < 0 d = deg.to_i d_r = deg - d m = (d_r * 60).to_i m_r = d_r * 60 - m s = m_r * 60 return sprintf("%4s ° %02d ′ %06.3f ″", "#{pm}#{d}", m, s) end
display_all()
click to toggle source
¶ ↑
結果出力
¶ ↑
# File lib/eph_jcg/ephemeris.rb, line 219 def display_all str = "[ JST: #{Time.at(@jst).strftime("%Y-%m-%d %H:%M:%S")}," str << " UTC: #{Time.at(@utc).strftime("%Y-%m-%d %H:%M:%S")} ]\n" str << sprintf(" SUN R.A. = %12.8f h", @sun_ra ) str << sprintf(" (= %s)\n", hour2hms(@sun_ra )) str << sprintf(" SUN DEC. = %12.8f °", @sun_dec ) str << sprintf(" (= %s)\n", deg2dms(@sun_dec )) str << sprintf(" SUN DIST. = %12.8f AU\n", @sun_dist ) str << sprintf(" SUN hG. = %12.8f h", @sun_h ) str << sprintf(" (= %s)\n", hour2hms(@sun_h )) str << sprintf(" SUN S.D. = %12.8f ′", @sun_sd ) str << sprintf(" (= %s)\n", deg2dms(@sun_sd / 60.0 )) str << sprintf(" MOON R.A. = %12.8f h", @moon_ra ) str << sprintf(" (= %s)\n", hour2hms(@moon_ra )) str << sprintf(" MOON DEC. = %12.8f °", @moon_dec ) str << sprintf(" (= %s)\n", deg2dms(@moon_dec)) str << sprintf(" MOON H.P. = %12.8f °", @moon_hp ) str << sprintf(" (= %s)\n", deg2dms(@moon_hp )) str << sprintf(" MOON hG. = %12.8f h", @moon_h ) str << sprintf(" (= %s)\n", hour2hms(@moon_h )) str << sprintf(" MOON S.D. = %12.8f ′", @moon_sd ) str << sprintf(" (= %s)\n", deg2dms(@moon_sd / 60.0)) str << sprintf(" R = %12.8f h", @r ) str << sprintf(" (= %s)\n", hour2hms(@r )) str << sprintf(" EPS. = %12.8f °", @eps ) str << sprintf(" (= %s)\n", deg2dms(@eps )) str << " ---\n" str << sprintf(" SUN LAMBDA =%13.8f °", @sun_lambda ) str << sprintf(" (=%s)\n", deg2dms(@sun_lambda )) str << sprintf(" SUN BETA =%13.8f °", @sun_beta ) str << sprintf(" (=%s)\n", deg2dms(@sun_beta )) str << sprintf(" MOON LAMBDA =%13.8f °", @moon_lambda ) str << sprintf(" (=%s)\n", deg2dms(@moon_lambda)) str << sprintf(" MOON BETA =%13.8f °", @moon_beta ) str << sprintf(" (=%s)\n", deg2dms(@moon_beta )) str << sprintf(" DIFF LAMBDA =%13.8f °\n", @lambda_s_m ) puts str end
hour2hms(hour)
click to toggle source
Private Instance Methods
calc_beta(alpha, delta, eps)
click to toggle source
¶ ↑
視黄緯の計算 * 次式により視黄経を計算する β = arcsin(sin δ cos ε − cos δ sin α sin ε) (α : 視赤経、δ : 視赤緯、 ε : 黄道傾斜角) @param: alpha(視赤経, R.A.) @param: delta(視赤緯, Dec.) @return: beta (視黄緯)
¶ ↑
# File lib/eph_jcg/ephemeris.rb, line 418 def calc_beta(alpha, delta, eps) alpha = alpha * 15 * PI / 180.0 delta = delta * PI / 180.0 eps = eps * PI / 180.0 beta = Math.sin(delta) * Math.cos(eps) \ - Math.cos(delta) * Math.sin(alpha) * Math.sin(eps) return Math.asin(beta) * 180 / PI end
calc_cmn(div, year, t)
click to toggle source
¶ ↑
共通計算 * SUN_RA, SUN_DEC, SUN_DIST, MOON_RA, MOON_DEC, MOON_HP, R, EPS 用の計算 @param: div (定数名) @param: year(年) @param: t (時刻引数) @return: val (計算結果)
¶ ↑
# File lib/eph_jcg/ephemeris.rb, line 270 def calc_cmn(div, year, t) a, b, coeffs = get_coeffs(div, year, t) theta = calc_theta(a, b, t) val = calc_ft(theta, coeffs) if div =~ /_RA$|^R$/ while val >= 24.0; val -= 24.0; end while val <= 0.0; val += 24.0; end end return val end
calc_ft(theta, coeffs)
click to toggle source
¶ ↑
所要値の計算 * θ, 係数配列から次式により所要値を計算する。 f(t) = C_0 + C_1 * cos(θ) + C_2 * cos(2θ) + ... + C_N * cos(Nθ) @param: theta (θ) @param: coeffs(係数配列) @return: ft (所要値)
¶ ↑
# File lib/eph_jcg/ephemeris.rb, line 335 def calc_ft(theta, coeffs) ft = 0.0 coeffs.each_with_index do |c, i| ft += c * Math.cos(theta * i * PI / 180.0) end return ft end
calc_h(f, ra, r)
click to toggle source
calc_lambda(alpha, delta, eps)
click to toggle source
¶ ↑
視黄経の計算 * 次式により視黄経を計算する λ = arctan(sin δ sin ε + cos δ sin α cos ε / cos δ cos α) (α : 視赤経、δ : 視赤緯、 ε : 黄道傾斜角) @param: alpha (視赤経, R.A.) @param: delta (視赤緯, Dec.) @return: lambda(視黄経)
¶ ↑
# File lib/eph_jcg/ephemeris.rb, line 395 def calc_lambda(alpha, delta, eps) alpha = alpha * 15 * PI / 180.0 delta = delta * PI / 180.0 eps = eps * PI / 180.0 lambda_a = Math.sin(delta) * Math.sin(eps) \ + Math.cos(delta) * Math.sin(alpha) * Math.cos(eps) lambda_b = Math.cos(delta) * Math.cos(alpha) lambda = Math.atan2(lambda_a, lambda_b) * 180 / PI lambda += 360 if lambda < 0 return lambda end
calc_lambda_sun_moon(sun_lambda, moon_lambda)
click to toggle source
calc_sd_moon(moon_hp)
click to toggle source
calc_sd_sun(sun_dist)
click to toggle source
calc_theta(a, b, t)
click to toggle source
¶ ↑
θ の計算 * θ を次式により計算する。 θ = cos^(-1)((2 * t - (a + b)) / (b - a)) 但し、0°<= θ <= 180° @param: a (期間(開始)) @param: b (期間(終了)) @param: t (時刻引数) @return: theta(単位: °)
¶ ↑
# File lib/eph_jcg/ephemeris.rb, line 317 def calc_theta(a, b, t) b = t if b < t # 年末のΔT秒分も計算可能とするための応急処置 theta = (2 * t - (a + b)) / (b - a).to_f theta = 1.0 if theta > 1.0 theta = -1.0 if theta < -1.0 return Math.acos(theta) * 180 / PI end
get_coeffs(div, year, t)
click to toggle source
¶ ↑
係数等の取得 * 引数の文字列の定数配列から a, b, 係数配列を取得する。 @param: div (定数名) @param: year(年) @param: t (時刻引数) @return: [a, b, 係数配列]
¶ ↑
# File lib/eph_jcg/ephemeris.rb, line 291 def get_coeffs(div, year, t) a, b = 0, 0 coeffs = Array.new Object.const_get("EphJcg::#{div}").reverse.each do |row| next unless row[0] == year if row[1][0] <= t.to_i && t.to_i <= row[1][1] a, b = row[1] coeffs = row[2] break end end return [a, b, coeffs] end