Module: When::TimeStandard
- Included in:
- TimeStandard
- Defined in:
- lib/when_exe/timestandard.rb,
lib/when_exe/region/martian.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]]
- DeltaT =
1599
[ 142.00, # 1599 141.00,140.00,139.00,139.00,139.00,139.00,139.00,140.00,140.00,141.00, # 1600- 141.00,141.00,141.00,140.00,139.00,138.00,137.00,134.00,132.00,128.00, # 1610- 124.00,119.00,115.00,110.00,106.00,102.00, 98.00, 95.00, 91.00, 88.00, # 1620- 85.00, 82.00, 79.00, 77.00, 74.00, 72.00, 70.00, 67.00, 65.00, 63.00, # 1630- 62.00, 60.00, 58.00, 57.00, 55.00, 54.00, 53.00, 51.00, 50.00, 49.00, # 1640- 48.00, 47.00, 46.00, 45.00, 44.00, 43.00, 42.00, 41.00, 40.00, 38.00, # 1650- 37.00, 36.00, 35.00, 34.00, 33.00, 32.00, 31.00, 30.00, 28.00, 27.00, # 1660- 26.00, 25.00, 24.00, 23.00, 22.00, 21.00, 20.00, 19.00, 18.00, 17.00, # 1670- 16.00, 15.00, 14.00, 14.00, 13.00, 12.00, 12.00, 11.00, 11.00, 10.00, # 1680- 10.00, 10.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, # 1690- 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 10.00, 10.00, # 1700- 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 11.00, 11.00, 11.00, # 1710- 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, # 1720- 11.00, 11.00, 11.00, 11.00, 12.00, 12.00, 12.00, 12.00, 12.00, 12.00, # 1730- 12.00, 12.00, 12.00, 12.00, 13.00, 13.00, 13.00, 13.00, 13.00, 13.00, # 1740- 13.00, 14.00, 14.00, 14.00, 14.00, 14.00, 14.00, 14.00, 15.00, 15.00, # 1750- 15.00, 15.00, 15.00, 15.00, 15.00, 16.00, 16.00, 16.00, 16.00, 16.00, # 1760- 16.00, 16.00, 16.00, 16.00, 16.00, 17.00, 17.00, 17.00, 17.00, 17.00, # 1770- 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, # 1780- 17.00, 17.00, 16.00, 16.00, 16.00, 16.00, 15.00, 15.00, 14.00, 14.00, # 1790- 13.70, 13.40, 13.10, 12.90, 12.70, 12.60, 12.50, 12.50, 12.50, 12.50, # 1800- 12.50, 12.50, 12.50, 12.50, 12.50, 12.50, 12.50, 12.40, 12.30, 12.20, # 1810- 12.00, 11.70, 11.40, 11.10, 10.60, 10.20, 9.60, 9.10, 8.60, 8.00, # 1820- 7.50, 7.00, 6.60, 6.30, 6.00, 5.80, 5.70, 5.60, 5.60, 5.60, # 1830- 5.70, 5.80, 5.90, 6.10, 6.20, 6.30, 6.50, 6.60, 6.80, 6.90, # 1840- 7.10, 7.20, 7.30, 7.40, 7.50, 7.60, 7.70, 7.70, 7.80, 7.80, # 1850- 7.88, 7.82, 7.54, 6.97, 6.40, 6.02, 5.41, 4.10, 2.92, 1.82, # 1860- 1.61, 0.10, -1.02, -1.28, -2.69, -3.24, -3.64, -4.54, -4.71, -5.11, # 1870- -5.40, -5.42, -5.20, -5.46, -5.46, -5.79, -5.63, -5.64, -5.80, -5.66, # 1880- -5.87, -6.01, -6.19, -6.64, -6.44, -6.47, -6.09, -5.76, -4.66, -3.74, # 1890- -2.72, -1.54, -0.02, 1.24, 2.64, 3.86, 5.37, 6.14, 7.75, 9.13, # 1900- 10.46, 11.53, 13.36, 14.65, 16.01, 17.20, 18.24, 19.06, 20.25, 20.95, # 1910- 21.16, 22.25, 22.41, 23.03, 23.49, 23.62, 23.86, 24.49, 24.34, 24.08, # 1920- 24.02, 24.00, 23.87, 23.95, 23.86, 23.93, 23.73, 23.92, 23.96, 24.02, # 1930- 24.33, 24.83, 25.30, 25.70, 26.24, 26.77, 27.28, 27.78, 28.25, 28.71, # 1940- 29.15, 29.57, 29.97, 30.36, 30.72, 31.07, 31.35, 31.68, 32.18, 32.68, # 1950- 33.15, 33.59, 34.00, 34.47, 35.03, 35.73, 36.54, 37.43, 38.29, 39.20, # 1960- 40.18, 41.17, 42.23, 43.37, 44.49, 45.48, 46.46, 47.52, 48.53, 49.59, # 1970- 50.54, 51.38, 52.17, 52.96, 53.79, 54.34, 54.87, 55.32, 55.82, 56.30, # 1980- 56.86, 57.57, 58.31, 59.12, 59.99, 60.79, 61.63, 62.30, 62.97, 63.47, # 1990- 63.83, 64.09, 64.30, 64.47, 64.57, 64.69, 64.85, 65.15, 65.46, 65.78, # 2000- 66.07, 66.32, 66.60 # 2010- ]
Class Method Summary collapse
-
._is_systemtime_universal? ⇒ Boolean
処理系が閏秒を無視しているか否か.
-
._leap_seconds ⇒ Object
閏秒の挿入記録を取得する.
-
._setup_(leap_seconds = nil) ⇒ void
When::TimeStandard Module のグローバルな設定を行う.
-
.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).
-
.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
._is_systemtime_universal? ⇒ Boolean
処理系が閏秒を無視しているか否か
145 146 147 148 |
# File 'lib/when_exe/timestandard.rb', line 145 def _is_systemtime_universal? @is_systemtime_universal = ((Time.utc(1976).to_i - Time.utc(1975).to_i) % 86400 == 0) if @is_systemtime_universal == nil @is_systemtime_universal end |
._leap_seconds ⇒ Object
閏秒の挿入記録を取得する
139 140 141 |
# File 'lib/when_exe/timestandard.rb', line 139 def _leap_seconds @leap_seconds ||= TAI_UTC.reverse end |
._setup_(leap_seconds = nil) ⇒ void
This method returns an undefined value.
When::TimeStandard Module のグローバルな設定を行う
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/when_exe/timestandard.rb', line 119 def _setup_(leap_seconds=nil) @_lock_ = Mutex.new if When.multi_thread @_lock_.lock if @_lock_ leap_seconds ||= TAI_UTC @leap_seconds = if leap_seconds.kind_of?(String) OpenURI 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 @_lock_.unlock if @_lock_ end |
.delta_t(jd_utc) ⇒ Numeric Also known as: deltaT
ΔT
157 158 159 |
# File 'lib/when_exe/timestandard.rb', line 157 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)
168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/when_exe/timestandard.rb', line 168 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)
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/when_exe/timestandard.rb', line 186 def delta_t_observed(jd_utc) c2000 = (jd_utc - When::Ephemeris::EPOCH2000)/When::Ephemeris::JCENT # 2000年からの経過世紀 year = c2000 * 100.0 + 2000.0 # 0年からの経過年 i = (year-1599.0).floor # 1599年からの経過年(整数) if year >= 2009.0 dt = 65.46 + 0.224 * (year-2009.0) elsif i>0 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 dt = DeltaT[i] + n*d1 + n*(n-1.0)/4.0*(d10+d21) + n*(n-1.0)*(n-0.5)/6.0*d210 elsif year <948.0 dt = 2715.6 + 573.36 * c2000 + 46.5*c2000*c2000 else dt = 50.6 + 67.5 * c2000 + 22.5*c2000*c2000 end return dt end |
.from_dynamical_time(time) ⇒ Numeric
dynamical time を universal time に変換する
227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/when_exe/timestandard.rb', line 227 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 に変換する
245 246 247 248 |
# File 'lib/when_exe/timestandard.rb', line 245 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 に変換する
215 216 217 218 219 |
# File 'lib/when_exe/timestandard.rb', line 215 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 |