astronoby 0.9.0 → 0.10.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.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/CHANGELOG.md +101 -0
  4. data/README.md +6 -1
  5. data/UPGRADING.md +84 -0
  6. data/docs/README.md +80 -15
  7. data/docs/angles.md +1 -0
  8. data/docs/configuration.md +20 -17
  9. data/docs/coordinates.md +72 -12
  10. data/docs/deep_sky_bodies.md +1 -1
  11. data/docs/ephem.md +5 -2
  12. data/docs/equinoxes_solstices_times.md +4 -3
  13. data/docs/glossary.md +97 -1
  14. data/docs/iers.md +40 -0
  15. data/docs/instant.md +20 -15
  16. data/docs/lunar_eclipses.md +93 -0
  17. data/docs/lunar_observation.md +87 -0
  18. data/docs/moon_phases.md +4 -1
  19. data/docs/observer.md +20 -6
  20. data/docs/planetary_phenomena.md +78 -0
  21. data/docs/reference_frames.md +192 -34
  22. data/docs/rise_transit_set_times.md +6 -4
  23. data/docs/solar_system_bodies.md +26 -4
  24. data/docs/twilight_times.md +25 -21
  25. data/lib/astronoby/angle.rb +63 -2
  26. data/lib/astronoby/angles/dms.rb +18 -1
  27. data/lib/astronoby/angles/hms.rb +14 -1
  28. data/lib/astronoby/angular_velocity.rb +21 -0
  29. data/lib/astronoby/bodies/deep_sky_object.rb +6 -1
  30. data/lib/astronoby/bodies/deep_sky_object_position.rb +32 -17
  31. data/lib/astronoby/bodies/earth.rb +7 -44
  32. data/lib/astronoby/bodies/jupiter.rb +10 -0
  33. data/lib/astronoby/bodies/mars.rb +10 -0
  34. data/lib/astronoby/bodies/mercury.rb +10 -0
  35. data/lib/astronoby/bodies/moon.rb +158 -32
  36. data/lib/astronoby/bodies/neptune.rb +10 -0
  37. data/lib/astronoby/bodies/saturn.rb +10 -0
  38. data/lib/astronoby/bodies/solar_system_body.rb +240 -61
  39. data/lib/astronoby/bodies/sun.rb +79 -4
  40. data/lib/astronoby/bodies/uranus.rb +10 -0
  41. data/lib/astronoby/bodies/venus.rb +10 -0
  42. data/lib/astronoby/body.rb +6 -0
  43. data/lib/astronoby/center.rb +84 -0
  44. data/lib/astronoby/constellation.rb +9 -1
  45. data/lib/astronoby/coordinates/ecliptic.rb +10 -1
  46. data/lib/astronoby/coordinates/equatorial.rb +64 -8
  47. data/lib/astronoby/coordinates/geodetic.rb +102 -0
  48. data/lib/astronoby/coordinates/horizontal.rb +13 -1
  49. data/lib/astronoby/distance.rb +35 -0
  50. data/lib/astronoby/duration.rb +116 -0
  51. data/lib/astronoby/earth_rotation.rb +70 -0
  52. data/lib/astronoby/equinox_solstice.rb +31 -8
  53. data/lib/astronoby/errors.rb +11 -0
  54. data/lib/astronoby/events/conjunction.rb +51 -0
  55. data/lib/astronoby/events/conjunction_opposition_calculator.rb +84 -0
  56. data/lib/astronoby/events/eclipse_phase.rb +27 -0
  57. data/lib/astronoby/events/extremum_calculator.rb +23 -176
  58. data/lib/astronoby/events/greatest_elongation.rb +58 -0
  59. data/lib/astronoby/events/greatest_elongation_calculator.rb +56 -0
  60. data/lib/astronoby/events/lunar_eclipse.rb +99 -0
  61. data/lib/astronoby/events/lunar_eclipse_calculator.rb +285 -0
  62. data/lib/astronoby/events/opposition.rb +19 -0
  63. data/lib/astronoby/events/rise_transit_set_event.rb +12 -1
  64. data/lib/astronoby/events/rise_transit_set_events.rb +12 -1
  65. data/lib/astronoby/events/twilight_event.rb +24 -6
  66. data/lib/astronoby/events/twilight_events.rb +26 -6
  67. data/lib/astronoby/extremum_finder.rb +148 -0
  68. data/lib/astronoby/instant.rb +10 -7
  69. data/lib/astronoby/libration.rb +25 -0
  70. data/lib/astronoby/mean_obliquity.rb +8 -0
  71. data/lib/astronoby/moon_orientation_ephemeris.rb +69 -0
  72. data/lib/astronoby/moon_physical_ephemeris.rb +263 -0
  73. data/lib/astronoby/nutation.rb +10 -20
  74. data/lib/astronoby/observer.rb +67 -49
  75. data/lib/astronoby/orientation.rb +107 -0
  76. data/lib/astronoby/position.rb +16 -0
  77. data/lib/astronoby/precession.rb +61 -60
  78. data/lib/astronoby/reference_frame.rb +73 -7
  79. data/lib/astronoby/reference_frames/apparent.rb +26 -7
  80. data/lib/astronoby/reference_frames/astrometric.rb +14 -1
  81. data/lib/astronoby/reference_frames/geometric.rb +7 -1
  82. data/lib/astronoby/reference_frames/mean_of_date.rb +13 -1
  83. data/lib/astronoby/reference_frames/teme.rb +153 -0
  84. data/lib/astronoby/reference_frames/topocentric.rb +30 -4
  85. data/lib/astronoby/refraction.rb +26 -5
  86. data/lib/astronoby/root_finder.rb +83 -0
  87. data/lib/astronoby/rotation.rb +49 -0
  88. data/lib/astronoby/time/greenwich_apparent_sidereal_time.rb +9 -0
  89. data/lib/astronoby/time/greenwich_mean_sidereal_time.rb +42 -5
  90. data/lib/astronoby/time/greenwich_sidereal_time.rb +21 -0
  91. data/lib/astronoby/time/local_apparent_sidereal_time.rb +21 -0
  92. data/lib/astronoby/time/local_mean_sidereal_time.rb +21 -0
  93. data/lib/astronoby/time/local_sidereal_time.rb +24 -0
  94. data/lib/astronoby/time/sidereal_time.rb +23 -1
  95. data/lib/astronoby/true_obliquity.rb +4 -0
  96. data/lib/astronoby/util/maths.rb +8 -0
  97. data/lib/astronoby/util/time.rb +10 -485
  98. data/lib/astronoby/vector.rb +10 -0
  99. data/lib/astronoby/velocity.rb +39 -0
  100. data/lib/astronoby/version.rb +1 -1
  101. data/lib/astronoby.rb +22 -0
  102. metadata +45 -5
@@ -15,16 +15,17 @@ Astronoby::EquinoxSolstice.march_equinox(2025, ephem)
15
15
  # => 2025-03-20 09:01:29 UTC
16
16
 
17
17
  Astronoby::EquinoxSolstice.june_solstice(2025, ephem)
18
- # => 2025-06-21 02:42:19 UTC
18
+ # => 2025-06-21 02:42:16 UTC
19
19
 
20
20
  Astronoby::EquinoxSolstice.september_equinox(2025, ephem)
21
- # => 2025-09-22 18:19:22 UTC
21
+ # => 2025-09-22 18:19:21 UTC
22
22
 
23
23
  Astronoby::EquinoxSolstice.december_solstice(2025, ephem)
24
- # => 2025-12-21 15:03:03 UTC
24
+ # => 2025-12-21 15:03:05 UTC
25
25
  ```
26
26
 
27
27
  ## See also
28
+
28
29
  - [Twilight Times](twilight_times.md) - for seasonal sun events
29
30
  - [Moon Phases](moon_phases.md) - for lunar events
30
31
  - [Ephemerides](ephem.md) - for data sources
data/docs/glossary.md CHANGED
@@ -5,130 +5,223 @@ This glossary defines key astronomical and technical terms used throughout the A
5
5
  ## Astronomical Terms
6
6
 
7
7
  ### **Aberration**
8
+
8
9
  The apparent displacement of a celestial object due to the finite speed of light and the motion of the observer. In Astronoby, this is automatically corrected in apparent reference frames.
9
10
 
10
11
  ### **Altitude**
12
+
11
13
  The angular distance of a celestial object above the observer's local horizon, measured in degrees from 0° (horizon) to 90° (zenith).
12
14
 
13
15
  ### **Apparent Position**
16
+
14
17
  The position of a celestial object as it appears in the sky, corrected for light-time, aberration, and other effects. This is what you actually see when looking through a telescope.
15
18
 
16
19
  ### **Arc Second**
20
+
17
21
  A unit of angular measurement equal to 1/3600th of a degree. Often used to describe the precision of astronomical calculations.
18
22
 
19
23
  ### **Azimuth**
24
+
20
25
  The angular distance around the horizon from north, measured clockwise in degrees. North is 0°, east is 90°, south is 180°, and west is 270°.
21
26
 
22
27
  ### **Barycentre**
28
+
23
29
  The centre of mass of a system of bodies. In the Solar System, this is the point around which all planets orbit, which is usually close to but not exactly at the Sun's centre.
24
30
 
25
31
  ### **Celestial Equator**
32
+
26
33
  The projection of Earth's equator onto the celestial sphere. It's the reference plane for equatorial coordinates.
27
34
 
28
35
  ### **Celestial Sphere**
36
+
29
37
  An imaginary sphere surrounding Earth, on which all celestial objects appear to be located. Used as a reference system for astronomical coordinates.
30
38
 
31
39
  ### **Constellation**
40
+
32
41
  A region of the sky containing a group of stars that form a recognizable pattern. Astronoby can determine which constellation a celestial body appears to be in.
33
42
 
34
43
  ### **Declination**
44
+
35
45
  The angular distance north or south of the celestial equator, measured in degrees. Positive values are north, negative values are south.
36
46
 
37
47
  ### **Ecliptic**
48
+
38
49
  The apparent path of the Sun across the celestial sphere throughout the year. It's the plane of Earth's orbit around the Sun.
39
50
 
40
51
  ### **Ephemeris**
52
+
41
53
  A table or file containing the calculated positions of celestial objects at specific times. Astronoby uses ephemeris files from JPL and IMCCE for high-precision calculations.
42
54
 
43
55
  ### **Equinox**
56
+
44
57
  The two times each year when the Sun crosses the celestial equator, making day and night approximately equal in length. The March (vernal) and September (autumnal) equinoxes.
45
58
 
46
59
  ### **Geocentric**
60
+
47
61
  As seen from the centre of Earth. Geocentric coordinates are useful for calculations but don't account for an observer's specific location.
48
62
 
49
63
  ### **Horizon**
64
+
50
65
  The apparent boundary between Earth and sky as seen by an observer. The local horizon depends on the observer's location and elevation.
51
66
 
52
67
  ### **Illuminated Fraction**
68
+
53
69
  The portion of a celestial body's disk that appears illuminated as seen from Earth. For the Moon, this varies from 0 (new moon) to 1 (full moon).
54
70
 
55
71
  ### **Julian Date**
72
+
56
73
  A continuous count of days since January 1, 4713 BCE. Used in astronomy for precise time measurements and calculations.
57
74
 
58
75
  ### **Light-Time Correction**
76
+
59
77
  The adjustment made to account for the time it takes light to travel from a celestial object to Earth. Important for accurate position calculations.
60
78
 
61
79
  ### **Magnitude**
80
+
62
81
  A measure of a celestial object's brightness. Lower numbers indicate brighter objects (e.g., -4 is brighter than +2). Apparent magnitude is as seen from Earth, absolute magnitude is intrinsic brightness.
63
82
 
64
83
  ### **Meridian**
84
+
65
85
  An imaginary line passing through the observer's zenith and the north and south celestial poles. Objects transit (cross) the meridian when they reach their highest point in the sky.
66
86
 
67
87
  ### **Nutation**
88
+
68
89
  Small periodic variations in the orientation of Earth's rotation axis, caused by gravitational forces from the Sun and Moon.
69
90
 
70
91
  ### **Obliquity**
92
+
71
93
  The angle between Earth's equatorial plane and the ecliptic plane. Currently about 23.4° and slowly decreasing.
72
94
 
73
95
  ### **Parallax**
96
+
74
97
  The apparent shift in position of a nearby object when viewed from different locations. Important for calculating distances to nearby stars.
75
98
 
76
99
  ### **Phase Angle**
100
+
77
101
  The angle between the Sun, a celestial object, and Earth. For planets, this determines how much of the disk is illuminated.
78
102
 
79
103
  ### **Precession**
104
+
80
105
  The slow, continuous change in the orientation of Earth's rotation axis, causing the positions of the equinoxes to shift over time.
81
106
 
82
107
  ### **Refraction**
108
+
83
109
  The bending of light as it passes through Earth's atmosphere, causing celestial objects to appear slightly higher in the sky than they actually are.
84
110
 
85
111
  ### **Right Ascension**
112
+
86
113
  The angular distance eastward along the celestial equator from the vernal equinox, measured in hours (0-24h) or degrees (0-360°).
87
114
 
88
115
  ### **Solstice**
116
+
89
117
  The two times each year when the Sun reaches its northernmost (June) or southernmost (December) position relative to the celestial equator.
90
118
 
91
119
  ### **Topocentric**
120
+
92
121
  As seen from a specific location on Earth's surface. Topocentric positions account for the observer's latitude, longitude, and elevation.
93
122
 
123
+ ### **TEME (True Equator, Mean Equinox)**
124
+
125
+ The reference frame used by the SGP4/SDP4 satellite orbit propagators. It shares the true equator with the apparent frame but uses the mean equinox (tracked by GMST) instead of the true equinox (tracked by GAST).
126
+
94
127
  ### **Transit**
128
+
95
129
  The moment when a celestial object crosses the observer's meridian, reaching its highest point in the sky for that day.
96
130
 
97
131
  ### **Twilight**
132
+
98
133
  The period before sunrise and after sunset when the sky is partially illuminated by scattered sunlight. Civil, nautical, and astronomical twilight have different definitions based on the Sun's position below the horizon.
99
134
 
100
135
  ### **Zenith**
136
+
101
137
  The point directly above an observer on Earth, at an altitude of 90°.
102
138
 
103
139
  ## Technical Terms
104
140
 
105
141
  ### **API (Application Programming Interface)**
142
+
106
143
  The set of methods and classes that programmers use to interact with the Astronoby library.
107
144
 
145
+ ### **Body**
146
+
147
+ A catalog definition that can position itself at an instant, returning a Position. Solar system bodies (the classes themselves, e.g. `Astronoby::Saturn`) and deep-sky objects (`Astronoby::DeepSkyObject` instances) both fulfil this role.
148
+
108
149
  ### **Cache**
150
+
109
151
  A temporary storage system that stores frequently used calculation results to improve performance.
110
152
 
153
+ ### **Centre**
154
+
155
+ The point a reference frame is relative to, modelled by the `Astronoby::Center` value object: barycentric (Solar System barycentre), geocentric (Earth's centre), or topocentric (a specific observer's location).
156
+
111
157
  ### **Coordinate System**
158
+
112
159
  A system for specifying the position of objects in space. Astronoby supports equatorial, ecliptic, and horizontal coordinate systems.
113
160
 
114
161
  ### **Ephemeris File**
162
+
115
163
  A binary file (usually with .bsp extension) containing orbital data for Solar System bodies. These files are produced by JPL and IMCCE.
116
164
 
117
165
  ### **Floating-Point Precision**
166
+
118
167
  The accuracy of decimal number calculations. Higher precision values in Astronoby provide more accurate results but may be slower.
119
168
 
169
+ ### **BCRS (Barycentric Celestial Reference System)**
170
+
171
+ A coordinate system centered on the Solar System barycentre with axes aligned to the ICRS. In Astronoby, this corresponds to the geometric reference frame.
172
+
173
+ ### **ECEF (Earth-Centered Earth-Fixed)**
174
+
175
+ A Cartesian coordinate system that rotates with the Earth. Equivalent to ITRS. In Astronoby, observer positions are expressed in ECEF.
176
+
177
+ ### **Equation of the Equinoxes**
178
+
179
+ The difference between Greenwich Apparent Sidereal Time (GAST) and Greenwich Mean Sidereal Time (GMST), equal to the nutation in longitude projected onto the equator (Δψ cos ε₀). It defines the angular offset between the mean and true equinoxes.
180
+
181
+ ### **GAST (Greenwich Apparent Sidereal Time)**
182
+
183
+ The hour angle of the true vernal equinox at the Greenwich meridian. Equal to GMST plus the equation of the equinoxes. Used to rotate observer positions from ECEF into the true-equinox celestial frame.
184
+
185
+ ### **GCRS (Geocentric Celestial Reference System)**
186
+
187
+ A coordinate system centered on the Earth's centre with axes aligned to the ICRS. In Astronoby, this corresponds to the astrometric reference frame.
188
+
189
+ ### **GMST (Greenwich Mean Sidereal Time)**
190
+
191
+ The hour angle of the mean vernal equinox at the Greenwich meridian. It measures Earth's rotation relative to the mean equinox, without nutation corrections. Used in the TEME ↔ ECEF conversion.
192
+
193
+ ### **ICRS (International Celestial Reference System)**
194
+
195
+ The standard celestial reference system adopted by the IAU. Its axes are defined by the positions of extragalactic radio sources and are practically fixed in space. JPL ephemeris data is given in ICRS-aligned coordinates.
196
+
197
+ ### **ITRS (International Terrestrial Reference System)**
198
+
199
+ The standard Earth-fixed reference system, also known as ECEF (Earth-Centered Earth-Fixed). Observer positions in Astronoby are expressed in ITRS before being rotated into the celestial frame.
200
+
201
+ ### **Position**
202
+
203
+ A target resolved at a specific instant, exposing the reference frame chain (astrometric, apparent, topocentric, ...) for a Body. Solar system body instances and `Astronoby::DeepSkyObjectPosition` instances fulfil this role.
204
+
120
205
  ### **Reference Frame**
121
- A coordinate system used to specify positions. Astronoby provides geometric, astrometric, mean of date, apparent, and topocentric reference frames.
206
+
207
+ A coordinate system used to specify positions. Astronoby provides geometric, astrometric, mean of date, apparent, and topocentric reference frames for celestial bodies, plus TEME for satellite tracking. See [Reference Frames](reference_frames.md) for how they map to IAU/IERS standard systems.
208
+
209
+ ### **WGS-84 (World Geodetic System 1984)**
210
+
211
+ The geodetic reference system used by GPS and Astronoby for specifying observer latitude, longitude, and elevation. Observer coordinates are converted from WGS-84 geodetic to ITRS geocentric Cartesian internally.
122
212
 
123
213
  ### **SPICE**
214
+
124
215
  A NASA toolkit for computing positions and orientations of Solar System bodies. Astronoby uses SPICE binary kernels (.bsp files) for ephemeris data.
125
216
 
126
217
  ### **UTC (Coordinated Universal Time)**
218
+
127
219
  The primary time standard used worldwide. All astronomical calculations in Astronoby are based on UTC.
128
220
 
129
221
  ## Units and Measurements
130
222
 
131
223
  ### **Angular Units**
224
+
132
225
  - **Degree (°)**: 1/360th of a circle
133
226
  - **Arc Minute (′)**: 1/60th of a degree
134
227
  - **Arc Second (″)**: 1/60th of an arc minute
@@ -136,16 +229,19 @@ The primary time standard used worldwide. All astronomical calculations in Astro
136
229
  - **Radian**: 180/π degrees (≈57.3°)
137
230
 
138
231
  ### **Distance Units**
232
+
139
233
  - **Astronomical Unit (AU)**: The average distance between Earth and Sun (≈149.6 million km)
140
234
  - **Kilometre (km)**: Standard metric unit for distances
141
235
  - **Metre (m)**: Standard metric unit for elevations
142
236
 
143
237
  ### **Time Units**
238
+
144
239
  - **Julian Day**: Continuous day count since 4713 BCE
145
240
  - **Terrestrial Time (TT)**: Astronomical time scale used for calculations
146
241
  - **UTC**: Coordinated Universal Time, the standard for civil time
147
242
 
148
243
  ## See also
244
+
149
245
  - [Quick Start Guide](README.md) - for getting started
150
246
  - [Coordinates](coordinates.md) - for coordinate systems
151
247
  - [Reference Frames](reference_frames.md) - for position calculations
data/docs/iers.md ADDED
@@ -0,0 +1,40 @@
1
+ # IERS Data
2
+
3
+ Astronoby relies on the [`iers`](https://github.com/rhannequin/iers) gem for
4
+ access to data published by the [International Earth Rotation and Reference
5
+ Systems Service (IERS)][IERS]. This data is used for:
6
+
7
+ - **Delta T (TT - UT1)**: the difference between Terrestrial Time and Universal
8
+ Time, used when converting between UTC and the internal TT time scale (see
9
+ [Instant](instant.md))
10
+ - **Greenwich Mean Sidereal Time (GMST)**: computed via the Earth Rotation Angle
11
+ (ERA) based expression from the [IERS Conventions (2010)]
12
+
13
+ ## Data coverage
14
+
15
+ The `iers` gem ships with bundled IERS data files that work out of the box
16
+ with no network access required. The bundled data covers dates roughly from
17
+ 1800 to early 2027.
18
+
19
+ - **Before 1800**: Delta T is not available; Astronoby returns 0.
20
+ - **After the end of bundled data**: Astronoby uses the last known Delta T
21
+ value, which remains a reasonable approximation for dates in the near future.
22
+
23
+ ## Updating data
24
+
25
+ The bundled data can be refreshed to extend coverage into the future:
26
+
27
+ ```rb
28
+ IERS::Data.update!
29
+ ```
30
+
31
+ This downloads the latest IERS finals data and stores it in the gem's cache
32
+ directory. Updated data is used automatically on subsequent calculations.
33
+
34
+ ## See also
35
+
36
+ - [Instant](instant.md) - for time scales and Delta T
37
+ - [Configuration](configuration.md) - for performance settings
38
+
39
+ [IERS]: https://www.iers.org
40
+ [IERS Conventions (2010)]: https://www.iers.org/IERS/EN/Publications/TechnicalNotes/tn36.html
data/docs/instant.md CHANGED
@@ -14,7 +14,9 @@ from the irregularities in the rotation of Earth and the irregularly fluctuating
14
14
  mean solar time.
15
15
 
16
16
  Astronoby handles this situation by implementing an `Astronoby::Instant` class,
17
- used in most calculations instead of `Time`.
17
+ used in most calculations instead of `Time`. Converting between UTC and
18
+ Terrestrial Time requires knowing [Delta T (TT - UT1)][Delta T], which
19
+ Astronoby obtains from [IERS data](iers.md).
18
20
 
19
21
  `Astronoby::Instant` is a value object that stores an instant in time on Earth
20
22
  in [Terrestrial Time], an astronomical time standard defined by the
@@ -28,9 +30,10 @@ standards can be expressed, such as the
28
30
  ## Initialization
29
31
 
30
32
  An `Astronoby::Instant` object can be instantiated from:
31
- * Terrestrial time (`Numeric`): `.from_terrestrial_time`
32
- * Ruby `Time` object: `.from_time`
33
- * UTC Julian date (`Numeric`): `.from_utc_julian_date`
33
+
34
+ - Terrestrial time (`Numeric`): `.from_terrestrial_time`
35
+ - Ruby `Time` object: `.from_time`
36
+ - UTC Julian date (`Numeric`): `.from_utc_julian_date`
34
37
 
35
38
  ```rb
36
39
  Astronoby::Instant.from_terrestrial_time(2460796)
@@ -48,7 +51,7 @@ Astronoby::Instant.from_utc_julian_date(2460796)
48
51
 
49
52
  From the same instant, it is possible to extract different time standards.
50
53
 
51
- * Gregorian `Date`
54
+ - Gregorian `Date`
52
55
 
53
56
  ```rb
54
57
  instant = Astronoby::Instant.from_terrestrial_time(2460796)
@@ -57,34 +60,34 @@ instant.to_date
57
60
  # => #<Date: 2025-04-30 ((2460796j,0s,0n),+0s,2299161j)>
58
61
  ```
59
62
 
60
- * UTC `DateTime`
63
+ - UTC `DateTime`
61
64
 
62
65
  ```rb
63
66
  instant = Astronoby::Instant.from_terrestrial_time(2460796)
64
67
 
65
68
  instant.to_datetime
66
- # => #<DateTime: 2025-04-30T11:58:51+00:00 ((2460796j,43131s,12159n),+0s,2299161j)>
69
+ # => #<DateTime: 2025-04-30T11:58:50+00:00 ((2460796j,43130s,845637619n),+0s,2299161j)>
67
70
  ```
68
71
 
69
- * UTC `Time`
72
+ - UTC `Time`
70
73
 
71
74
  ```rb
72
75
  instant = Astronoby::Instant.from_terrestrial_time(2460796)
73
76
 
74
77
  instant.to_datetime
75
- # => 2025-04-30 11:58:51.000012159 UTC
78
+ # => 2025-04-30T11:58:50+00:00 UTC
76
79
  ```
77
80
 
78
- * Greenwich Sidereal Time
81
+ - Greenwich Sidereal Time
79
82
 
80
83
  ```rb
81
84
  instant = Astronoby::Instant.from_terrestrial_time(2460796)
82
85
 
83
86
  instant.gmst
84
- # => 2.5597425440141457
87
+ # => 2.5597070126923764
85
88
  ```
86
89
 
87
- * International Atomic Time
90
+ - International Atomic Time
88
91
 
89
92
  ```rb
90
93
  instant = Astronoby::Instant.from_terrestrial_time(2460796)
@@ -93,16 +96,16 @@ instant.tai.to_f
93
96
  # => 2460795.9996275003
94
97
  ```
95
98
 
96
- * UTC offset (difference with UTC in days)
99
+ - UTC offset (difference with UTC in days)
97
100
 
98
101
  ```rb
99
102
  instant = Astronoby::Instant.from_terrestrial_time(2460796)
100
103
 
101
104
  instant.utc_offset.to_f
102
- # => 0.0007986109703819444
105
+ # => 0.0008003974106626159
103
106
  ```
