astro_moon 0.1 → 0.2
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/README +3 -0
- data/lib/astro/moon.rb +18 -6
- metadata +2 -2
data/README
CHANGED
@@ -4,3 +4,6 @@ This file is a thoughtless manual compilation of Astro::MoonPhase perl
|
|
4
4
|
module (which, in turn, is influenced by moontool.c). I don't know
|
5
5
|
how it all works.
|
6
6
|
|
7
|
+
This gem contains an example script (bin/moon.rb), which hopefully helps to
|
8
|
+
understand the API of this module.
|
9
|
+
|
data/lib/astro/moon.rb
CHANGED
@@ -11,13 +11,25 @@ module Astro # :nodoc:
|
|
11
11
|
module Moon # :doc:
|
12
12
|
class << self
|
13
13
|
|
14
|
-
# a container structure for phase() return value.
|
14
|
+
# a container structure for phase() return value. accessors:
|
15
|
+
# phase - moon phase, 0 or 1 for new moon, 0.5 for full moon, etc
|
16
|
+
# illumination - moon illumination, 0.0 .. 0.1
|
17
|
+
# age - moon age, in days from the most recent new moon
|
18
|
+
# distance - moon distance from earth, in kilometers
|
19
|
+
# angle - moon angle
|
20
|
+
# sun_distance - sun distance from earth, in kilometers
|
21
|
+
# sun_angle - sun angle
|
15
22
|
Phase = Struct.new(:phase, :illumination, :age, :distance, :angle,
|
16
23
|
:sun_distance, :sun_angle)
|
17
24
|
|
18
|
-
# a container structure for phasehunt() return value.
|
25
|
+
# a container structure for phasehunt() return value. accessors:
|
26
|
+
# moon_start - a DateTime of the most recent new moon
|
27
|
+
# moon_end - a DateTime of the next new moon
|
28
|
+
# moon_fill - a DateTime of the full moon of this lunar month
|
29
|
+
# first_quarter, last_quarter -- <...>
|
19
30
|
PhaseHunt = Struct.new(:moon_start, :first_quarter, :moon_full,
|
20
31
|
:last_quarter, :moon_end)
|
32
|
+
|
21
33
|
# Astronomical constants.
|
22
34
|
# 1980 January 0.0
|
23
35
|
EPOCH = 2444238.5
|
@@ -60,7 +72,7 @@ module Astro # :nodoc:
|
|
60
72
|
|
61
73
|
# Finds the key dates of the specified lunar month.
|
62
74
|
# Takes a DateTime object (or creates one using now() function).
|
63
|
-
# Returns a PhaseHunt struct instance.
|
75
|
+
# Returns a PhaseHunt struct instance. (see Constants section)
|
64
76
|
#
|
65
77
|
# # find the date/time of the full moon in this lunar month
|
66
78
|
# Astro::Moon.phasehunt.moon_full.strftime("%D %T %Z") \
|
@@ -71,7 +83,7 @@ module Astro # :nodoc:
|
|
71
83
|
sdate = date.ajd
|
72
84
|
|
73
85
|
adate = sdate - 45
|
74
|
-
ad1 = DateTime.
|
86
|
+
ad1 = DateTime.jd(adate)
|
75
87
|
|
76
88
|
k1 = ((ad1.year + ((ad1.month - 1) *
|
77
89
|
(1.0 / 12.0)) - 1900) * 12.3685).floor
|
@@ -100,7 +112,7 @@ module Astro # :nodoc:
|
|
100
112
|
|
101
113
|
# Finds the lunar phase for the specified date.
|
102
114
|
# Takes a DateTime object (or creates one using now() function).
|
103
|
-
# Returns a Phase struct instance.
|
115
|
+
# Returns a Phase struct instance. (see Constants section)
|
104
116
|
#
|
105
117
|
# # find the current moon illumination, in percents
|
106
118
|
# Astro::Moon.phase.illumination * 100 # => 63.1104513958699
|
@@ -304,7 +316,7 @@ module Astro # :nodoc:
|
|
304
316
|
if !apcor || apcor == 0
|
305
317
|
raise "truephase() called with invalid phase selector (#{phase})."
|
306
318
|
end
|
307
|
-
return DateTime.
|
319
|
+
return DateTime.jd(pt + 0.5)
|
308
320
|
end
|
309
321
|
|
310
322
|
def kepler(m, ecc)
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: astro_moon
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "0.
|
7
|
-
date: 2007-03-
|
6
|
+
version: "0.2"
|
7
|
+
date: 2007-03-15 00:00:00 +03:00
|
8
8
|
summary: A library for calculating the lunar phases and dates
|
9
9
|
require_paths:
|
10
10
|
- lib
|