astronoby 0.3.0 → 0.4.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 +72 -0
- data/Gemfile.lock +3 -3
- data/README.md +52 -17
- data/UPGRADING.md +24 -0
- data/lib/astronoby/aberration.rb +7 -5
- data/lib/astronoby/angle.rb +26 -34
- data/lib/astronoby/bodies/sun.rb +117 -122
- data/lib/astronoby/constants.rb +25 -0
- data/lib/astronoby/coordinates/ecliptic.rb +4 -4
- data/lib/astronoby/coordinates/equatorial.rb +3 -2
- data/lib/astronoby/coordinates/horizontal.rb +6 -2
- data/lib/astronoby/epoch.rb +0 -2
- data/lib/astronoby/equinox_solstice.rb +3 -2
- data/lib/astronoby/events/observation_events.rb +319 -0
- data/lib/astronoby/events/twilight_events.rb +121 -0
- data/lib/astronoby/geocentric_parallax.rb +2 -2
- data/lib/astronoby/mean_obliquity.rb +2 -2
- data/lib/astronoby/nutation.rb +5 -3
- data/lib/astronoby/observer.rb +33 -14
- data/lib/astronoby/precession.rb +1 -1
- data/lib/astronoby/time/greenwich_sidereal_time.rb +18 -29
- data/lib/astronoby/time/local_sidereal_time.rb +4 -4
- data/lib/astronoby/util/maths.rb +72 -0
- data/lib/astronoby/util/time.rb +88 -0
- data/lib/astronoby/util/trigonometry.rb +4 -4
- data/lib/astronoby/version.rb +1 -1
- data/lib/astronoby.rb +5 -1
- metadata +8 -4
- data/lib/astronoby/body.rb +0 -155
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c65785b0c459ba8add86fcceb906205caa79a80f47b7f33c0b7ee008173fd14
|
4
|
+
data.tar.gz: 66478c6055d84e34f560490f225ae3e3d5020972e729b37e8f6f0a6566ae173e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bae651aabaec62d258a768952eb3cd830d99639acf33f02b9f0ab6fd2eeff8215d9a30087a5818736b777c1a86344918f98f33f987f65829a8712cb20477c55
|
7
|
+
data.tar.gz: 401659e2d49599246ad2ea1a455a6d60b9797c49e730cacf8a614f4235929263c9318644373a96ea496969fcb814cc93144a8dbfffd0a0318e1628500bb1c8e8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,77 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.4.0 - 2024-04-29
|
4
|
+
|
5
|
+
_If you are upgrading: please see [UPGRADING.md]._
|
6
|
+
|
7
|
+
[UPGRADING.md]: https://github.com/rhannequin/astronoby/blob/main/UPGRADING.md
|
8
|
+
|
9
|
+
### Bug fixes
|
10
|
+
|
11
|
+
* Fix ecliptic to equatorial epoch ([#56])
|
12
|
+
|
13
|
+
[#56]: https://github.com/rhannequin/astronoby/pull/56
|
14
|
+
|
15
|
+
### Features
|
16
|
+
|
17
|
+
* Add twilight times ([#49])
|
18
|
+
* Add interpolation method ([#52])
|
19
|
+
* Add decimal_hour_to_time util ([#53])
|
20
|
+
* Calculate leap seconds for an instant ([#54])
|
21
|
+
* Add `Angle#-@` ([#55])
|
22
|
+
* Enable equivalence and hash equality to `Observer` ([#57])
|
23
|
+
* Twilight events dedicated class ([#61])
|
24
|
+
|
25
|
+
[#49]: https://github.com/rhannequin/astronoby/pull/49
|
26
|
+
[#52]: https://github.com/rhannequin/astronoby/pull/52
|
27
|
+
[#53]: https://github.com/rhannequin/astronoby/pull/53
|
28
|
+
[#54]: https://github.com/rhannequin/astronoby/pull/54
|
29
|
+
[#55]: https://github.com/rhannequin/astronoby/pull/55
|
30
|
+
[#57]: https://github.com/rhannequin/astronoby/pull/57
|
31
|
+
[#61]: https://github.com/rhannequin/astronoby/pull/61
|
32
|
+
|
33
|
+
### Improvements
|
34
|
+
|
35
|
+
* Upgrade bundler from 2.3.11 to 2.5.7 by @dorianmariecom ([#45])
|
36
|
+
* Drop `BigDecimal` ([#46])
|
37
|
+
* Bump rake from 13.1.0 to 13.2.0 ([#47])
|
38
|
+
* Increase Ruby versions support ([#48])
|
39
|
+
* Bump rake from 13.2.0 to 13.2.1 ([#51])
|
40
|
+
* Dedicated constants class ([#62])
|
41
|
+
* Improve accuracy of equation of time ([#63])
|
42
|
+
* Twilight times better accuracy ([#65])
|
43
|
+
* Update UPGRADING.md ([#66])
|
44
|
+
* release: Bump version to 0.4.0 ([#67])
|
45
|
+
|
46
|
+
[#45]: https://github.com/rhannequin/astronoby/pull/45
|
47
|
+
[#46]: https://github.com/rhannequin/astronoby/pull/46
|
48
|
+
[#47]: https://github.com/rhannequin/astronoby/pull/47
|
49
|
+
[#48]: https://github.com/rhannequin/astronoby/pull/48
|
50
|
+
[#51]: https://github.com/rhannequin/astronoby/pull/51
|
51
|
+
[#62]: https://github.com/rhannequin/astronoby/pull/62
|
52
|
+
[#63]: https://github.com/rhannequin/astronoby/pull/63
|
53
|
+
[#65]: https://github.com/rhannequin/astronoby/pull/65
|
54
|
+
[#66]: https://github.com/rhannequin/astronoby/pull/66
|
55
|
+
[#67]: https://github.com/rhannequin/astronoby/pull/67
|
56
|
+
|
57
|
+
### Backward-incompatible changes
|
58
|
+
|
59
|
+
* More accurate rising, transit and setting times ([#50])
|
60
|
+
* Observation events dedicated and centralized class ([#60])
|
61
|
+
* Change `Astronoby::Sun` constructor ([#64])
|
62
|
+
|
63
|
+
[#50]: https://github.com/rhannequin/astronoby/pull/50
|
64
|
+
[#60]: https://github.com/rhannequin/astronoby/pull/60
|
65
|
+
[#64]: https://github.com/rhannequin/astronoby/pull/64
|
66
|
+
|
67
|
+
### New Contributors
|
68
|
+
|
69
|
+
* @dorianmariecom made their first contribution in [#45]
|
70
|
+
|
71
|
+
[#45]: https://github.com/rhannequin/astronoby/pull/45
|
72
|
+
|
73
|
+
**Full Changelog**: https://github.com/rhannequin/astronoby/compare/v0.3.0...v0.4.0
|
74
|
+
|
3
75
|
## 0.3.0 - 2024-03-29
|
4
76
|
|
5
77
|
_If you are upgrading: please see [`UPGRADING.md`]._
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
astronoby (0.
|
4
|
+
astronoby (0.4.0)
|
5
5
|
matrix (~> 0.4.2)
|
6
6
|
rake (~> 13.0)
|
7
7
|
rspec (~> 3.0)
|
@@ -21,7 +21,7 @@ GEM
|
|
21
21
|
racc
|
22
22
|
racc (1.7.3)
|
23
23
|
rainbow (3.1.1)
|
24
|
-
rake (13.1
|
24
|
+
rake (13.2.1)
|
25
25
|
regexp_parser (2.9.0)
|
26
26
|
rexml (3.2.6)
|
27
27
|
rspec (3.13.0)
|
@@ -77,4 +77,4 @@ DEPENDENCIES
|
|
77
77
|
standard (~> 1.3)
|
78
78
|
|
79
79
|
BUNDLED WITH
|
80
|
-
2.
|
80
|
+
2.5.7
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ major one is released.
|
|
32
32
|
|
33
33
|
```rb
|
34
34
|
angle1 = Astronoby::Angle.from_degrees(90)
|
35
|
-
angle2 = Astronoby::Angle.from_radians(
|
35
|
+
angle2 = Astronoby::Angle.from_radians(Math::PI / 2)
|
36
36
|
angle3 = Astronoby::Angle.from_hours(12)
|
37
37
|
|
38
38
|
angle1 == angle2
|
@@ -71,47 +71,82 @@ horizontal.azimuth.str(:dms)
|
|
71
71
|
|
72
72
|
```rb
|
73
73
|
time = Time.utc(2023, 2, 17, 11, 0, 0)
|
74
|
-
epoch = Astronoby::Epoch.from_time(time)
|
75
74
|
|
76
75
|
latitude = Astronoby::Angle.from_degrees(48.8566)
|
77
76
|
longitude = Astronoby::Angle.from_degrees(2.3522)
|
78
77
|
|
79
|
-
sun = Astronoby::Sun.new(
|
78
|
+
sun = Astronoby::Sun.new(time: time)
|
80
79
|
|
81
80
|
horizontal_coordinates = sun.horizontal_coordinates(
|
82
81
|
latitude: latitude,
|
83
82
|
longitude: longitude
|
84
83
|
)
|
85
84
|
|
86
|
-
horizontal_coordinates.altitude.degrees
|
87
|
-
# => 27.
|
85
|
+
horizontal_coordinates.altitude.degrees
|
86
|
+
# => 27.500082409271247
|
88
87
|
|
89
88
|
horizontal_coordinates.altitude.str(:dms)
|
90
|
-
# => "+27° 30′ 0.
|
89
|
+
# => "+27° 30′ 0.2966″"
|
91
90
|
```
|
92
91
|
|
93
92
|
### Sunrise and sunset times and azimuths
|
94
93
|
|
95
94
|
```rb
|
96
|
-
|
97
|
-
epoch = Astronoby::Epoch.from_time(date)
|
95
|
+
time = Time.new(2015, 2, 5)
|
98
96
|
observer = Astronoby::Observer.new(
|
99
97
|
latitude: Astronoby::Angle.from_degrees(38),
|
100
98
|
longitude: Astronoby::Angle.from_degrees(-78)
|
101
99
|
)
|
102
|
-
sun = Astronoby::Sun.new(
|
100
|
+
sun = Astronoby::Sun.new(time: time)
|
101
|
+
observation_events = sun.observation_events(observer: observer)
|
103
102
|
|
104
|
-
|
105
|
-
# => 2015-02-05 12:
|
103
|
+
observation_events.rising_time
|
104
|
+
# => 2015-02-05 12:12:59 UTC
|
106
105
|
|
107
|
-
|
108
|
-
# => "+109°
|
106
|
+
observation_events.rising_azimuth.str(:dms)
|
107
|
+
# => "+109° 46′ 43.145″"
|
109
108
|
|
110
|
-
|
111
|
-
# => 2015-02-05
|
109
|
+
observation_events.transit_time
|
110
|
+
# => 2015-02-05 17:25:59 UTC
|
112
111
|
|
113
|
-
|
114
|
-
# => "+
|
112
|
+
observation_events.transit_altitude.str(:dms)
|
113
|
+
# => "+36° 8′ 15.7638″"
|
114
|
+
|
115
|
+
observation_events.setting_time
|
116
|
+
# => 2015-02-05 22:39:27 UTC
|
117
|
+
|
118
|
+
observation_events.setting_azimuth.str(:dms)
|
119
|
+
# => "+250° 23′ 33.614″"
|
120
|
+
```
|
121
|
+
|
122
|
+
### Twilight times
|
123
|
+
|
124
|
+
```rb
|
125
|
+
time = Time.new(2024, 1, 1)
|
126
|
+
sun = Astronoby::Sun.new(time: time)
|
127
|
+
observer = Astronoby::Observer.new(
|
128
|
+
latitude: Astronoby::Angle.from_degrees(48.8566),
|
129
|
+
longitude: Astronoby::Angle.from_degrees(2.3522)
|
130
|
+
)
|
131
|
+
twilight_events = sun.twilight_events(observer: observer)
|
132
|
+
|
133
|
+
twilight_events.morning_astronomical_twilight_time
|
134
|
+
# => 2024-01-01 05:49:25 UTC
|
135
|
+
|
136
|
+
twilight_events.morning_nautical_twilight_time
|
137
|
+
# => 2024-01-01 06:27:42 UTC
|
138
|
+
|
139
|
+
twilight_events.morning_civil_twilight_time
|
140
|
+
# => 2024-01-01 07:07:50 UTC
|
141
|
+
|
142
|
+
twilight_events.evening_civil_twilight_time
|
143
|
+
# => 2024-01-01 16:40:01 UTC
|
144
|
+
|
145
|
+
twilight_events.evening_nautical_twilight_time
|
146
|
+
# => 2024-01-01 17:20:10 UTC
|
147
|
+
|
148
|
+
twilight_events.evening_astronomical_twilight_time
|
149
|
+
# => 2024-01-01 17:58:26 UTC
|
115
150
|
```
|
116
151
|
|
117
152
|
### Solstice and Equinox times
|
data/UPGRADING.md
CHANGED
@@ -7,6 +7,30 @@ 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.3.0 to 0.4.0
|
11
|
+
|
12
|
+
### `Body` class removed ([#50])
|
13
|
+
|
14
|
+
The different behaviors from `Body` have been moved to other classes like
|
15
|
+
`Events::ObservationEvents`.
|
16
|
+
|
17
|
+
[#50]: https://github.com/rhannequin/astronoby/pull/50
|
18
|
+
|
19
|
+
### Rising and setting times and azimuths removed from `Sun` ([#60])
|
20
|
+
|
21
|
+
`#rising_time`, `#rising_azimuth`, `#setting_time` and `#setting_azimuth`
|
22
|
+
have been removed from `Astronoby::Sun` and moved to
|
23
|
+
`Astronoby::Events::ObservationEvents`.
|
24
|
+
|
25
|
+
[#60]: https://github.com/rhannequin/astronoby/pull/60
|
26
|
+
|
27
|
+
### `Sun` constructor changed ([#64])
|
28
|
+
|
29
|
+
The `Sun` constructor now doesn't accept the `epoch` key argument anymore,
|
30
|
+
but only a new `time` key argument.
|
31
|
+
|
32
|
+
[#64]: https://github.com/rhannequin/astronoby/pull/64
|
33
|
+
|
10
34
|
## Upgrading from 0.2.0 to 0.3.0
|
11
35
|
|
12
36
|
### `Sun#ecliptic_coordinates` method removed (#41)
|
data/lib/astronoby/aberration.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
module Astronoby
|
4
4
|
class Aberration
|
5
|
+
MAXIMUM_SHIFT = Angle.from_degrees(20.5)
|
6
|
+
|
5
7
|
def self.for_ecliptic_coordinates(coordinates:, epoch:)
|
6
8
|
new(coordinates, epoch).apply
|
7
9
|
end
|
@@ -18,15 +20,15 @@ module Astronoby
|
|
18
20
|
# Chapter: 36 - Aberration
|
19
21
|
def apply
|
20
22
|
delta_longitude = Angle.from_degrees(
|
21
|
-
-
|
23
|
+
-MAXIMUM_SHIFT.degrees * (
|
22
24
|
sun_longitude - @coordinates.longitude
|
23
|
-
).cos / @coordinates.latitude.cos /
|
25
|
+
).cos / @coordinates.latitude.cos / Constants::SECONDS_PER_DEGREE
|
24
26
|
)
|
25
27
|
|
26
28
|
delta_latitude = Angle.from_degrees(
|
27
|
-
-
|
29
|
+
-MAXIMUM_SHIFT.degrees *
|
28
30
|
(sun_longitude - @coordinates.longitude).sin *
|
29
|
-
@coordinates.latitude.sin /
|
31
|
+
@coordinates.latitude.sin / Constants::SECONDS_PER_DEGREE
|
30
32
|
)
|
31
33
|
|
32
34
|
Coordinates::Ecliptic.new(
|
@@ -37,7 +39,7 @@ module Astronoby
|
|
37
39
|
|
38
40
|
def sun_longitude
|
39
41
|
@_sun_longitude ||= Sun
|
40
|
-
.new(
|
42
|
+
.new(time: Epoch.to_utc(@epoch))
|
41
43
|
.true_ecliptic_coordinates
|
42
44
|
.longitude
|
43
45
|
end
|
data/lib/astronoby/angle.rb
CHANGED
@@ -1,23 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "bigdecimal/math"
|
4
|
-
|
5
3
|
module Astronoby
|
6
4
|
class Angle
|
7
5
|
include Comparable
|
8
6
|
|
9
|
-
|
10
|
-
PI = BigMath.PI(PRECISION)
|
11
|
-
PI_IN_DEGREES = BigDecimal("180")
|
12
|
-
|
13
|
-
FULL_CIRCLE_IN_RADIANS = (2 * PI)
|
14
|
-
|
15
|
-
RADIAN_PER_HOUR = PI / BigDecimal("12")
|
16
|
-
MINUTES_PER_DEGREE = BigDecimal("60")
|
17
|
-
MINUTES_PER_HOUR = BigDecimal("60")
|
18
|
-
SECONDS_PER_MINUTE = BigDecimal("60")
|
19
|
-
SECONDS_PER_HOUR = MINUTES_PER_HOUR * SECONDS_PER_MINUTE
|
20
|
-
|
7
|
+
MIN_PRECISION = 10
|
21
8
|
FORMATS = %i[dms hms].freeze
|
22
9
|
|
23
10
|
class << self
|
@@ -26,28 +13,32 @@ module Astronoby
|
|
26
13
|
end
|
27
14
|
|
28
15
|
def from_radians(radians)
|
29
|
-
normalized_radians = radians.remainder(
|
16
|
+
normalized_radians = radians.remainder(Constants::RADIANS_PER_CIRCLE)
|
30
17
|
new(normalized_radians)
|
31
18
|
end
|
32
19
|
|
33
20
|
def from_degrees(degrees)
|
34
|
-
radians = degrees / PI_IN_DEGREES * PI
|
21
|
+
radians = degrees / Constants::PI_IN_DEGREES * Math::PI
|
35
22
|
from_radians(radians)
|
36
23
|
end
|
37
24
|
|
38
25
|
def from_hours(hours)
|
39
|
-
radians = hours * RADIAN_PER_HOUR
|
26
|
+
radians = hours * Constants::RADIAN_PER_HOUR
|
40
27
|
from_radians(radians)
|
41
28
|
end
|
42
29
|
|
43
30
|
def from_hms(hour, minute, second)
|
44
|
-
hours = hour +
|
31
|
+
hours = hour +
|
32
|
+
minute / Constants::MINUTES_PER_HOUR +
|
33
|
+
second / Constants::SECONDS_PER_HOUR
|
45
34
|
from_hours(hours)
|
46
35
|
end
|
47
36
|
|
48
37
|
def from_dms(degree, minute, second)
|
49
38
|
sign = degree.negative? ? -1 : 1
|
50
|
-
degrees = degree.abs +
|
39
|
+
degrees = degree.abs +
|
40
|
+
minute / Constants::MINUTES_PER_HOUR +
|
41
|
+
second / Constants::SECONDS_PER_HOUR
|
51
42
|
from_degrees(sign * degrees)
|
52
43
|
end
|
53
44
|
|
@@ -70,20 +61,16 @@ module Astronoby
|
|
70
61
|
attr_reader :radians
|
71
62
|
|
72
63
|
def initialize(radians)
|
73
|
-
@radians =
|
74
|
-
BigDecimal(radians)
|
75
|
-
else
|
76
|
-
BigDecimal(radians, PRECISION)
|
77
|
-
end
|
64
|
+
@radians = radians
|
78
65
|
freeze
|
79
66
|
end
|
80
67
|
|
81
68
|
def degrees
|
82
|
-
@radians * PI_IN_DEGREES / PI
|
69
|
+
@radians * Constants::PI_IN_DEGREES / Math::PI
|
83
70
|
end
|
84
71
|
|
85
72
|
def hours
|
86
|
-
@radians / RADIAN_PER_HOUR
|
73
|
+
@radians / Constants::RADIAN_PER_HOUR
|
87
74
|
end
|
88
75
|
|
89
76
|
def +(other)
|
@@ -94,6 +81,10 @@ module Astronoby
|
|
94
81
|
self.class.from_radians(@radians - other.radians)
|
95
82
|
end
|
96
83
|
|
84
|
+
def -@
|
85
|
+
self.class.from_radians(-@radians)
|
86
|
+
end
|
87
|
+
|
97
88
|
def sin
|
98
89
|
Math.sin(radians)
|
99
90
|
end
|
@@ -144,31 +135,32 @@ module Astronoby
|
|
144
135
|
sign = deg.negative? ? "-" : "+"
|
145
136
|
absolute_degrees = deg.abs
|
146
137
|
degrees = absolute_degrees.floor
|
147
|
-
decimal_minutes = MINUTES_PER_DEGREE *
|
138
|
+
decimal_minutes = Constants::MINUTES_PER_DEGREE *
|
139
|
+
(absolute_degrees - degrees)
|
148
140
|
absolute_decimal_minutes = (
|
149
|
-
MINUTES_PER_DEGREE * (absolute_degrees - degrees)
|
141
|
+
Constants::MINUTES_PER_DEGREE * (absolute_degrees - degrees)
|
150
142
|
).abs
|
151
143
|
minutes = decimal_minutes.floor
|
152
|
-
seconds = SECONDS_PER_MINUTE * (
|
144
|
+
seconds = Constants::SECONDS_PER_MINUTE * (
|
153
145
|
absolute_decimal_minutes - absolute_decimal_minutes.floor
|
154
146
|
)
|
155
147
|
|
156
|
-
Dms.new(sign, degrees, minutes, seconds.
|
148
|
+
Dms.new(sign, degrees, minutes, seconds.floor(4))
|
157
149
|
end
|
158
150
|
|
159
151
|
def to_hms(hrs)
|
160
152
|
absolute_hours = hrs.abs
|
161
153
|
hours = absolute_hours.floor
|
162
|
-
decimal_minutes = MINUTES_PER_HOUR * (absolute_hours - hours)
|
154
|
+
decimal_minutes = Constants::MINUTES_PER_HOUR * (absolute_hours - hours)
|
163
155
|
absolute_decimal_minutes = (
|
164
|
-
MINUTES_PER_HOUR * (absolute_hours - hours)
|
156
|
+
Constants::MINUTES_PER_HOUR * (absolute_hours - hours)
|
165
157
|
).abs
|
166
158
|
minutes = decimal_minutes.floor
|
167
|
-
seconds = SECONDS_PER_MINUTE * (
|
159
|
+
seconds = Constants::SECONDS_PER_MINUTE * (
|
168
160
|
absolute_decimal_minutes - absolute_decimal_minutes.floor
|
169
161
|
)
|
170
162
|
|
171
|
-
Hms.new(hours, minutes, seconds.
|
163
|
+
Hms.new(hours, minutes, seconds.floor(4))
|
172
164
|
end
|
173
165
|
end
|
174
166
|
end
|