Class: Korba::Tle

Inherits:
Object
  • Object
show all
Includes:
OrbitUtils
Defined in:
lib/korba/tle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OrbitUtils

#deg_to_rad, #distance, #eccentric_anomaly, #height_at_apogee, #height_at_perigee, #normalize_deg, #normalize_rad, #path_angle, #rad_to_deg, #semi_major_axis, #true_anomaly, #velocity

Constructor Details

#initialize(tle = nil, type: :string) ⇒ Tle



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/korba/tle.rb', line 13

def initialize(tle = nil, type: :string)
  return if tle.nil?

  case type
  when :string
    initialize_from_string(tle)
  when :json
    initialize_from_json(tle)
  end
  set_epoch_datetime_and_julian_date
  set_element_set_record_values
end

Instance Attribute Details

#arg_of_pericenterObject (readonly)

Returns the value of attribute arg_of_pericenter.



8
9
10
# File 'lib/korba/tle.rb', line 8

def arg_of_pericenter
  @arg_of_pericenter
end

#bstarObject (readonly)

Returns the value of attribute bstar.



8
9
10
# File 'lib/korba/tle.rb', line 8

def bstar
  @bstar
end

#classification_typeObject (readonly)

Returns the value of attribute classification_type.



8
9
10
# File 'lib/korba/tle.rb', line 8

def classification_type
  @classification_type
end

#eccentricityObject (readonly)

Returns the value of attribute eccentricity.



8
9
10
# File 'lib/korba/tle.rb', line 8

def eccentricity
  @eccentricity
end

#element_set_noObject (readonly)

Returns the value of attribute element_set_no.



8
9
10
# File 'lib/korba/tle.rb', line 8

def element_set_no
  @element_set_no
end

#element_set_recordObject (readonly)

Returns the value of attribute element_set_record.



8
9
10
# File 'lib/korba/tle.rb', line 8

def element_set_record
  @element_set_record
end

#epochObject (readonly)

Returns the value of attribute epoch.



8
9
10
# File 'lib/korba/tle.rb', line 8

def epoch
  @epoch
end

#epoch_datetimeObject (readonly)

Returns the value of attribute epoch_datetime.



8
9
10
# File 'lib/korba/tle.rb', line 8

def epoch_datetime
  @epoch_datetime
end

#epoch_daysObject (readonly)

Returns the value of attribute epoch_days.



8
9
10
# File 'lib/korba/tle.rb', line 8

def epoch_days
  @epoch_days
end

#inclinationObject (readonly)

Returns the value of attribute inclination.



8
9
10
# File 'lib/korba/tle.rb', line 8

def inclination
  @inclination
end

#julian_dateObject (readonly)

Returns the value of attribute julian_date.



8
9
10
# File 'lib/korba/tle.rb', line 8

def julian_date
  @julian_date
end

#mean_anomalyObject (readonly)

Returns the value of attribute mean_anomaly.



8
9
10
# File 'lib/korba/tle.rb', line 8

def mean_anomaly
  @mean_anomaly
end

#mean_motionObject (readonly)

Returns the value of attribute mean_motion.



8
9
10
# File 'lib/korba/tle.rb', line 8

def mean_motion
  @mean_motion
end

#mean_motion_ddotObject (readonly)

Returns the value of attribute mean_motion_ddot.



8
9
10
# File 'lib/korba/tle.rb', line 8

def mean_motion_ddot
  @mean_motion_ddot
end

#mean_motion_dotObject (readonly)

Returns the value of attribute mean_motion_dot.



8
9
10
# File 'lib/korba/tle.rb', line 8

def mean_motion_dot
  @mean_motion_dot
end

#object_idObject (readonly)

Returns the value of attribute object_id.



8
9
10
# File 'lib/korba/tle.rb', line 8

def object_id
  @object_id
end

#object_nameObject (readonly)

Returns the value of attribute object_name.



8
9
10
# File 'lib/korba/tle.rb', line 8

def object_name
  @object_name
end

#ra_of_asc_nodeObject (readonly)

Returns the value of attribute ra_of_asc_node.



8
9
10
# File 'lib/korba/tle.rb', line 8

def ra_of_asc_node
  @ra_of_asc_node
end

#revolution_numberObject (readonly)

Returns the value of attribute revolution_number.



8
9
10
# File 'lib/korba/tle.rb', line 8

def revolution_number
  @revolution_number
end

#satellite_numberObject (readonly)

Returns the value of attribute satellite_number.



8
9
10
# File 'lib/korba/tle.rb', line 8

def satellite_number
  @satellite_number
end

#tle_jsonObject (readonly)

Returns the value of attribute tle_json.



8
9
10
# File 'lib/korba/tle.rb', line 8

def tle_json
  @tle_json
end

#tle_stringObject (readonly)

Returns the value of attribute tle_string.



8
9
10
# File 'lib/korba/tle.rb', line 8

def tle_string
  @tle_string
end

Instance Method Details

#propagate_to(minutesAfterEpoch) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/korba/tle.rb', line 42

def propagate_to(minutesAfterEpoch)
  r = [0, 0, 0]
  v = [0, 0, 0]

  @element_set_record.error = 0
  SGP4.sgp4(@element_set_record, minutesAfterEpoch, r, v)
  @sgp4Error = @element_set_record.error
  r = r.map { _1 * 1000 }
  v = v.map { _1 * 1000 }
  Car.new(object_name:, epoch:, x: r[0], y: r[1], z: r[2], vx: v[0], vy: v[1], vz: v[2])
end

#to_carObject



37
38
39
40
# File 'lib/korba/tle.rb', line 37

def to_car
  kep = to_kep
  kep.to_car
end

#to_kepObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/korba/tle.rb', line 26

def to_kep
  Kep.new(object_name:,
          epoch:,
          semi_major_axis:,
          eccentricity:,
          inclination:,
          ra_of_asc_node:,
          arg_of_pericenter:,
          mean_anomaly:)
end