astronoby 0.7.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.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +87 -3
- data/README.md +56 -32
- data/UPGRADING.md +50 -21
- data/docs/README.md +196 -0
- data/docs/angles.md +137 -0
- data/docs/celestial_bodies.md +107 -0
- data/docs/configuration.md +98 -0
- data/docs/coordinates.md +167 -0
- data/docs/ephem.md +85 -0
- data/docs/equinoxes_solstices_times.md +31 -0
- data/docs/glossary.md +152 -0
- data/docs/instant.md +139 -0
- data/docs/moon_phases.md +79 -0
- data/docs/observer.md +65 -0
- data/docs/reference_frames.md +138 -0
- data/docs/rise_transit_set_times.md +119 -0
- data/docs/twilight_times.md +123 -0
- data/lib/astronoby/bodies/earth.rb +8 -2
- data/lib/astronoby/bodies/jupiter.rb +17 -0
- data/lib/astronoby/bodies/mars.rb +17 -0
- data/lib/astronoby/bodies/mercury.rb +21 -0
- data/lib/astronoby/bodies/moon.rb +29 -36
- data/lib/astronoby/bodies/neptune.rb +21 -0
- data/lib/astronoby/bodies/saturn.rb +26 -0
- data/lib/astronoby/bodies/solar_system_body.rb +139 -29
- data/lib/astronoby/bodies/sun.rb +25 -2
- data/lib/astronoby/bodies/uranus.rb +5 -0
- data/lib/astronoby/bodies/venus.rb +25 -0
- data/lib/astronoby/cache.rb +188 -0
- data/lib/astronoby/configuration.rb +92 -0
- data/lib/astronoby/constants.rb +4 -1
- data/lib/astronoby/constellation.rb +12 -0
- data/lib/astronoby/constellations/data.rb +42 -0
- data/lib/astronoby/constellations/finder.rb +35 -0
- data/lib/astronoby/constellations/repository.rb +20 -0
- data/lib/astronoby/coordinates/equatorial.rb +3 -3
- data/lib/astronoby/data/constellations/constellation_names.dat +88 -0
- data/lib/astronoby/data/constellations/indexed_abbreviations.dat +88 -0
- data/lib/astronoby/data/constellations/radec_to_index.dat +238 -0
- data/lib/astronoby/data/constellations/sorted_declinations.dat +202 -0
- data/lib/astronoby/data/constellations/sorted_right_ascensions.dat +237 -0
- data/lib/astronoby/equinox_solstice.rb +2 -2
- data/lib/astronoby/events/moon_phases.rb +15 -14
- data/lib/astronoby/events/rise_transit_set_calculator.rb +32 -8
- data/lib/astronoby/events/twilight_calculator.rb +115 -60
- data/lib/astronoby/events/twilight_events.rb +28 -0
- data/lib/astronoby/instant.rb +7 -2
- data/lib/astronoby/julian_date.rb +78 -0
- data/lib/astronoby/mean_obliquity.rb +8 -10
- data/lib/astronoby/nutation.rb +11 -3
- data/lib/astronoby/observer.rb +1 -1
- data/lib/astronoby/precession.rb +48 -38
- data/lib/astronoby/reference_frame.rb +2 -1
- data/lib/astronoby/reference_frames/apparent.rb +1 -1
- data/lib/astronoby/reference_frames/mean_of_date.rb +1 -1
- data/lib/astronoby/reference_frames/topocentric.rb +1 -11
- data/lib/astronoby/time/greenwich_sidereal_time.rb +2 -2
- data/lib/astronoby/true_obliquity.rb +2 -3
- data/lib/astronoby/util/time.rb +1 -1
- data/lib/astronoby/version.rb +1 -1
- data/lib/astronoby.rb +8 -1
- metadata +59 -11
- data/Gemfile +0 -5
- data/Gemfile.lock +0 -102
- data/benchmark/README.md +0 -131
- data/benchmark/benchmark.rb +0 -259
- data/benchmark/data/imcce.csv.zip +0 -0
- data/benchmark/data/sun_calc.csv.zip +0 -0
- data/lib/astronoby/epoch.rb +0 -22
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
|
data/docs/moon_phases.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Moon Phases
|
2
|
+
|
3
|
+
Astronoby lets you compute the current Moon phase, or when the major ones
|
4
|
+
happen.
|
5
|
+
|
6
|
+
## Current Moon phase
|
7
|
+
|
8
|
+
`Astronoby::Moon` provides two pieces of information about the current Moon phase: the
|
9
|
+
illuminated fraction and the phase fraction.
|
10
|
+
|
11
|
+
### `#illuminated_fraction`
|
12
|
+
|
13
|
+
As mentioned in the name, this method provides the illuminated fraction of the
|
14
|
+
Moon. It will not give precise information about the "age" of the Moon as the
|
15
|
+
same illumination happens twice in the same lunar month.
|
16
|
+
|
17
|
+
```rb
|
18
|
+
ephem = Astronoby::Ephem.load("inpop19a.bsp")
|
19
|
+
time = Time.utc(2025, 5, 1)
|
20
|
+
instant = Astronoby::Instant.from_time(time)
|
21
|
+
|
22
|
+
moon = Astronoby::Moon.new(ephem: ephem, instant: instant)
|
23
|
+
|
24
|
+
moon.illuminated_fraction.round(2)
|
25
|
+
# => 0.15
|
26
|
+
# 15% of the Moon is illuminated as seen from Earth
|
27
|
+
```
|
28
|
+
|
29
|
+
### `#current_phase_fraction`
|
30
|
+
|
31
|
+
This method is more convenient for a user interested in how far we are into the
|
32
|
+
lunar month as it returns a fraction from 0 to 1 between two new Moons.
|
33
|
+
|
34
|
+
```rb
|
35
|
+
ephem = Astronoby::Ephem.load("inpop19a.bsp")
|
36
|
+
|
37
|
+
time = Time.utc(2025, 5, 1)
|
38
|
+
instant = Astronoby::Instant.from_time(time)
|
39
|
+
moon = Astronoby::Moon.new(ephem: ephem, instant: instant)
|
40
|
+
|
41
|
+
moon.current_phase_fraction.round(2)
|
42
|
+
# => 0.11
|
43
|
+
|
44
|
+
time = Time.utc(2025, 5, 15)
|
45
|
+
instant = Astronoby::Instant.from_time(time)
|
46
|
+
moon = Astronoby::Moon.new(ephem: ephem, instant: instant)
|
47
|
+
|
48
|
+
moon.current_phase_fraction.round(2)
|
49
|
+
# => 0.59
|
50
|
+
```
|
51
|
+
|
52
|
+
## Major Moon phases in the month
|
53
|
+
|
54
|
+
If you are interested to know when the major Moon phases will happen during a
|
55
|
+
civil month, you can use `Astronoby::Events::MoonPhases` and its class method
|
56
|
+
`::phases_for` with the key arguments `year` and `month`, both `Integer`.
|
57
|
+
|
58
|
+
It returns an array of `Astronoby::MoonPhase` objects, which each expose a
|
59
|
+
`phase` (`Symbol`) and a `time` (`Time`).
|
60
|
+
|
61
|
+
Please note that because a lunar month is around 29 days, some months will have
|
62
|
+
the same phase twice.
|
63
|
+
|
64
|
+
```rb
|
65
|
+
phases = Astronoby::Events::MoonPhases.phases_for(year: 2024, month: 5)
|
66
|
+
|
67
|
+
phases.each { puts "#{_1.phase}: #{_1.time}" }
|
68
|
+
# last_quarter: 2024-05-01 11:27:15 UTC
|
69
|
+
# new_moon: 2024-05-08 03:21:56 UTC
|
70
|
+
# first_quarter: 2024-05-15 11:48:02 UTC
|
71
|
+
# full_moon: 2024-05-23 13:53:12 UTC
|
72
|
+
# last_quarter: 2024-05-30 17:12:43 UTC
|
73
|
+
```
|
74
|
+
|
75
|
+
## See also
|
76
|
+
- [Twilight Times](twilight_times.md) - for sun-related events
|
77
|
+
- [Rise, Transit and Set Times](rise_transit_set_times.md) - for moon events
|
78
|
+
- [Celestial Bodies](celestial_bodies.md) - for moon object details
|
79
|
+
- [Ephemerides](ephem.md) - for data sources
|
data/docs/observer.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Observer
|
2
|
+
|
3
|
+
`Astronoby::Observer` is the representation of an observer on Earth. Most of the
|
4
|
+
events computed by Astronoby are location and date based.
|
5
|
+
|
6
|
+
## Initialization
|
7
|
+
|
8
|
+
The two required key arguments to instantiate an observer are:
|
9
|
+
* `latitude` (`Astronoby::Angle`): the angle from the equator to the observer,
|
10
|
+
from 90° to -90°, with positive angles for the Northern Hemisphere.
|
11
|
+
* `longitude` (`Astronoby::Angle`): the angle from the Greenwich meridian to the
|
12
|
+
observer, from 180° to -180°, with positive angles eastward of the Greenwich
|
13
|
+
meridian.
|
14
|
+
|
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].
|
17
|
+
|
18
|
+
It is also possible to give the following optional key arguments:
|
19
|
+
* `elevation` (`Astronoby::Distance`): the distance above or below the average
|
20
|
+
sea level
|
21
|
+
* `utc_offset`: local time difference with UTC. Check the [timezone specifiers]
|
22
|
+
for the format.
|
23
|
+
|
24
|
+
```rb
|
25
|
+
# Location: Alhambra, Spain
|
26
|
+
|
27
|
+
observer = Astronoby::Observer.new(
|
28
|
+
latitude: Astronoby::Angle.from_degrees(37.176),
|
29
|
+
longitude: Astronoby::Angle.from_degrees(-3.588),
|
30
|
+
elevation: Astronoby::Distance.from_meters(792)
|
31
|
+
)
|
32
|
+
```
|
33
|
+
|
34
|
+
You can learn more about angles on the [Angles page].
|
35
|
+
|
36
|
+
## Value equality
|
37
|
+
|
38
|
+
`Astronoby::Observer` is a value object, which means it implements value
|
39
|
+
equality.
|
40
|
+
|
41
|
+
```rb
|
42
|
+
observer1 = Astronoby::Observer.new(
|
43
|
+
latitude: Astronoby::Angle.from_degrees(90),
|
44
|
+
longitude: Astronoby::Angle.from_degrees(180)
|
45
|
+
)
|
46
|
+
|
47
|
+
observer2 = Astronoby::Observer.new(
|
48
|
+
latitude: Astronoby::Angle.from_hours(6),
|
49
|
+
longitude: Astronoby::Angle.from_hours(12)
|
50
|
+
)
|
51
|
+
|
52
|
+
observer1 == observer2
|
53
|
+
# => true
|
54
|
+
```
|
55
|
+
|
56
|
+
[World Geodetic System]: https://en.wikipedia.org/wiki/World_Geodetic_System
|
57
|
+
[GPS]: https://en.wikipedia.org/wiki/GPS
|
58
|
+
[timezone specifiers]: https://ruby-doc.org/3.4.1/Time.html#class-Time-label-Timezone+Specifiers
|
59
|
+
[Angles page]: angles.md
|
60
|
+
|
61
|
+
## See also
|
62
|
+
- [Angles](angles.md) - for working with latitude and longitude
|
63
|
+
- [Coordinates](coordinates.md) - for understanding position systems
|
64
|
+
- [Reference Frames](reference_frames.md) - for topocentric calculations
|
65
|
+
- [Celestial Bodies](celestial_bodies.md) - for observing objects
|
@@ -0,0 +1,138 @@
|
|
1
|
+
# Reference Frames
|
2
|
+
|
3
|
+
A given body at a given time can be perceived at different positions, depending
|
4
|
+
on the reference frame and the corrections applied.
|
5
|
+
|
6
|
+
Astronoby provides five reference frames for each celestial body:
|
7
|
+
|
8
|
+
* Geometric
|
9
|
+
* Astrometric
|
10
|
+
* Mean of date
|
11
|
+
* Apparent
|
12
|
+
* Topocentric
|
13
|
+
|
14
|
+
All reference frames provide this common interface:
|
15
|
+
|
16
|
+
* `#position`: Vector of position as x,y,z `Astronoby::Distance` objects
|
17
|
+
* `#velocity`: Vector of velocity as x,y,z `Astronoby::Velocity` objects
|
18
|
+
* `#distance`: Distance from the centre (`Astronoby::Distance`)
|
19
|
+
* `#equatorial`: Equatorial coordinates (`Astronoby::Coordinates::Equatorial`)
|
20
|
+
* `#ecliptic`: Ecliptic coordinates (`Astronoby::Coordinates::Ecliptic`)
|
21
|
+
|
22
|
+
## Geometric
|
23
|
+
|
24
|
+
Also called "mean J2000", this reference frame is related to the mean ecliptic
|
25
|
+
or terrestrial equator and the mean equinox of the reference date (J2000). It is
|
26
|
+
the strict position computed from the ephemeris file in a reference frame
|
27
|
+
centered on the Solar System barycentre, with no corrections applied.
|
28
|
+
|
29
|
+
```rb
|
30
|
+
ephem = Astronoby::Ephem.load("inpop19a.bsp")
|
31
|
+
time = Time.utc(1962, 7, 24)
|
32
|
+
instant = Astronoby::Instant.from_time(time)
|
33
|
+
|
34
|
+
moon = Astronoby::Moon.new(ephem: ephem, instant: instant)
|
35
|
+
geometric = moon.geometric
|
36
|
+
# => #<Astronoby::Geometric:0x000000011e7ffd40
|
37
|
+
|
38
|
+
geometric.distance.au
|
39
|
+
# => 1.0095091198501744
|
40
|
+
|
41
|
+
geometric.equatorial.right_ascension.str(:hms, precision: 0)
|
42
|
+
# => "20h 13m 52s"
|
43
|
+
```
|
44
|
+
|
45
|
+
## Astrometric
|
46
|
+
|
47
|
+
Also called "astrometric J2000", this reference frame is related to the ecliptic
|
48
|
+
or the mean terrestrial equator and the mean equinox of the reference date
|
49
|
+
(J2000). It applies light-time correction between the celestial body and the
|
50
|
+
observer. The frame is centred on the Earth's centre, as are all the following
|
51
|
+
reference frames.
|
52
|
+
|
53
|
+
```rb
|
54
|
+
ephem = Astronoby::Ephem.load("inpop19a.bsp")
|
55
|
+
time = Time.utc(1962, 7, 24)
|
56
|
+
instant = Astronoby::Instant.from_time(time)
|
57
|
+
|
58
|
+
moon = Astronoby::Moon.new(ephem: ephem, instant: instant)
|
59
|
+
astrometric = moon.astrometric
|
60
|
+
|
61
|
+
astrometric.distance.km.round
|
62
|
+
# => 371187
|
63
|
+
|
64
|
+
astrometric.equatorial.right_ascension.str(:hms, precision: 0)
|
65
|
+
# => "1h 54m 27s"
|
66
|
+
```
|
67
|
+
|
68
|
+
## Mean of date
|
69
|
+
|
70
|
+
This reference frame is related to the ecliptic or the mean equator and the mean
|
71
|
+
equinox of the date. It provides the geometric position corrected for the
|
72
|
+
precessional motion of the Earth's rotation axis (precession and nutation).
|
73
|
+
|
74
|
+
|
75
|
+
```rb
|
76
|
+
ephem = Astronoby::Ephem.load("inpop19a.bsp")
|
77
|
+
time = Time.utc(1962, 7, 24)
|
78
|
+
instant = Astronoby::Instant.from_time(time)
|
79
|
+
|
80
|
+
moon = Astronoby::Moon.new(ephem: ephem, instant: instant)
|
81
|
+
mean_of_date = moon.mean_of_date
|
82
|
+
|
83
|
+
mean_of_date.equatorial.right_ascension.str(:hms, precision: 0)
|
84
|
+
# => "1h 52m 29s"
|
85
|
+
```
|
86
|
+
|
87
|
+
## Apparent
|
88
|
+
|
89
|
+
This reference frame is related to the true ecliptic or equator and the true
|
90
|
+
equinox of the date. It is the actual position in the sky of a celestial object
|
91
|
+
as seen from the centre of the Earth. It applies several corrections to the
|
92
|
+
astrometric position:the deflection of light, the aberration, the precession and
|
93
|
+
the nutation.
|
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
|
+
moon = Astronoby::Moon.new(ephem: ephem, instant: instant)
|
101
|
+
apparent = moon.apparent
|
102
|
+
|
103
|
+
apparent.equatorial.right_ascension.str(:hms, precision: 0)
|
104
|
+
# => "1h 52m 28s"
|
105
|
+
```
|
106
|
+
|
107
|
+
## Topocentric
|
108
|
+
|
109
|
+
This reference frame is the final transformation of a position. It provides the
|
110
|
+
apparent position of a celestial body as seen from a location on Earth. It can
|
111
|
+
only be produced given an observer (`Astronoby::Observer`). It provides another
|
112
|
+
set of coordinates: horizontal (`Astronoby::Coordinates::Horizontal`).
|
113
|
+
|
114
|
+
```rb
|
115
|
+
ephem = Astronoby::Ephem.load("inpop19a.bsp")
|
116
|
+
time = Time.utc(1962, 7, 24)
|
117
|
+
instant = Astronoby::Instant.from_time(time)
|
118
|
+
observer = Astronoby::Observer.new(
|
119
|
+
latitude: Astronoby::Angle.from_degrees(48.838),
|
120
|
+
longitude: Astronoby::Angle.from_degrees(2.4843)
|
121
|
+
)
|
122
|
+
|
123
|
+
moon = Astronoby::Moon.new(ephem: ephem, instant: instant)
|
124
|
+
topocentric = moon.observed_by(observer)
|
125
|
+
|
126
|
+
topocentric.horizontal.azimuth.str(:dms, precision: 0)
|
127
|
+
# => "+90° 14′ 19″"
|
128
|
+
```
|
129
|
+
|
130
|
+
You can learn more about observers on the [Observer page].
|
131
|
+
|
132
|
+
## See also
|
133
|
+
- [Coordinates](coordinates.md) - for understanding coordinate systems
|
134
|
+
- [Observer](observer.md) - for location setup
|
135
|
+
- [Celestial Bodies](celestial_bodies.md) - for object positions
|
136
|
+
- [Ephemerides](ephem.md) - for data sources
|
137
|
+
|
138
|
+
[Observer page]: observer.md
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# Rise, Transit and Set Times
|
2
|
+
|
3
|
+
Astronoby provides a calculator to compute all the rise, transit and set times
|
4
|
+
that will happen for a celestial body as observed from Earth during a period
|
5
|
+
of time: `Astronoby::RiseTransitSetCalculator`.
|
6
|
+
|
7
|
+
## Initialization
|
8
|
+
|
9
|
+
Once instantiated, the calculator doesn't do anything yet, it waits for your
|
10
|
+
instruction.
|
11
|
+
|
12
|
+
It takes as key arguments:
|
13
|
+
* `body` (`Astronoby::SolarSystemBody`): any supported celestial body,
|
14
|
+
e.g. `Astronoby::Sun`
|
15
|
+
* `observer` (`Astronoby::Observer`): location on Earth of the observer
|
16
|
+
* `ephem`: ephemeris to provide the initial raw data
|
17
|
+
|
18
|
+
You can learn more about [celestial bodies] and [ephemerides].
|
19
|
+
|
20
|
+
```rb
|
21
|
+
ephem = Astronoby::Ephem.load("inpop19a.bsp")
|
22
|
+
|
23
|
+
observer = Astronoby::Observer.new(
|
24
|
+
latitude: Astronoby::Angle.from_degrees(41.0082),
|
25
|
+
longitude: Astronoby::Angle.from_degrees(28.9784),
|
26
|
+
elevation: Astronoby::Distance.from_meters(40)
|
27
|
+
)
|
28
|
+
|
29
|
+
calculator = Astronoby::RiseTransitSetCalculator.new(
|
30
|
+
body: Astronoby::Saturn,
|
31
|
+
observer: observer,
|
32
|
+
ephem: ephem
|
33
|
+
)
|
34
|
+
```
|
35
|
+
|
36
|
+
You can learn more about observers on the
|
37
|
+
[Observer page](https://github.com/rhannequin/astronoby/wiki/Observer).
|
38
|
+
|
39
|
+
## `#events_between`
|
40
|
+
|
41
|
+
This is the main method of the calculator. It provides all the rising, transit
|
42
|
+
and setting times that will happen between two dates. It returns a
|
43
|
+
`Astronoby::RiseTransitSetEvents` object which exposes the methods
|
44
|
+
`#rising_times`, `#transit_times` and `#setting_times`.
|
45
|
+
|
46
|
+
```rb
|
47
|
+
events = calculator.events_between(
|
48
|
+
Time.utc(2025, 5, 1),
|
49
|
+
Time.utc(2025, 5, 3)
|
50
|
+
)
|
51
|
+
|
52
|
+
events.rising_times
|
53
|
+
# => [2025-05-01 01:28:48 UTC, 2025-05-02 01:25:07 UTC]
|
54
|
+
|
55
|
+
events.transit_times
|
56
|
+
# => [2025-05-01 07:21:34 UTC, 2025-05-02 07:18:01 UTC]
|
57
|
+
|
58
|
+
events.setting_times
|
59
|
+
# => [2025-05-01 13:14:24 UTC, 2025-05-02 13:10:59 UTC]
|
60
|
+
```
|
61
|
+
|
62
|
+
## `#events_on`
|
63
|
+
|
64
|
+
You can call `#events_on` to compute the event times that will happen during a
|
65
|
+
civil day. You can provide a UTC offset to specify the boundaries of the civil
|
66
|
+
day for your location.
|
67
|
+
|
68
|
+
This method also returns a `Astronoby::RiseTransitSetEvents` object because some
|
69
|
+
celestial bodies could occasionally have the same event happen multiple times in
|
70
|
+
a single day. This is the case for the Moon, for example, which can seem to rise
|
71
|
+
twice in the same civil day because of its quick motion around the Earth.
|
72
|
+
|
73
|
+
```rb
|
74
|
+
events = calculator.events_on(Date.new(2025, 5, 1))
|
75
|
+
|
76
|
+
events.rising_times
|
77
|
+
# => [2025-05-01 01:28:48 UTC]
|
78
|
+
|
79
|
+
events.transit_times
|
80
|
+
# => [2025-05-01 07:21:34 UTC]
|
81
|
+
|
82
|
+
events.setting_times
|
83
|
+
# => [2025-05-01 13:14:24 UTC]
|
84
|
+
```
|
85
|
+
|
86
|
+
## `#event_on`
|
87
|
+
|
88
|
+
For convenience, `Astronoby::RiseTransitSetCalculator` also exposes a
|
89
|
+
`#event_on` method that behaves the same way as `#events_on` but returns the
|
90
|
+
first time of rising, transit and setting for the civil date, as these events
|
91
|
+
only happen once in most cases. It returns a `Astronoby::RiseTransitSetEvent`
|
92
|
+
which exposes the instance methods `#rising_time`, `#transit_time` and
|
93
|
+
`#setting_time`.
|
94
|
+
|
95
|
+
```rb
|
96
|
+
utc_offset = "+03:00"
|
97
|
+
event = calculator.event_on(
|
98
|
+
Date.new(2025, 5, 1),
|
99
|
+
utc_offset: utc_offset
|
100
|
+
)
|
101
|
+
|
102
|
+
event.rising_time.localtime(utc_offset)
|
103
|
+
# => 2025-05-01 04:28:48 +0300
|
104
|
+
|
105
|
+
event.transit_time.localtime(utc_offset)
|
106
|
+
# => 2025-05-01 10:21:34 +0300
|
107
|
+
|
108
|
+
event.setting_time.localtime(utc_offset)
|
109
|
+
# => 2025-05-01 16:14:24 +0300
|
110
|
+
```
|
111
|
+
|
112
|
+
[celestial bodies]: celestial_bodies.md
|
113
|
+
[ephemerides]: ephem.md
|
114
|
+
|
115
|
+
## See also
|
116
|
+
- [Twilight Times](twilight_times.md) - for sun-related events
|
117
|
+
- [Celestial Bodies](celestial_bodies.md) - for object information
|
118
|
+
- [Observer](observer.md) - for location setup
|
119
|
+
- [Ephemerides](ephem.md) - for data sources
|