104
107
 
105
- * Barycentric Dynamic Time
108
+ - Barycentric Dynamic Time
106
109
 
107
110
  ```rb
108
111
  # This is not handled for now, and returns TT
@@ -131,8 +134,10 @@ instant1 < instant2
131
134
  [Gregorian calendar]: https://en.wikipedia.org/wiki/Gregorian_calendar
132
135
  [Terrestrial Time]: https://en.wikipedia.org/wiki/Terrestrial_Time
133
136
  [Julian Date]: https://en.wikipedia.org/wiki/Julian_day
137
+ [Delta T]: https://en.wikipedia.org/wiki/ΔT_(timekeeping)
134
138
 
135
139
  ## See also
140
+
136
141
  - [Ephemerides](ephem.md) - for time-based calculations
137
142
  - [Solar System Bodies](solar_system_bodies.md) - for object positions
138
143
  - [Reference Frames](reference_frames.md) - for coordinate systems
@@ -0,0 +1,93 @@
1
+ # Lunar Eclipses
2
+
3
+ Astronoby computes lunar eclipses: the passages of the Moon through Earth's shadow. A lunar eclipse is a geocentric event, the same for every observer who can see the Moon, so no observer is involved. The geometry is built from the apparent geocentric positions of the Sun and Moon, which matches the standard reduction used by [NASA's Five Millennium Canon of Lunar Eclipses] and by IMCCE.
4
+
5
+ There are three kinds of lunar eclipses. A penumbral eclipse is when the Moon only enters Earth's penumbra, the outer, partial shadow. A partial eclipse is when part of the Moon enters the umbra, the inner, total shadow. A total eclipse is when the whole Moon enters the umbra.
6
+
7
+ ## Finding eclipses
8
+
9
+ `Astronoby::Moon.eclipse_events` takes an ephemeris and a time range, and returns the lunar eclipses whose greatest instant falls in that range, sorted by time.
10
+
11
+ ```rb
12
+ ephem = Astronoby::Ephem.load("inpop19a.bsp")
13
+
14
+ eclipses = Astronoby::Moon.eclipse_events(
15
+ ephem: ephem,
16
+ start_time: Time.utc(2025, 1, 1),
17
+ end_time: Time.utc(2026, 1, 1)
18
+ )
19
+
20
+ eclipses.map { |eclipse| [eclipse.instant.to_time, eclipse.kind] }
21
+ # => [[2025-03-14 06:58:47 UTC, :total], [2025-09-07 18:11:49 UTC, :total]]
22
+ ```
23
+
24
+ ## An eclipse
25
+
26
+ Each eclipse is an `Astronoby::LunarEclipse`. Its `#instant` (also available as `#greatest_eclipse`) is the moment of greatest eclipse, when the Moon's centre is least distant from the axis of Earth's shadow.
27
+
28
+ ```rb
29
+ eclipse = eclipses.first
30
+
31
+ eclipse.kind # => :total
32
+ eclipse.total? # => true
33
+ eclipse.instant.to_time # => 2025-03-14 06:58:47 UTC
34
+ eclipse.greatest_eclipse # => same as #instant
35
+ ```
36
+
37
+ The umbral and penumbral magnitudes are the fractions of the Moon's diameter immersed in the umbra and the penumbra at greatest eclipse. The umbral magnitude is negative for a penumbral eclipse (the Moon misses the umbra), between 0 and 1 for a partial eclipse, and 1 or more for a total eclipse.
38
+
39
+ ```rb
40
+ eclipse.umbral_magnitude # => 1.179
41
+ eclipse.penumbral_magnitude # => 2.26
42
+ ```
43
+
44
+ `#gamma` is the least distance of the Moon's centre from the axis of Earth's shadow at greatest eclipse, in Earth radii, positive when the Moon passes north of the axis and negative when it passes south. It is the standard, dimensionless eclipse parameter used by IMCCE and NASA. The same quantity is also available as a `Astronoby::Distance` through `#shadow_axis_distance`.
45
+
46
+ ```rb
47
+ eclipse.gamma # => 0.348
48
+ eclipse.shadow_axis_distance.km # => 2222.37
49
+ ```
50
+
51
+ ## Phases
52
+
53
+ An eclipse exposes its phases as `Astronoby::EclipsePhase` objects, each with a `#starting_instant`, an `#ending_instant`, and a `#duration` (an `Astronoby::Duration`). The penumbral phase is always present. The partial phase is present for partial and total eclipses, and the total phase (totality) only for total eclipses. A phase that does not occur is `nil`.
54
+
55
+ ```rb
56
+ eclipse.penumbral.starting_instant.to_time # => 2025-03-14 03:57:29 UTC (P1)
57
+ eclipse.partial.starting_instant.to_time # => 2025-03-14 05:09:37 UTC (U1)
58
+ eclipse.total.starting_instant.to_time # => 2025-03-14 06:26:01 UTC (U2)
59
+ eclipse.total.ending_instant.to_time # => 2025-03-14 07:31:32 UTC (U3)
60
+ eclipse.partial.ending_instant.to_time # => 2025-03-14 08:47:55 UTC (U4)
61
+ eclipse.penumbral.ending_instant.to_time # => 2025-03-14 10:00:08 UTC (P4)
62
+
63
+ eclipse.total.duration.seconds # => 3931 (seconds of totality)
64
+ ```
65
+
66
+ For a penumbral eclipse, `#partial` and `#total` are `nil`. For a partial eclipse, `#total` is `nil`.
67
+
68
+ ```rb
69
+ penumbral_eclipse = Astronoby::Moon.eclipse_events(
70
+ ephem: ephem,
71
+ start_time: Time.utc(2024, 3, 1),
72
+ end_time: Time.utc(2024, 4, 1)
73
+ ).first
74
+
75
+ penumbral_eclipse.kind # => :penumbral
76
+ penumbral_eclipse.partial # => nil
77
+ penumbral_eclipse.total # => nil
78
+ ```
79
+
80
+ ## Precision
81
+
82
+ Earth's shadow is enlarged by its atmosphere. Astronoby enlarges Earth's radius by 1/99 before building the shadow cones, a factor calibrated against IMCCE. Validated across the 2023 to 2025 eclipses, the eclipse kind, greatest eclipse instant, magnitudes, and contact times all match IMCCE to within a second or two.
83
+
84
+ ## See also
85
+
86
+ - [Moon Phases](moon_phases.md) - for lunar phases
87
+ - [Lunar Observation](lunar_observation.md) - for libration, axis and limb angles
88
+ - [Planetary Phenomena](planetary_phenomena.md) - for conjunctions, oppositions and elongations
89
+ - [Solar System Bodies](solar_system_bodies.md) - for moon object details
90
+ - [Ephemerides](ephem.md) - for data sources
91
+
92
+ [NASA's Five Millennium Canon of Lunar Eclipses]: https://eclipse.gsfc.nasa.gov/SEpubs/5MCLE.html
93
+ [IMCCE]: https://www.imcce.fr/
@@ -0,0 +1,87 @@
1
+ # Lunar Observation
2
+
3
+ Beyond phases and apsides, Astronoby exposes the quantities lunar observers rely on to describe the Moon's appearance and orientation in the sky: its libration, the position angle of its rotation axis, the position angle of its bright limb, and the parallactic angle. By default they follow Jean Meeus, *Astronomical Algorithms*, 2nd edition, and are derived from the Moon's and the Sun's apparent positions, which Astronoby already computes from the ephemeris. The libration and the position angle of the axis can additionally use the integrated lunar orientation from a JPL DE kernel to reach arcsecond accuracy, as described below.
4
+
5
+ All of these are available directly on a `Astronoby::Moon` instance.
6
+
7
+ ```rb
8
+ ephem = Astronoby::Ephem.load("inpop19a.bsp")
9
+ instant = Astronoby::Instant.from_time(Time.utc(2025, 3, 1))
10
+ moon = Astronoby::Moon.new(instant: instant, ephem: ephem)
11
+ ```
12
+
13
+ ## Libration
14
+
15
+ Libration is the apparent oscillation that lets an observer on Earth see slightly more than half of the lunar surface over time. `Astronoby::Moon#libration` returns a `Astronoby::Libration` value object holding the total (optical plus physical) libration in longitude and latitude, both as `Astronoby::Angle` objects. A positive longitude exposes more of the Moon's eastern limb (Mare Crisium side); a positive latitude exposes more of its northern limb.
16
+
17
+ ```rb
18
+ libration = moon.libration
19
+
20
+ libration.longitude.str(:dms) # => "-2° 5′ 4.4219″"
21
+ libration.latitude.str(:dms) # => "+0° 28′ 45.9616″"
22
+ ```
23
+
24
+ By default this is the analytic optical plus physical libration from Meeus's series. Compared with the lunar orientation integrated in the JPL DE solution (as reported by JPL Horizons), the libration in longitude and the position angle of the axis agree to within a few arcseconds, while the libration in latitude agrees to about 0.02 degrees. That residual is the well known difference between the mean lunar equator used by the classical Meeus method and the DE mean-Earth frame. It is eliminated by loading an orientation kernel.
25
+
26
+ ## Arcsecond accuracy with an orientation kernel
27
+
28
+ For the libration and the position angle of the axis, you can reach the accuracy of JPL Horizons, Skyfield and IMCCE by also loading a binary PCK lunar orientation kernel, such as `moon_pa_de440_200625.bpc`, which carries the integrated DE440 orientation of the Moon. Load it once with `Astronoby::Orientation` and pass it to the Moon alongside the ephemeris.
29
+
30
+ ```rb
31
+ ephem = Astronoby::Ephem.load("de440.bsp")
32
+ orientation = Astronoby::Orientation.load("moon_pa_de440_200625.bpc")
33
+
34
+ moon = Astronoby::Moon.new(instant: instant, ephem: ephem, orientation: orientation)
35
+
36
+ moon.libration.latitude.str(:dms) # => "+0° 27′ 27.7258″"
37
+ moon.position_angle_of_axis.str(:dms) # => "-21° 48′ 32.9625″"
38
+ ```
39
+
40
+ The libration is then computed as the selenographic longitude and latitude of the sub-Earth point in the Moon's mean-Earth body-fixed frame, and matches JPL Horizons to better than an arcsecond. Without an orientation kernel the Moon keeps using the analytic method, so this is an opt-in refinement, not a requirement. The `bright_limb_position_angle` and `parallactic_angle` are unaffected and do not need a kernel.
41
+
42
+ If you do not already have the kernel, Astronoby can download it for you.
43
+
44
+ ```rb
45
+ Astronoby::Orientation.download(
46
+ name: "moon_pa_de440_200625.bpc",
47
+ target: "moon_pa_de440_200625.bpc"
48
+ )
49
+ ```
50
+
51
+ ## Position angle of the axis
52
+
53
+ `Astronoby::Moon#position_angle_of_axis` returns the position angle of the Moon's axis of rotation, the angle of the projection of the lunar north pole, measured eastward from the north point of the disk. It is returned as an `Astronoby::Angle`.
54
+
55
+ ```rb
56
+ moon.position_angle_of_axis.str(:dms) # => "-21° 48′ 46.657″"
57
+ ```
58
+
59
+ ## Position angle of the bright limb
60
+
61
+ `Astronoby::Moon#bright_limb_position_angle` returns the position angle of the midpoint of the illuminated limb, measured eastward from the north point of the disk, between 0 and 360 degrees. It is a geocentric quantity computed from the apparent equatorial coordinates of the Moon and the Sun, and it points towards the Sun, since the bright limb is the limb facing the Sun.
62
+
63
+ ```rb
64
+ moon.bright_limb_position_angle.str(:dms) # => "+248° 1′ 57.9467″"
65
+ ```
66
+
67
+ ## Parallactic angle
68
+
69
+ The parallactic angle is the angle at the Moon between the direction of the north celestial pole and the direction of the observer's zenith. Unlike the previous quantities it depends on the observer, so it is computed from the topocentric place, where lunar parallax is significant. `Astronoby::Moon#parallactic_angle` takes an observer and returns an `Astronoby::Angle`.
70
+
71
+ ```rb
72
+ observer = Astronoby::Observer.new(
73
+ latitude: Astronoby::Angle.from_degrees(48.8566),
74
+ longitude: Astronoby::Angle.from_degrees(2.3522)
75
+ )
76
+
77
+ moon.parallactic_angle(observer: observer).str(:dms) # => "+11° 42′ 47.1246″"
78
+ ```
79
+
80
+ ## See also
81
+
82
+ - [Solar System Bodies](solar_system_bodies.md) - for the Moon's other properties
83
+ - [Moon Phases](moon_phases.md) - for lunar phase events
84
+ - [Lunar Eclipses](lunar_eclipses.md) - for eclipses of the Moon
85
+ - [Observer](observer.md) - for setting up observation locations
86
+ - [Reference Frames](reference_frames.md) - for coordinate systems
87
+ - [Angles](angles.md) - for working with angular measurements
data/docs/moon_phases.md CHANGED
@@ -69,11 +69,14 @@ phases.each { puts "#{_1.phase}: #{_1.time}" }
69
69
  # new_moon: 2024-05-08 03:21:56 UTC
70
70
  # first_quarter: 2024-05-15 11:48:02 UTC
71
71
  # full_moon: 2024-05-23 13:53:12 UTC
72
- # last_quarter: 2024-05-30 17:12:43 UTC
72
+ # last_quarter: 2024-05-30 17:12:42 UTC
73
73
  ```
74
74
 
75
75
  ## See also
76
+
76
77
  - [Twilight Times](twilight_times.md) - for sun-related events
77
78
  - [Rise, Transit and Set Times](rise_transit_set_times.md) - for moon events
79
+ - [Lunar Observation](lunar_observation.md) - for libration, axis and limb angles
80
+ - [Lunar Eclipses](lunar_eclipses.md) - for eclipses of the Moon
78
81
  - [Solar System Bodies](solar_system_bodies.md) - for moon object details
79
82
  - [Ephemerides](ephem.md) - for data sources
data/docs/observer.md CHANGED
@@ -6,19 +6,31 @@ events computed by Astronoby are location and date based.
6
6
  ## Initialization
7
7
 
8
8
  The two required key arguments to instantiate an observer are:
9
- * `latitude` (`Astronoby::Angle`): the angle from the equator to the observer,
9
+
10
+ - `latitude` (`Astronoby::Angle`): the angle from the equator to the observer,
10
11
  from 90° to -90°, with positive angles for the Northern Hemisphere.
11
- * `longitude` (`Astronoby::Angle`): the angle from the Greenwich meridian to the
12
+ - `longitude` (`Astronoby::Angle`): the angle from the Greenwich meridian to the
12
13
  observer, from 180° to -180°, with positive angles eastward of the Greenwich
13
14
  meridian.
14
15
 
15
- Latitude and longitude are defined according to the [World Geodetic System].
16
- In other words, they are the same as those used for the [GPS].
16
+ Latitude and longitude are defined according to the [World Geodetic System]
17
+ (WGS-84). In other words, they are the same as those used for the [GPS].
18
+
19
+ Internally, the observer's geodetic coordinates are converted to geocentric
20
+ Cartesian coordinates in the **International Terrestrial Reference System
21
+ (ITRS)**, also known as Earth-Centered Earth-Fixed (ECEF). These are then
22
+ rotated into the celestial frame using Earth rotation (GAST) via
23
+ `Astronoby::EarthRotation` and IERS polar motion corrections. See
24
+ [Reference Frames](reference_frames.md) for details.
25
+
26
+ The reverse conversion (ECEF → geodetic) is available via
27
+ [`Astronoby::Coordinates::Geodetic.from_ecef`][Coordinates page].
17
28
 
18
29
  It is also possible to give the following optional key arguments:
19
- * `elevation` (`Astronoby::Distance`): the distance above or below the average
30
+
31
+ - `elevation` (`Astronoby::Distance`): the distance above or below the average
20
32
  sea level
21
- * `utc_offset`: local time difference with UTC. Check the [timezone specifiers]
33
+ - `utc_offset`: local time difference with UTC. Check the [timezone specifiers]
22
34
  for the format.
23
35
 
24
36
  ```rb
@@ -57,8 +69,10 @@ observer1 == observer2
57
69
  [GPS]: https://en.wikipedia.org/wiki/GPS
58
70
  [timezone specifiers]: https://ruby-doc.org/3.4.1/Time.html#class-Time-label-Timezone+Specifiers
59
71
  [Angles page]: angles.md
72
+ [Coordinates page]: coordinates.md#geodetic
60
73
 
61
74
  ## See also
75
+
62
76
  - [Angles](angles.md) - for working with latitude and longitude
63
77
  - [Coordinates](coordinates.md) - for understanding position systems
64
78
  - [Reference Frames](reference_frames.md) - for topocentric calculations