diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-03-07 23:42:46 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-03-07 23:42:46 -0500 |
commit | 727498350ee97618f5a23f93addaef43e7d950af (patch) | |
tree | ea77abba309c71e438bbf3fd5aa600c86116e7f9 /src/cal/get_tle/check_tle.pl.in | |
parent | ece6c047eacb388ed4d36ce1eb18cc96b47a047e (diff) | |
download | calfuse-727498350ee97618f5a23f93addaef43e7d950af.tar.gz |
Massive fixes. Adding the rest of the code.
Diffstat (limited to 'src/cal/get_tle/check_tle.pl.in')
-rw-r--r-- | src/cal/get_tle/check_tle.pl.in | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/src/cal/get_tle/check_tle.pl.in b/src/cal/get_tle/check_tle.pl.in new file mode 100644 index 0000000..9a3ec3d --- /dev/null +++ b/src/cal/get_tle/check_tle.pl.in @@ -0,0 +1,100 @@ +#!/usr/bin/env perl +use FileHandle; + +# *************************************************** +# add_tle.pl +# +# This Perl module will read in the latest five orbital elements +# from the file five.tle (which was created by get_tle.pl) and +# add any new orbital elements to the file FUSE.TLE. +# +# Author: Ed Murphy +# +# History: Written July 27, 1999 +# +# *************************************************** + +# Define the file names. old_maintle_filename is not actually opened, +# but is used in a system call at the end of the program. + +$maintle_filename = "@DATADIR@/calfiles/FUSE.TLE"; +$outtle_filename = "check_tle.dat"; + +# Open the files. +open (TLE_MAINFILE, "<$maintle_filename") || die "Cannot open $maintle_filename"; +open (TLE_OUT, ">$outtle_filename") || die "Cannot open $outtle_filename"; + +# Read the first two lines from the maintle file to get the date of the +# most recent set of TLEs. Save these lines for later output. +while ($line1 = <TLE_MAINFILE>) { + $line2 = <TLE_MAINFILE>; + $line3 = <TLE_MAINFILE>; + + &parse_lines; + + &calculate_a0; + &calculate_orbs; + + printf TLE_OUT "%7.3f %6.2f %6.2f %7.2f %6.2f %7.4f %6.2f %6.2f %8.6f\n",$day, $apogee, $perigee, $semiax, $raan, $incl, $mean_anom, $arg_perig, $eccen; + +} + + close (TLE_MAINFILE); + close (TLE_OUT); + +### end of Perl script + + +sub parse_lines { +$year = substr($line2, 18, 2); +$doy = substr($line2, 20, 3); +$dayfrac = substr($line2, 23, 9); +$day=$doy.$dayfrac; +$epoch = $year.$doy.$dayfrac; +$incl = substr($line3, 9, 8); +$raan = substr($line3, 17,8); +$eccen = substr($line3, 26, 7); +$eccen = "0." . $eccen; +$mean_mot = substr($line3, 52, 11); +$mean_anom = substr($line3, 43, 8); +$arg_perig = substr($line3, 34, 8); + + +if ($year > 50) { + $year += 1900; +} else { + $year += 2000; +} + +$dayfrac = "0".$dayfrac; + +} + +sub calculate_a0 { + +$mu = 3.986005E5; +$pi = 3.14159265358979; +$radian = 0.0174532925200; + +$mm=2.0*$pi*$mean_mot/(24.0*60.0); +$ke=0.74366916E-1; +$k2=5.413080E-4; +$a1=($ke/$mm)**(2.0/3.0); +$inrad = $incl * $radian; + +$d1=3.0/2.0*$k2/($a1*$a1)*(3.0*cos($inrad)*cos($inrad)-1.0)/((1.0-$eccen*$eccen)**(3.0/2.0)); +$a0=$a1*(1.0-$d1/3.0-$d1*$d1-134.0/81.0*$d1*$d1*$d1); +$d0=3.0/2.0*$k2/($a0*$a0)*(3.0*cos($inrad)*cos($inrad)-1.0)/((1.0-$eccen*$eccen)**(3.0/2.0)); +$semiax=$a0/(1-$d0)*6378.135; + +} + +sub calculate_orbs { + +$period = 60.0*24.0/($mean_mot/(1+$d0)); +$cax=$eccen*$semiax; +$perigee=$semiax-$cax-6378.1; +$apogee=$semiax+$cax-6378.1; + +} + |