when_exe 0.3.2 → 0.3.3
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.
- data/LICENSE.ja.txt +25 -25
- data/LICENSE.txt +31 -31
- data/bin/locales.rb +2 -1
- data/bin/when.rb.config +1 -1
- data/lib/when_exe.rb +70 -48
- data/lib/when_exe/basictypes.rb +99 -65
- data/lib/when_exe/calendartypes.rb +40 -178
- data/lib/when_exe/coordinates.rb +156 -62
- data/lib/when_exe/core/compatibility.rb +10 -0
- data/lib/when_exe/core/extension.rb +40 -0
- data/lib/when_exe/ephemeris.rb +112 -50
- data/lib/when_exe/icalendar.rb +125 -91
- data/lib/when_exe/inspect.rb +100 -48
- data/lib/when_exe/locales/ar.rb +48 -48
- data/lib/when_exe/locales/bg.rb +1 -1
- data/lib/when_exe/locales/bs.rb +4 -2
- data/lib/when_exe/locales/ca.rb +1 -1
- data/lib/when_exe/locales/en_CA.rb +3 -4
- data/lib/when_exe/locales/en_IE.rb +88 -0
- data/lib/when_exe/locales/en_US.rb +87 -0
- data/lib/when_exe/locales/es_CR.rb +84 -0
- data/lib/when_exe/locales/es_EC.rb +85 -0
- data/lib/when_exe/locales/es_PA.rb +85 -0
- data/lib/when_exe/locales/fr.rb +39 -39
- data/lib/when_exe/locales/hu.rb +15 -14
- data/lib/when_exe/locales/it.rb +1 -1
- data/lib/when_exe/locales/ja.rb +2 -2
- data/lib/when_exe/locales/locales.rb +7 -0
- data/lib/when_exe/locales/lt.rb +21 -19
- data/lib/when_exe/locales/ms.rb +84 -0
- data/lib/when_exe/locales/nl.rb +2 -2
- data/lib/when_exe/locales/ru.rb +1 -1
- data/lib/when_exe/locales/uk.rb +1 -1
- data/lib/when_exe/locales/ur.rb +84 -0
- data/lib/when_exe/mini_application.rb +44 -43
- data/lib/when_exe/parts/enumerator.rb +3 -3
- data/lib/when_exe/parts/geometric_complex.rb +6 -1
- data/lib/when_exe/parts/locale.rb +49 -18
- data/lib/when_exe/parts/method_cash.rb +61 -0
- data/lib/when_exe/parts/resource.rb +221 -106
- data/lib/when_exe/parts/timezone.rb +70 -33
- data/lib/when_exe/region/bahai.rb +2 -2
- data/lib/when_exe/region/balinese.rb +40 -43
- data/lib/when_exe/region/chinese.rb +93 -33
- data/lib/when_exe/region/chinese_calendar.rb +117 -1
- data/lib/when_exe/region/chinese_epoch.rb +65 -10
- data/lib/when_exe/region/christian.rb +97 -2
- data/lib/when_exe/region/ephemeric_notes.rb +353 -0
- data/lib/when_exe/region/french.rb +1 -1
- data/lib/when_exe/region/geologicalage.rb +171 -171
- data/lib/when_exe/region/indian.rb +18 -14
- data/lib/when_exe/region/iranian.rb +1 -1
- data/lib/when_exe/region/japanese.rb +49 -12
- data/lib/when_exe/region/japanese_notes.rb +838 -507
- data/lib/when_exe/region/japanese_residues.rb +724 -662
- data/lib/when_exe/region/javanese.rb +7 -7
- data/lib/when_exe/region/mayan.rb +19 -17
- data/lib/when_exe/region/nihon_shoki.rb +3 -3
- data/lib/when_exe/region/residue.rb +29 -28
- data/lib/when_exe/region/shire.rb +2 -2
- data/lib/when_exe/region/tibetan.rb +87 -5
- data/lib/when_exe/region/world.rb +1 -1
- data/lib/when_exe/timestandard.rb +85 -7
- data/lib/when_exe/tmobjects.rb +32 -4
- data/lib/when_exe/tmposition.rb +104 -55
- data/lib/when_exe/tmreference.rb +157 -60
- data/lib/when_exe/version.rb +2 -2
- data/test/examples/JapanHolidays.ics +3 -3
- data/test/examples/JapanHolidaysRFC6350.ics +499 -0
- data/test/examples/Residue.m17n +3 -2
- data/test/examples/Spatial.m17n +3 -3
- data/test/examples/USA-DST.ics +27 -27
- data/test/examples/today.rb +1 -1
- data/test/test.rb +4 -2
- data/test/test/basictypes.rb +40 -15
- data/test/test/coordinates.rb +9 -4
- data/test/test/icalendar.rb +24 -14
- data/test/test/inspect.rb +5 -3
- data/test/test/parts.rb +11 -2
- data/test/test/region/chinese.rb +4 -4
- data/test/test/region/civil.rb +124 -0
- data/test/test/region/geologicalage.rb +5 -2
- data/test/test/region/indian.rb +2 -0
- data/test/test/region/japanese.rb +156 -1
- data/test/test/region/jewish.rb +3 -3
- data/test/test/region/m17n.rb +9 -9
- data/test/test/region/mayan.rb +122 -5
- data/test/test/region/residue.rb +1 -1
- data/test/test/tmobjects.rb +27 -64
- data/test/test/tmposition.rb +48 -1
- data/test/test/tmreference.rb +66 -4
- data/when_exe.gemspec +1 -1
- metadata +15 -6
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
|
|
6
6
|
=end
|
|
7
7
|
|
|
8
|
+
require 'date'
|
|
8
9
|
require 'when_exe/core/duration'
|
|
9
10
|
|
|
10
11
|
#
|
|
@@ -27,6 +28,7 @@ class Time
|
|
|
27
28
|
# @note core/extension
|
|
28
29
|
#
|
|
29
30
|
def julian_date(options={})
|
|
31
|
+
options[:clock] ||= Clock(self.utc_offset)
|
|
30
32
|
When::TM::JulianDate.universal_time(self.to_f * When::TM::IntervalLength::SECOND, options)
|
|
31
33
|
end
|
|
32
34
|
alias :to_julian_date :julian_date
|
|
@@ -55,6 +57,33 @@ class Date
|
|
|
55
57
|
|
|
56
58
|
include When::TM::TemporalPosition::Conversion if When::TM.const_defined?(:TemporalPosition)
|
|
57
59
|
|
|
60
|
+
alias :__method_missing :method_missing
|
|
61
|
+
|
|
62
|
+
# その他のメソッド
|
|
63
|
+
#
|
|
64
|
+
# @note
|
|
65
|
+
# self で定義されていないメソッドは
|
|
66
|
+
# tm_position で変換して処理する
|
|
67
|
+
#
|
|
68
|
+
def method_missing(name, *args, &block)
|
|
69
|
+
return __method_missing(name, *args, &block) if When::Parts::MethodCash::Escape.key?(name)
|
|
70
|
+
self.class.module_eval %Q{
|
|
71
|
+
def #{name}(*args, &block)
|
|
72
|
+
result = tm_position.send("#{name}", *args, &block)
|
|
73
|
+
case result
|
|
74
|
+
when When::TM::DateAndTime ; result.to_date_time
|
|
75
|
+
when When::TM::CalDate ; result.to_date
|
|
76
|
+
else ; result
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
} unless When::Parts::MethodCash.escape(name)
|
|
80
|
+
result = tm_position.send(name, *args, &block)
|
|
81
|
+
case result
|
|
82
|
+
when When::TM::DateAndTime ; result.to_date_time
|
|
83
|
+
when When::TM::CalDate ; result.to_date
|
|
84
|
+
else ; result
|
|
85
|
+
end
|
|
86
|
+
end
|
|
58
87
|
end
|
|
59
88
|
|
|
60
89
|
#
|
|
@@ -392,4 +421,15 @@ class Array
|
|
|
392
421
|
When.TemporalPosition(*(self.dup << options))
|
|
393
422
|
end
|
|
394
423
|
alias :to_tm_position :tm_position
|
|
424
|
+
|
|
425
|
+
# self を[幹,枝]と解釈してWhen::Coordinates::Pair を生成
|
|
426
|
+
#
|
|
427
|
+
# @see When::Coordinates::Pair._force_pair
|
|
428
|
+
#
|
|
429
|
+
# @return [When::Coordinates::Pair]
|
|
430
|
+
#
|
|
431
|
+
def to_pair
|
|
432
|
+
Coordinates::Pair._force_pair(*self)
|
|
433
|
+
end
|
|
434
|
+
alias :pair :to_pair
|
|
395
435
|
end
|
data/lib/when_exe/ephemeris.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
=begin
|
|
3
|
-
Copyright (C) 2011-
|
|
3
|
+
Copyright (C) 2011-2014 Takashi SUGA
|
|
4
4
|
|
|
5
5
|
You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
|
|
6
6
|
=end
|
|
@@ -279,28 +279,32 @@ module When::Ephemeris
|
|
|
279
279
|
#
|
|
280
280
|
# @param [Numeric] t0 独立変数の初期近似値
|
|
281
281
|
# @param [Numeric] y0 逆変換される関数値(nil なら極値を求める)
|
|
282
|
+
# @param [Numeric] delta 戻り値が周期量である場合の周期
|
|
282
283
|
# @param [Numeric] count 収束までの最大繰り返し回数
|
|
283
284
|
# @param [Float] error 収束と判断する誤差
|
|
284
285
|
# @param [Block] func 逆変換される関数
|
|
285
286
|
#
|
|
286
287
|
# @return [Numeric] 逆変換結果
|
|
287
288
|
#
|
|
288
|
-
def root(t0, y0=nil, count=10, error=1E-6, &func)
|
|
289
|
+
def root(t0, y0=nil, delta=0, count=10, error=1E-6, &func)
|
|
289
290
|
|
|
290
291
|
# 近似値0,1
|
|
291
292
|
# printf("y0=%20.7f\n",y0)
|
|
292
|
-
|
|
293
|
-
|
|
293
|
+
d = [0.01, error * 10].max
|
|
294
|
+
t = [t0-d, t0+d ]
|
|
295
|
+
y = [func.call(t[0]), func.call(t[1])]
|
|
296
|
+
y.map! {|y1| _adjust(y1, y0, delta)} unless delta==0
|
|
294
297
|
# printf("t=%20.7f,L=%20.7f\n",t[1],y[1])
|
|
295
298
|
|
|
296
299
|
# 近似値2(1次関数による近似)
|
|
297
|
-
t << (y0 ? (t[1]-t[0])/(y[1]-y[0])*(y0-y[0])+t[0] : t0
|
|
300
|
+
t << (y0 ? (t[1]-t[0])/(y[1]-y[0])*(y0-y[0])+t[0] : t0)
|
|
298
301
|
|
|
299
302
|
# 繰り返し
|
|
300
303
|
i = count
|
|
301
304
|
while ((t[2]-t[1]).abs > error) && (i > 0)
|
|
302
305
|
# 予備計算
|
|
303
306
|
y << func.call(t[2])
|
|
307
|
+
y[2] = _adjust(y[2], y0, delta) unless delta==0
|
|
304
308
|
break if y0 && (y[2]-y0).abs <= error / 10
|
|
305
309
|
|
|
306
310
|
# printf("t=%20.7f,L=%20.7f\n",t[2],y[2])
|
|
@@ -330,11 +334,18 @@ module When::Ephemeris
|
|
|
330
334
|
|
|
331
335
|
t.shift
|
|
332
336
|
y.shift
|
|
337
|
+
i -= 1
|
|
333
338
|
end
|
|
334
339
|
raise RangeError, "The result does not converge." if i<=0
|
|
335
340
|
return t[2]
|
|
336
341
|
end
|
|
337
342
|
|
|
343
|
+
# y が周期量である場合の周期の補正
|
|
344
|
+
def _adjust(y1, y0, delta)
|
|
345
|
+
(-2..+2).to_a.map {|i| y1 + i * delta}.sort_by {|y| (y-y0).abs}[0]
|
|
346
|
+
end
|
|
347
|
+
private :_adjust
|
|
348
|
+
|
|
338
349
|
#
|
|
339
350
|
# 天体の座標
|
|
340
351
|
#
|
|
@@ -403,7 +414,7 @@ module When::Ephemeris
|
|
|
403
414
|
def polar
|
|
404
415
|
@phi, @theta, @radius = _to_p3(@x, @y, @z) unless @radius
|
|
405
416
|
@c ||= @phi
|
|
406
|
-
@phi -= (@phi - @c
|
|
417
|
+
@phi -= (@phi - @c).round
|
|
407
418
|
return [@phi, @theta, @radius, @c]
|
|
408
419
|
end
|
|
409
420
|
|
|
@@ -607,6 +618,30 @@ module When::Ephemeris
|
|
|
607
618
|
rotate_z(-0.25 + n.radius)
|
|
608
619
|
end
|
|
609
620
|
|
|
621
|
+
# 赤道座標 -> 赤道座標[時角]
|
|
622
|
+
#
|
|
623
|
+
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
624
|
+
# @param [When::TM::TemporalPosition] t
|
|
625
|
+
# @param [When::Coordinates::Spatial] loc 観測地
|
|
626
|
+
#
|
|
627
|
+
# @return [When::Ephemeris::Coords]
|
|
628
|
+
#
|
|
629
|
+
def r_to_rh(t, loc)
|
|
630
|
+
rotate_z(-loc.local_sidereal_time(t) / 24)
|
|
631
|
+
end
|
|
632
|
+
|
|
633
|
+
# 赤道座標[時角] -> 地平座標
|
|
634
|
+
#
|
|
635
|
+
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
636
|
+
# @param [When::TM::TemporalPosition] t
|
|
637
|
+
# @param [When::Coordinates::Spatial] loc 観測地
|
|
638
|
+
#
|
|
639
|
+
# @return [When::Ephemeris::Coords]
|
|
640
|
+
#
|
|
641
|
+
def rh_to_h(t, loc)
|
|
642
|
+
rotate_y(loc.lat / (360.0*When::Coordinates::Spatial::DEGREE) - 0.25)
|
|
643
|
+
end
|
|
644
|
+
|
|
610
645
|
# 赤道座標 -> 地平座標
|
|
611
646
|
#
|
|
612
647
|
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
@@ -698,7 +733,7 @@ module When::Ephemeris
|
|
|
698
733
|
@theta ||= 0.0 # 緯度
|
|
699
734
|
@radius ||= 1.0 # 距離
|
|
700
735
|
@c ||= @phi # 周期番号
|
|
701
|
-
@phi -= (@phi - @c
|
|
736
|
+
@phi -= (@phi - @c).round
|
|
702
737
|
end
|
|
703
738
|
end
|
|
704
739
|
end
|
|
@@ -1150,8 +1185,10 @@ module When::Ephemeris
|
|
|
1150
1185
|
def forwarded_formula(name, date)
|
|
1151
1186
|
return nil unless When::Ephemeris::Formula.method_defined?(name)
|
|
1152
1187
|
return @formula[0] if @formula && @formula[0].location
|
|
1153
|
-
|
|
1154
|
-
|
|
1188
|
+
location = date.location if date.respond_to?(:location)
|
|
1189
|
+
location ||= When::Coordinates::Spatial.default_location
|
|
1190
|
+
return nil unless location
|
|
1191
|
+
When.Resource('_ep:Formula?location=(' + location.iri + ')')
|
|
1155
1192
|
end
|
|
1156
1193
|
end
|
|
1157
1194
|
|
|
@@ -1171,6 +1208,10 @@ module When::Ephemeris
|
|
|
1171
1208
|
# @return [Numeric]
|
|
1172
1209
|
attr_reader :lat
|
|
1173
1210
|
|
|
1211
|
+
# 観測地の高度 / m
|
|
1212
|
+
# @return [Numeric]
|
|
1213
|
+
attr_reader :alt
|
|
1214
|
+
|
|
1174
1215
|
# 時刻系('universal' or 'dynamical')
|
|
1175
1216
|
# @return [String]
|
|
1176
1217
|
attr_reader :time_standard
|
|
@@ -1221,6 +1262,20 @@ module When::Ephemeris
|
|
|
1221
1262
|
root(time0, cn) {|t| time_to_cn(t)}
|
|
1222
1263
|
end
|
|
1223
1264
|
|
|
1265
|
+
# 当該日付のthiti の変化範囲
|
|
1266
|
+
#
|
|
1267
|
+
# @param [When::TM::TemporalPosition] date 日付
|
|
1268
|
+
#
|
|
1269
|
+
# @return [Range] 当該日付のthiti の変化範囲(朔を含む場合 nil)
|
|
1270
|
+
#
|
|
1271
|
+
def thiti_range(date)
|
|
1272
|
+
date = date.floor
|
|
1273
|
+
p0, p1 = [date, date.succ].map {|d|
|
|
1274
|
+
(30.0 * time_to_cn(d)) % 30.0
|
|
1275
|
+
}
|
|
1276
|
+
p0 >= p1 ? nil : p0...p1
|
|
1277
|
+
end
|
|
1278
|
+
|
|
1224
1279
|
# 指定の周期番号パターンになる最も近い過去の日時
|
|
1225
1280
|
#
|
|
1226
1281
|
# @param [Numeric] date ユリウス日(Terrestrial Time)
|
|
@@ -1244,9 +1299,10 @@ module When::Ephemeris
|
|
|
1244
1299
|
# @param [When::TM::TemporalPosition] t
|
|
1245
1300
|
# @param [Integer] system 座標系
|
|
1246
1301
|
#
|
|
1247
|
-
# [ 0 - When::Coordinates::Spatial::ECLIPTIC
|
|
1248
|
-
# [ 1 - When::Coordinates::Spatial::EQUATORIAL
|
|
1249
|
-
# [ 2 - When::Coordinates::Spatial::
|
|
1302
|
+
# [ 0 - 黄道座標 When::Coordinates::Spatial::ECLIPTIC ]
|
|
1303
|
+
# [ 1 - 赤道座標 When::Coordinates::Spatial::EQUATORIAL ]
|
|
1304
|
+
# [ 2 - 赤道座標[時角] When::Coordinates::Spatial::EQUATORIAL_HA ]
|
|
1305
|
+
# [ 3 - 地平座標 When::Coordinates::Spatial::HORIZONTAL ]
|
|
1250
1306
|
#
|
|
1251
1307
|
# @param [When::Ephemeris::CelestialObject] target 対象星
|
|
1252
1308
|
#
|
|
@@ -1254,8 +1310,9 @@ module When::Ephemeris
|
|
|
1254
1310
|
#
|
|
1255
1311
|
def _coords(t, system, target)
|
|
1256
1312
|
pos = target.coords(t, @location)
|
|
1257
|
-
pos = pos.y_to_r(t, @location)
|
|
1258
|
-
pos = pos.
|
|
1313
|
+
pos = pos.y_to_r(t, @location) if system >= When::Coordinates::Spatial::EQUATORIAL
|
|
1314
|
+
pos = pos.r_to_rh(t, @location) if system >= When::Coordinates::Spatial::EQUATORIAL_HA
|
|
1315
|
+
pos = pos.rh_to_h(t, @location) if system >= When::Coordinates::Spatial::HORIZONTAL
|
|
1259
1316
|
return pos
|
|
1260
1317
|
end
|
|
1261
1318
|
|
|
@@ -1312,15 +1369,15 @@ module When::Ephemeris
|
|
|
1312
1369
|
def day_event(t, event, target=When.Resource('_ep:Sun'), height=nil)
|
|
1313
1370
|
# 時刻の初期値
|
|
1314
1371
|
dl = @location.long / (360.0 * When::Coordinates::Spatial::DEGREE)
|
|
1315
|
-
t0 = (+t +
|
|
1372
|
+
t0 = (+t + dl).round - dl
|
|
1316
1373
|
dt = _coords(t0, When::Coordinates::Spatial::EQUATORIAL, target).phi -
|
|
1317
1374
|
@location.local_sidereal_time(t0) / 24.0 + 0.25 * (event||0)
|
|
1318
|
-
t0 += dt -
|
|
1375
|
+
t0 += dt - dt.round
|
|
1319
1376
|
|
|
1320
1377
|
# 天体の地平座標での高度または方位角
|
|
1321
1378
|
case event
|
|
1322
1379
|
when 0
|
|
1323
|
-
meridian = _coords(t0, When::Coordinates::Spatial::
|
|
1380
|
+
meridian = _coords(t0, When::Coordinates::Spatial::EQUATORIAL_HA, target).phi.round
|
|
1324
1381
|
when +1, -1
|
|
1325
1382
|
height ||= target.instance_of?(When::Ephemeris::Sun) ? '0' : 'A'
|
|
1326
1383
|
if height.kind_of?(String)
|
|
@@ -1335,8 +1392,8 @@ module When::Ephemeris
|
|
|
1335
1392
|
|
|
1336
1393
|
# イベントの時刻
|
|
1337
1394
|
_to_seed_type(
|
|
1338
|
-
event == 0 ? (root(t0, meridian) {|t1| _coords(t1, When::Coordinates::Spatial::
|
|
1339
|
-
(root(t0, height
|
|
1395
|
+
event == 0 ? (root(t0, meridian, 1) {|t1| _coords(t1, When::Coordinates::Spatial::EQUATORIAL_HA, target).phi}) :
|
|
1396
|
+
(root(t0, height ) {|t1| _coords(t1, When::Coordinates::Spatial::HORIZONTAL, target).theta }),
|
|
1340
1397
|
t)
|
|
1341
1398
|
end
|
|
1342
1399
|
|
|
@@ -1351,7 +1408,7 @@ module When::Ephemeris
|
|
|
1351
1408
|
#
|
|
1352
1409
|
# @return [Numeric, When::TM::TemporalPosotion] 日の出の日時(ユリウス日(Terrestrial Time)またはWhen::TM::DateAndTime
|
|
1353
1410
|
#
|
|
1354
|
-
def
|
|
1411
|
+
def sunrise(t, height='0')
|
|
1355
1412
|
day_event(t, -1, When.Resource('_ep:Sun'), height)
|
|
1356
1413
|
end
|
|
1357
1414
|
|
|
@@ -1366,7 +1423,7 @@ module When::Ephemeris
|
|
|
1366
1423
|
#
|
|
1367
1424
|
# @return [Numeric, When::TM::TemporalPosotion] 日の入りの日時(ユリウス日(Terrestrial Time)またはWhen::TM::DateAndTime
|
|
1368
1425
|
#
|
|
1369
|
-
def
|
|
1426
|
+
def sunset(t, height='0')
|
|
1370
1427
|
day_event(t, +1, When.Resource('_ep:Sun'), height)
|
|
1371
1428
|
end
|
|
1372
1429
|
|
|
@@ -1403,8 +1460,8 @@ module When::Ephemeris
|
|
|
1403
1460
|
# @return [Numeric, When::TM::TemporalPosotion] 月の出の日時(ユリウス日(Terrestrial Time)またはWhen::TM::DateAndTime
|
|
1404
1461
|
# 該当時刻がなければ nil
|
|
1405
1462
|
#
|
|
1406
|
-
def
|
|
1407
|
-
|
|
1463
|
+
def moonrise(t, height='A')
|
|
1464
|
+
day_event_in_the_day(t, -1, When.Resource('_ep:Moon'), height)
|
|
1408
1465
|
end
|
|
1409
1466
|
|
|
1410
1467
|
# 月の入りの日時
|
|
@@ -1418,8 +1475,8 @@ module When::Ephemeris
|
|
|
1418
1475
|
# @return [Numeric, When::TM::TemporalPosotion] 月の入りの日時(ユリウス日(Terrestrial Time)またはWhen::TM::DateAndTime
|
|
1419
1476
|
# 該当時刻がなければ nil
|
|
1420
1477
|
#
|
|
1421
|
-
def
|
|
1422
|
-
|
|
1478
|
+
def moonset(t, height='A')
|
|
1479
|
+
day_event_in_the_day(t, +1, When.Resource('_ep:Moon'), height)
|
|
1423
1480
|
end
|
|
1424
1481
|
|
|
1425
1482
|
# 月の最大高度の日時
|
|
@@ -1431,7 +1488,7 @@ module When::Ephemeris
|
|
|
1431
1488
|
# 該当時刻がなければ nil
|
|
1432
1489
|
#
|
|
1433
1490
|
def moon_noon(t)
|
|
1434
|
-
|
|
1491
|
+
day_event_in_the_day(t, nil, When.Resource('_ep:Moon'))
|
|
1435
1492
|
end
|
|
1436
1493
|
|
|
1437
1494
|
# 月の南中の日時
|
|
@@ -1443,7 +1500,7 @@ module When::Ephemeris
|
|
|
1443
1500
|
# 該当時刻がなければ nil
|
|
1444
1501
|
#
|
|
1445
1502
|
def meridian_passage_of_moon(t)
|
|
1446
|
-
|
|
1503
|
+
day_event_in_the_day(t, 0, When.Resource('_ep:Moon'))
|
|
1447
1504
|
end
|
|
1448
1505
|
|
|
1449
1506
|
# 恒星の出没と太陽の位置関係に関するイベントの日時
|
|
@@ -1476,7 +1533,7 @@ module When::Ephemeris
|
|
|
1476
1533
|
# The Sun's height when the event happens
|
|
1477
1534
|
unless bs
|
|
1478
1535
|
mag = target.luminosity
|
|
1479
|
-
bs = Bs[mag<-0.5 ? 0 : (mag<4.5 ?
|
|
1536
|
+
bs = Bs[mag<-0.5 ? 0 : (mag<4.5 ? mag.round+1 : 6)][event]
|
|
1480
1537
|
end
|
|
1481
1538
|
|
|
1482
1539
|
# イベントの時刻
|
|
@@ -1490,25 +1547,29 @@ module When::Ephemeris
|
|
|
1490
1547
|
break if tt >= +t
|
|
1491
1548
|
lam += 1
|
|
1492
1549
|
end
|
|
1493
|
-
_to_seed_type(day_event((tt+
|
|
1550
|
+
_to_seed_type(day_event((tt+long/360.0).round, Sgn[event][0], When.Resource('_ep:Sun'), bs), t)
|
|
1494
1551
|
end
|
|
1495
1552
|
|
|
1496
1553
|
# ユリウス日(Numeric)を seed と同じ型に変換して返します。
|
|
1497
1554
|
#
|
|
1498
1555
|
# @param [Numeric] d ユリウス日(Terrestrial Time)
|
|
1499
1556
|
# @param [Numeric] seed
|
|
1557
|
+
# @param [Hash] seed
|
|
1500
1558
|
# @param [When::TM::TemporalPosition] seed
|
|
1501
1559
|
#
|
|
1502
1560
|
# @return [Numeric, When::TM::TemporalPosotion]
|
|
1503
1561
|
#
|
|
1504
1562
|
def _to_seed_type(d, seed)
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1563
|
+
case seed
|
|
1564
|
+
when Numeric ; return d
|
|
1565
|
+
when When::TimeValue ; seed = seed._attr
|
|
1566
|
+
else ; seed = seed.dup
|
|
1567
|
+
end
|
|
1568
|
+
seed[:precision] = nil
|
|
1569
|
+
seed[:clock] ||= When::TM::Clock.local_time
|
|
1509
1570
|
t = When::TM::JulianDate._d_to_t(d)
|
|
1510
|
-
|
|
1511
|
-
|
|
1571
|
+
seed[:frame].jul_trans(@is_dynamical ? When::TM::JulianDate.dynamical_time(t) :
|
|
1572
|
+
When::TM::JulianDate.universal_time(t), seed)
|
|
1512
1573
|
end
|
|
1513
1574
|
|
|
1514
1575
|
private
|
|
@@ -1527,16 +1588,17 @@ module When::Ephemeris
|
|
|
1527
1588
|
# @sun_0m = t = CYCLE_0M日 での太陽年番号
|
|
1528
1589
|
# @sun_1m = t = CYCLE_1M日 までの太陽年番号の比例定数
|
|
1529
1590
|
def _normalize(args=[], options={})
|
|
1530
|
-
@location
|
|
1531
|
-
@long, @lat
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
@
|
|
1535
|
-
@
|
|
1591
|
+
@location = When.Resource(@location, '_l:') if @location.kind_of?(String)
|
|
1592
|
+
@long, @lat, @alt = [@location.long / When::Coordinates::Spatial::DEGREE,
|
|
1593
|
+
@location.lat / When::Coordinates::Spatial::DEGREE,
|
|
1594
|
+
@location.alt] if @location
|
|
1595
|
+
@formula ||= '1L'
|
|
1596
|
+
@time_standard ||= 'dynamical'
|
|
1597
|
+
@is_dynamical = (@time_standard[0..0].downcase == 'd')
|
|
1536
1598
|
|
|
1537
1599
|
_normalize_grahas
|
|
1538
1600
|
|
|
1539
|
-
@proc
|
|
1601
|
+
@proc ||=
|
|
1540
1602
|
case @formula
|
|
1541
1603
|
when Hash
|
|
1542
1604
|
@formula['Rem'] = (-@formula['Epoch']) % @formula['Period']
|
|
@@ -1599,7 +1661,7 @@ module When::Ephemeris
|
|
|
1599
1661
|
#
|
|
1600
1662
|
# 見つからなければ nil
|
|
1601
1663
|
#
|
|
1602
|
-
def
|
|
1664
|
+
def day_event_in_the_day(t, event, target=When.Resource('_ep:Sun'), height=nil)
|
|
1603
1665
|
today = t.to_i
|
|
1604
1666
|
3.times do
|
|
1605
1667
|
r = day_event(t, event, target, height)
|
|
@@ -1725,12 +1787,12 @@ module When::Ephemeris
|
|
|
1725
1787
|
attr_reader :month_epoch
|
|
1726
1788
|
|
|
1727
1789
|
# 計算の元期(日)
|
|
1728
|
-
|
|
1729
|
-
|
|
1790
|
+
# @return [Numeric]
|
|
1791
|
+
attr_reader :day_epoch
|
|
1730
1792
|
|
|
1731
1793
|
# 回帰年
|
|
1732
|
-
|
|
1733
|
-
|
|
1794
|
+
# @return [Numeric]
|
|
1795
|
+
attr_reader :year_length
|
|
1734
1796
|
|
|
1735
1797
|
# 恒星月
|
|
1736
1798
|
# @return [Numeric]
|
|
@@ -1767,7 +1829,7 @@ module When::Ephemeris
|
|
|
1767
1829
|
#
|
|
1768
1830
|
# @return [Numeric] 日の出の日時のユリウス日
|
|
1769
1831
|
#
|
|
1770
|
-
def
|
|
1832
|
+
def sunrise(sdn, height=nil)
|
|
1771
1833
|
return sdn.to_i - @long / 360.0 - 0.25
|
|
1772
1834
|
end
|
|
1773
1835
|
|
|
@@ -1799,8 +1861,8 @@ module When::Ephemeris
|
|
|
1799
1861
|
def cn_to_time_(cn, time0=nil)
|
|
1800
1862
|
time0 ||= (cn - @cycle_number_0m) / @cycle_number_1m
|
|
1801
1863
|
case @formula
|
|
1802
|
-
when /S/ ; (time0 + 1.0/256 - @day_epoch)
|
|
1803
|
-
when /L/ ; (time0 + 1.0/256 - @day_epoch)
|
|
1864
|
+
when /S/ ; ((time0 + 1.0/256 - @day_epoch) / @solar_terms).floor * @solar_terms + @day_epoch
|
|
1865
|
+
when /L/ ; ((time0 + 1.0/256 - @day_epoch) / @month_tithi).floor * @month_tithi + @day_epoch
|
|
1804
1866
|
end
|
|
1805
1867
|
end
|
|
1806
1868
|
|