astronoby 0.6.0 → 0.8.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 (96) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -0
  3. data/.standard.yml +1 -0
  4. data/CHANGELOG.md +203 -3
  5. data/README.md +69 -288
  6. data/UPGRADING.md +267 -0
  7. data/docs/README.md +196 -0
  8. data/docs/angles.md +137 -0
  9. data/docs/celestial_bodies.md +107 -0
  10. data/docs/configuration.md +98 -0
  11. data/docs/coordinates.md +167 -0
  12. data/docs/ephem.md +85 -0
  13. data/docs/equinoxes_solstices_times.md +31 -0
  14. data/docs/glossary.md +152 -0
  15. data/docs/instant.md +139 -0
  16. data/docs/moon_phases.md +79 -0
  17. data/docs/observer.md +65 -0
  18. data/docs/reference_frames.md +138 -0
  19. data/docs/rise_transit_set_times.md +119 -0
  20. data/docs/twilight_times.md +123 -0
  21. data/lib/astronoby/aberration.rb +56 -31
  22. data/lib/astronoby/angle.rb +20 -16
  23. data/lib/astronoby/angles/dms.rb +2 -2
  24. data/lib/astronoby/angles/hms.rb +2 -2
  25. data/lib/astronoby/bodies/earth.rb +62 -0
  26. data/lib/astronoby/bodies/jupiter.rb +28 -0
  27. data/lib/astronoby/bodies/mars.rb +28 -0
  28. data/lib/astronoby/bodies/mercury.rb +32 -0
  29. data/lib/astronoby/bodies/moon.rb +51 -298
  30. data/lib/astronoby/bodies/neptune.rb +32 -0
  31. data/lib/astronoby/bodies/saturn.rb +37 -0
  32. data/lib/astronoby/bodies/solar_system_body.rb +232 -0
  33. data/lib/astronoby/bodies/sun.rb +33 -214
  34. data/lib/astronoby/bodies/uranus.rb +16 -0
  35. data/lib/astronoby/bodies/venus.rb +36 -0
  36. data/lib/astronoby/cache.rb +188 -0
  37. data/lib/astronoby/configuration.rb +92 -0
  38. data/lib/astronoby/constants.rb +17 -2
  39. data/lib/astronoby/constellation.rb +12 -0
  40. data/lib/astronoby/constellations/data.rb +42 -0
  41. data/lib/astronoby/constellations/finder.rb +35 -0
  42. data/lib/astronoby/constellations/repository.rb +20 -0
  43. data/lib/astronoby/coordinates/ecliptic.rb +2 -37
  44. data/lib/astronoby/coordinates/equatorial.rb +28 -10
  45. data/lib/astronoby/coordinates/horizontal.rb +0 -46
  46. data/lib/astronoby/corrections/light_time_delay.rb +90 -0
  47. data/lib/astronoby/data/constellations/constellation_names.dat +88 -0
  48. data/lib/astronoby/data/constellations/indexed_abbreviations.dat +88 -0
  49. data/lib/astronoby/data/constellations/radec_to_index.dat +238 -0
  50. data/lib/astronoby/data/constellations/sorted_declinations.dat +202 -0
  51. data/lib/astronoby/data/constellations/sorted_right_ascensions.dat +237 -0
  52. data/lib/astronoby/deflection.rb +187 -0
  53. data/lib/astronoby/distance.rb +9 -0
  54. data/lib/astronoby/ephem.rb +39 -0
  55. data/lib/astronoby/equinox_solstice.rb +22 -19
  56. data/lib/astronoby/errors.rb +4 -0
  57. data/lib/astronoby/events/moon_phases.rb +15 -13
  58. data/lib/astronoby/events/rise_transit_set_calculator.rb +376 -0
  59. data/lib/astronoby/events/rise_transit_set_event.rb +13 -0
  60. data/lib/astronoby/events/rise_transit_set_events.rb +13 -0
  61. data/lib/astronoby/events/twilight_calculator.rb +221 -0
  62. data/lib/astronoby/events/twilight_event.rb +28 -0
  63. data/lib/astronoby/events/twilight_events.rb +22 -115
  64. data/lib/astronoby/instant.rb +176 -0
  65. data/lib/astronoby/julian_date.rb +78 -0
  66. data/lib/astronoby/mean_obliquity.rb +24 -13
  67. data/lib/astronoby/nutation.rb +235 -42
  68. data/lib/astronoby/observer.rb +55 -0
  69. data/lib/astronoby/precession.rb +102 -18
  70. data/lib/astronoby/reference_frame.rb +50 -0
  71. data/lib/astronoby/reference_frames/apparent.rb +60 -0
  72. data/lib/astronoby/reference_frames/astrometric.rb +21 -0
  73. data/lib/astronoby/reference_frames/geometric.rb +20 -0
  74. data/lib/astronoby/reference_frames/mean_of_date.rb +38 -0
  75. data/lib/astronoby/reference_frames/topocentric.rb +72 -0
  76. data/lib/astronoby/time/greenwich_sidereal_time.rb +2 -2
  77. data/lib/astronoby/true_obliquity.rb +3 -3
  78. data/lib/astronoby/util/maths.rb +70 -73
  79. data/lib/astronoby/util/time.rb +455 -32
  80. data/lib/astronoby/vector.rb +36 -0
  81. data/lib/astronoby/velocity.rb +116 -0
  82. data/lib/astronoby/version.rb +1 -1
  83. data/lib/astronoby.rb +33 -5
  84. metadata +117 -24
  85. data/.tool-versions +0 -1
  86. data/Gemfile +0 -5
  87. data/Gemfile.lock +0 -80
  88. data/benchmark/README.md +0 -131
  89. data/benchmark/benchmark.rb +0 -259
  90. data/benchmark/data/imcce.csv.zip +0 -0
  91. data/benchmark/data/sun_calc.csv.zip +0 -0
  92. data/lib/astronoby/astronomical_models/ephemeride_lunaire_parisienne.rb +0 -143
  93. data/lib/astronoby/epoch.rb +0 -22
  94. data/lib/astronoby/events/observation_events.rb +0 -285
  95. data/lib/astronoby/events/rise_transit_set_iteration.rb +0 -218
  96. data/lib/astronoby/util/astrodynamics.rb +0 -60
