korba 0.4.0 → 0.6.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 +8 -0
- data/README.md +21 -1
- data/lib/korba/car.rb +18 -0
- data/lib/korba/kep.rb +19 -2
- data/lib/korba/kepler_equation_fucntion.rb +20 -0
- data/lib/korba/newton_function.rb +25 -0
- data/lib/korba/orbit_utils.rb +52 -3
- data/lib/korba/sgp4/elset_rec.rb +432 -0
- data/lib/korba/sgp4/sgp4.rb +2027 -0
- data/lib/korba/tle.rb +97 -14
- data/lib/korba/version.rb +1 -1
- data/lib/korba.rb +5 -0
- metadata +8 -3
data/lib/korba/tle.rb
CHANGED
@@ -3,9 +3,12 @@ require_relative "orbit_utils"
|
|
3
3
|
|
4
4
|
module Korba
|
5
5
|
class Tle
|
6
|
-
include
|
6
|
+
include OrbitUtils
|
7
7
|
|
8
|
-
attr_reader :tle_json, :tle_string, :
|
8
|
+
attr_reader :tle_json, :tle_string, :object_id, :object_name, :epoch_datetime, :julian_date,
|
9
|
+
:satellite_number, :classification_type, :epoch, :mean_motion_dot, :mean_motion_ddot, :bstar, :element_set_no,
|
10
|
+
:inclination, :ra_of_asc_node, :eccentricity, :arg_of_pericenter, :mean_anomaly, :mean_motion, :revolution_number,
|
11
|
+
:element_set_record, :epoch_days
|
9
12
|
|
10
13
|
def initialize(tle = nil, type: :string)
|
11
14
|
return if tle.nil?
|
@@ -16,17 +19,36 @@ module Korba
|
|
16
19
|
when :json
|
17
20
|
initialize_from_json(tle)
|
18
21
|
end
|
22
|
+
set_epoch_datetime_and_julian_date
|
23
|
+
set_element_set_record_values
|
19
24
|
end
|
20
25
|
|
21
26
|
def to_kep
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
Kep.new(object_name:,
|
28
|
+
epoch:,
|
29
|
+
semi_major_axis:,
|
30
|
+
eccentricity:,
|
31
|
+
inclination:,
|
32
|
+
ra_of_asc_node:,
|
33
|
+
arg_of_pericenter:,
|
34
|
+
mean_anomaly:)
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_car
|
38
|
+
kep = to_kep
|
39
|
+
kep.to_car
|
40
|
+
end
|
41
|
+
|
42
|
+
def propagate_to(minutesAfterEpoch)
|
43
|
+
r = [0, 0, 0]
|
44
|
+
v = [0, 0, 0]
|
45
|
+
|
46
|
+
@element_set_record.error = 0
|
47
|
+
SGP4.sgp4(@element_set_record, minutesAfterEpoch, r, v)
|
48
|
+
@sgp4Error = @element_set_record.error
|
49
|
+
r = r.map { _1 * 1000 }
|
50
|
+
v = v.map { _1 * 1000 }
|
51
|
+
Car.new(object_name:, epoch:, x: r[0], y: r[1], z: r[2], vx: v[0], vy: v[1], vz: v[2])
|
30
52
|
end
|
31
53
|
|
32
54
|
private
|
@@ -41,12 +63,31 @@ module Korba
|
|
41
63
|
|
42
64
|
def parse_line1(line1_strings)
|
43
65
|
# TODO: object_id
|
66
|
+
@satellite_number = line1_strings[1][0..4].to_i
|
67
|
+
@classification_type = line1_strings[1][-1]
|
44
68
|
# For now, only supports years after 2000
|
45
69
|
epoch_year = line1_strings[3][0..1].to_i + 2000
|
46
|
-
|
47
|
-
# Subtract 1 from
|
48
|
-
epoch_time = Time.new(epoch_year, 1, 1, 0, 0, 0, "+00:00") + (
|
70
|
+
@epoch_days = line1_strings[3][2..].to_f
|
71
|
+
# Subtract 1 from epoch_days because January 1st is considered day 1
|
72
|
+
epoch_time = Time.new(epoch_year, 1, 1, 0, 0, 0, "+00:00") + (epoch_days - 1) * 24 * 60 * 60
|
49
73
|
@epoch = epoch_time.strftime("%Y-%m-%dT%H:%M:%S.%6N")
|
74
|
+
|
75
|
+
mean_motion_dot_sign = line1_strings[4][0] == "-" ? -1 : 1
|
76
|
+
mean_motion_dot_value_start = line1_strings[4].size == 10 ? 1 : 0
|
77
|
+
@mean_motion_dot = mean_motion_dot_sign * "0#{line1_strings[4][mean_motion_dot_value_start..]}".to_f
|
78
|
+
|
79
|
+
mean_motion_ddot_sign = line1_strings[5][0] == "-" ? -1 : 1
|
80
|
+
mean_motion_ddot_value_start = line1_strings[5].size == 8 ? 1 : 0
|
81
|
+
mean_motion_ddot_exponent = line1_strings[5][mean_motion_ddot_value_start + 5..mean_motion_ddot_value_start + 6].to_i
|
82
|
+
@mean_motion_ddot =
|
83
|
+
mean_motion_ddot_sign * "0.#{line1_strings[5][mean_motion_ddot_value_start..mean_motion_ddot_value_start + 4]}".to_f * 10 ** mean_motion_ddot_exponent
|
84
|
+
|
85
|
+
bstar_sign = line1_strings[6][0] == "-" ? -1 : 1
|
86
|
+
bstar_value_start = line1_strings[6].size == 8 ? 1 : 0
|
87
|
+
bstar_exponent = line1_strings[6][bstar_value_start + 5..bstar_value_start + 6].to_i
|
88
|
+
@bstar = bstar_sign * "0.#{line1_strings[6][bstar_value_start..bstar_value_start + 4]}".to_f * 10 ** bstar_exponent
|
89
|
+
|
90
|
+
@element_set_no = line1_strings[8][0..2].to_i
|
50
91
|
end
|
51
92
|
|
52
93
|
def parse_line2(line2_strings)
|
@@ -55,20 +96,62 @@ module Korba
|
|
55
96
|
@eccentricity = "0.#{line2_strings[4]}".to_f
|
56
97
|
@arg_of_pericenter = line2_strings[5].to_f
|
57
98
|
@mean_anomaly = line2_strings[6].to_f
|
58
|
-
@mean_motion = line2_strings[7].to_f
|
99
|
+
@mean_motion = line2_strings[7][0..10].to_f
|
100
|
+
@revolution_number = line2_strings[7][11..15].to_i
|
59
101
|
end
|
60
102
|
|
61
103
|
def initialize_from_json(tle_json)
|
62
104
|
@tle_json = tle_json
|
63
105
|
@object_name = tle_json[:OBJECT_NAME]
|
64
106
|
@object_id = tle_json[:OBJECT_ID]
|
107
|
+
@satellite_number = tle_json[:NORAD_CAT_ID]
|
108
|
+
@classification_type = tle_json[:CLASSIFICATION_TYPE]
|
65
109
|
@epoch = tle_json[:EPOCH]
|
110
|
+
@mean_motion_dot = tle_json[:MEAN_MOTION_DOT]
|
111
|
+
@mean_motion_ddot = tle_json[:MEAN_MOTION_DDOT]
|
112
|
+
@bstar = tle_json[:BSTAR]
|
113
|
+
@element_set_no = tle_json[:ELEMENT_SET_NO]
|
66
114
|
@mean_motion = tle_json[:MEAN_MOTION]
|
67
115
|
@eccentricity = tle_json[:ECCENTRICITY]
|
68
116
|
@inclination = tle_json[:INCLINATION]
|
69
117
|
@ra_of_asc_node = tle_json[:RA_OF_ASC_NODE]
|
70
118
|
@arg_of_pericenter = tle_json[:ARG_OF_PERICENTER]
|
71
119
|
@mean_anomaly = tle_json[:MEAN_ANOMALY]
|
120
|
+
@revolution_number = tle_json[:REV_AT_EPOCH]
|
121
|
+
end
|
122
|
+
|
123
|
+
def set_epoch_datetime_and_julian_date
|
124
|
+
@epoch_datetime = Time.new(@epoch + " UTC")
|
125
|
+
@julian_date = SGP4.jday(
|
126
|
+
epoch_datetime.year, epoch_datetime.mon, epoch_datetime.day, epoch_datetime.hour, epoch_datetime.min, epoch_datetime.sec
|
127
|
+
)
|
128
|
+
end
|
129
|
+
|
130
|
+
def set_element_set_record_values
|
131
|
+
@element_set_record = ElsetRec.new
|
132
|
+
@element_set_record.whichconst = 3 # wgs84
|
133
|
+
@element_set_record.epochyr = epoch_datetime.year
|
134
|
+
@element_set_record.epochdays = epoch_days
|
135
|
+
@element_set_record.jdsatepoch = julian_date[0]
|
136
|
+
@element_set_record.jdsatepochF = julian_date[1]
|
137
|
+
|
138
|
+
@element_set_record.classification = classification_type
|
139
|
+
@element_set_record.elnum = element_set_no
|
140
|
+
@element_set_record.revnum = revolution_number
|
141
|
+
@element_set_record.satnum = satellite_number
|
142
|
+
@element_set_record.bstar = bstar
|
143
|
+
@element_set_record.inclo = deg_to_rad(inclination)
|
144
|
+
@element_set_record.nodeo = deg_to_rad(ra_of_asc_node)
|
145
|
+
@element_set_record.argpo = deg_to_rad(arg_of_pericenter)
|
146
|
+
@element_set_record.mo = deg_to_rad(mean_anomaly)
|
147
|
+
@element_set_record.ecco = eccentricity
|
148
|
+
|
149
|
+
xpdotp = 1440.0 / (2.0 * Math::PI)
|
150
|
+
@element_set_record.no_kozai = mean_motion / xpdotp
|
151
|
+
@element_set_record.ndot = mean_motion_dot / (xpdotp * 1440.0)
|
152
|
+
@element_set_record.nddot = mean_motion_ddot / (xpdotp * 1440.0 * 1440.0)
|
153
|
+
# update element_set_record
|
154
|
+
SGP4.sgp4init("a", @element_set_record)
|
72
155
|
end
|
73
156
|
end
|
74
157
|
end
|
data/lib/korba/version.rb
CHANGED
data/lib/korba.rb
CHANGED
@@ -4,6 +4,11 @@ require_relative "korba/version"
|
|
4
4
|
require_relative "korba/constant"
|
5
5
|
require_relative "korba/tle"
|
6
6
|
require_relative "korba/kep"
|
7
|
+
require_relative "korba/car"
|
8
|
+
require_relative "korba/orbit_utils"
|
9
|
+
require_relative "korba/kepler_equation_fucntion"
|
10
|
+
require_relative "korba/sgp4/elset_rec"
|
11
|
+
require_relative "korba/sgp4/sgp4"
|
7
12
|
|
8
13
|
module Korba
|
9
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: korba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kk0000-kk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Orbital elements calculation library
|
14
14
|
email:
|
@@ -22,9 +22,14 @@ files:
|
|
22
22
|
- README.md
|
23
23
|
- Rakefile
|
24
24
|
- lib/korba.rb
|
25
|
+
- lib/korba/car.rb
|
25
26
|
- lib/korba/constant.rb
|
26
27
|
- lib/korba/kep.rb
|
28
|
+
- lib/korba/kepler_equation_fucntion.rb
|
29
|
+
- lib/korba/newton_function.rb
|
27
30
|
- lib/korba/orbit_utils.rb
|
31
|
+
- lib/korba/sgp4/elset_rec.rb
|
32
|
+
- lib/korba/sgp4/sgp4.rb
|
28
33
|
- lib/korba/tle.rb
|
29
34
|
- lib/korba/version.rb
|
30
35
|
- sig/korba.rbs
|
@@ -50,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
55
|
- !ruby/object:Gem::Version
|
51
56
|
version: '0'
|
52
57
|
requirements: []
|
53
|
-
rubygems_version: 3.5.
|
58
|
+
rubygems_version: 3.5.23
|
54
59
|
signing_key:
|
55
60
|
specification_version: 4
|
56
61
|
summary: Orbital elements calculation library
|