Module: When::TimeStandard
- Included in:
- TimeStandard
- Defined in:
- lib/when_exe/timestandard.rb,
lib/when_exe/region/martian.rb,
lib/when_exe/timestandard-canopus.rb
Overview
標準的な時刻系の定義
Defined Under Namespace
Classes: LocalApparentTime, LocalMeanTime, MartianTimeCoordinated, TemporalHourSystem, TimeStandard, UniversalTime
Constant Summary collapse
- DeltaT0 =
TT(Terrestrial Time) - UTC(Universal Time, Coordinated) at 1970-01-01T00:00:00Z
(40 + 377.0/2048) * When::TM::Duration::SECOND
- TAI_UTC =
[[2437300.5, 1.422818, 37300.0, 0.001296 ], [2437512.5, 1.372818, 37300.0, 0.001296 ], [2437665.5, 1.845858, 37665.0, 0.0011232], [2438334.5, 1.945858, 37665.0, 0.0011232], [2438395.5, 3.24013, 38761.0, 0.001296 ], [2438486.5, 3.34013, 38761.0, 0.001296 ], [2438639.5, 3.44013, 38761.0, 0.001296 ], [2438761.5, 3.54013, 38761.0, 0.001296 ], [2438820.5, 3.64013, 38761.0, 0.001296 ], [2438942.5, 3.74013, 38761.0, 0.001296 ], [2439004.5, 3.84013, 38761.0, 0.001296 ], [2439126.5, 4.31317, 39126.0, 0.002592 ], [2439887.5, 4.21317, 39126.0, 0.002592 ], [2441317.5, 10.0], [2441499.5, 11.0], [2441683.5, 12.0], [2442048.5, 13.0], [2442413.5, 14.0], [2442778.5, 15.0], [2443144.5, 16.0], [2443509.5, 17.0], [2443874.5, 18.0], [2444239.5, 19.0], [2444786.5, 20.0], [2445151.5, 21.0], [2445516.5, 22.0], [2446247.5, 23.0], [2447161.5, 24.0], [2447892.5, 25.0], [2448257.5, 26.0], [2448804.5, 27.0], [2449169.5, 28.0], [2449534.5, 29.0], [2450083.5, 30.0], [2450630.5, 31.0], [2451179.5, 32.0], [2453736.5, 33.0], [2454832.5, 34.0], [2456109.5, 35.0], [2457204.5, 36.0], [2457754.5, 37.0]]
- DeltaT =
1999
[ 63.467, # 1999 63.827, 64.092, 64.300, 64.473, 64.573, 64.689, 64.846, 65.145, 65.456, 65.779, # 2000- 66.070, 66.324, 66.603, 66.909, 67.282, 67.642, 68.102, 68.594, 68.968 # 2010- ]
Class Method Summary collapse
-
._setup_(leap_seconds = nil) ⇒ void
When::TimeStandard Module のグローバルな設定を行う.
-
._setup_info ⇒ Hash
設定情報を取得する.
-
.delta_t(jd_utc) ⇒ Numeric
(also: deltaT)
ΔT.
-
.delta_t_coordinated(jd_utc) ⇒ Numeric
ΔT - 閏秒による(TT-UTC).
-
.delta_t_observed(jd_utc) ⇒ Numeric
ΔT - 観測による(TT-UT1) mix of Table and NASA.
-
.delta_t_observed_nasa(jd_utc) ⇒ Numeric
ΔT - 観測による(TT-UT1) from eclipse.gsfc.nasa.gov/SEhelp/deltatpoly2004.html.
-
.delta_t_observed_poly(year) ⇒ Object
多項式による近似.
-
.from_dynamical_time(time) ⇒ Numeric
dynamical time を universal time に変換する.
-
.from_time_object(time) ⇒ Numeric
Time オブジェクトを dynamical time に変換する.
-
.to_dynamical_time(time) ⇒ Numeric
universal time を dynamical time に変換する.
-
.to_time_object(time) ⇒ ::Time
dynamical time を Time オブジェクトに変換する.
Class Method Details
._setup_(leap_seconds = nil) ⇒ void
本メソッドでマルチスレッド対応の管理変数の初期化を行っている。 このため、本メソッド自体はスレッドセーフでない。
This method returns an undefined value.
When::TimeStandard Module のグローバルな設定を行う
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/when_exe/timestandard.rb', line 81 def _setup_(leap_seconds=nil) @_lock_ = Mutex.new if When.multi_thread leap_seconds ||= TAI_UTC @leap_seconds = if leap_seconds.kind_of?(String) OpenURI URI.send(:open, leap_seconds) do |file| file.read.split(/[\n\r]+/).map { |line| line.split(/[^\d.]+/)[3..6].map {|d| d.to_f} }.reverse end else leap_seconds.reverse end end |
._setup_info ⇒ Hash
設定情報を取得する
101 102 103 |
# File 'lib/when_exe/timestandard.rb', line 101 def _setup_info {:leap_seconds => _leap_seconds} end |
.delta_t(jd_utc) ⇒ Numeric Also known as: deltaT
ΔT
125 126 127 |
# File 'lib/when_exe/timestandard.rb', line 125 def delta_t(jd_utc) (delta_t_coordinated(jd_utc) * 4096 + 1).floor / 4096.0 end |
.delta_t_coordinated(jd_utc) ⇒ Numeric
ΔT - 閏秒による(TT-UTC)
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/when_exe/timestandard.rb', line 136 def delta_t_coordinated(jd_utc) list = _leap_seconds list.each do |v| if jd_utc >= v[0] result = 32.184 + v[1] result += (jd_utc - (2400000.5 + v[2])) * v[3] unless (v[3]||0) == 0 return result end end delta_t_observed(jd_utc) end |
.delta_t_observed(jd_utc) ⇒ Numeric
ΔT - 観測による(TT-UT1) mix of Table and NASA
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/when_exe/timestandard.rb', line 154 def delta_t_observed(jd_utc) year = (jd_utc - When::Ephemeris::EPOCH2000)/When::Ephemeris::JYEAR + 2000 # 0年からの経過世紀 return delta_t_observed_poly(year) unless 2000 <= year && year < 2050 return delta_t_observed_poly(year) + DeltaThreshold * (year - 2050.0) / (YearThreshold - 2050.0) if year >= YearThreshold i = (year-1999.0).floor # 1999年からの経過年(整数) n = year % 1 d0 = DeltaT[i+0] - DeltaT[i-1] d1 = DeltaT[i+1] - DeltaT[i+0] d2 = DeltaT[i+2] - DeltaT[i+1] d10 = d1 - d0 d21 = d2 - d1 d210 = d21 - d10 DeltaT[i] + n*d1 + n*(n-1.0)/4.0*(d10+d21) + n*(n-1.0)*(n-0.5)/6.0*d210 end |
.delta_t_observed_nasa(jd_utc) ⇒ Numeric
ΔT - 観測による(TT-UT1) from eclipse.gsfc.nasa.gov/SEhelp/deltatpoly2004.html
176 177 178 |
# File 'lib/when_exe/timestandard.rb', line 176 def delta_t_observed_nasa(jd_utc) delta_t_observed_poly((jd_utc - When::Ephemeris::EPOCH2000)/When::Ephemeris::JYEAR + 2000.0) # 0年からの経過年 end |
.delta_t_observed_poly(year) ⇒ Object
多項式による近似
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 |
# File 'lib/when_exe/timestandard.rb', line 181 def delta_t_observed_poly(year) u = (year-1820)/100 # 2150 ... 3000 if year >= 2150 -20 + 32 * u**2 # 2050 ... 2150 elsif year >= 2050 -20 + 32 * u**2 - 0.5628 * (2150 - year) # 2005 ... 2050 elsif year >= 2005 t = year - 2000 62.92 + 0.32217 * t + 0.005589 * t**2 # 1986 ... 2005 elsif year >= 1986 t = year - 2000 63.86 + 0.3345 * t - 0.060374 * t**2 + 0.0017275 * t**3 + 0.000651814 * t**4 + 0.00002373599 * t**5 # 1961 ... 1986 elsif year >= 1961 t = year - 1975 45.45 + 1.067*t - t**2/260 - t**3 / 718 # 1941 ... 1961 elsif year >= 1941 t = year - 1950 29.07 + 0.407*t - t**2/233 + t**3 / 2547 # 1920 ... 1941 elsif year >= 1920 t = year - 1920 21.20 + 0.84493*t - 0.076100 * t**2 + 0.0020936 * t**3 # 1900 ... 1920 elsif year >= 1900 t = year - 1900 -2.79 + 1.494119 * t - 0.0598939 * t**2 + 0.0061966 * t**3 - 0.000197 * t**4 # 1860 ... 1900 elsif year >= 1860 t = year - 1860 7.62 + 0.5737 * t - 0.251754 * t**2 + 0.01680668 * t**3 - 0.0004473624 * t**4 + t**5 / 233174 # 1800 ... 1860 elsif year >= 1800 t = year - 1800 13.72 - 0.332447 * t + 0.0068612 * t**2 + 0.0041116 * t**3 - 0.00037436 * t**4 + 0.0000121272 * t**5 - 0.0000001699 * t**6 + 0.000000000875 * t**7 # 1700 ... 1800 elsif year >= 1700 t = year - 1700 8.83 + 0.1603 * t - 0.0059285 * t**2 + 0.00013336 * t**3 - t**4 / 1174000 # 1600 ... 1700 elsif year >= 1600 t = year - 1600 120 - 0.9808 * t - 0.01532 * t**2 + t**3 / 7129 # 500 ... 1600 elsif year >= 500 u = (year - 1000) / 100 1574.2 - 556.01 * u + 71.23472 * u**2 + 0.319781 * u**3 - 0.8503463 * u**4 - 0.005050998 * u**5 + 0.0083572073 * u**6 # -500 ... 500 elsif year >= -500 u = year / 100 10583.6 - 1014.41 * u + 33.78311 * u**2 - 5.952053 * u**3 - 0.1798452 * u**4 + 0.022174192 * u**5 + 0.0090316521 * u**6 # ... -500 else -20 + 32 * u**2 end end |
.from_dynamical_time(time) ⇒ Numeric
dynamical time を universal time に変換する
277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/when_exe/timestandard.rb', line 277 def from_dynamical_time(time) return time unless -Float::MAX/4 < time && time < Float::MAX/4 jd_tt = When::TM::JulianDate._t_to_d(time) utc = time - delta_t(jd_tt) * When::TM::Duration::SECOND diff = time - to_dynamical_time(utc) return utc if diff == 0 # 間に閏秒なし utc += diff diff = time - to_dynamical_time(utc) return utc if diff == 0 # 間に閏秒なし return When::Coordinates::LeapSeconds.new(utc+diff, -diff, When::TM::Duration::SECOND) end |
.from_time_object(time) ⇒ Numeric
Time オブジェクトを dynamical time に変換する
295 296 297 298 |
# File 'lib/when_exe/timestandard.rb', line 295 def from_time_object(time) time = time.to_f * When::TM::Duration::SECOND _is_systemtime_universal? ? to_dynamical_time(time) : time + DeltaT0 end |
.to_dynamical_time(time) ⇒ Numeric
universal time を dynamical time に変換する
265 266 267 268 269 |
# File 'lib/when_exe/timestandard.rb', line 265 def to_dynamical_time(time) return time unless -Float::MAX/4 < time && time < Float::MAX/4 jd_utc = When::TM::JulianDate._t_to_d(time * 1) +time + delta_t(jd_utc) * When::TM::Duration::SECOND end |