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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73b07a2e353f23c02f3b3f81df5a8e8627b48320
4
- data.tar.gz: e4ce92fc88c1365104e6876ed64a3d570b6962df
3
+ metadata.gz: fedaa4c974693e551cd74527c8ec2d30d892d4cc
4
+ data.tar.gz: a896f85395d724780530c003619f02eb8c2b50e4
5
5
  SHA512:
6
- metadata.gz: dcd38b0bf57a188390faa5ead0ef487463c3ffeade680a0d751ebd7484439279497cf85b41d5f5d7d4bd5535462ec83a19f6e1865b228fe263feecf7c5371721
7
- data.tar.gz: aeda53957dc63572db12b6602f28b0441f764fc4ffe91552262723e329353347dccffa09f1be45f174ed8dcd8e20be6c25fe145fda6084124876c445e656e12a
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, azimath), Sunset(time, azimath), Sun's meridian passage(time, altitude),
10
- Moorise(time, azimath), Moonset(time, azimath), Moon's meridian passage(time, altitude),
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.
@@ -246,13 +246,18 @@ module MkSunmoon
246
246
  #=========================================================================
247
247
  def compute_sun(div)
248
248
  time_val = compute_time_sun(div)
249
- time_str = val2hhmmss(time_val * 24.0)
250
- jy = (@jd + time_val + @dt / 86400.0 - 2451545.0) / 365.25
251
- lambda = compute_lambda_sun(jy)
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
- angle = compute_angle_ecliptic(jy, time_val, lambda, 0.0)
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
- r = 0.266994 / dist
301
- diff = 0.0024428 / dist
302
- height = -1 * r - Const::REFRACTION - @incl + diff
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: kbn (0: 出, 1: 入, 2: 南中)
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, kbn)
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
- tk = Math.acos(tk) / Const::PI_180
640
+ return 0.0 if tk.abs > 1
641
+ tk = Math.acos(tk) / Const::PI_180
632
642
  # tkは出のときマイナス、入のときプラス
633
- tk = -tk if kbn == 0 && tk > 0
634
- tk = -tk if kbn == 1 && tk < 0
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
- if dt > 180
641
- while dt > 180; dt -= 360; end
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
 
@@ -1,3 +1,3 @@
1
1
  module MkSunmoon
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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 = ["mk-mode.com"]
9
+ spec.authors = ["komasaru"]
10
10
  spec.email = ["masaru@mk-mode.com"]
11
11
 
12
12
  spec.summary = %q{Sunrise, Sunset, Moonrise, Moonset library.}
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mk_sunmoon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
- - mk-mode.com
7
+ - komasaru
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []