astronoby 0.6.0 → 0.7.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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -0
  3. data/.standard.yml +1 -0
  4. data/CHANGELOG.md +116 -0
  5. data/Gemfile.lock +45 -23
  6. data/README.md +42 -285
  7. data/UPGRADING.md +238 -0
  8. data/lib/astronoby/aberration.rb +56 -31
  9. data/lib/astronoby/angle.rb +20 -16
  10. data/lib/astronoby/angles/dms.rb +2 -2
  11. data/lib/astronoby/angles/hms.rb +2 -2
  12. data/lib/astronoby/bodies/earth.rb +56 -0
  13. data/lib/astronoby/bodies/jupiter.rb +11 -0
  14. data/lib/astronoby/bodies/mars.rb +11 -0
  15. data/lib/astronoby/bodies/mercury.rb +11 -0
  16. data/lib/astronoby/bodies/moon.rb +50 -290
  17. data/lib/astronoby/bodies/neptune.rb +11 -0
  18. data/lib/astronoby/bodies/saturn.rb +11 -0
  19. data/lib/astronoby/bodies/solar_system_body.rb +122 -0
  20. data/lib/astronoby/bodies/sun.rb +16 -220
  21. data/lib/astronoby/bodies/uranus.rb +11 -0
  22. data/lib/astronoby/bodies/venus.rb +11 -0
  23. data/lib/astronoby/constants.rb +13 -1
  24. data/lib/astronoby/coordinates/ecliptic.rb +2 -37
  25. data/lib/astronoby/coordinates/equatorial.rb +25 -7
  26. data/lib/astronoby/coordinates/horizontal.rb +0 -46
  27. data/lib/astronoby/corrections/light_time_delay.rb +90 -0
  28. data/lib/astronoby/deflection.rb +187 -0
  29. data/lib/astronoby/distance.rb +9 -0
  30. data/lib/astronoby/ephem.rb +39 -0
  31. data/lib/astronoby/equinox_solstice.rb +21 -18
  32. data/lib/astronoby/errors.rb +4 -0
  33. data/lib/astronoby/events/moon_phases.rb +2 -1
  34. data/lib/astronoby/events/rise_transit_set_calculator.rb +352 -0
  35. data/lib/astronoby/events/rise_transit_set_event.rb +13 -0
  36. data/lib/astronoby/events/rise_transit_set_events.rb +13 -0
  37. data/lib/astronoby/events/twilight_calculator.rb +166 -0
  38. data/lib/astronoby/events/twilight_event.rb +28 -0
  39. data/lib/astronoby/instant.rb +171 -0
  40. data/lib/astronoby/mean_obliquity.rb +23 -10
  41. data/lib/astronoby/nutation.rb +227 -42
  42. data/lib/astronoby/observer.rb +55 -0
  43. data/lib/astronoby/precession.rb +91 -17
  44. data/lib/astronoby/reference_frame.rb +49 -0
  45. data/lib/astronoby/reference_frames/apparent.rb +60 -0
  46. data/lib/astronoby/reference_frames/astrometric.rb +21 -0
  47. data/lib/astronoby/reference_frames/geometric.rb +20 -0
  48. data/lib/astronoby/reference_frames/mean_of_date.rb +38 -0
  49. data/lib/astronoby/reference_frames/topocentric.rb +82 -0
  50. data/lib/astronoby/true_obliquity.rb +2 -1
  51. data/lib/astronoby/util/maths.rb +70 -73
  52. data/lib/astronoby/util/time.rb +454 -31
  53. data/lib/astronoby/vector.rb +36 -0
  54. data/lib/astronoby/velocity.rb +116 -0
  55. data/lib/astronoby/version.rb +1 -1
  56. data/lib/astronoby.rb +26 -5
  57. metadata +61 -16
  58. data/.tool-versions +0 -1
  59. data/lib/astronoby/astronomical_models/ephemeride_lunaire_parisienne.rb +0 -143
  60. data/lib/astronoby/events/observation_events.rb +0 -285
  61. data/lib/astronoby/events/rise_transit_set_iteration.rb +0 -218
  62. data/lib/astronoby/events/twilight_events.rb +0 -121
  63. data/lib/astronoby/util/astrodynamics.rb +0 -60