@@ -0,0 +1,98 @@
1
+ # Configuration
2
+
3
+ Astronoby handles an internal configuration to enable users to tweak the
4
+ performance and precision of computed data.
5
+
6
+ ## Cache
7
+
8
+ Some calculations are expensive but also repetitive in the intermediate computed
9
+ data. To improve performance, an internal cache system has been developed.
10
+
11
+ ➡️ **Please note caching is disabled by default.**
12
+
13
+ ### Enable caching
14
+
15
+ You can turn caching on with the following command:
16
+
17
+ ```rb
18
+ Astronoby.configuration.cache_enabled = true
19
+ ```
20
+
21
+ Once caching is enabled, it will be used for the following parts of the library
22
+ with default precision values:
23
+ * [Geometric positions]
24
+ * [Topocentric positions] when computing rising/transit/setting times
25
+ * [Moon phases]
26
+ * Nutation
27
+ * Precession
28
+
29
+ ## Cache precision
30
+
31
+ When cache is enabled, some data is cached following a default precision
32
+ threshold so that precision doesn't noticeably decrease.
33
+
34
+ However, users may want to improve performance even more at the cost of some
35
+ precision.
36
+
37
+ It is possible to change the precision value for the following:
38
+ * Geometric position, default: `9`
39
+ * Topocentric position, default: `5`
40
+ * Nutation, default: `2`
41
+ * Precession, default: `2`
42
+
43
+ ### Precision value
44
+
45
+ The precision value is how much rounded instants are. Because instants are
46
+ stored as a [Julian Day], rounding may not seem very natural.
47
+
48
+ Let's take the example of `1`. Rounding a Julian Day with only one digit means
49
+ that all times within 8640 seconds will be rounded to the same instant, which
50
+ means a maximum rounding of 2.4 hours.
51
+
52
+ * `1`: 2.4 hours
53
+ * `2`: 14.4 minutes
54
+ * `3`: 86.4 seconds
55
+ * `4`: 8.6 seconds
56
+ * `5`: 0.86 seconds
57
+ * `6`: 0.086 seconds
58
+ * `7`: 0.0086 seconds
59
+ * ...
60
+
61
+ ### Setting custom precision
62
+
63
+ To set up your own precision, you can use:
64
+
65
+ ```rb
66
+ Astronoby.cache_precision(:geometric, 5)
67
+ ```
68
+
69
+ All geometric positions of the same celestial body within 0.86 seconds will be
70
+ rounded and cached.
71
+
72
+ ## Cache size
73
+
74
+ Cache has limited and configurable capacity, set by default to 10,000 stored
75
+ items. This value can be changed to any positive number.
76
+
77
+ ```rb
78
+ Astronoby.configuration.cache_enabled = true
79
+
80
+ Astronoby.cache.max_size
81
+ # => 10000
82
+
83
+ Astronoby.cache.max_size = 1000000
84
+
85
+ Astronoby.cache.max_size
86
+ # => 1000000
87
+ ```
88
+
89
+ [Geometric positions]: reference_frames.md#geometric
90
+ [Topocentric positions]: reference_frames.md#topocentric
91
+ [Moon phases]: moon_phases.md
92
+ [Julian Day]: https://en.wikipedia.org/wiki/Julian_day
93
+
94
+ ## See also
95
+ - [Reference Frames](reference_frames.md) - for understanding position calculations
96
+ - [Ephemerides](ephem.md) - for data sources
97
+ - [Performance Benchmarks](benchmarks/README.md) - for testing improvements
98
+ - [Cache System](cache.md) - for detailed caching information
@@ -0,0 +1,167 @@
1
+ # Coordinates
2
+
3
+ Astronoby provides three different types of coordinates:
4
+
5
+ * Equatorial
6
+ * Ecliptic
7
+ * Horizontal
8
+
9
+ Equatorial and ecliptic coordinates are available for each [reference frame],
10
+ while horizontal coordinates are only available for a topocentric position.
11
+
12
+ ## Equatorial
13
+
14
+ In Astronoby, equatorial coordinates are geocentric spherical coordinates. As
15
+ per [Wikipedia]'s definition:
16
+
17
+ > defined by an origin at the centre of Earth, fundamental plane consisting of
18
+ > the projection of Earth's equator onto the celestial sphere (forming the
19
+ > celestial equator, a primary direction towards the March equinox, and a
20
+ > right-handed convention.
21
+
22
+ They have two main angular attributes:
23
+
24
+ ### Right ascension
25
+
26
+ Angle measured East from the Vernal Equinox, the point where the Sun crosses the
27
+ celestial equator in March as it passes from the southern to the northern half
28
+ of the sky. By convention, right ascension is usually displayed in hours.
29
+
30
+ ```rb
31
+ ephem = Astronoby::Ephem.load("inpop19a.bsp")
32
+ time = Time.utc(1962, 7, 24)
33
+ instant = Astronoby::Instant.from_time(time)
34
+
35
+ saturn = Astronoby::Saturn.new(ephem: ephem, instant: instant)
36
+ equatorial = saturn.apparent.equatorial
37
+
38
+ equatorial.right_ascension.str(:hms)
39
+ # => "20h 45m 2.6702s"
40
+ ```
41
+
42
+ You can learn more about angles on the [Angle page].
43
+
44
+ ### Declination
45
+
46
+ Angle measured north and south of the celestial equator in degrees, with north
47
+ being positive. The North Celestial Pole is at +90° and the South Celestial Pole
48
+ is at -90°.
49
+
50
+ ```rb
51
+ equatorial.declination.str(:dms)
52
+ # => "-18° 46′ 16.1226″"
53
+ ```
54
+
55
+ ### Hour angle
56
+
57
+ Sometimes convenient for astronomers, a third attribute can be derived from
58
+ equatorial coordinates: the hour angle. It is the angle between the meridian
59
+ plane and the hour circle, meaning it depends on the observer's longitude and
60
+ time. By convention, the hour angle is usually displayed in hours.
61
+
62
+ ```rb
63
+ longitude = Astronoby::Angle.from_degrees(2)
64
+
65
+ equatorial.compute_hour_angle(longitude: longitude, time: time).str(:hms)
66
+ # => "23h 27m 54.9585s"
67
+ ```
68
+
69
+ ## Ecliptic
70
+
71
+ In Astronoby, ecliptic coordinates are geocentric spherical coordinates. Their
72
+ origin is the centre of Earth, their primary direction is towards the March
73
+ equinox, and they have a right-hand convention. Ecliptic coordinates are
74
+ particularly handy for representing positions of Solar System objects.
75
+
76
+ As per Wikipedia's definition:
77
+
78
+ > The celestial equator and the ecliptic are slowly moving due to perturbing
79
+ > forces on the Earth, therefore the orientation of the primary direction, their
80
+ > intersection at the March equinox, is not quite fixed. A slow motion of
81
+ > Earth's axis, precession, causes a slow, continuous turning of the coordinate
82
+ > system westward about the poles of the ecliptic. Superimposed on this is a
83
+ > smaller motion of the ecliptic, and a small oscillation of the Earth's axis,
84
+ > nutation.
85
+
86
+ This primary direction depends on the [reference frame] used.
87
+
88
+ They have two main angular attributes:
89
+
90
+ ### Latitude
91
+
92
+ The ecliptic latitude measures the angular distance of an object along the
93
+ ecliptic from the primary direction.
94
+
95
+ ```rb
96
+ ephem = Astronoby::Ephem.load("inpop19a.bsp")
97
+ time = Time.utc(1962, 7, 24)
98
+ instant = Astronoby::Instant.from_time(time)
99
+
100
+ saturn = Astronoby::Saturn.new(ephem: ephem, instant: instant)
101
+ ecliptic = saturn.apparent.ecliptic
102
+
103
+ ecliptic.latitude.str(:dms)
104
+ # => "-0° 41′ 27.5439″"
105
+ ```
106
+
107
+ ### Longitude
108
+
109
+ The ecliptic latitude measures the angular distance of an object from the
110
+ ecliptic towards the north (positive) or south (negative) ecliptic pole.
111
+
112
+ ```rb
113
+ ecliptic.longitude.str(:dms)
114
+ # => "+308° 38′ 33.1744″"
115
+ ```
116
+
117
+ ## Horizontal
118
+
119
+ Horizontal coordinates are the most observer-centred and human-intuitive
120
+ coordinates. They measure where an object is in the sky as seen from an observer
121
+ on Earth as "up and down" and "left and right".
122
+
123
+ In Astronoby, they can only be computed from a [topocentric position].
124
+
125
+ They have two main angular attributes:
126
+
127
+ ### Altitude
128
+
129
+ The angle between the object and the observer's local horizon.
130
+
131
+ ```rb
132
+ ephem = Astronoby::Ephem.load("inpop19a.bsp")
133
+ time = Time.utc(1962, 7, 24)
134
+ instant = Astronoby::Instant.from_time(time)
135
+
136
+ observer = Astronoby::Observer.new(
137
+ latitude: Astronoby::Angle.from_degrees(42),
138
+ longitude: Astronoby::Angle.from_degrees(2)
139
+ )
140
+
141
+ saturn = Astronoby::Saturn.new(ephem: ephem, instant: instant)
142
+ horizontal = saturn.observed_by(observer).horizontal
143
+
144
+ horizontal.altitude.str(:dms)
145
+ # => "+28° 46′ 39.5994″"
146
+ ```
147
+
148
+ ### Azimuth
149
+
150
+ The angle of the object around the horizon from the north and increasing
151
+ eastward.
152
+
153
+ ```rb
154
+ horizontal.azimuth.str(:dms)
155
+ # => "+171° 19′ 50.5798″"
156
+ ```
157
+
158
+ [reference frame]: reference_frames.md
159
+ [Wikipedia]: https://en.wikipedia.org/wiki/Equatorial_coordinate_system
160
+ [Angle page]: angles.md
161
+ [topocentric position]: reference_frames.md#topocentric
162
+
163
+ ## See also
164
+ - [Reference Frames](reference_frames.md) - for coordinate system details
165
+ - [Angles](angles.md) - for working with angular measurements
166
+ - [Observer](observer.md) - for location setup
167
+ - [Celestial Bodies](celestial_bodies.md) - for object positions
data/docs/ephem.md ADDED
@@ -0,0 +1,85 @@
1
+ # `Ephem`
2
+
3
+ `Astronoby` depends on the gem [`ephem`] which provides a Ruby interface for
4
+ <abbr title="Jet Propulsion Laboratory">JPL</abbr> SPICE binary kernels.
5
+
6
+ These kernels are extremely precise ephemerides produced by the JPL and are the
7
+ foundation of the data provided by Astronoby. The [IMCCE] also produces
8
+ kernels in the same format for their
9
+ <abbr title="Intégrateur numérique planétaire de l'Observatoire de Paris">INPOP</abbr>
10
+ model.
11
+
12
+ ## Download an ephemeris
13
+
14
+ To download an ephemeris, you can either do it manually or use `ephem` by
15
+ providing the filename.
16
+
17
+ ### Manually
18
+
19
+ Ephemerides are available for download from:
20
+ * the JPL public FTP interface: https://ssd.jpl.nasa.gov/ftp/eph/planets/bsp/
21
+ * the INPOP releases page of the IMCCE: https://www.imcce.fr/inpop
22
+
23
+ You can download any `.bsp` file. For the moment, Astronoby only supports the
24
+ planets of the Solar System, and the Sun and the Moon, so you need to
25
+ download a _Development Ephemeris_, which starts with `de` (i.e. `de421.bsp`),
26
+ or any of the INPOP ephemeris files (i.e. `inpop19a.bsp`).
27
+
28
+ ### With `Ephem`
29
+
30
+ If you already know the ephemeris you want to use, you can use `Ephem` to
31
+ download and store it for you:
32
+
33
+ ```rb
34
+ Astronoby::Ephem.download(name: "de421.bsp", target: "tmp/de421.bsp")
35
+ ```
36
+
37
+ ## Load an ephemeris
38
+
39
+ To compute the position of a Solar System body, you need to provide an ephemeris
40
+ to extract the data from. You can use `Astronoby::Ephem` to load the file you
41
+ downloaded.
42
+
43
+ ```rb
44
+ ephem = Astronoby::Ephem.load("tmp/de421.bsp")
45
+ ```
46
+
47
+ ## How to choose the right ephemeris?
48
+
49
+ JPL produces many different kernels over the years, with different accuracy and
50
+ ranges of supported years. Here are some that we recommend to begin with:
51
+ - `de421.bsp`: from 1900 to 2050, 17 MB
52
+ - `de440s.bsp`: from 1849 to 2150, 32 MB
53
+ - `inpop19a.bsp`: from 1900 to 2100, 22 MB
54
+
55
+ ## How to limit weight and increase speed?
56
+
57
+ The `Ephem` library offers a <abbr title="Command-Line Interface">CLI</abbr> to
58
+ produce excerpt ephemerides in order to limit the range of dates or bodies.
59
+
60
+ Here is an example to produce an excerpt ephemeris for the year 2025:
61
+
62
+ ```
63
+ ruby-ephem excerpt 2024-12-31 2026-01-01 de440s.bsp de440s_2025_excerpt.bsp
64
+ ```
65
+
66
+ You can also specify which bodies of the Solar System (or "targets") you want to
67
+ include:
68
+
69
+ ```
70
+ ruby-ephem excerpt --targets 10,399 2024-12-31 2026-01-01 inpop19a.bsp inpop19a_2025_sun_earth.bsp
71
+ ```
72
+
73
+ You may want to check how bodies are handled between JPL DE and IMCCE INPOP. For
74
+ example, the excerpt file from a JPL DE kernel needs to include targets `3` and
75
+ `399` for the Earth, while the excerpt file from a IMCCE INPOP kernel only needs
76
+ the target `399`.
77
+
78
+ [`ephem`]: https://github.com/rhannequin/ruby-ephem
79
+ [IMCCE]: https://www.imcce.fr
80
+
81
+ ## See also
82
+ - [Celestial Bodies](celestial_bodies.md) - for using ephemeris data
83
+ - [Reference Frames](reference_frames.md) - for coordinate calculations
84
+ - [Observer](observer.md) - for location-based calculations
85
+ - [Configuration](configuration.md) - for performance tuning
@@ -0,0 +1,31 @@
1
+ # Equinoxes and Solstice Times
2
+
3
+ The equinox and solstice are two precise events that each happen twice a year.
4
+
5
+ The equinox is the time when the Sun appears directly above the equator, the
6
+ solstice is the time when the Sun reaches its most northerly or southerly
7
+ excursion relative to the celestial equator on the celestial sphere.
8
+
9
+ Astronoby enables you to compute the time for each of these four events.
10
+
11
+ ```rb
12
+ ephem = Astronoby::Ephem.load("inpop19a.bsp")
13
+
14
+ Astronoby::EquinoxSolstice.march_equinox(2025, ephem)
15
+ # => 2025-03-20 09:01:29 UTC
16
+
17
+ Astronoby::EquinoxSolstice.june_solstice(2025, ephem)
18
+ # => 2025-06-21 02:42:19 UTC
19
+
20
+ Astronoby::EquinoxSolstice.september_equinox(2025, ephem)
21
+ # => 2025-09-22 18:19:22 UTC
22
+
23
+ Astronoby::EquinoxSolstice.december_solstice(2025, ephem)
24
+ # => 2025-12-21 15:03:03 UTC
25
+ ```
26
+
27
+ ## See also
28
+ - [Twilight Times](twilight_times.md) - for seasonal sun events
29
+ - [Moon Phases](moon_phases.md) - for lunar events
30
+ - [Ephemerides](ephem.md) - for data sources
31
+ - [Instant](instant.md) - for time handling
data/docs/glossary.md ADDED
@@ -0,0 +1,152 @@
1
+ # Glossary
2
+
3
+ This glossary defines key astronomical and technical terms used throughout the Astronoby documentation.
4
+
5
+ ## Astronomical Terms
6
+
7
+ ### **Aberration**
8
+ 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
+ ### **Altitude**
11
+ The angular distance of a celestial object above the observer's local horizon, measured in degrees from 0° (horizon) to 90° (zenith).
12
+
13
+ ### **Apparent Position**
14
+ 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
+
16
+ ### **Arc Second**
17
+ A unit of angular measurement equal to 1/3600th of a degree. Often used to describe the precision of astronomical calculations.
18
+
19
+ ### **Azimuth**
20
+ 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
+
22
+ ### **Barycentre**
23
+ 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
+
25
+ ### **Celestial Equator**
26
+ The projection of Earth's equator onto the celestial sphere. It's the reference plane for equatorial coordinates.
27
+
28
+ ### **Celestial Sphere**
29
+ An imaginary sphere surrounding Earth, on which all celestial objects appear to be located. Used as a reference system for astronomical coordinates.
30
+
31
+ ### **Constellation**
32
+ 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
+
34
+ ### **Declination**
35
+ The angular distance north or south of the celestial equator, measured in degrees. Positive values are north, negative values are south.
36
+
37
+ ### **Ecliptic**
38
+ 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
+
40
+ ### **Ephemeris**
41
+ 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
+
43
+ ### **Equinox**
44
+ 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
+
46
+ ### **Geocentric**
47
+ As seen from the centre of Earth. Geocentric coordinates are useful for calculations but don't account for an observer's specific location.
48
+
49
+ ### **Horizon**
50
+ The apparent boundary between Earth and sky as seen by an observer. The local horizon depends on the observer's location and elevation.
51
+
52
+ ### **Illuminated Fraction**
53
+ 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
+
55
+ ### **Julian Date**
56
+ A continuous count of days since January 1, 4713 BCE. Used in astronomy for precise time measurements and calculations.
57
+
58
+ ### **Light-Time Correction**
59
+ 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
+
61
+ ### **Magnitude**
62
+ 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
+
64
+ ### **Meridian**
65
+ 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
+
67
+ ### **Nutation**
68
+ Small periodic variations in the orientation of Earth's rotation axis, caused by gravitational forces from the Sun and Moon.
69
+
70
+ ### **Obliquity**
71
+ The angle between Earth's equatorial plane and the ecliptic plane. Currently about 23.4° and slowly decreasing.
72
+
73
+ ### **Parallax**
74
+ The apparent shift in position of a nearby object when viewed from different locations. Important for calculating distances to nearby stars.
75
+
76
+ ### **Phase Angle**
77
+ The angle between the Sun, a celestial object, and Earth. For planets, this determines how much of the disk is illuminated.
78
+
79
+ ### **Precession**
80
+ The slow, continuous change in the orientation of Earth's rotation axis, causing the positions of the equinoxes to shift over time.
81
+
82
+ ### **Refraction**
83
+ 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
+
85
+ ### **Right Ascension**
86
+ The angular distance eastward along the celestial equator from the vernal equinox, measured in hours (0-24h) or degrees (0-360°).
87
+
88
+ ### **Solstice**
89
+ The two times each year when the Sun reaches its northernmost (June) or southernmost (December) position relative to the celestial equator.
90
+
91
+ ### **Topocentric**
92
+ As seen from a specific location on Earth's surface. Topocentric positions account for the observer's latitude, longitude, and elevation.
93
+
94
+ ### **Transit**
95
+ The moment when a celestial object crosses the observer's meridian, reaching its highest point in the sky for that day.
96
+
97
+ ### **Twilight**
98
+ 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
+
100
+ ### **Zenith**
101
+ The point directly above an observer on Earth, at an altitude of 90°.
102
+
103
+ ## Technical Terms
104
+
105
+ ### **API (Application Programming Interface)**
106
+ The set of methods and classes that programmers use to interact with the Astronoby library.
107
+
108
+ ### **Cache**
109
+ A temporary storage system that stores frequently used calculation results to improve performance.
110
+
111
+ ### **Coordinate System**
112
+ A system for specifying the position of objects in space. Astronoby supports equatorial, ecliptic, and horizontal coordinate systems.
113
+
114
+ ### **Ephemeris File**
115
+ A binary file (usually with .bsp extension) containing orbital data for Solar System bodies. These files are produced by JPL and IMCCE.
116
+
117
+ ### **Floating-Point Precision**
118
+ The accuracy of decimal number calculations. Higher precision values in Astronoby provide more accurate results but may be slower.
119
+
120
+ ### **Reference Frame**
121
+ A coordinate system used to specify positions. Astronoby provides geometric, astrometric, mean of date, apparent, and topocentric reference frames.
122
+
123
+ ### **SPICE**
124
+ A NASA toolkit for computing positions and orientations of Solar System bodies. Astronoby uses SPICE binary kernels (.bsp files) for ephemeris data.
125
+
126
+ ### **UTC (Coordinated Universal Time)**
127
+ The primary time standard used worldwide. All astronomical calculations in Astronoby are based on UTC.
128
+
129
+ ## Units and Measurements
130
+
131
+ ### **Angular Units**
132
+ - **Degree (°)**: 1/360th of a circle
133
+ - **Arc Minute (′)**: 1/60th of a degree
134
+ - **Arc Second (″)**: 1/60th of an arc minute
135
+ - **Hour (h)**: 15 degrees (used for right ascension)
136
+ - **Radian**: 180/π degrees (≈57.3°)
137
+
138
+ ### **Distance Units**
139
+ - **Astronomical Unit (AU)**: The average distance between Earth and Sun (≈149.6 million km)
140
+ - **Kilometre (km)**: Standard metric unit for distances
141
+ - **Metre (m)**: Standard metric unit for elevations
142
+
143
+ ### **Time Units**
144
+ - **Julian Day**: Continuous day count since 4713 BCE
145
+ - **Terrestrial Time (TT)**: Astronomical time scale used for calculations
146
+ - **UTC**: Coordinated Universal Time, the standard for civil time
147
+
148
+ ## See also
149
+ - [Quick Start Guide](README.md) - for getting started
150
+ - [Coordinates](coordinates.md) - for coordinate systems
151
+ - [Reference Frames](reference_frames.md) - for position calculations
152
+ - [Angles](angles.md) - for angular measurements
data/docs/instant.md ADDED
@@ -0,0 +1,139 @@
1
+ # `Instant`
2
+
3
+ Time in astronomy is usually a slightly different concept than in everyday
4
+ life. Today, the vast majority of people use the [Gregorian calendar] and a time
5
+ based on <abbr title="Coordinated Universal Time">UTC</abbr>. This timescale is
6
+ convenient for matching what we experience on Earth, but it is not static, it
7
+ includes leap days, leap seconds.
8
+
9
+ Also, most of us live in areas where the local legal time is not UTC, so we
10
+ have to deal with time zones that are arbitrary and constantly changing.
11
+
12
+ Astronomical calculations need a stable, uniform and linear time scale, free
13
+ from the irregularities in the rotation of Earth and the irregularly fluctuating
14
+ mean solar time.
15
+
16
+ Astronoby handles this situation by implementing an `Astronoby::Instant` class,
17
+ used in most calculations instead of `Time`.
18
+
19
+ `Astronoby::Instant` is a value object that stores an instant in time on Earth
20
+ in [Terrestrial Time], an astronomical time standard defined by the
21
+ International Astronomical Union, as a [Julian Date].
22
+
23
+ From this instant in <abbr title="Terrestrial Time">TT</abbr>, other time
24
+ standards can be expressed, such as the
25
+ <abbr title="International Atomic Time">TAI</abbr> or the
26
+ <abbr title="Barycentric Dynamic Time">TDB</abbr>.
27
+
28
+ ## Initialization
29
+
30
+ 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`
34
+
35
+ ```rb
36
+ Astronoby::Instant.from_terrestrial_time(2460796)
37
+ # => Represents UTC time 2025-04-30 11:58:51
38
+
39
+ Astronoby::Instant.from_time(Time.utc(2025, 5, 1))
40
+ # => Represents terrestrial time Julian Date 2460796.500798611
41
+
42
+ Astronoby::Instant.from_utc_julian_date(2460796)
43
+ # => Represents UTC time 2025-04-30 12:00:00
44
+ # => Represents terrestrial time Julian Date 2460796.000798611
45
+ ```
46
+
47
+ ## Time standards
48
+
49
+ From the same instant, it is possible to extract different time standards.
50
+
51
+ * Gregorian `Date`
52
+
53
+ ```rb
54
+ instant = Astronoby::Instant.from_terrestrial_time(2460796)
55
+
56
+ instant.to_date
57
+ # => #<Date: 2025-04-30 ((2460796j,0s,0n),+0s,2299161j)>
58
+ ```
59
+
60
+ * UTC `DateTime`
61
+
62
+ ```rb
63
+ instant = Astronoby::Instant.from_terrestrial_time(2460796)
64
+
65
+ instant.to_datetime
66
+ # => #<DateTime: 2025-04-30T11:58:51+00:00 ((2460796j,43131s,12159n),+0s,2299161j)>
67
+ ```
68
+
69
+ * UTC `Time`
70
+
71
+ ```rb
72
+ instant = Astronoby::Instant.from_terrestrial_time(2460796)
73
+
74
+ instant.to_datetime
75
+ # => 2025-04-30 11:58:51.000012159 UTC
76
+ ```
77
+
78
+ * Greenwich Sidereal Time
79
+
80
+ ```rb
81
+ instant = Astronoby::Instant.from_terrestrial_time(2460796)
82
+
83
+ instant.gmst
84
+ # => 2.5597425440141457
85
+ ```
86
+
87
+ * International Atomic Time
88
+
89
+ ```rb
90
+ instant = Astronoby::Instant.from_terrestrial_time(2460796)
91
+
92
+ instant.tai.to_f
93
+ # => 2460795.9996275003
94
+ ```
95
+
96
+ * UTC offset (difference with UTC in days)
97
+
98
+ ```rb
99
+ instant = Astronoby::Instant.from_terrestrial_time(2460796)
100
+
101
+ instant.utc_offset.to_f
102
+ # => 0.0007986109703819444
103
+ ```
104
+
105
+ * Barycentric Dynamic Time
106
+
107
+ ```rb
108
+ # This is not handled for now, and returns TT
109
+
110
+ instant = Astronoby::Instant.from_terrestrial_time(2460796)
111
+
112
+ instant.tdb
113
+ # => 2460796
114
+ ```
115
+
116
+ ## Value Equality
117
+
118
+ As a value object, it is possible to compare different instants.
119
+
120
+ ```rb
121
+ instant1 = Astronoby::Instant.from_terrestrial_time(2460796)
122
+ instant2 = Astronoby::Instant.from_terrestrial_time(2460797)
123
+
124
+ instant1.diff(instant2)
125
+ # => -1
126
+
127
+ instant1 < instant2
128
+ # => true
129
+ ```
130
+
131
+ [Gregorian calendar]: https://en.wikipedia.org/wiki/Gregorian_calendar
132
+ [Terrestrial Time]: https://en.wikipedia.org/wiki/Terrestrial_Time
133
+ [Julian Date]: https://en.wikipedia.org/wiki/Julian_day
134
+
135
+ ## See also
136
+ - [Ephemerides](ephem.md) - for time-based calculations
137
+ - [Celestial Bodies](celestial_bodies.md) - for object positions
138
+ - [Reference Frames](reference_frames.md) - for coordinate systems
139
+ - [Configuration](configuration.md) - for performance settings