aboutsummaryrefslogtreecommitdiff
path: root/src/cal/get_tle/check_tle.pl.in
blob: 9a3ec3d91fd4b74e6fa780c9e464aba469530a38 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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;

}