astronoby 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +48 -0
- data/Gemfile.lock +38 -36
- data/README.md +17 -2
- data/UPGRADING.md +109 -0
- data/lib/astronoby/angle.rb +2 -0
- data/lib/astronoby/bodies/sun.rb +157 -12
- data/lib/astronoby/body.rb +126 -51
- data/lib/astronoby/coordinates/equatorial.rb +4 -5
- data/lib/astronoby/coordinates/horizontal.rb +4 -4
- data/lib/astronoby/equinox_solstice.rb +153 -0
- data/lib/astronoby/errors.rb +2 -0
- data/lib/astronoby/geocentric_parallax.rb +130 -0
- data/lib/astronoby/observer.rb +57 -0
- data/lib/astronoby/refraction.rb +48 -36
- data/lib/astronoby/time/greenwich_sidereal_time.rb +86 -0
- data/lib/astronoby/time/local_sidereal_time.rb +41 -0
- data/lib/astronoby/version.rb +1 -1
- data/lib/astronoby.rb +5 -1
- metadata +8 -3
- data/lib/astronoby/util/time.rb +0 -93
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Astronoby
|
|
4
|
+
class GreenwichSiderealTime
|
|
5
|
+
JULIAN_CENTURIES_EXPONENTS = [
|
|
6
|
+
BigDecimal("6.697374558"),
|
|
7
|
+
BigDecimal("2400.051336"),
|
|
8
|
+
BigDecimal("0.000025862")
|
|
9
|
+
].freeze
|
|
10
|
+
|
|
11
|
+
attr_reader :date, :time
|
|
12
|
+
|
|
13
|
+
# Source:
|
|
14
|
+
# Title: Practical Astronomy with your Calculator or Spreadsheet
|
|
15
|
+
# Authors: Peter Duffett-Smith and Jonathan Zwart
|
|
16
|
+
# Edition: Cambridge University Press
|
|
17
|
+
# Chapter: 12 - Conversion of UT to Greenwich sidereal time (GST)
|
|
18
|
+
def self.from_utc(utc)
|
|
19
|
+
date = utc.to_date
|
|
20
|
+
julian_day = utc.to_date.ajd
|
|
21
|
+
t = (julian_day - Epoch::J2000) / Epoch::DAYS_PER_JULIAN_CENTURY
|
|
22
|
+
t0 = (
|
|
23
|
+
(JULIAN_CENTURIES_EXPONENTS[0] +
|
|
24
|
+
(JULIAN_CENTURIES_EXPONENTS[1] * t) +
|
|
25
|
+
(JULIAN_CENTURIES_EXPONENTS[2] * t * t)) % 24
|
|
26
|
+
).abs
|
|
27
|
+
|
|
28
|
+
ut_in_hours = utc.hour +
|
|
29
|
+
utc.min / 60.0 +
|
|
30
|
+
(utc.sec + utc.subsec) / 3600.0
|
|
31
|
+
|
|
32
|
+
gmst = BigDecimal("1.002737909") * ut_in_hours + t0
|
|
33
|
+
gmst += 24 if gmst.negative?
|
|
34
|
+
gmst -= 24 if gmst > 24
|
|
35
|
+
|
|
36
|
+
new(date: date, time: gmst)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def initialize(date:, time:)
|
|
40
|
+
@date = date
|
|
41
|
+
@time = time
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Source:
|
|
45
|
+
# Title: Practical Astronomy with your Calculator or Spreadsheet
|
|
46
|
+
# Authors: Peter Duffett-Smith and Jonathan Zwart
|
|
47
|
+
# Edition: Cambridge University Press
|
|
48
|
+
# Chapter: 13 - Conversion of GST to UT
|
|
49
|
+
def to_utc
|
|
50
|
+
date = @date
|
|
51
|
+
julian_day = @date.ajd
|
|
52
|
+
t = (julian_day - Epoch::J2000) / Epoch::DAYS_PER_JULIAN_CENTURY
|
|
53
|
+
|
|
54
|
+
t0 = (
|
|
55
|
+
(JULIAN_CENTURIES_EXPONENTS[0] +
|
|
56
|
+
(JULIAN_CENTURIES_EXPONENTS[1] * t) +
|
|
57
|
+
(JULIAN_CENTURIES_EXPONENTS[2] * t * t)) % 24
|
|
58
|
+
).abs
|
|
59
|
+
|
|
60
|
+
a = @time - t0
|
|
61
|
+
a += 24 if a.negative?
|
|
62
|
+
a -= 24 if a > 24
|
|
63
|
+
|
|
64
|
+
utc = BigDecimal("0.9972695663") * a
|
|
65
|
+
|
|
66
|
+
decimal_hour_to_time(date, utc)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def to_lst(longitude:)
|
|
70
|
+
LocalSiderealTime.from_gst(gst: self, longitude: longitude)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
private
|
|
74
|
+
|
|
75
|
+
def decimal_hour_to_time(date, decimal)
|
|
76
|
+
absolute_hour = decimal.abs
|
|
77
|
+
hour = absolute_hour.floor
|
|
78
|
+
decimal_minute = 60 * (absolute_hour - hour)
|
|
79
|
+
absolute_decimal_minute = (60 * (absolute_hour - hour)).abs
|
|
80
|
+
minute = decimal_minute.floor
|
|
81
|
+
second = 60 * (absolute_decimal_minute - absolute_decimal_minute.floor)
|
|
82
|
+
|
|
83
|
+
::Time.utc(date.year, date.month, date.day, hour, minute, second).round
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Astronoby
|
|
4
|
+
class LocalSiderealTime
|
|
5
|
+
attr_reader :date, :time, :longitude
|
|
6
|
+
|
|
7
|
+
# Source:
|
|
8
|
+
# Title: Practical Astronomy with your Calculator or Spreadsheet
|
|
9
|
+
# Authors: Peter Duffett-Smith and Jonathan Zwart
|
|
10
|
+
# Edition: Cambridge University Press
|
|
11
|
+
# Chapter: 14 - Local sidereal time (LST)
|
|
12
|
+
def self.from_gst(gst:, longitude:)
|
|
13
|
+
date = gst.date
|
|
14
|
+
time = gst.time + longitude.hours
|
|
15
|
+
time += 24 if time.negative?
|
|
16
|
+
time -= 24 if time > 24
|
|
17
|
+
|
|
18
|
+
new(date: date, time: time, longitude: longitude)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def initialize(date:, time:, longitude:)
|
|
22
|
+
@date = date
|
|
23
|
+
@time = time
|
|
24
|
+
@longitude = longitude
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Source:
|
|
28
|
+
# Title: Practical Astronomy with your Calculator or Spreadsheet
|
|
29
|
+
# Authors: Peter Duffett-Smith and Jonathan Zwart
|
|
30
|
+
# Edition: Cambridge University Press
|
|
31
|
+
# Chapter: 15 - Converting LST to GST
|
|
32
|
+
def to_gst
|
|
33
|
+
date = @date
|
|
34
|
+
time = @time - @longitude.hours
|
|
35
|
+
time += 24 if time.negative?
|
|
36
|
+
time -= 24 if time > 24
|
|
37
|
+
|
|
38
|
+
GreenwichSiderealTime.new(date: date, time: time)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
data/lib/astronoby/version.rb
CHANGED
data/lib/astronoby.rb
CHANGED
|
@@ -10,13 +10,17 @@ require "astronoby/coordinates/ecliptic"
|
|
|
10
10
|
require "astronoby/coordinates/equatorial"
|
|
11
11
|
require "astronoby/coordinates/horizontal"
|
|
12
12
|
require "astronoby/aberration"
|
|
13
|
+
require "astronoby/equinox_solstice"
|
|
13
14
|
require "astronoby/errors"
|
|
15
|
+
require "astronoby/geocentric_parallax"
|
|
14
16
|
require "astronoby/mean_obliquity"
|
|
15
17
|
require "astronoby/nutation"
|
|
18
|
+
require "astronoby/observer"
|
|
16
19
|
require "astronoby/precession"
|
|
17
20
|
require "astronoby/refraction"
|
|
21
|
+
require "astronoby/time/greenwich_sidereal_time"
|
|
22
|
+
require "astronoby/time/local_sidereal_time"
|
|
18
23
|
require "astronoby/util/astrodynamics"
|
|
19
|
-
require "astronoby/util/time"
|
|
20
24
|
require "astronoby/util/trigonometry"
|
|
21
25
|
require "astronoby/true_obliquity"
|
|
22
26
|
require "astronoby/version"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: astronoby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rémy Hannequin
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-03-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: matrix
|
|
@@ -85,6 +85,7 @@ files:
|
|
|
85
85
|
- LICENSE.txt
|
|
86
86
|
- README.md
|
|
87
87
|
- Rakefile
|
|
88
|
+
- UPGRADING.md
|
|
88
89
|
- lib/astronoby.rb
|
|
89
90
|
- lib/astronoby/aberration.rb
|
|
90
91
|
- lib/astronoby/angle.rb
|
|
@@ -96,14 +97,18 @@ files:
|
|
|
96
97
|
- lib/astronoby/coordinates/equatorial.rb
|
|
97
98
|
- lib/astronoby/coordinates/horizontal.rb
|
|
98
99
|
- lib/astronoby/epoch.rb
|
|
100
|
+
- lib/astronoby/equinox_solstice.rb
|
|
99
101
|
- lib/astronoby/errors.rb
|
|
102
|
+
- lib/astronoby/geocentric_parallax.rb
|
|
100
103
|
- lib/astronoby/mean_obliquity.rb
|
|
101
104
|
- lib/astronoby/nutation.rb
|
|
105
|
+
- lib/astronoby/observer.rb
|
|
102
106
|
- lib/astronoby/precession.rb
|
|
103
107
|
- lib/astronoby/refraction.rb
|
|
108
|
+
- lib/astronoby/time/greenwich_sidereal_time.rb
|
|
109
|
+
- lib/astronoby/time/local_sidereal_time.rb
|
|
104
110
|
- lib/astronoby/true_obliquity.rb
|
|
105
111
|
- lib/astronoby/util/astrodynamics.rb
|
|
106
|
-
- lib/astronoby/util/time.rb
|
|
107
112
|
- lib/astronoby/util/trigonometry.rb
|
|
108
113
|
- lib/astronoby/version.rb
|
|
109
114
|
homepage: https://github.com/rhannequin/astronoby
|
data/lib/astronoby/util/time.rb
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Astronoby
|
|
4
|
-
module Util
|
|
5
|
-
module Time
|
|
6
|
-
class << self
|
|
7
|
-
# Source:
|
|
8
|
-
# Title: Practical Astronomy with your Calculator or Spreadsheet
|
|
9
|
-
# Authors: Peter Duffett-Smith and Jonathan Zwart
|
|
10
|
-
# Edition: Cambridge University Press
|
|
11
|
-
# Chapter: 12 - Conversion of UT to Greenwich sidereal time (GST)
|
|
12
|
-
def ut_to_gmst(universal_time)
|
|
13
|
-
julian_day = universal_time.to_date.ajd
|
|
14
|
-
t = (julian_day - Epoch::J2000) / Epoch::DAYS_PER_JULIAN_CENTURY
|
|
15
|
-
t0 = (
|
|
16
|
-
(BigDecimal("6.697374558") +
|
|
17
|
-
(BigDecimal("2400.051336") * t) +
|
|
18
|
-
(BigDecimal("0.000025862") * t * t)) % 24
|
|
19
|
-
).abs
|
|
20
|
-
|
|
21
|
-
ut_in_hours = universal_time.hour +
|
|
22
|
-
universal_time.min / 60.0 +
|
|
23
|
-
(universal_time.sec + universal_time.subsec) / 3600.0
|
|
24
|
-
|
|
25
|
-
gmst = BigDecimal("1.002737909") * ut_in_hours + t0
|
|
26
|
-
|
|
27
|
-
# If gmst negative, add 24 hours to the date
|
|
28
|
-
# If gmst is greater than 24, subtract 24 hours from the date
|
|
29
|
-
gmst += 24 if gmst.negative?
|
|
30
|
-
gmst -= 24 if gmst > 24
|
|
31
|
-
|
|
32
|
-
gmst
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def lst_to_ut(date:, longitude:, lst:)
|
|
36
|
-
gmst = lst_to_gmst(lst: lst, longitude: longitude)
|
|
37
|
-
julian_day = date.ajd
|
|
38
|
-
jd0 = ::DateTime.new(date.year, 1, 1, 0, 0, 0).ajd - 1
|
|
39
|
-
days_into_the_year = julian_day - jd0
|
|
40
|
-
|
|
41
|
-
t = (jd0 - Epoch::J1900) / Epoch::DAYS_PER_JULIAN_CENTURY
|
|
42
|
-
r = BigDecimal("6.6460656") +
|
|
43
|
-
BigDecimal("2400.051262") * t +
|
|
44
|
-
BigDecimal("0.00002581") * t * t
|
|
45
|
-
b = 24 - r + 24 * (date.year - 1900)
|
|
46
|
-
|
|
47
|
-
# If t0 negative, add 24 hours to the date
|
|
48
|
-
# If t0 is greater than 24, subtract 24 hours from the date
|
|
49
|
-
t0 = BigDecimal("0.0657098") * days_into_the_year - b
|
|
50
|
-
t0 += 24 if t0.negative?
|
|
51
|
-
|
|
52
|
-
a = gmst - t0
|
|
53
|
-
a += 24 if a.negative?
|
|
54
|
-
|
|
55
|
-
ut = BigDecimal("0.99727") * a
|
|
56
|
-
|
|
57
|
-
absolute_hour = ut.abs
|
|
58
|
-
hour = absolute_hour.floor
|
|
59
|
-
decimal_minute = 60 * (absolute_hour - hour)
|
|
60
|
-
absolute_decimal_minute = (60 * (absolute_hour - hour)).abs
|
|
61
|
-
minute = decimal_minute.floor
|
|
62
|
-
second = (
|
|
63
|
-
60 * (absolute_decimal_minute - absolute_decimal_minute.floor)
|
|
64
|
-
).round
|
|
65
|
-
|
|
66
|
-
::Time.utc(
|
|
67
|
-
date.year,
|
|
68
|
-
date.month,
|
|
69
|
-
date.day,
|
|
70
|
-
hour,
|
|
71
|
-
minute,
|
|
72
|
-
second
|
|
73
|
-
)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def local_sidereal_time(time:, longitude:)
|
|
77
|
-
ut_to_gmst(time.utc) + longitude.hours
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def lst_to_gmst(lst:, longitude:)
|
|
81
|
-
gmst = lst - longitude.hours
|
|
82
|
-
|
|
83
|
-
# If gmst negative, add 24 hours to the date
|
|
84
|
-
# If gmst is greater than 24, subtract 24 hours from the date
|
|
85
|
-
gmst += 24 if gmst.negative?
|
|
86
|
-
gmst -= 24 if gmst > 24
|
|
87
|
-
|
|
88
|
-
gmst
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|