Last active
August 29, 2015 14:23
-
-
Save stevenpetryk/3e13ea64ebc49d4571f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ARGV[0] | |
tle = File.open(ARGV[0]).read | |
tle_line_1 = tle.lines[0] | |
tle_line_2 = tle.lines[1] | |
else | |
print 'Line 1 > ' | |
tle_line_1 = gets.chomp | |
print 'Line 2 > ' | |
tle_line_2 = gets.chomp | |
end | |
# Converts TLE scientific notation to a float: | |
# sci_to_f('-412-6') # => -0.000412 | |
# | |
def sci_to_f(input) | |
if input[0] == '-' | |
components = input[1..-1].split('-').map(&:to_f) | |
components[0] = -components[0] | |
else | |
components = input.split('-').map(&:to_f) | |
end | |
components[0] * 10 ** -components[1] | |
end | |
mean_elements = { | |
"Element set epoch" => tle_line_1[18..31], | |
"First derivative of mean motion" => tle_line_1[33..42], | |
"Second derivative of mean motion" => sci_to_f(tle_line_1[44..51]), | |
"BSTAR" => sci_to_f(tle_line_1[53..60]), | |
"Inclination" => tle_line_2[8..15], | |
"RAAN" => tle_line_2[17..24], | |
"Eccentricity" => tle_line_2[26..32], | |
"Argument of perigee" => tle_line_2[34..41], | |
"Mean anomaly" => tle_line_2[43..50], | |
"Mean motion" => tle_line_2[52..62] | |
} | |
mean_elements.each_pair do |key, value| | |
puts '', "#{key}:" | |
puts "%f" % value.to_f | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment