astronoby 0.0.1 → 0.1.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/.tool-versions +1 -0
- data/CHANGELOG.md +26 -4
- data/CONTRIBUTING.md +86 -0
- data/Gemfile.lock +46 -31
- data/README.md +66 -9
- data/lib/astronoby/aberration.rb +42 -0
- data/lib/astronoby/angle.rb +155 -21
- data/lib/astronoby/angles/dms.rb +18 -0
- data/lib/astronoby/angles/hms.rb +17 -0
- data/lib/astronoby/bodies/sun.rb +81 -0
- data/lib/astronoby/body.rb +80 -0
- data/lib/astronoby/coordinates/ecliptic.rb +42 -0
- data/lib/astronoby/coordinates/equatorial.rb +89 -0
- data/lib/astronoby/coordinates/horizontal.rb +53 -0
- data/lib/astronoby/epoch.rb +24 -0
- data/lib/astronoby/errors.rb +5 -0
- data/lib/astronoby/mean_obliquity.rb +32 -0
- data/lib/astronoby/nutation.rb +71 -0
- data/lib/astronoby/precession.rb +86 -0
- data/lib/astronoby/refraction.rb +61 -0
- data/lib/astronoby/true_obliquity.rb +12 -0
- data/lib/astronoby/util/astrodynamics.rb +60 -0
- data/lib/astronoby/util/time.rb +93 -0
- data/lib/astronoby/util/trigonometry.rb +26 -0
- data/lib/astronoby/version.rb +1 -1
- data/lib/astronoby.rb +19 -8
- metadata +40 -25
- data/.prettierrc +0 -11
- data/.standard.yml +0 -3
- data/astronoby.gemspec +0 -40
- data/lib/astronoby/angles/degree.rb +0 -17
- data/lib/astronoby/angles/radian.rb +0 -17
- data/sig/astronoby.rbs +0 -4
@@ -0,0 +1,93 @@
|
|
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
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bigdecimal/math"
|
4
|
+
|
5
|
+
module Astronoby
|
6
|
+
module Util
|
7
|
+
module Trigonometry
|
8
|
+
class << self
|
9
|
+
# Source:
|
10
|
+
# Title: Celestial Calculations
|
11
|
+
# Author: J. L. Lawrence
|
12
|
+
# Edition: MIT Press
|
13
|
+
# Chapter: 4 - Orbits and Coordinate Systems
|
14
|
+
def adjustement_for_arctangent(y, x, angle)
|
15
|
+
return angle if y.positive? && x.positive?
|
16
|
+
|
17
|
+
if y.negative? && x.positive?
|
18
|
+
return Angle.as_degrees(angle.degrees + 360)
|
19
|
+
end
|
20
|
+
|
21
|
+
Angle.as_degrees(angle.degrees + 180)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/astronoby/version.rb
CHANGED
data/lib/astronoby.rb
CHANGED
@@ -1,11 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "astronoby/version"
|
4
3
|
require "astronoby/angle"
|
5
|
-
require "astronoby/angles/
|
6
|
-
require "astronoby/angles/
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
require "astronoby/angles/dms"
|
5
|
+
require "astronoby/angles/hms"
|
6
|
+
require "astronoby/epoch"
|
7
|
+
require "astronoby/body"
|
8
|
+
require "astronoby/bodies/sun"
|
9
|
+
require "astronoby/coordinates/ecliptic"
|
10
|
+
require "astronoby/coordinates/equatorial"
|
11
|
+
require "astronoby/coordinates/horizontal"
|
12
|
+
require "astronoby/aberration"
|
13
|
+
require "astronoby/errors"
|
14
|
+
require "astronoby/mean_obliquity"
|
15
|
+
require "astronoby/nutation"
|
16
|
+
require "astronoby/precession"
|
17
|
+
require "astronoby/refraction"
|
18
|
+
require "astronoby/util/astrodynamics"
|
19
|
+
require "astronoby/util/time"
|
20
|
+
require "astronoby/util/trigonometry"
|
21
|
+
require "astronoby/true_obliquity"
|
22
|
+
require "astronoby/version"
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: astronoby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rémy Hannequin
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: matrix
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.4.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.4.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
-
type: :
|
47
|
+
version: '3.0'
|
48
|
+
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: standard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,31 +66,46 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.3'
|
69
|
-
description: Ruby version of the calculations from
|
70
|
-
|
69
|
+
description: Ruby version of the calculations from various books like Celestial Calculations
|
70
|
+
by J. L. Lawrence, Practical Astronomy with your Calculator or Spreadsheet by Peter
|
71
|
+
Duffett-Smith and Jonathan Zwart, or Astronomical Algorithms by Jean Meeus
|
71
72
|
email:
|
72
73
|
- hello@rhannequ.in
|
73
74
|
executables: []
|
74
75
|
extensions: []
|
75
76
|
extra_rdoc_files: []
|
76
77
|
files:
|
77
|
-
- ".prettierrc"
|
78
78
|
- ".rspec"
|
79
|
-
- ".
|
79
|
+
- ".tool-versions"
|
80
80
|
- CHANGELOG.md
|
81
81
|
- CODE_OF_CONDUCT.md
|
82
|
+
- CONTRIBUTING.md
|
82
83
|
- Gemfile
|
83
84
|
- Gemfile.lock
|
84
85
|
- LICENSE.txt
|
85
86
|
- README.md
|
86
87
|
- Rakefile
|
87
|
-
- astronoby.gemspec
|
88
88
|
- lib/astronoby.rb
|
89
|
+
- lib/astronoby/aberration.rb
|
89
90
|
- lib/astronoby/angle.rb
|
90
|
-
- lib/astronoby/angles/
|
91
|
-
- lib/astronoby/angles/
|
91
|
+
- lib/astronoby/angles/dms.rb
|
92
|
+
- lib/astronoby/angles/hms.rb
|
93
|
+
- lib/astronoby/bodies/sun.rb
|
94
|
+
- lib/astronoby/body.rb
|
95
|
+
- lib/astronoby/coordinates/ecliptic.rb
|
96
|
+
- lib/astronoby/coordinates/equatorial.rb
|
97
|
+
- lib/astronoby/coordinates/horizontal.rb
|
98
|
+
- lib/astronoby/epoch.rb
|
99
|
+
- lib/astronoby/errors.rb
|
100
|
+
- lib/astronoby/mean_obliquity.rb
|
101
|
+
- lib/astronoby/nutation.rb
|
102
|
+
- lib/astronoby/precession.rb
|
103
|
+
- lib/astronoby/refraction.rb
|
104
|
+
- lib/astronoby/true_obliquity.rb
|
105
|
+
- lib/astronoby/util/astrodynamics.rb
|
106
|
+
- lib/astronoby/util/time.rb
|
107
|
+
- lib/astronoby/util/trigonometry.rb
|
92
108
|
- lib/astronoby/version.rb
|
93
|
-
- sig/astronoby.rbs
|
94
109
|
homepage: https://github.com/rhannequin/astronoby
|
95
110
|
licenses:
|
96
111
|
- MIT
|
@@ -98,7 +113,7 @@ metadata:
|
|
98
113
|
homepage_uri: https://github.com/rhannequin/astronoby
|
99
114
|
source_code_uri: https://github.com/rhannequin/astronoby
|
100
115
|
changelog_uri: https://github.com/rhannequin/astronoby/blob/main/CHANGELOG.md
|
101
|
-
post_install_message:
|
116
|
+
post_install_message:
|
102
117
|
rdoc_options: []
|
103
118
|
require_paths:
|
104
119
|
- lib
|
@@ -106,15 +121,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
121
|
requirements:
|
107
122
|
- - ">="
|
108
123
|
- !ruby/object:Gem::Version
|
109
|
-
version: 2.
|
124
|
+
version: 3.2.0
|
110
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
126
|
requirements:
|
112
127
|
- - ">="
|
113
128
|
- !ruby/object:Gem::Version
|
114
129
|
version: '0'
|
115
130
|
requirements: []
|
116
|
-
rubygems_version: 3.3
|
117
|
-
signing_key:
|
131
|
+
rubygems_version: 3.5.3
|
132
|
+
signing_key:
|
118
133
|
specification_version: 4
|
119
134
|
summary: Astronomical calculations
|
120
135
|
test_files: []
|
data/.prettierrc
DELETED
data/.standard.yml
DELETED
data/astronoby.gemspec
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/astronoby/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "astronoby"
|
7
|
-
spec.version = Astronoby::VERSION
|
8
|
-
spec.authors = ["Rémy Hannequin"]
|
9
|
-
spec.email = ["hello@rhannequ.in"]
|
10
|
-
|
11
|
-
spec.summary = "Astronomical calculations"
|
12
|
-
spec.description = "Ruby version of the calculations from Astronomical Algorithms by Jean Meeus"
|
13
|
-
spec.homepage = "https://github.com/rhannequin/astronoby"
|
14
|
-
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">= 2.7.6"
|
16
|
-
|
17
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
-
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
-
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
20
|
-
|
21
|
-
# Specify which files should be added to the gem when it is released.
|
22
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
-
spec.files = Dir.chdir(__dir__) do
|
24
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
26
|
-
end
|
27
|
-
end
|
28
|
-
spec.bindir = "exe"
|
29
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
-
spec.require_paths = ["lib"]
|
31
|
-
|
32
|
-
spec.add_dependency "rake", "~> 13.0"
|
33
|
-
spec.add_dependency "rspec", "~> 3.0"
|
34
|
-
|
35
|
-
spec.add_development_dependency "prettier", "~> 2.0"
|
36
|
-
spec.add_development_dependency "standard", "~> 1.3"
|
37
|
-
|
38
|
-
# For more information and examples about making a new gem, check out our
|
39
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
40
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Astronoby
|
4
|
-
class Degree < Angle
|
5
|
-
def initialize(angle)
|
6
|
-
super(angle, unit: DEGREES)
|
7
|
-
end
|
8
|
-
|
9
|
-
def to_degrees
|
10
|
-
self
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_radians
|
14
|
-
self.class.as_radians(@angle / 180 * PI)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Astronoby
|
4
|
-
class Radian < Angle
|
5
|
-
def initialize(angle)
|
6
|
-
super(angle, unit: RADIANS)
|
7
|
-
end
|
8
|
-
|
9
|
-
def to_degrees
|
10
|
-
self.class.as_degrees(@angle * 180 / PI)
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_radians
|
14
|
-
self
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/sig/astronoby.rbs
DELETED