astronoby 0.2.0 → 0.3.0
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 +21 -2
- data/Gemfile.lock +1 -1
- data/README.md +69 -6
- data/UPGRADING.md +50 -0
- data/lib/astronoby/aberration.rb +6 -3
- data/lib/astronoby/angle.rb +16 -20
- data/lib/astronoby/bodies/sun.rb +44 -22
- data/lib/astronoby/body.rb +3 -3
- data/lib/astronoby/coordinates/ecliptic.rb +19 -8
- data/lib/astronoby/coordinates/equatorial.rb +4 -4
- data/lib/astronoby/coordinates/horizontal.rb +3 -3
- data/lib/astronoby/equinox_solstice.rb +5 -19
- data/lib/astronoby/mean_obliquity.rb +2 -2
- data/lib/astronoby/nutation.rb +4 -4
- data/lib/astronoby/precession.rb +5 -5
- data/lib/astronoby/refraction.rb +4 -4
- data/lib/astronoby/util/astrodynamics.rb +2 -2
- data/lib/astronoby/util/trigonometry.rb +2 -2
- data/lib/astronoby/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: 2ab8b9191b1b2452c678389fbc4c1750c4080c8f3cddf55cf7aebad2d99a0da7
|
4
|
+
data.tar.gz: f823456f556792e1d2ea3747f3665c84442a907c3a08271df5f871204bd09f10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b14d2a19972991fecc5b0a12c15fe18f3a9a07d0e9fc705fe2d984af14e45ae82962332361e65dace20c27b5f6e05e19483385731770abe463a3bf28adcfb354
|
7
|
+
data.tar.gz: 725810244872e539789b23d2b28ce656781a1f9121fabc76c3e2ebc5c9e6616900bff852290cf8719a10feb7a06afa42f7d02f4e00ac3ba2dadc4dea47d6a24c
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,27 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## 0.
|
3
|
+
## 0.3.0 - 2024-03-29
|
4
4
|
|
5
5
|
_If you are upgrading: please see [`UPGRADING.md`]._
|
6
6
|
|
7
|
-
|
7
|
+
### Improvements
|
8
|
+
|
9
|
+
* Drop `Angle#==` ([#42])
|
10
|
+
* Improved accuracy with Sun's location predictions ([#41])
|
11
|
+
|
12
|
+
### Breaking changes
|
13
|
+
|
14
|
+
* **breaking:** Difference between true and apparent ecliptic and equatorial
|
15
|
+
coordinates ([#41])
|
16
|
+
* **breaking:** Rename `Angle::as_*` into `Angle::from_*` ([#43])
|
17
|
+
|
18
|
+
[#41]: https://github.com/rhannequin/astronoby/pull/41
|
19
|
+
[#42]: https://github.com/rhannequin/astronoby/pull/42
|
20
|
+
[#43]: https://github.com/rhannequin/astronoby/pull/43
|
21
|
+
|
22
|
+
## 0.2.0 - 2024-03-24
|
23
|
+
|
24
|
+
_If you are upgrading: please see [`UPGRADING.md`]._
|
8
25
|
|
9
26
|
### Features
|
10
27
|
|
@@ -74,3 +91,5 @@ _If you are upgrading: please see [`UPGRADING.md`]._
|
|
74
91
|
|
75
92
|
* Add `Astronoby::Angle`
|
76
93
|
* Support angles in degrees and radians
|
94
|
+
|
95
|
+
[`UPGRADING.md`]: https://github.com/rhannequin/astronoby/blob/main/UPGRADING.md
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -28,14 +28,53 @@ This library is still in heavy development. The public is not stable, please
|
|
28
28
|
be aware new minor versions will probably lead to breaking changes until a
|
29
29
|
major one is released.
|
30
30
|
|
31
|
+
### Angle manipulation
|
32
|
+
|
33
|
+
```rb
|
34
|
+
angle1 = Astronoby::Angle.from_degrees(90)
|
35
|
+
angle2 = Astronoby::Angle.from_radians(Astronoby::Angle::PI / 2)
|
36
|
+
angle3 = Astronoby::Angle.from_hours(12)
|
37
|
+
|
38
|
+
angle1 == angle2
|
39
|
+
# => true
|
40
|
+
|
41
|
+
angle1 < angle3
|
42
|
+
# => true
|
43
|
+
|
44
|
+
angle = angle1 + angle2 + angle3
|
45
|
+
angle.cos
|
46
|
+
# => 1.0
|
47
|
+
```
|
48
|
+
|
49
|
+
### Coordinates conversion
|
50
|
+
|
51
|
+
```rb
|
52
|
+
equatorial = Astronoby::Coordinates::Equatorial.new(
|
53
|
+
right_ascension: Astronoby::Angle.from_hms(17, 43, 54),
|
54
|
+
declination: Astronoby::Angle.from_dms(-22, 10, 0)
|
55
|
+
)
|
56
|
+
|
57
|
+
horizontal = equatorial.to_horizontal(
|
58
|
+
time: Time.new(2016, 1, 21, 21, 30, 0, "-05:00"),
|
59
|
+
latitude: Astronoby::Angle.from_degrees(38),
|
60
|
+
longitude: Astronoby::Angle.from_degrees(-78)
|
61
|
+
)
|
62
|
+
|
63
|
+
horizontal.altitude.str(:dms)
|
64
|
+
# => "-73° 27′ 19.1557″"
|
65
|
+
|
66
|
+
horizontal.azimuth.str(:dms)
|
67
|
+
# => "+341° 33′ 21.587″"
|
68
|
+
```
|
69
|
+
|
31
70
|
### Sun's location in the sky
|
32
71
|
|
33
72
|
```rb
|
34
73
|
time = Time.utc(2023, 2, 17, 11, 0, 0)
|
35
74
|
epoch = Astronoby::Epoch.from_time(time)
|
36
75
|
|
37
|
-
latitude = Astronoby::Angle.
|
38
|
-
longitude = Astronoby::Angle.
|
76
|
+
latitude = Astronoby::Angle.from_degrees(48.8566)
|
77
|
+
longitude = Astronoby::Angle.from_degrees(2.3522)
|
39
78
|
|
40
79
|
sun = Astronoby::Sun.new(epoch: epoch)
|
41
80
|
|
@@ -45,10 +84,34 @@ horizontal_coordinates = sun.horizontal_coordinates(
|
|
45
84
|
)
|
46
85
|
|
47
86
|
horizontal_coordinates.altitude.degrees.to_f
|
48
|
-
# => 27.
|
87
|
+
# => 27.50008242057459
|
49
88
|
|
50
89
|
horizontal_coordinates.altitude.str(:dms)
|
51
|
-
# => "+27° 30′
|
90
|
+
# => "+27° 30′ 0.2967″"
|
91
|
+
```
|
92
|
+
|
93
|
+
### Sunrise and sunset times and azimuths
|
94
|
+
|
95
|
+
```rb
|
96
|
+
date = Date.new(2015, 2, 5)
|
97
|
+
epoch = Astronoby::Epoch.from_time(date)
|
98
|
+
observer = Astronoby::Observer.new(
|
99
|
+
latitude: Astronoby::Angle.from_degrees(38),
|
100
|
+
longitude: Astronoby::Angle.from_degrees(-78)
|
101
|
+
)
|
102
|
+
sun = Astronoby::Sun.new(epoch: epoch)
|
103
|
+
|
104
|
+
sun.rising_time(observer: observer)
|
105
|
+
# => 2015-02-05 12:13:26 UTC
|
106
|
+
|
107
|
+
sun.rising_azimuth(observer: observer).str(:dms)
|
108
|
+
# => "+109° 41′ 22.2585″"
|
109
|
+
|
110
|
+
sun.setting_time(observer: observer)
|
111
|
+
# => 2015-02-05 22:35:12 UTC
|
112
|
+
|
113
|
+
sun.setting_azimuth(observer: observer).str(:dms)
|
114
|
+
# => "+250° 18′ 37.7414″"
|
52
115
|
```
|
53
116
|
|
54
117
|
### Solstice and Equinox times
|
@@ -57,10 +120,10 @@ horizontal_coordinates.altitude.str(:dms)
|
|
57
120
|
year = 2024
|
58
121
|
|
59
122
|
Astronoby::EquinoxSolstice.march_equinox(year)
|
60
|
-
# => 2024-03-20 03:05:
|
123
|
+
# => 2024-03-20 03:05:08 UTC
|
61
124
|
|
62
125
|
Astronoby::EquinoxSolstice.june_solstice(year)
|
63
|
-
# => 2024-06-20 20:50:
|
126
|
+
# => 2024-06-20 20:50:18 UTC
|
64
127
|
```
|
65
128
|
|
66
129
|
## Precision
|
data/UPGRADING.md
CHANGED
@@ -7,6 +7,56 @@ changes to it as long as a major version has not been released.
|
|
7
7
|
If you are already using Astronoby and wish to follow the changes to its
|
8
8
|
public API, please read the upgrading notes for each release.
|
9
9
|
|
10
|
+
## Upgrading from 0.2.0 to 0.3.0
|
11
|
+
|
12
|
+
### `Sun#ecliptic_coordinates` method removed (#41)
|
13
|
+
|
14
|
+
Removed in favor of `#true_ecliptic_coordinates` and
|
15
|
+
`#apparent_ecliptic_coordinates`.
|
16
|
+
|
17
|
+
### `Coordinates::Ecliptic#to_horizontal` method removed (#41)
|
18
|
+
|
19
|
+
Removed in favor of `#to_true_horizontal` and
|
20
|
+
`#to_apparent_horizontal`.
|
21
|
+
|
22
|
+
### `Sun#true_ecliptic_coordinates` method added (#41)
|
23
|
+
|
24
|
+
Returns the true ecliptic coordinates for the date's epoch.
|
25
|
+
|
26
|
+
### `Sun#apparent_ecliptic_coordinates` method added (#41)
|
27
|
+
|
28
|
+
Returns the apparent ecliptic coordinates for the date's epoch, including
|
29
|
+
corrections for the nutation and aberration.
|
30
|
+
|
31
|
+
### `Coordinates::Ecliptic#to_true_horizontal` method added (#41)
|
32
|
+
|
33
|
+
Returns the true equatorial coordinates for ths date's epoch.
|
34
|
+
|
35
|
+
### `Coordinates::Ecliptic#to_apparent_horizontal` method added (#41)
|
36
|
+
|
37
|
+
Returns the apparent equatorial coordinates for the date's epoch, including
|
38
|
+
corrections for the obliquity.
|
39
|
+
|
40
|
+
### `Angle::as_radians` renamed into `Angle::from_radians` (#43)
|
41
|
+
|
42
|
+
Behaviour not changed.
|
43
|
+
|
44
|
+
### `Angle::as_degrees` renamed into `Angle::from_degrees` (#43)
|
45
|
+
|
46
|
+
Behaviour not changed.
|
47
|
+
|
48
|
+
### `Angle::as_hours` renamed into `Angle::from_hours` (#43)
|
49
|
+
|
50
|
+
Behaviour not changed.
|
51
|
+
|
52
|
+
### `Angle::as_dms` renamed into `Angle::from_dms` (#43)
|
53
|
+
|
54
|
+
Behaviour not changed.
|
55
|
+
|
56
|
+
### `Angle::as_hms` renamed into `Angle::from_hms` (#43)
|
57
|
+
|
58
|
+
Behaviour not changed.
|
59
|
+
|
10
60
|
## Upgrading from 0.1.0 to 0.2.0
|
11
61
|
|
12
62
|
### `Observer` class added (#29)
|
data/lib/astronoby/aberration.rb
CHANGED
@@ -17,13 +17,13 @@ module Astronoby
|
|
17
17
|
# Edition: Cambridge University Press
|
18
18
|
# Chapter: 36 - Aberration
|
19
19
|
def apply
|
20
|
-
delta_longitude = Angle.
|
20
|
+
delta_longitude = Angle.from_degrees(
|
21
21
|
-20.5 * (
|
22
22
|
sun_longitude - @coordinates.longitude
|
23
23
|
).cos / @coordinates.latitude.cos / 3600
|
24
24
|
)
|
25
25
|
|
26
|
-
delta_latitude = Angle.
|
26
|
+
delta_latitude = Angle.from_degrees(
|
27
27
|
-20.5 *
|
28
28
|
(sun_longitude - @coordinates.longitude).sin *
|
29
29
|
@coordinates.latitude.sin / 3600
|
@@ -36,7 +36,10 @@ module Astronoby
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def sun_longitude
|
39
|
-
@_sun_longitude ||= Sun
|
39
|
+
@_sun_longitude ||= Sun
|
40
|
+
.new(epoch: @epoch)
|
41
|
+
.true_ecliptic_coordinates
|
42
|
+
.longitude
|
40
43
|
end
|
41
44
|
end
|
42
45
|
end
|
data/lib/astronoby/angle.rb
CHANGED
@@ -25,45 +25,45 @@ module Astronoby
|
|
25
25
|
new(0)
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def from_radians(radians)
|
29
29
|
normalized_radians = radians.remainder(FULL_CIRCLE_IN_RADIANS)
|
30
30
|
new(normalized_radians)
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
33
|
+
def from_degrees(degrees)
|
34
34
|
radians = degrees / PI_IN_DEGREES * PI
|
35
|
-
|
35
|
+
from_radians(radians)
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
38
|
+
def from_hours(hours)
|
39
39
|
radians = hours * RADIAN_PER_HOUR
|
40
|
-
|
40
|
+
from_radians(radians)
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
43
|
+
def from_hms(hour, minute, second)
|
44
44
|
hours = hour + minute / MINUTES_PER_HOUR + second / SECONDS_PER_HOUR
|
45
|
-
|
45
|
+
from_hours(hours)
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
48
|
+
def from_dms(degree, minute, second)
|
49
49
|
sign = degree.negative? ? -1 : 1
|
50
50
|
degrees = degree.abs + minute / MINUTES_PER_HOUR + second / SECONDS_PER_HOUR
|
51
|
-
|
51
|
+
from_degrees(sign * degrees)
|
52
52
|
end
|
53
53
|
|
54
54
|
def asin(ratio)
|
55
55
|
radians = Math.asin(ratio)
|
56
|
-
|
56
|
+
from_radians(radians)
|
57
57
|
end
|
58
58
|
|
59
59
|
def acos(ratio)
|
60
60
|
radians = Math.acos(ratio)
|
61
|
-
|
61
|
+
from_radians(radians)
|
62
62
|
end
|
63
63
|
|
64
64
|
def atan(ratio)
|
65
65
|
radians = Math.atan(ratio)
|
66
|
-
|
66
|
+
from_radians(radians)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -87,11 +87,11 @@ module Astronoby
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def +(other)
|
90
|
-
self.class.
|
90
|
+
self.class.from_radians(radians + other.radians)
|
91
91
|
end
|
92
92
|
|
93
93
|
def -(other)
|
94
|
-
self.class.
|
94
|
+
self.class.from_radians(@radians - other.radians)
|
95
95
|
end
|
96
96
|
|
97
97
|
def sin
|
@@ -118,20 +118,16 @@ module Astronoby
|
|
118
118
|
radians.zero?
|
119
119
|
end
|
120
120
|
|
121
|
-
def ==(other)
|
122
|
-
other.is_a?(self.class) && radians == other.radians
|
123
|
-
end
|
124
|
-
alias_method :eql?, :==
|
125
|
-
|
126
121
|
def hash
|
127
122
|
[radians, self.class].hash
|
128
123
|
end
|
129
124
|
|
130
125
|
def <=>(other)
|
131
|
-
return
|
126
|
+
return unless other.is_a?(self.class)
|
132
127
|
|
133
128
|
radians <=> other.radians
|
134
129
|
end
|
130
|
+
alias_method :eql?, :==
|
135
131
|
|
136
132
|
def str(format)
|
137
133
|
case format
|
data/lib/astronoby/bodies/sun.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Astronoby
|
4
4
|
class Sun
|
5
5
|
SEMI_MAJOR_AXIS_IN_METERS = 149_598_500_000
|
6
|
-
ANGULAR_DIAMETER = Angle.
|
6
|
+
ANGULAR_DIAMETER = Angle.from_degrees(0.533128)
|
7
7
|
INTERPOLATION_FACTOR = BigDecimal("24.07")
|
8
8
|
|
9
9
|
# Source:
|
@@ -19,8 +19,8 @@ module Astronoby
|
|
19
19
|
epoch_at_noon = Epoch.from_time(noon)
|
20
20
|
sun_at_noon = new(epoch: epoch_at_noon)
|
21
21
|
equatorial_hours = sun_at_noon
|
22
|
-
.
|
23
|
-
.
|
22
|
+
.apparent_ecliptic_coordinates
|
23
|
+
.to_apparent_equatorial(epoch: epoch_at_noon)
|
24
24
|
.right_ascension
|
25
25
|
.hours
|
26
26
|
gst = GreenwichSiderealTime
|
@@ -41,13 +41,24 @@ module Astronoby
|
|
41
41
|
@epoch = epoch
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
def ecliptic_coordinates
|
44
|
+
def true_ecliptic_coordinates
|
46
45
|
Coordinates::Ecliptic.new(
|
47
46
|
latitude: Angle.zero,
|
48
|
-
longitude:
|
49
|
-
|
50
|
-
|
47
|
+
longitude: true_longitude
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
def apparent_ecliptic_coordinates
|
52
|
+
nutation = Nutation.for_ecliptic_longitude(epoch: @epoch)
|
53
|
+
longitude_with_aberration = Aberration.for_ecliptic_coordinates(
|
54
|
+
coordinates: true_ecliptic_coordinates,
|
55
|
+
epoch: @epoch
|
56
|
+
).longitude
|
57
|
+
apparent_longitude = nutation + longitude_with_aberration
|
58
|
+
|
59
|
+
Coordinates::Ecliptic.new(
|
60
|
+
latitude: Angle.zero,
|
61
|
+
longitude: apparent_longitude
|
51
62
|
)
|
52
63
|
end
|
53
64
|
|
@@ -59,8 +70,8 @@ module Astronoby
|
|
59
70
|
def horizontal_coordinates(latitude:, longitude:)
|
60
71
|
time = Epoch.to_utc(@epoch)
|
61
72
|
|
62
|
-
|
63
|
-
.
|
73
|
+
apparent_ecliptic_coordinates
|
74
|
+
.to_apparent_equatorial(epoch: @epoch)
|
64
75
|
.to_horizontal(time: time, latitude: latitude, longitude: longitude)
|
65
76
|
end
|
66
77
|
|
@@ -83,7 +94,8 @@ module Astronoby
|
|
83
94
|
# @param observer [Astronoby::Observer] Observer of the event
|
84
95
|
# @return [Astronoby::Angle, nil] Azimuth of sunrise
|
85
96
|
def rising_azimuth(observer:)
|
86
|
-
equatorial_coordinates =
|
97
|
+
equatorial_coordinates = apparent_ecliptic_coordinates
|
98
|
+
.to_apparent_equatorial(epoch: @epoch)
|
87
99
|
Body.new(equatorial_coordinates).rising_azimuth(
|
88
100
|
latitude: observer.latitude,
|
89
101
|
vertical_shift: vertical_shift
|
@@ -109,7 +121,8 @@ module Astronoby
|
|
109
121
|
# @param observer [Astronoby::Observer] Observer of the event
|
110
122
|
# @return [Astronoby::Angle, nil] Azimuth of sunset
|
111
123
|
def setting_azimuth(observer:)
|
112
|
-
equatorial_coordinates =
|
124
|
+
equatorial_coordinates = apparent_ecliptic_coordinates
|
125
|
+
.to_apparent_equatorial(epoch: @epoch)
|
113
126
|
Body.new(equatorial_coordinates).setting_azimuth(
|
114
127
|
latitude: observer.latitude,
|
115
128
|
vertical_shift: vertical_shift
|
@@ -123,7 +136,9 @@ module Astronoby
|
|
123
136
|
|
124
137
|
# @return [Astronoby::Angle] Apparent Sun's angular size
|
125
138
|
def angular_size
|
126
|
-
Angle.
|
139
|
+
Angle.from_degrees(
|
140
|
+
ANGULAR_DIAMETER.degrees * distance_angular_size_factor
|
141
|
+
)
|
127
142
|
end
|
128
143
|
|
129
144
|
# @return [Astronoby::Angle] Sun's true anomaly
|
@@ -139,27 +154,33 @@ module Astronoby
|
|
139
154
|
(1 + orbital_eccentricity.degrees) / (1 - orbital_eccentricity.degrees)
|
140
155
|
) * Math.tan(eccentric_anomaly.radians / 2)
|
141
156
|
|
142
|
-
Angle.
|
157
|
+
Angle.from_degrees((Angle.atan(tan).degrees * 2) % 360)
|
143
158
|
end
|
144
159
|
|
145
160
|
# @return [Astronoby::Angle] Sun's longitude at perigee
|
146
161
|
def longitude_at_perigee
|
147
|
-
Angle.
|
162
|
+
Angle.from_degrees(
|
148
163
|
(281.2208444 + 1.719175 * centuries + 0.000452778 * centuries**2) % 360
|
149
164
|
)
|
150
165
|
end
|
151
166
|
|
152
167
|
# @return [Astronoby::Angle] Sun's orbital eccentricity
|
153
168
|
def orbital_eccentricity
|
154
|
-
Angle.
|
169
|
+
Angle.from_degrees(
|
155
170
|
(0.01675104 - 0.0000418 * centuries - 0.000000126 * centuries**2) % 360
|
156
171
|
)
|
157
172
|
end
|
158
173
|
|
159
174
|
private
|
160
175
|
|
176
|
+
def true_longitude
|
177
|
+
Angle.from_degrees(
|
178
|
+
(true_anomaly + longitude_at_perigee).degrees % 360
|
179
|
+
)
|
180
|
+
end
|
181
|
+
|
161
182
|
def mean_anomaly
|
162
|
-
Angle.
|
183
|
+
Angle.from_degrees(
|
163
184
|
(longitude_at_base_epoch - longitude_at_perigee).degrees % 360
|
164
185
|
)
|
165
186
|
end
|
@@ -173,7 +194,7 @@ module Astronoby
|
|
173
194
|
end
|
174
195
|
|
175
196
|
def longitude_at_base_epoch
|
176
|
-
Angle.
|
197
|
+
Angle.from_degrees(
|
177
198
|
(279.6966778 + 36000.76892 * centuries + 0.0003025 * centuries**2) % 360
|
178
199
|
)
|
179
200
|
end
|
@@ -191,9 +212,10 @@ module Astronoby
|
|
191
212
|
sun_at_midnight = self.class.new(epoch: epoch)
|
192
213
|
shift = Body::DEFAULT_REFRACTION_VERTICAL_SHIFT +
|
193
214
|
GeocentricParallax.angle(distance: sun_at_midnight.earth_distance) +
|
194
|
-
Angle.
|
195
|
-
ecliptic_coordinates = sun_at_midnight.
|
196
|
-
equatorial_coordinates = ecliptic_coordinates
|
215
|
+
Angle.from_degrees(sun_at_midnight.angular_size.degrees / 2)
|
216
|
+
ecliptic_coordinates = sun_at_midnight.apparent_ecliptic_coordinates
|
217
|
+
equatorial_coordinates = ecliptic_coordinates
|
218
|
+
.to_apparent_equatorial(epoch: epoch)
|
197
219
|
|
198
220
|
event_time = if event == :rising
|
199
221
|
Body.new(equatorial_coordinates).rising_time(
|
@@ -220,7 +242,7 @@ module Astronoby
|
|
220
242
|
def vertical_shift
|
221
243
|
Astronoby::Body::DEFAULT_REFRACTION_VERTICAL_SHIFT +
|
222
244
|
Astronoby::GeocentricParallax.angle(distance: earth_distance) +
|
223
|
-
Astronoby::Angle.
|
245
|
+
Astronoby::Angle.from_degrees(angular_size.degrees / 2)
|
224
246
|
end
|
225
247
|
end
|
226
248
|
end
|
data/lib/astronoby/body.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Astronoby
|
4
4
|
class Body
|
5
|
-
DEFAULT_REFRACTION_VERTICAL_SHIFT = Angle.
|
5
|
+
DEFAULT_REFRACTION_VERTICAL_SHIFT = Angle.from_dms(0, 34, 0)
|
6
6
|
RISING_SETTING_HOUR_ANGLE_RATIO_RANGE = (-1..1)
|
7
7
|
|
8
8
|
def initialize(equatorial_coordinates)
|
@@ -80,7 +80,7 @@ module Astronoby
|
|
80
80
|
vertical_shift: nil
|
81
81
|
)
|
82
82
|
time_ratio = time_ratio(latitude, apparent, vertical_shift)
|
83
|
-
return
|
83
|
+
return unless RISING_SETTING_HOUR_ANGLE_RATIO_RANGE.cover?(time_ratio)
|
84
84
|
|
85
85
|
hour_angle = Angle.acos(time_ratio)
|
86
86
|
local_sidereal_time = LocalSiderealTime.new(
|
@@ -108,7 +108,7 @@ module Astronoby
|
|
108
108
|
|
109
109
|
azimuth_ratio = azimuth_ratio(latitude, apparent, vertical_shift)
|
110
110
|
|
111
|
-
Angle.
|
111
|
+
Angle.from_degrees(360 - Angle.acos(azimuth_ratio).degrees)
|
112
112
|
end
|
113
113
|
|
114
114
|
private
|
@@ -15,26 +15,37 @@ module Astronoby
|
|
15
15
|
# Author: J. L. Lawrence
|
16
16
|
# Edition: MIT Press
|
17
17
|
# Chapter: 4 - Orbits and Coordinate Systems
|
18
|
-
|
18
|
+
|
19
|
+
def to_true_equatorial(epoch:)
|
19
20
|
mean_obliquity = MeanObliquity.for_epoch(epoch)
|
21
|
+
to_equatorial(obliquity: mean_obliquity)
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_apparent_equatorial(epoch:)
|
25
|
+
apparent_obliquity = TrueObliquity.for_epoch(epoch)
|
26
|
+
to_equatorial(obliquity: apparent_obliquity)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
20
30
|
|
21
|
-
|
22
|
-
|
23
|
-
@
|
31
|
+
def to_equatorial(obliquity:)
|
32
|
+
y = Angle.from_radians(
|
33
|
+
@longitude.sin * obliquity.cos -
|
34
|
+
@latitude.tan * obliquity.sin
|
24
35
|
)
|
25
|
-
x = Angle.
|
36
|
+
x = Angle.from_radians(@longitude.cos)
|
26
37
|
r = Angle.atan(y.radians / x.radians)
|
27
38
|
right_ascension = Util::Trigonometry.adjustement_for_arctangent(y, x, r)
|
28
39
|
|
29
40
|
declination = Angle.asin(
|
30
|
-
@latitude.sin *
|
31
|
-
|
41
|
+
@latitude.sin * obliquity.cos +
|
42
|
+
@latitude.cos * obliquity.sin * @longitude.sin
|
32
43
|
)
|
33
44
|
|
34
45
|
Equatorial.new(
|
35
46
|
right_ascension: right_ascension,
|
36
47
|
declination: declination,
|
37
|
-
epoch: epoch
|
48
|
+
epoch: @epoch
|
38
49
|
)
|
39
50
|
end
|
40
51
|
end
|
@@ -25,7 +25,7 @@ module Astronoby
|
|
25
25
|
ha = (lst.time - @right_ascension.hours)
|
26
26
|
ha += 24 if ha.negative?
|
27
27
|
|
28
|
-
Angle.
|
28
|
+
Angle.from_hours(ha)
|
29
29
|
end
|
30
30
|
|
31
31
|
def to_horizontal(time:, latitude:, longitude:)
|
@@ -39,7 +39,7 @@ module Astronoby
|
|
39
39
|
azimuth = Angle.acos(t2)
|
40
40
|
|
41
41
|
if ha.sin.positive?
|
42
|
-
azimuth = Angle.
|
42
|
+
azimuth = Angle.from_degrees(BigDecimal("360") - azimuth.degrees)
|
43
43
|
end
|
44
44
|
|
45
45
|
Horizontal.new(
|
@@ -58,11 +58,11 @@ module Astronoby
|
|
58
58
|
def to_ecliptic(epoch:)
|
59
59
|
mean_obliquity = MeanObliquity.for_epoch(epoch)
|
60
60
|
|
61
|
-
y = Angle.
|
61
|
+
y = Angle.from_radians(
|
62
62
|
@right_ascension.sin * mean_obliquity.cos +
|
63
63
|
@declination.tan * mean_obliquity.sin
|
64
64
|
)
|
65
|
-
x = Angle.
|
65
|
+
x = Angle.from_radians(@right_ascension.cos)
|
66
66
|
r = Angle.atan(y.radians / x.radians)
|
67
67
|
longitude = Util::Trigonometry.adjustement_for_arctangent(y, x, r)
|
68
68
|
|
@@ -31,17 +31,17 @@ module Astronoby
|
|
31
31
|
|
32
32
|
if @azimuth.sin.positive?
|
33
33
|
hour_angle_degrees = Angle
|
34
|
-
.
|
34
|
+
.from_degrees(BigDecimal("360") - hour_angle_degrees)
|
35
35
|
.degrees
|
36
36
|
end
|
37
37
|
|
38
|
-
hour_angle_hours = Angle.
|
38
|
+
hour_angle_hours = Angle.from_degrees(hour_angle_degrees).hours
|
39
39
|
lst = GreenwichSiderealTime
|
40
40
|
.from_utc(time.utc)
|
41
41
|
.to_lst(longitude: @longitude)
|
42
42
|
right_ascension_decimal = lst.time - hour_angle_hours
|
43
43
|
right_ascension_decimal += 24 if right_ascension_decimal.negative?
|
44
|
-
right_ascension = Angle.
|
44
|
+
right_ascension = Angle.from_hours(right_ascension_decimal)
|
45
45
|
|
46
46
|
Equatorial.new(
|
47
47
|
right_ascension: right_ascension,
|
@@ -102,13 +102,13 @@ module Astronoby
|
|
102
102
|
|
103
103
|
def compute
|
104
104
|
t = (julian_day - Epoch::J2000) / Epoch::DAYS_PER_JULIAN_CENTURY
|
105
|
-
w = Angle.
|
105
|
+
w = Angle.from_degrees(35999.373 * t) - Angle.from_degrees(2.47)
|
106
106
|
delta = 1 +
|
107
107
|
0.0334 * w.cos +
|
108
|
-
0.0007 * Angle.
|
108
|
+
0.0007 * Angle.from_degrees(w.degrees * 2).cos
|
109
109
|
|
110
110
|
s = PERIODIC_TERMS.sum do |a, b, c|
|
111
|
-
a * (Angle.
|
111
|
+
a * (Angle.from_degrees(b) + Angle.from_degrees(c * t)).cos
|
112
112
|
end
|
113
113
|
|
114
114
|
delta_days = 0.00001 * s / delta
|
@@ -131,23 +131,9 @@ module Astronoby
|
|
131
131
|
|
132
132
|
def correction(epoch)
|
133
133
|
sun = Sun.new(epoch: epoch)
|
134
|
+
longitude = sun.apparent_ecliptic_coordinates.longitude
|
134
135
|
|
135
|
-
|
136
|
-
|
137
|
-
earth_radius_vector = 1 / (
|
138
|
-
1 +
|
139
|
-
sun.orbital_eccentricity.degrees *
|
140
|
-
(sun.true_anomaly - sun.longitude_at_perigee).cos
|
141
|
-
)
|
142
|
-
aberration = Angle.as_degrees(
|
143
|
-
Angle.as_dms(0, 0, 20.4898).degrees / -earth_radius_vector
|
144
|
-
)
|
145
|
-
|
146
|
-
corrected_longitude = sun.ecliptic_coordinates.longitude +
|
147
|
-
nutation +
|
148
|
-
aberration
|
149
|
-
|
150
|
-
58 * Angle.as_degrees(@event * 90 - corrected_longitude.degrees).sin
|
136
|
+
58 * Angle.from_degrees(@event * 90 - longitude.degrees).sin
|
151
137
|
end
|
152
138
|
end
|
153
139
|
end
|
@@ -16,7 +16,7 @@ module Astronoby
|
|
16
16
|
|
17
17
|
t = (epoch - EPOCH_OF_REFERENCE) / Epoch::DAYS_PER_JULIAN_CENTURY
|
18
18
|
|
19
|
-
Angle.
|
19
|
+
Angle.from_degrees(
|
20
20
|
obliquity_of_reference.degrees - (
|
21
21
|
46.815 * t -
|
22
22
|
0.0006 * t * t +
|
@@ -26,7 +26,7 @@ module Astronoby
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.obliquity_of_reference
|
29
|
-
Angle.
|
29
|
+
Angle.from_dms(23, 26, 21.45)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
data/lib/astronoby/nutation.rb
CHANGED
@@ -21,7 +21,7 @@ module Astronoby
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def for_ecliptic_longitude
|
24
|
-
Angle.
|
24
|
+
Angle.from_dms(
|
25
25
|
0,
|
26
26
|
0,
|
27
27
|
(
|
@@ -32,7 +32,7 @@ module Astronoby
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def for_obliquity_of_the_ecliptic
|
35
|
-
Angle.
|
35
|
+
Angle.from_dms(
|
36
36
|
0,
|
37
37
|
0,
|
38
38
|
(
|
@@ -49,13 +49,13 @@ module Astronoby
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def sun_mean_longitude
|
52
|
-
Angle.
|
52
|
+
Angle.from_degrees(
|
53
53
|
(279.6967 + 360.0 * (centuries_a - centuries_a.to_i)) % 360
|
54
54
|
)
|
55
55
|
end
|
56
56
|
|
57
57
|
def moon_ascending_node_longitude
|
58
|
-
Angle.
|
58
|
+
Angle.from_degrees(
|
59
59
|
(259.1833 - 360.0 * (centuries_b - centuries_b.to_i)) % 360
|
60
60
|
)
|
61
61
|
end
|
data/lib/astronoby/precession.rb
CHANGED
@@ -33,8 +33,8 @@ module Astronoby
|
|
33
33
|
|
34
34
|
Coordinates::Equatorial.new(
|
35
35
|
right_ascension: Util::Trigonometry.adjustement_for_arctangent(
|
36
|
-
Angle.
|
37
|
-
Angle.
|
36
|
+
Angle.from_radians(w[1]),
|
37
|
+
Angle.from_radians(w[0]),
|
38
38
|
Angle.atan(w[1] / w[0])
|
39
39
|
),
|
40
40
|
declination: Angle.asin(w[2]),
|
@@ -47,13 +47,13 @@ module Astronoby
|
|
47
47
|
def matrix_for_epoch(epoch)
|
48
48
|
t = (epoch - Epoch::DEFAULT_EPOCH) / Epoch::DAYS_PER_JULIAN_CENTURY
|
49
49
|
|
50
|
-
zeta = Angle.
|
50
|
+
zeta = Angle.from_degrees(
|
51
51
|
0.6406161 * t + 0.0000839 * t * t + 0.000005 * t * t * t
|
52
52
|
)
|
53
|
-
z = Angle.
|
53
|
+
z = Angle.from_degrees(
|
54
54
|
0.6406161 * t + 0.0003041 * t * t + 0.0000051 * t * t * t
|
55
55
|
)
|
56
|
-
theta = Angle.
|
56
|
+
theta = Angle.from_degrees(
|
57
57
|
0.5567530 * t - 0.0001185 * t * t - 0.0000116 * t * t * t
|
58
58
|
)
|
59
59
|
|
data/lib/astronoby/refraction.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
module Astronoby
|
4
4
|
class Refraction
|
5
|
-
LOW_ALTITUDE_BODY_ANGLE = Angle.
|
6
|
-
ZENITH = Angle.
|
5
|
+
LOW_ALTITUDE_BODY_ANGLE = Angle.from_degrees(15)
|
6
|
+
ZENITH = Angle.from_degrees(90)
|
7
7
|
|
8
8
|
def self.angle(coordinates:, observer:)
|
9
9
|
new(coordinates, observer).refraction_angle
|
@@ -56,7 +56,7 @@ module Astronoby
|
|
56
56
|
|
57
57
|
def high_altitude_angle
|
58
58
|
zenith_angle = ZENITH - @coordinates.altitude
|
59
|
-
Angle.
|
59
|
+
Angle.from_degrees(0.00452 * pressure * zenith_angle.tan / temperature)
|
60
60
|
end
|
61
61
|
|
62
62
|
def low_altitude_angle
|
@@ -67,7 +67,7 @@ module Astronoby
|
|
67
67
|
1 + 0.505 * altitude_in_degrees + 0.0845 * altitude_in_degrees**2
|
68
68
|
)
|
69
69
|
|
70
|
-
Angle.
|
70
|
+
Angle.from_degrees(term1 / term2)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -42,7 +42,7 @@ module Astronoby
|
|
42
42
|
previous_solution &&
|
43
43
|
(solution - previous_solution).abs <= precision
|
44
44
|
)
|
45
|
-
return Angle.
|
45
|
+
return Angle.from_radians(solution)
|
46
46
|
end
|
47
47
|
|
48
48
|
eccentric_anomaly_newton_raphson(
|
@@ -51,7 +51,7 @@ module Astronoby
|
|
51
51
|
precision,
|
52
52
|
maximum_iteration_count,
|
53
53
|
current_iteration + 1,
|
54
|
-
Angle.
|
54
|
+
Angle.from_radians(solution)
|
55
55
|
)
|
56
56
|
end
|
57
57
|
end
|
@@ -15,10 +15,10 @@ module Astronoby
|
|
15
15
|
return angle if y.positive? && x.positive?
|
16
16
|
|
17
17
|
if y.negative? && x.positive?
|
18
|
-
return Angle.
|
18
|
+
return Angle.from_degrees(angle.degrees + 360)
|
19
19
|
end
|
20
20
|
|
21
|
-
Angle.
|
21
|
+
Angle.from_degrees(angle.degrees + 180)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/lib/astronoby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: astronoby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rémy Hannequin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: matrix
|