lib/sgp4.rb
#trim orbital elements to proper format
trim orbital elements to proper format
trim orbital elements to proper format
def trim(orbital_elements)
    orbital_elements["line_number_1"]=orbital_elements["line_number_1"].to_s.strip
    orbital_elements["catalog_no_1"]=orbital_elements["catalog_no_1"].to_s.strip
    orbital_elements["security_classification"]=orbital_elements["security_classification"].to_s.strip
    orbital_elements["international_identification"]=orbital_elements["international_identification"].to_s.strip
    epy = orbital_elements["epoch_year"]
    if epy.to_i<57 then
      orbital_elements["epoch_year"]=epy.to_i+2000
    else
      orbital_elements["epoch_year"]=epy.to_i+1900
    end
    orbital_elements["epoch"] = orbital_elements["epoch"].to_f
    orbital_elements["first_derivative_mean_motion"] = orbital_elements["first_derivative_mean_motion"].to_f
    second_derivative_mean_motion_mantissa = orbital_elements["second_derivative_mean_motion"][0..5].to_s.strip
    second_derivative_mean_motion_exponent = "1e" + orbital_elements["second_derivative_mean_motion"][6..7].to_s.strip
    orbital_elements["second_derivative_mean_motion"] = second_derivative_mean_motion_mantissa.to_f*second_derivative_mean_motion_exponent.to_f
    bstar_mantissa = (orbital_elements["bstar"][0..5]).to_i*1e-5
    bstar_exponent = "1e" + orbital_elements["bstar"][6..7].to_s.strip
    orbital_elements["bstar"] = bstar_mantissa.to_f*bstar_exponent.to_f
    orbital_elements["ephemeris_type"]=orbital_elements["ephemeris_type"].to_s.strip
    orbital_elements["element_number"]=orbital_elements["element_number"].to_i
    orbital_elements["check_sum_1"]=orbital_elements["check_sum_1"].to_s.strip
    orbital_elements["line_number_2"]=orbital_elements["line_number_2"].to_s.strip
    orbital_elements["catalog_no_2"]=orbital_elements["catalog_no_2"].to_s.strip
    orbital_elements["inclination"]=orbital_elements["inclination"].to_f
    orbital_elements["right_ascension"]=orbital_elements["right_ascension"].to_f
    orbital_elements["eccentricity"] = orbital_elements["eccentricity"].to_i*1e-7
    orbital_elements["argument_of_perigee"]=orbital_elements["argument_of_perigee"].to_f
    orbital_elements["mean_anomaly"]=orbital_elements["mean_anomaly"].to_f
    orbital_elements["mean_motion"]=orbital_elements["mean_motion"].to_f
    orbital_elements["rev_number_at_epoch"]=orbital_elements["rev_number_at_epoch"].to_i
    orbital_elements["check_sum_2"]=orbital_elements["check_sum_2"].to_s.strip
    return orbital_elements
  end
def trim ( orbital_elements ) orbital_elements [ "line_number_1" ] = orbital_elements [ "line_number_1" ] . to_s . strip orbital_elements [ "catalog_no_1" ] = orbital_elements [ "catalog_no_1" ] . to_s . strip orbital_elements [ "security_classification" ] = orbital_elements [ "security_classification" ] . to_s . strip orbital_elements [ "international_identification" ] = orbital_elements [ "international_identification" ] . to_s . strip epy = orbital_elements [ "epoch_year" ] if epy . to_i < 57 then orbital_elements [ "epoch_year" ] = epy . to_i + 2000 else orbital_elements [ "epoch_year" ] = epy . to_i + 1900 end orbital_elements [ "epoch" ] = orbital_elements [ "epoch" ] . to_f orbital_elements [ "first_derivative_mean_motion" ] = orbital_elements [ "first_derivative_mean_motion" ] . to_f second_derivative_mean_motion_mantissa = orbital_elements [ "second_derivative_mean_motion" ] [ 0 .. 5 ] . to_s . strip second_derivative_mean_motion_exponent = "1e" + orbital_elements [ "second_derivative_mean_motion" ] [ 6 .. 7 ] . to_s . strip orbital_elements [ "second_derivative_mean_motion" ] = second_derivative_mean_motion_mantissa . to_f * second_derivative_mean_motion_exponent . to_f bstar_mantissa = ( orbital_elements [ "bstar" ] [ 0 .. 5 ] ) . to_i * 1e-5 bstar_exponent = "1e" + orbital_elements [ "bstar" ] [ 6 .. 7 ] . to_s . strip orbital_elements [ "bstar" ] = bstar_mantissa . to_f * bstar_exponent . to_f orbital_elements [ "ephemeris_type" ] = orbital_elements [ "ephemeris_type" ] . to_s . strip orbital_elements [ "element_number" ] = orbital_elements [ "element_number" ] . to_i orbital_elements [ "check_sum_1" ] = orbital_elements [ "check_sum_1" ] . to_s . strip orbital_elements [ "line_number_2" ] = orbital_elements [ "line_number_2" ] . to_s . strip orbital_elements [ "catalog_no_2" ] = orbital_elements [ "catalog_no_2" ] . to_s . strip orbital_elements [ "inclination" ] = orbital_elements [ "inclination" ] . to_f orbital_elements [ "right_ascension" ] = orbital_elements [ "right_ascension" ] . to_f orbital_elements [ "eccentricity" ] = orbital_elements [ "eccentricity" ] . to_i * 1e-7 orbital_elements [ "argument_of_perigee" ] = orbital_elements [ "argument_of_perigee" ] . to_f orbital_elements [ "mean_anomaly" ] = orbital_elements [ "mean_anomaly" ] . to_f orbital_elements [ "mean_motion" ] = orbital_elements [ "mean_motion" ] . to_f orbital_elements [ "rev_number_at_epoch" ] = orbital_elements [ "rev_number_at_epoch" ] . to_i orbital_elements [ "check_sum_2" ] = orbital_elements [ "check_sum_2" ] . to_s . strip return orbital_elements end
trim orbital elements to proper format
trim orbital elements to proper format
#epoch_year should be smaller than 2057.
orbital_elements
<not_specific>