data/lib/astronoby.rb CHANGED
@@ -5,31 +5,52 @@ require "astronoby/angle"
5
5
  require "astronoby/angles/dms"
6
6
  require "astronoby/angles/hms"
7
7
  require "astronoby/distance"
8
+ require "astronoby/ephem"
8
9
  require "astronoby/epoch"
9
- require "astronoby/astronomical_models/ephemeride_lunaire_parisienne"
10
+ require "astronoby/instant"
11
+ require "astronoby/vector"
12
+ require "astronoby/velocity"
10
13
  require "astronoby/astronomical_models/moon_phases_periodic_terms"
14
+ require "astronoby/bodies/solar_system_body"
11
15
  require "astronoby/bodies/moon"
12
16
  require "astronoby/bodies/sun"
17
+ require "astronoby/bodies/mercury"
18
+ require "astronoby/bodies/venus"
19
+ require "astronoby/bodies/earth"
20
+ require "astronoby/bodies/mars"
21
+ require "astronoby/bodies/jupiter"
22
+ require "astronoby/bodies/saturn"
23
+ require "astronoby/bodies/uranus"
24
+ require "astronoby/bodies/neptune"
13
25
  require "astronoby/coordinates/ecliptic"
14
26
  require "astronoby/coordinates/equatorial"
15
27
  require "astronoby/coordinates/horizontal"
28
+ require "astronoby/corrections/light_time_delay"
16
29
  require "astronoby/aberration"
30
+ require "astronoby/deflection"
17
31
  require "astronoby/equinox_solstice"
18
32
  require "astronoby/errors"
19
33
  require "astronoby/events/moon_phases"
20
- require "astronoby/events/observation_events"
21
- require "astronoby/events/rise_transit_set_iteration"
22
- require "astronoby/events/twilight_events"
34
+ require "astronoby/events/rise_transit_set_event"
35
+ require "astronoby/events/rise_transit_set_events"
36
+ require "astronoby/events/rise_transit_set_calculator"
37
+ require "astronoby/events/twilight_event"
38
+ require "astronoby/events/twilight_calculator"
23
39
  require "astronoby/geocentric_parallax"
24
40
  require "astronoby/mean_obliquity"
25
41
  require "astronoby/moon_phase"
26
42
  require "astronoby/nutation"
27
43
  require "astronoby/observer"
28
44
  require "astronoby/precession"
45
+ require "astronoby/reference_frame"
46
+ require "astronoby/reference_frames/geometric"
47
+ require "astronoby/reference_frames/astrometric"
48
+ require "astronoby/reference_frames/mean_of_date"
49
+ require "astronoby/reference_frames/apparent"
50
+ require "astronoby/reference_frames/topocentric"
29
51
  require "astronoby/refraction"
30
52
  require "astronoby/time/greenwich_sidereal_time"
31
53
  require "astronoby/time/local_sidereal_time"
32
- require "astronoby/util/astrodynamics"
33
54
  require "astronoby/util/maths"
34
55
  require "astronoby/util/time"
35
56
  require "astronoby/util/trigonometry"
metadata CHANGED
@@ -1,15 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: astronoby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rémy Hannequin
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-12-10 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: ephem
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '0.3'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '0.3'
13
26
  - !ruby/object:Gem::Dependency
14
27
  name: matrix
15
28
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +79,20 @@ dependencies:
66
79
  - - "~>"
67
80
  - !ruby/object:Gem::Version
68
81
  version: '2.3'
82
+ - !ruby/object:Gem::Dependency
83
+ name: simplecov
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '0.22'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '0.22'
69
96
  - !ruby/object:Gem::Dependency
70
97
  name: standard
71
98
  requirement: !ruby/object:Gem::Requirement
@@ -80,17 +107,16 @@ dependencies:
80
107
  - - "~>"
81
108
  - !ruby/object:Gem::Version
82
109
  version: '1.3'
83
- description: Ruby version of the calculations from various books like Celestial Calculations
84
- by J. L. Lawrence, Practical Astronomy with your Calculator or Spreadsheet by Peter
85
- Duffett-Smith and Jonathan Zwart, or Astronomical Algorithms by Jean Meeus
110
+ description: Astronomy and astrometry Ruby library for astronomical data and events.
86
111
  email:
87
- - hello@rhannequ.in
112
+ - remy.hannequin@gmail.com
88
113
  executables: []
89
114
  extensions: []
90
115
  extra_rdoc_files: []
91
116
  files:
92
117
  - ".rspec"
93
- - ".tool-versions"
118
+ - ".ruby-version"
119
+ - ".standard.yml"
94
120
  - CHANGELOG.md
95
121
  - CODE_OF_CONDUCT.md
96
122
  - CONTRIBUTING.md
@@ -109,36 +135,57 @@ files:
109
135
  - lib/astronoby/angle.rb
110
136
  - lib/astronoby/angles/dms.rb
111
137
  - lib/astronoby/angles/hms.rb
112
- - lib/astronoby/astronomical_models/ephemeride_lunaire_parisienne.rb
113
138
  - lib/astronoby/astronomical_models/moon_phases_periodic_terms.rb
139
+ - lib/astronoby/bodies/earth.rb
140
+ - lib/astronoby/bodies/jupiter.rb
141
+ - lib/astronoby/bodies/mars.rb
142
+ - lib/astronoby/bodies/mercury.rb
114
143
  - lib/astronoby/bodies/moon.rb
144
+ - lib/astronoby/bodies/neptune.rb
145
+ - lib/astronoby/bodies/saturn.rb
146
+ - lib/astronoby/bodies/solar_system_body.rb
115
147
  - lib/astronoby/bodies/sun.rb
148
+ - lib/astronoby/bodies/uranus.rb
149
+ - lib/astronoby/bodies/venus.rb
116
150
  - lib/astronoby/constants.rb
117
151
  - lib/astronoby/coordinates/ecliptic.rb
118
152
  - lib/astronoby/coordinates/equatorial.rb
119
153
  - lib/astronoby/coordinates/horizontal.rb
154
+ - lib/astronoby/corrections/light_time_delay.rb
155
+ - lib/astronoby/deflection.rb
120
156
  - lib/astronoby/distance.rb
157
+ - lib/astronoby/ephem.rb
121
158
  - lib/astronoby/epoch.rb
122
159
  - lib/astronoby/equinox_solstice.rb
123
160
  - lib/astronoby/errors.rb
124
161
  - lib/astronoby/events/moon_phases.rb
125
- - lib/astronoby/events/observation_events.rb
126
- - lib/astronoby/events/rise_transit_set_iteration.rb
127
- - lib/astronoby/events/twilight_events.rb
162
+ - lib/astronoby/events/rise_transit_set_calculator.rb
163
+ - lib/astronoby/events/rise_transit_set_event.rb
164
+ - lib/astronoby/events/rise_transit_set_events.rb
165
+ - lib/astronoby/events/twilight_calculator.rb
166
+ - lib/astronoby/events/twilight_event.rb
128
167
  - lib/astronoby/geocentric_parallax.rb
168
+ - lib/astronoby/instant.rb
129
169
  - lib/astronoby/mean_obliquity.rb
130
170
  - lib/astronoby/moon_phase.rb
131
171
  - lib/astronoby/nutation.rb
132
172
  - lib/astronoby/observer.rb
133
173
  - lib/astronoby/precession.rb
