mk_sunmoon 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -2
- data/lib/mk_sunmoon/compute.rb +31 -25
- data/lib/mk_sunmoon/version.rb +1 -1
- data/mk_sunmoon.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fedaa4c974693e551cd74527c8ec2d30d892d4cc
|
4
|
+
data.tar.gz: a896f85395d724780530c003619f02eb8c2b50e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d55dcdfd0450cd2d0acb17a367732323bf1d6f91fa7cd989c719262d23eea8491df71e8605857de36e8691714aa38171a4fb28c6322cbe7d5e5aada50df2b623
|
7
|
+
data.tar.gz: fad6ad0cea6bf0bd3832cbc005f109052ba688d010aecae8efb6f2ed14e8c698a1e07f2bbbad50e0ce83e5f6b60c1cc8f69ab8dd6d48eb4e37c1b7fc5cc1f534
|
data/README.md
CHANGED
@@ -6,8 +6,8 @@ This is the gem library which calculates rise/set/meridian_passage of Sun and Mo
|
|
6
6
|
|
7
7
|
### Computable items
|
8
8
|
|
9
|
-
Sunrise(time,
|
10
|
-
Moorise(time,
|
9
|
+
Sunrise(time, azimuth), Sunset(time, azimuth), Sun's meridian passage(time, altitude),
|
10
|
+
Moorise(time, azimuth), Moonset(time, azimuth), Moon's meridian passage(time, altitude),
|
11
11
|
|
12
12
|
### Original Text
|
13
13
|
|
@@ -37,6 +37,12 @@ require 'mk_sunmoon'
|
|
37
37
|
o = MkSunmoon.new("20160613", 35.47222222, 133.05055556, 0)
|
38
38
|
exit unless o
|
39
39
|
|
40
|
+
p o.year # => 2016
|
41
|
+
p o.month # => 6
|
42
|
+
p o.day # => 13
|
43
|
+
p o.lat # => 35.47222222
|
44
|
+
p o.lon # => 133.05055556
|
45
|
+
p o.alt # => 0.0
|
40
46
|
p o.sunrise # => ["04:51:52", 60.3625538738466]
|
41
47
|
p o.sunset # => ["19:23:59", 299.679632987787]
|
42
48
|
p o.sun_mp # => ["12:07:52", 77.75865299128155]
|
@@ -45,6 +51,11 @@ p o.moonset # => ["00:32:24", 272.8282647107956]
|
|
45
51
|
p o.moon_mp # => ["18:58:52", 54.1049869601976]
|
46
52
|
```
|
47
53
|
|
54
|
+
When latitude and longitude which you set as arguments are formats like `999°99′99.999″`, You must convert degree formats like `999.9999°`. (e.g. 35°28′20″ -> 35.47222222°)
|
55
|
+
|
56
|
+
If times and azimuth of Sunrise, Sunset are `--:--:--` and `---`, it means that those are "night of the midnight sun" or "polar night".
|
57
|
+
If times of Moonrise, Moonset, Moon Meridian Passase are `--:--:--`, it means that those phenomenons are occurred in the target date.
|
58
|
+
|
48
59
|
## Development
|
49
60
|
|
50
61
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec mk_sunmoon` to use the gem in this directory, ignoring other installed copies of this gem.
|
data/lib/mk_sunmoon/compute.rb
CHANGED
@@ -246,13 +246,18 @@ module MkSunmoon
|
|
246
246
|
#=========================================================================
|
247
247
|
def compute_sun(div)
|
248
248
|
time_val = compute_time_sun(div)
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
if div == 2
|
253
|
-
angle = compute_height_ecliptic(jy, time_val, lambda, 0.0)
|
249
|
+
if time_val == 0.0
|
250
|
+
time_str = "--:--:--"
|
251
|
+
angle = "---"
|
254
252
|
else
|
255
|
-
|
253
|
+
time_str = val2hhmmss(time_val * 24.0)
|
254
|
+
jy = (@jd + time_val + @dt / 86400.0 - 2451545.0) / 365.25
|
255
|
+
lambda = compute_lambda_sun(jy)
|
256
|
+
if div == 2
|
257
|
+
angle = compute_height_ecliptic(jy, time_val, lambda, 0.0)
|
258
|
+
else
|
259
|
+
angle = compute_angle_ecliptic(jy, time_val, lambda, 0.0)
|
260
|
+
end
|
256
261
|
end
|
257
262
|
return [time_str, angle]
|
258
263
|
end
|
@@ -283,7 +288,7 @@ module MkSunmoon
|
|
283
288
|
end
|
284
289
|
|
285
290
|
#=========================================================================
|
286
|
-
#
|
291
|
+
# 日の出/日の入/日の南中計算
|
287
292
|
#
|
288
293
|
# @param: div (0: 出, 1: 入, 2: 南中)
|
289
294
|
# @return: time (0.xxxx日)
|
@@ -297,22 +302,27 @@ module MkSunmoon
|
|
297
302
|
lambda = compute_lambda_sun(jy)
|
298
303
|
dist = compute_dist_sun(jy)
|
299
304
|
alpha, delta = eclip2equat(jy, lambda, 0.0)
|
300
|
-
|
301
|
-
|
302
|
-
|
305
|
+
unless div == 2 # 南中のときは計算しない
|
306
|
+
r = 0.266994 / dist
|
307
|
+
diff = 0.0024428 / dist
|
308
|
+
height = -1 * r - Const::REFRACTION - @incl + diff
|
309
|
+
end
|
303
310
|
time_sidereal = compute_sidereal_time(jy, t)
|
304
311
|
hour_angle_diff = compute_hour_angle_diff(
|
305
312
|
alpha, delta, time_sidereal, height, div
|
306
313
|
)
|
314
|
+
return 0.0 if hour_angle_diff == 0.0
|
307
315
|
# 仮定時刻に対する補正値
|
308
316
|
rev = hour_angle_diff / 360.0
|
309
317
|
t += rev
|
310
318
|
end
|
319
|
+
# 日の出・入がない場合は 0 とする
|
320
|
+
t = 0.0 if t < 0.0 || t >= 1.0
|
311
321
|
return t
|
312
322
|
end
|
313
323
|
|
314
324
|
#=========================================================================
|
315
|
-
#
|
325
|
+
# 月の出/月の入/月の南中計算
|
316
326
|
#
|
317
327
|
# @param: div (0: 出, 1: 入, 2: 南中)
|
318
328
|
# @return: time (0.xxxx日)
|
@@ -339,7 +349,7 @@ module MkSunmoon
|
|
339
349
|
t += rev
|
340
350
|
end
|
341
351
|
# 月の出/月の入りがない場合は 0 とする
|
342
|
-
t = 0 if t < 0 || t >= 1
|
352
|
+
t = 0.0 if t < 0.0 || t >= 1.0
|
343
353
|
return t
|
344
354
|
end
|
345
355
|
|
@@ -616,33 +626,29 @@ module MkSunmoon
|
|
616
626
|
# @param: delta(Decl.) (赤緯)
|
617
627
|
# @param: time_sidereal(恒星時Θ(度))
|
618
628
|
# @param: height (出没高度(度))
|
619
|
-
# @param:
|
629
|
+
# @param: div (0: 出, 1: 入, 2: 南中)
|
620
630
|
# @return: hour angle difference (時角の差 dt)
|
621
631
|
#=========================================================================
|
622
|
-
def compute_hour_angle_diff(alpha, delta, time_sidereal, height,
|
623
|
-
|
624
|
-
if kbn == 2
|
632
|
+
def compute_hour_angle_diff(alpha, delta, time_sidereal, height, div)
|
633
|
+
if div == 2
|
625
634
|
tk = 0
|
626
635
|
else
|
627
636
|
tk = Math.sin(Const::PI_180 * height)
|
628
637
|
tk -= Math.sin(Const::PI_180 * delta) * Math.sin(Const::PI_180 * @lat)
|
629
638
|
tk /= Math.cos(Const::PI_180 * delta) * Math.cos(Const::PI_180 * @lat)
|
630
639
|
# 出没点の時角
|
631
|
-
|
640
|
+
return 0.0 if tk.abs > 1
|
641
|
+
tk = Math.acos(tk) / Const::PI_180
|
632
642
|
# tkは出のときマイナス、入のときプラス
|
633
|
-
tk = -tk if
|
634
|
-
tk = -tk if
|
643
|
+
tk = -tk if div == 0 && tk > 0
|
644
|
+
tk = -tk if div == 1 && tk < 0
|
635
645
|
end
|
636
646
|
# 天体の時角
|
637
647
|
t = time_sidereal - alpha
|
638
648
|
dt = tk - t
|
639
649
|
# dtの絶対値を180°以下に調整
|
640
|
-
|
641
|
-
|
642
|
-
end
|
643
|
-
if dt < -180
|
644
|
-
while dt < -180; dt += 360; end
|
645
|
-
end
|
650
|
+
while dt > 180.0; dt -= 360.0; end
|
651
|
+
while dt < -180.0; dt += 360.0; end
|
646
652
|
return dt
|
647
653
|
end
|
648
654
|
|
data/lib/mk_sunmoon/version.rb
CHANGED
data/mk_sunmoon.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'mk_sunmoon/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "mk_sunmoon"
|
8
8
|
spec.version = MkSunmoon::VERSION
|
9
|
-
spec.authors = ["
|
9
|
+
spec.authors = ["komasaru"]
|
10
10
|
spec.email = ["masaru@mk-mode.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{Sunrise, Sunset, Moonrise, Moonset library.}
|