lunation 0.1.2 → 0.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -3
- data/README.md +1 -1
- data/lib/lunation/calculation/angle.rb +12 -0
- data/lib/lunation/calculation/moon_illuminated_fraction.rb +15 -15
- data/lib/lunation/calculation/moon_position.rb +28 -28
- data/lib/lunation/calculation/nutation_and_obliquity.rb +2 -2
- data/lib/lunation/calculation/sun_position.rb +9 -9
- data/lib/lunation/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7456b667a5f453f75f3651057cec0f580b23272d991c34f604bbeb1feee23674
|
4
|
+
data.tar.gz: b5f66e7c32897e674af455196081d53270a76250f69787f360739cb8fd655bf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c308d38a6a871d33c87e153df11ac409afda0f4f2ddb26a294b5771d86f300491fe9da1881d38277c4ae889da541d79dc383b5e046f49fd9923eb38d7978b4b
|
7
|
+
data.tar.gz: 7c4b9014eef9efa616a045a97bf285b93bca7d5fdb23feaa230bc841dfced221dd6b92209fc26187b18336d49c7a3625f7659d57cd9d040c52a838d9279cc811
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Lunation
|
2
2
|
|
3
|
-
|
3
|
+
Lunation provides a library of algorithms for computing positions and ephemeris of
|
4
4
|
celestial objects using Jean Meeus's astronomical algorithms.
|
5
5
|
|
6
6
|
## Installation
|
@@ -5,16 +5,16 @@ module Lunation
|
|
5
5
|
# UNIT: fraction (decimal)
|
6
6
|
def moon_illuminated_fraction
|
7
7
|
@moon_illuminated_fraction ||=
|
8
|
-
((1 +
|
8
|
+
((1 + moon_phase_angle.cos) / 2.0).round(4)
|
9
9
|
end
|
10
10
|
|
11
11
|
# (i) phase angle of the moon (48.3, A.A. p. 346)
|
12
12
|
# UNIT: Angle
|
13
13
|
def moon_phase_angle
|
14
14
|
@moon_phase_angle ||= begin
|
15
|
-
numerator = distance_between_earth_and_sun_in_kilometers *
|
15
|
+
numerator = distance_between_earth_and_sun_in_kilometers * moon_elongation_from_sun.sin
|
16
16
|
denominator = distance_between_earth_and_moon -
|
17
|
-
distance_between_earth_and_sun_in_kilometers *
|
17
|
+
distance_between_earth_and_sun_in_kilometers * moon_elongation_from_sun.cos
|
18
18
|
Angle.from_radians(Math.atan2(numerator, denominator))
|
19
19
|
end
|
20
20
|
end
|
@@ -23,11 +23,11 @@ module Lunation
|
|
23
23
|
# UNIT: Angle
|
24
24
|
def moon_elongation_from_sun
|
25
25
|
@moon_elongation_from_sun ||= begin
|
26
|
-
result =
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
result = sun_declination.sin *
|
27
|
+
moon_declination.sin +
|
28
|
+
sun_declination.cos *
|
29
|
+
moon_declination.cos *
|
30
|
+
(sun_right_ascension - moon_right_ascension).cos
|
31
31
|
Angle.from_radians(Math.acos(result))
|
32
32
|
end
|
33
33
|
end
|
@@ -36,13 +36,13 @@ module Lunation
|
|
36
36
|
# UNIT: Angle
|
37
37
|
def moon_position_angle_of_bright_limb
|
38
38
|
@moon_position_angle_of_bright_limb ||= begin
|
39
|
-
numerator =
|
40
|
-
|
41
|
-
denominator =
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
numerator = sun_declination.cos *
|
40
|
+
(sun_right_ascension - moon_right_ascension).sin
|
41
|
+
denominator = sun_declination.sin *
|
42
|
+
moon_declination.cos -
|
43
|
+
sun_declination.cos *
|
44
|
+
moon_declination.sin *
|
45
|
+
(sun_right_ascension - moon_right_ascension).cos
|
46
46
|
Angle.from_radians(Math.atan2(numerator, denominator))
|
47
47
|
end
|
48
48
|
end
|
@@ -86,15 +86,15 @@ module Lunation
|
|
86
86
|
if elem["sine_coefficient"].nil?
|
87
87
|
next acc
|
88
88
|
elsif [1, -1].include?(elem["sun_mean_anomaly"])
|
89
|
-
acc + elem["sine_coefficient"] * correction_eccentricity_of_earth *
|
89
|
+
acc + elem["sine_coefficient"] * correction_eccentricity_of_earth * sine_argument.sin
|
90
90
|
elsif [-2, 2].include?(elem["sun_mean_anomaly"])
|
91
|
-
acc + elem["sine_coefficient"] * correction_eccentricity_of_earth**2 *
|
91
|
+
acc + elem["sine_coefficient"] * correction_eccentricity_of_earth**2 * sine_argument.sin
|
92
92
|
else
|
93
|
-
acc + elem["sine_coefficient"] *
|
93
|
+
acc + elem["sine_coefficient"] * sine_argument.sin
|
94
94
|
end
|
95
|
-
end + 3958 *
|
96
|
-
1962 *
|
97
|
-
318 *
|
95
|
+
end + 3958 * correction_venus.sin +
|
96
|
+
1962 * (moon_mean_longitude - moon_argument_of_latitude_high_precision).sin +
|
97
|
+
318 * correction_jupiter.sin
|
98
98
|
result.round
|
99
99
|
end
|
100
100
|
end
|
@@ -114,18 +114,18 @@ module Lunation
|
|
114
114
|
if elem["sine_coefficient"].nil?
|
115
115
|
next acc
|
116
116
|
elsif [1, -1].include?(elem["sun_mean_anomaly"])
|
117
|
-
acc + elem["sine_coefficient"] * correction_eccentricity_of_earth *
|
117
|
+
acc + elem["sine_coefficient"] * correction_eccentricity_of_earth * sine_argument.sin
|
118
118
|
elsif [-2, 2].include?(elem["sun_mean_anomaly"])
|
119
|
-
acc + elem["sine_coefficient"] * correction_eccentricity_of_earth**2 *
|
119
|
+
acc + elem["sine_coefficient"] * correction_eccentricity_of_earth**2 * sine_argument.sin
|
120
120
|
else
|
121
|
-
acc + elem["sine_coefficient"] *
|
121
|
+
acc + elem["sine_coefficient"] * sine_argument.sin
|
122
122
|
end
|
123
|
-
end - 2235 *
|
124
|
-
382 *
|
125
|
-
175 *
|
126
|
-
175 *
|
127
|
-
127 *
|
128
|
-
-115 *
|
123
|
+
end - 2235 * moon_mean_longitude.sin +
|
124
|
+
382 * correction_latitude.sin +
|
125
|
+
175 * (correction_venus - moon_argument_of_latitude_high_precision).sin +
|
126
|
+
175 * (correction_venus + moon_argument_of_latitude_high_precision).sin +
|
127
|
+
127 * (moon_mean_longitude - moon_mean_anomaly_high_precision).sin +
|
128
|
+
-115 * (moon_mean_longitude + moon_mean_anomaly_high_precision).sin
|
129
129
|
result.round
|
130
130
|
end
|
131
131
|
end
|
@@ -145,11 +145,11 @@ module Lunation
|
|
145
145
|
if elem["cosine_coefficient"].nil?
|
146
146
|
next acc
|
147
147
|
elsif [1, -1].include?(elem["sun_mean_anomaly"])
|
148
|
-
acc + elem["cosine_coefficient"] * correction_eccentricity_of_earth *
|
148
|
+
acc + elem["cosine_coefficient"] * correction_eccentricity_of_earth * cosine_argument.cos
|
149
149
|
elsif [-2, 2].include?(elem["sun_mean_anomaly"])
|
150
|
-
acc + elem["cosine_coefficient"] * correction_eccentricity_of_earth**2 *
|
150
|
+
acc + elem["cosine_coefficient"] * correction_eccentricity_of_earth**2 * cosine_argument.cos
|
151
151
|
else
|
152
|
-
acc + elem["cosine_coefficient"] *
|
152
|
+
acc + elem["cosine_coefficient"] * cosine_argument.cos
|
153
153
|
end
|
154
154
|
end
|
155
155
|
result.round
|
@@ -201,11 +201,11 @@ module Lunation
|
|
201
201
|
# UNIT: Angle
|
202
202
|
def moon_right_ascension
|
203
203
|
@moon_right_ascension ||= begin
|
204
|
-
numerator =
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
denominator =
|
204
|
+
numerator = moon_apparent_ecliptic_longitude.sin *
|
205
|
+
obliquity_of_ecliptic.cos -
|
206
|
+
moon_ecliptic_latitude.tan *
|
207
|
+
obliquity_of_ecliptic.sin
|
208
|
+
denominator = moon_apparent_ecliptic_longitude.cos
|
209
209
|
Angle.from_radians(Math.atan2(numerator, denominator))
|
210
210
|
end
|
211
211
|
end
|
@@ -214,11 +214,11 @@ module Lunation
|
|
214
214
|
# UNIT: Angle
|
215
215
|
def moon_declination
|
216
216
|
@moon_declination ||= begin
|
217
|
-
result =
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
217
|
+
result = moon_ecliptic_latitude.sin *
|
218
|
+
obliquity_of_ecliptic.cos +
|
219
|
+
moon_ecliptic_latitude.cos *
|
220
|
+
obliquity_of_ecliptic.sin *
|
221
|
+
moon_apparent_ecliptic_longitude.sin
|
222
222
|
Angle.from_radians(Math.asin(result))
|
223
223
|
end
|
224
224
|
end
|
@@ -70,7 +70,7 @@ module Lunation
|
|
70
70
|
elem["longitude_of_ascending_node"] * longitude_of_ascending_node.decimal_degrees
|
71
71
|
)
|
72
72
|
coefficient = elem["sine_coefficient_first_term"] + elem["sine_coefficient_second_term"] * time
|
73
|
-
acc + coefficient *
|
73
|
+
acc + coefficient * argument.sin
|
74
74
|
end / 10_000.0
|
75
75
|
Angle.from_decimal_arcseconds(result)
|
76
76
|
end
|
@@ -89,7 +89,7 @@ module Lunation
|
|
89
89
|
elem["longitude_of_ascending_node"] * longitude_of_ascending_node.decimal_degrees
|
90
90
|
)
|
91
91
|
coefficient = elem["cosine_coefficient_first_term"] + elem["cosine_coefficient_second_term"] * time
|
92
|
-
acc + coefficient *
|
92
|
+
acc + coefficient * argument.cos
|
93
93
|
end / 10_000.0
|
94
94
|
Angle.from_decimal_arcseconds(result)
|
95
95
|
end
|
@@ -35,7 +35,7 @@ module Lunation
|
|
35
35
|
def sun_equation_of_center
|
36
36
|
@sun_equation_of_center ||= begin
|
37
37
|
result = Horner.compute(time, [1.914602, -0.004817, -0.000014]) *
|
38
|
-
|
38
|
+
sun_mean_anomaly2.sin +
|
39
39
|
(0.019993 - 0.000101 * time) * Math.sin(2 * sun_mean_anomaly2.radians) +
|
40
40
|
0.000289 * Math.sin(3 * sun_mean_anomaly2.radians)
|
41
41
|
Angle.from_decimal_degrees(result, normalize: false)
|
@@ -58,7 +58,7 @@ module Lunation
|
|
58
58
|
# UNIT: Astronomical Units (AU)
|
59
59
|
def distance_between_earth_and_sun_in_astronomical_units
|
60
60
|
@distance_between_earth_and_sun_in_astronomical_units ||= begin
|
61
|
-
result = 1.000001018 * (1 - earth_orbit_eccentricity**2) / (1 + earth_orbit_eccentricity *
|
61
|
+
result = 1.000001018 * (1 - earth_orbit_eccentricity**2) / (1 + earth_orbit_eccentricity * sun_anomaly.cos)
|
62
62
|
result.round(7)
|
63
63
|
end
|
64
64
|
end
|
@@ -84,7 +84,7 @@ module Lunation
|
|
84
84
|
@sun_ecliptic_longitude ||= begin
|
85
85
|
result = sun_true_longitude.decimal_degrees +
|
86
86
|
- 0.00569 +
|
87
|
-
- 0.00478 *
|
87
|
+
- 0.00478 * longitude_of_ascending_node_low_precision.sin
|
88
88
|
Angle.from_decimal_degrees(result)
|
89
89
|
end
|
90
90
|
end
|
@@ -94,7 +94,7 @@ module Lunation
|
|
94
94
|
def corrected_obliquity_of_ecliptic
|
95
95
|
@corrected_obliquity_of_ecliptic ||= begin
|
96
96
|
result = mean_obliquity_of_ecliptic.decimal_degrees +
|
97
|
-
0.00256 *
|
97
|
+
0.00256 * longitude_of_ascending_node.cos
|
98
98
|
Angle.from_decimal_degrees(result)
|
99
99
|
end
|
100
100
|
end
|
@@ -103,9 +103,9 @@ module Lunation
|
|
103
103
|
# UNIT: Angle
|
104
104
|
def sun_right_ascension
|
105
105
|
@sun_right_ascension ||= begin
|
106
|
-
numerator =
|
107
|
-
|
108
|
-
denominator =
|
106
|
+
numerator = corrected_obliquity_of_ecliptic.cos *
|
107
|
+
sun_ecliptic_longitude.sin
|
108
|
+
denominator = sun_ecliptic_longitude.cos
|
109
109
|
Angle.from_radians(Math.atan2(numerator, denominator))
|
110
110
|
end
|
111
111
|
end
|
@@ -114,8 +114,8 @@ module Lunation
|
|
114
114
|
# UNIT: Angle
|
115
115
|
def sun_declination
|
116
116
|
@sun_declination ||= begin
|
117
|
-
result =
|
118
|
-
|
117
|
+
result = corrected_obliquity_of_ecliptic.sin *
|
118
|
+
sun_ecliptic_longitude.sin
|
119
119
|
Angle.from_radians(Math.asin(result), normalize: false)
|
120
120
|
end
|
121
121
|
end
|
data/lib/lunation/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lunation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivo Kalverboer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Lunation offers a Ruby implementation of Meeus's Astronomical Algorithms.
|
14
14
|
email:
|