174
+ - lib/astronoby/reference_frame.rb
175
+ - lib/astronoby/reference_frames/apparent.rb
176
+ - lib/astronoby/reference_frames/astrometric.rb
177
+ - lib/astronoby/reference_frames/geometric.rb
178
+ - lib/astronoby/reference_frames/mean_of_date.rb
179
+ - lib/astronoby/reference_frames/topocentric.rb
134
180
  - lib/astronoby/refraction.rb
135
181
  - lib/astronoby/time/greenwich_sidereal_time.rb
136
182
  - lib/astronoby/time/local_sidereal_time.rb
137
183
  - lib/astronoby/true_obliquity.rb
138
- - lib/astronoby/util/astrodynamics.rb
139
184
  - lib/astronoby/util/maths.rb
140
185
  - lib/astronoby/util/time.rb
141
186
  - lib/astronoby/util/trigonometry.rb
187
+ - lib/astronoby/vector.rb
188
+ - lib/astronoby/velocity.rb
142
189
  - lib/astronoby/version.rb
143
190
  homepage: https://github.com/rhannequin/astronoby
144
191
  licenses:
@@ -147,7 +194,6 @@ metadata:
147
194
  homepage_uri: https://github.com/rhannequin/astronoby
148
195
  source_code_uri: https://github.com/rhannequin/astronoby
149
196
  changelog_uri: https://github.com/rhannequin/astronoby/blob/main/CHANGELOG.md
150
- post_install_message:
151
197
  rdoc_options: []
152
198
  require_paths:
153
199
  - lib
@@ -162,8 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
208
  - !ruby/object:Gem::Version
163
209
  version: '0'
164
210
  requirements: []
165
- rubygems_version: 3.5.3
166
- signing_key:
211
+ rubygems_version: 3.6.7
167
212
  specification_version: 4
168
213
  summary: Astronomical calculations
169
214
  test_files: []
data/.tool-versions DELETED
@@ -1 +0,0 @@
1
- ruby 3.2.2
@@ -1,143 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Astronoby
4
- class EphemerideLunaireParisienne
5
- # Lunar theory: Éphéméride Lunaire Parisienne
6
- # By Jean Chapront, Michelle Chapront-Touzé
7
- # https://en.wikipedia.org/wiki/Ephemeride_Lunaire_Parisienne
8
-
9
- DEGREES_UNIT = 10**-6
10
-
11
- # @return [Array] Periodic terms for the Moon's longitude and distance
12
- def self.periodic_terms_for_moon_longitude_and_distance
13
- [
14
- [0, 0, 1, 0, 6288774, -20905355],
15
- [2, 0, -1, 0, 1274027, -3699111],
16
- [2, 0, 0, 0, 658314, -2955968],
17
- [0, 0, 2, 0, 213618, -569925],
18
- [0, 1, 0, 0, -185116, 48888],
19
- [0, 0, 0, 2, -114332, -3149],
20
- [2, 0, -2, 0, 58793, 246158],
21
- [2, -1, -1, 0, 57066, -152138],
22
- [2, 0, 1, 0, 53322, -170733],
23
- [2, -1, 0, 0, 45758, -204586],
24
- [0, 1, -1, 0, -40923, -129620],
25
- [1, 0, 0, 0, -34720, 108743],
26
- [0, 1, 1, 0, -30383, 104755],
27
- [2, 0, 0, -2, 15327, 10321],
28
- [0, 0, 1, 2, -12528, 0],
29
- [0, 0, 1, -2, 10980, 79661],
30
- [4, 0, -1, 0, 10675, -34782],
31
- [0, 0, 3, 0, 10034, -23210],
32
- [4, 0, -2, 0, 8548, -21636],
33
- [2, 1, -1, 0, -7888, 24208],
34
- [2, 1, 0, 0, -6766, 30824],
35
- [1, 0, -1, 0, -5163, -8379],
36
- [1, 1, 0, 0, 4987, -16675],
37
- [2, -1, 1, 0, 4036, -12831],
38
- [2, 0, 2, 0, 3994, -10445],
39
- [4, 0, 0, 0, 3861, -11650],
40
- [2, 0, -3, 0, 3665, 14403],
41
- [0, 1, -2, 0, -2689, -7003],
42
- [2, 0, -1, 2, -2602, 0],
43
- [2, -1, -2, 0, 2390, 10056],
44
- [1, 0, 1, 0, -2348, 6322],
45
- [2, -2, 0, 0, 2236, -9884],
46
- [0, 1, 2, 0, -2120, 5751],
47
- [0, 2, 0, 0, -2069, 0],
48
- [2, -2, -1, 0, 2048, -4950],
49
- [2, 0, 1, -2, -1773, 4130],
50
- [2, 0, 0, 2, -1595, 0],
51
- [4, -1, -1, 0, 1215, -3958],
52
- [0, 0, 2, 2, -1110, 0],
53
- [3, 0, -1, 0, -892, 3258],
54
- [2, 1, 1, 0, -810, 2616],
55
- [4, -1, -2, 0, 759, -1897],
56
- [0, 2, -1, 0, -713, -2117],
57
- [2, 2, -1, 0, -700, 2354],
58
- [2, 1, -2, 0, 691, 0],
59
- [2, -1, 0, -2, 596, 0],
60
- [4, 0, 1, 0, 549, -1423],
61
- [0, 0, 4, 0, 537, -1117],
62
- [4, -1, 0, 0, 520, -1571],
63
- [1, 0, -2, 0, -487, -1739],
64
- [2, 1, 0, -2, -399, 0],
65
- [0, 0, 2, -2, -381, -4421],
66
- [1, 1, 1, 0, 351, 0],
67
- [3, 0, -2, 0, -340, 0],
68
- [4, 0, -3, 0, 330, 0],
69
- [2, -1, 2, 0, 327, 0],
70
- [0, 2, 1, 0, -323, 1165],
71
- [1, 1, -1, 0, 299, 0],
72
- [2, 0, 3, 0, 294, 0],
73
- [2, 0, -1, -2, 0, 8752]
74
- ]
75
- end
76
-
77
- # @return [Array] Periodic terms for the Moon's latitude
78
- def self.periodic_terms_for_moon_latitude
79
- [
80
- [0, 0, 0, 1, 5128122],
81
- [0, 0, 1, 1, 280602],
82
- [0, 0, 1, -1, 277693],
83
- [2, 0, 0, -1, 173237],
84
- [2, 0, -1, 1, 55413],
85
- [2, 0, -1, -1, 46271],
86
- [2, 0, 0, 1, 32573],
87
- [0, 0, 2, 1, 17198],
88
- [2, 0, 1, -1, 9266],
89
- [0, 0, 2, -1, 8822],
90
- [2, -1, 0, -1, 8216],
91
- [2, 0, -2, -1, 4324],
92
- [2, 0, 1, 1, 4200],
93
- [2, 1, 0, -1, -3359],
94
- [2, -1, -1, 1, 2463],
95
- [2, -1, 0, 1, 2211],
96
- [2, -1, -1, -1, 2065],
97
- [0, 1, -1, -1, -1870],
98
- [4, 0, -1, -1, 1828],
99
- [0, 1, 0, 1, -1794],
100
- [0, 0, 0, 3, -1749],
101
- [0, 1, -1, 1, -1565],
102
- [1, 0, 0, 1, -1491],
103
- [0, 1, 1, 1, -1475],
104
- [0, 1, 1, -1, -1410],
105
- [0, 1, 0, -1, -1344],
106
- [1, 0, 0, -1, -1335],
107
- [0, 0, 3, 1, 1107],
108
- [4, 0, 0, -1, 1021],
109
- [4, 0, -1, 1, 833],
110
- [0, 0, 1, -3, 777],
111
- [4, 0, -2, 1, 671],
112
- [2, 0, 0, -3, 607],
113
- [2, 0, 2, -1, 596],
114
- [2, -1, 1, -1, 491],
115
- [2, 0, -2, 1, -451],
116
- [0, 0, 3, -1, 439],
117
- [2, 0, 2, 1, 422],
118
- [2, 0, -3, -1, 421],
119
- [2, 1, -1, 1, -366],
120
- [2, 1, 0, 1, -351],
121
- [4, 0, 0, 1, 331],
122
- [2, -1, 1, 1, 315],
123
- [2, -2, 0, -1, 302],
124
- [0, 0, 1, 3, -283],
125
- [2, 1, 1, -1, -229],
126
- [1, 1, 0, -1, 223],
127
- [1, 1, 0, 1, 223],
128
- [0, 1, -2, -1, -220],
129
- [2, 1, -1, -1, -220],
130
- [1, 0, 1, 1, -185],
131
- [2, -1, -2, -1, 181],
132
- [0, 1, 2, 1, -177],
133
- [4, 0, -2, -1, 176],
134
- [4, -1, -1, -1, 166],
135
- [1, 0, 1, -1, -164],
136
- [4, 0, 1, -1, 132],
137
- [1, 0, -1, -1, -119],
138
- [4, -1, 0, -1, 115],
139
- [2, -2, 0, 1, 107]
140
- ]
141
- end
142
- end
143
- end
@@ -1,285 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Astronoby
4
- module Events
5
- class ObservationEvents
6
- STANDARD_ALTITUDE = Angle.from_dms(0, -34, 0)
7
- RISING_SETTING_HOUR_ANGLE_RATIO_RANGE = (-1..1)
8
- EARTH_SIDEREAL_ROTATION_RATE = 360.98564736629
9
- ITERATION_PRECISION = 0.0001
10
- ITERATION_LIMIT = 5
11
-
12
- attr_reader :rising_time,
13
- :rising_azimuth,
14
- :transit_time,
15
- :transit_altitude,
16
- :setting_time,
17
- :setting_azimuth
18
-
19
- # Source:
20
- # Title: Astronomical Algorithms
21
- # Author: Jean Meeus
22
- # Edition: 2nd edition
23
- # Chapter: 15 - Rising, Transit, and Setting
24
-
25
- # @param observer [Astronoby::Observer] Observer
26
- # @param date [Date] Date of the event
27
- # @param coordinates_of_the_previous_day [Astronoby::Coordinates::Equatorial]
28
- # Coordinates of the body of the previous day
29
- # @param coordinates_of_the_day [Astronoby::Coordinates::Equatorial]
30
- # Coordinates of the body of the day
31
- # @param coordinates_of_the_next_day [Astronoby::Coordinates::Equatorial]
32
- # Coordinates of the body of the next day
33
- # @param additional_altitude [Astronoby::Angle] Additional altitude to the
34
- # standard altitude adjustment
35
- def initialize(
36
- observer:,
37
- date:,
38
- coordinates_of_the_previous_day:,
39
- coordinates_of_the_day:,
40
- coordinates_of_the_next_day:,
41
- additional_altitude: Angle.zero
42
- )
43
- @observer = observer
44
- @date = date
45
- @coordinates_of_the_previous_day = coordinates_of_the_previous_day
46
- @coordinates_of_the_day = coordinates_of_the_day
47
- @coordinates_of_the_next_day = coordinates_of_the_next_day
48
- @standard_altitude = STANDARD_ALTITUDE
49
- @additional_altitude = additional_altitude
50
- compute
51
- end
52
-
53
- private
54
-
55
- def compute
56
- @initial_transit = initial_transit
57
- @transit_time = Util::Time.decimal_hour_to_time(
58
- @date,
59
- @observer.utc_offset,
60
- @initial_transit
61
- )
62
- @transit_altitude = local_horizontal_altitude_transit
63
-
64
- return if h0.nil?
65
-
66
- initial_rising = rationalize_decimal_time(
67
- @initial_transit - h0.degrees / Constants::DEGREES_PER_CIRCLE
68
- )
69
-
70
- initial_setting = rationalize_decimal_time(
71
- @initial_transit + h0.degrees / Constants::DEGREES_PER_CIRCLE
72
- )
73
-
74
- @final_rising, @final_transit, @final_setting =
75
- iterate(initial_rising, @initial_transit, initial_setting)
76
-
77
- rationalized_corrected_rising = rationalize_decimal_hours(
78
- Constants::HOURS_PER_DAY * @final_rising
79
- )
80
- rationalized_corrected_transit = rationalize_decimal_hours(
81
- Constants::HOURS_PER_DAY * @final_transit
82
- )
83
- rationalized_corrected_setting = rationalize_decimal_hours(
84
- Constants::HOURS_PER_DAY * @final_setting
85
- )
86
-
87
- @rising_time = Util::Time.decimal_hour_to_time(
88
- @date,
89
- @observer.utc_offset,
90
- rationalized_corrected_rising
91
- )
92
- @rising_azimuth = local_horizontal_azimuth_rising
93
- @transit_time = Util::Time.decimal_hour_to_time(
94
- @date,
95
- @observer.utc_offset,
96
- rationalized_corrected_transit
97
- )
98
- @transit_altitude = local_horizontal_altitude_transit
99
- @setting_time = Util::Time.decimal_hour_to_time(
100
- @date,
101
- @observer.utc_offset,
102
- rationalized_corrected_setting
103
- )
104
- @setting_azimuth = local_horizontal_azimuth_setting
105
- end
106
-
107
- def iterate(initial_rising, initial_transit, initial_setting)
108
- delta = 1
109
- iteration = 1
110
- corrected_rising = initial_rising
111
- corrected_transit = initial_transit
112
- corrected_setting = initial_setting
113
- until delta < ITERATION_PRECISION || iteration > ITERATION_LIMIT
114
- iterate = RiseTransitSetIteration.new(
115
- observer: @observer,
116
- date: @date,
117
- coordinates_of_the_next_day: @coordinates_of_the_next_day,
118
- coordinates_of_the_day: @coordinates_of_the_day,
119
- coordinates_of_the_previous_day: @coordinates_of_the_previous_day,
120
- shift: shift,
121
- initial_rising: corrected_rising,
122
- initial_transit: corrected_transit,
123
- initial_setting: corrected_setting
124
- ).iterate
125
- delta = iterate.sum
126
- corrected_rising = rationalize_decimal_time corrected_rising + iterate[0]
127
- corrected_transit = rationalize_decimal_time corrected_transit + iterate[1]
128
- corrected_setting = rationalize_decimal_time corrected_setting + iterate[2]
129
- iteration += 1
130
- end
131
- [corrected_rising, corrected_transit, corrected_setting]
132
- end
133
-
134
- def observer_longitude
135
- # Longitude must be treated positively westwards from the meridian of
136
- # Greenwich, and negatively to the east
137
- -@observer.longitude
138
- end
139
-
140
- def initial_transit
141
- rationalize_decimal_time(
142
- (
143
- @coordinates_of_the_day.right_ascension.degrees +
144
- observer_longitude.degrees -
145
- apparent_gst_at_midnight.degrees
146
- ) / Constants::DEGREES_PER_CIRCLE
147
- )
148
- end
149
-
150
- def h0
151
- @h0 ||= begin
152
- term1 = shift.sin -
153
- @observer.latitude.sin * @coordinates_of_the_day.declination.sin
154
- term2 = @observer.latitude.cos * @coordinates_of_the_day.declination.cos
155
- ratio = term1 / term2
156
- return nil unless RISING_SETTING_HOUR_ANGLE_RATIO_RANGE.cover?(ratio)
157
-
158
- Angle.acos(ratio)
159
- end
160
- end
161
-
162
- def apparent_gst_at_midnight
163
- Angle.from_hours(
164
- GreenwichSiderealTime.from_utc(
165
- Time.utc(@date.year, @date.month, @date.day)
166
- ).time
167
- )
168
- end
169
-
170
- def gst_transit
171
- Angle.from_degrees(
172
- apparent_gst_at_midnight.degrees +
173
- EARTH_SIDEREAL_ROTATION_RATE * (@final_transit || @initial_transit)
174
- )
175
- end
176
-
177
- def local_hour_angle_transit
178
- gst_transit - observer_longitude - right_ascension_transit
179
- end
180
-
181
- def local_horizontal_azimuth_rising
182
- term1 = declination_rising.sin + (-shift).sin * @observer.latitude.cos
183
- term2 = (-shift).cos * @observer.latitude.cos
184
- angle = term1 / term2
185
- return nil if angle.abs > 1
186
-
187
- Angle.acos(angle)
188
- end
189
-
190
- def local_horizontal_altitude_transit
191
- Angle.asin(
192
- @observer.latitude.sin * declination_transit.sin +
193
- @observer.latitude.cos * declination_transit.cos * local_hour_angle_transit.cos
194
- )
195
- end
196
-
197
- def local_horizontal_azimuth_setting
198
- term1 = declination_setting.sin + (-shift).sin * @observer.latitude.cos
199
- term2 = (-shift).cos * @observer.latitude.cos
200
- angle = term1 / term2
201
- return nil if angle.abs > 1
202
-
203
- Angle.from_degrees(
204
- Constants::DEGREES_PER_CIRCLE - Angle.acos(angle).degrees
205
- )
206
- end
207
-
208
- def rationalize_decimal_time(decimal_time)
209
- decimal_time += 1 while decimal_time.negative?
210
- decimal_time -= 1 while decimal_time > 1
211
- decimal_time
212
- end
213
-
214
- def rationalize_decimal_hours(decimal_hours)
215
- decimal_hours += Constants::HOURS_PER_DAY if decimal_hours.negative?
216
- decimal_hours -= Constants::HOURS_PER_DAY if decimal_hours > Constants::HOURS_PER_DAY
217
- decimal_hours
218
- end
219
-
220
- def right_ascension_transit
221
- Angle.from_degrees(
222
- Util::Maths.interpolate(
223
- Util::Maths.normalize_angles_for_interpolation(
224
- [
225
- @coordinates_of_the_previous_day.right_ascension.degrees,
226
- @coordinates_of_the_day.right_ascension.degrees,
227
- @coordinates_of_the_next_day.right_ascension.degrees
228
- ]
229
- ),
230
- @final_transit || @initial_transit
231
- )
232
- )
233
- end
234
-
235
- def declination_rising
236
- Angle.from_degrees(
237
- Util::Maths.interpolate(
238
- Util::Maths.normalize_angles_for_interpolation(
239
- [
240
- @coordinates_of_the_previous_day.declination.degrees,
241
- @coordinates_of_the_day.declination.degrees,
242
- @coordinates_of_the_next_day.declination.degrees
243
- ]
244
- ),
245
- @final_rising
246
- )
247
- )
248
- end
249
-
250
- def declination_transit
251
- Angle.from_degrees(
252
- Util::Maths.interpolate(
253
- Util::Maths.normalize_angles_for_interpolation(
254
- [
255
- @coordinates_of_the_previous_day.declination.degrees,
256
- @coordinates_of_the_day.declination.degrees,
257
- @coordinates_of_the_next_day.declination.degrees
258
- ]
259
- ),
260
- @final_transit || @initial_transit
261
- )
262
- )
263
- end
264
-
265
- def declination_setting
266
- Angle.from_degrees(
267
- Util::Maths.interpolate(
268
- Util::Maths.normalize_angles_for_interpolation(
269
- [
270
- @coordinates_of_the_previous_day.declination.degrees,
271
- @coordinates_of_the_day.declination.degrees,
272
- @coordinates_of_the_next_day.declination.degrees
273
- ]
274
- ),
275
- @final_setting
276
- )
277
- )
278
- end
279
-
280
- def shift
281
- @standard_altitude - @additional_altitude
282
- end
283
- end
284
- end
285
- end