REM This program has been completely re
-designed
and re
-written.
REM Program accepts the
name of a file of Two
-Line Orbital Elements
REM 2 - ASCII file which can be impoted by Lotus
1-2-3 REM Re
-designed program prepared 07.11.2001.
REM for both basic orbital
data and Lotus
1-2-3 created was deleted:
REM these
files can still be created
using the individual options
1 REM and 2. The Lotus
1-2-3 output file was changed
, so that the
REM raw TLE
data would no longer be included. A new
option was added
REM to create an ASCII file which could be
read into Excel
for REM a spreadsheet in that format. Finally
, the definitions specific
REM Excel
option updated because Excel cannot handle date
/epoch functions.
REM Modified
to reflect drives
and paths
to use with COMPAQ computer
REM element set which can be used in an Excel spreadsheet.
REM Minor modification
to include blank lines when preparing the .ORB
REM Program modified
to include an additional
option for extracing GEO
REM Read drive definitions from external file
REM Definitions of disk drives
for Compaq laptop computer.
hdisk$ = drive1$
hout$ = hdisk$ + "output\"
outh$ = hdisk$ + "output\"
REM Define standard directory paths
drivec1$ = outh$
drivec2$ = "H"
REM Conversion factor from degrees
to radians.
fact# = 3.1415265# / 180#
re# = 6378.145#
REM Radius of geostationary orbit
r24# = 42241.122#
REM Coefficient of precession formulae
j2# = .013324511#
REM Term used
for calculating the drift rate of GEO objects
drift0# = 1.00273791#
REM Define defalt drive
data: drive C.
drive1a$ = drivec1$
drive2a$ = drivec2$
top11$ = "=========================================================================="
top12$ = "Catalogue Orbital Orbital Orbital Perigee Apogee Arg of"
top13$ = " Number Epoch Inclination Period Perigee"
top14$ = " deg min km km deg"
top15$ = "--------------------------------------------------------------------------"
REM nnnnn yyyy mmm dd.dd iii.ii p
,ppp.pp pp
,ppp aaa
,aaa aaa
end11$ = "=========================================================================="
top41$ = "===================================================================================================================="
top42$ = "Catalogue Epoch Incl Node RA Node-DOT Period Perigee Apogee AoP AoP-DOT Ground"
top43$ = "Number deg deg deg/day min km km deg deg/day Track deg"
top44$ = "--------------------------------------------------------------------------------------------------------------------"
REM nnnnn yyyy mmm dd.dd iii.ii nnn.nn
-nn.nnnn pppp.pp ppppp aaaaaa aaa
-aa.aaaa ggg.gg
end41$ = "===================================================================================================================="
top51$ = "============================================================================================="
top52$ = "Catalogue Orbital Orbital Orbital Perigee Apogee Arg of Long Drift"
top53$ = " Number Epoch Inclination Period Perigee deg E deg E/day"
top54$ = "---------------------------------------------------------------------------------------------"
REM nnnnn yyyy mmm dd.dd iii.ii p
,ppp.pp pp
,ppp aaa
,aaa aaa lll
+dd.ddd
end51$ = "============================================================================================="
REM Define the gap between lines of
data: this separates
data for different
gap$ = " "
100
REM Subroutine which prints the menu
for converting TLE
data to 110
PRINT "Enter name of TLE file to be processed:" PRINT "Press 'RETURN' to terminate this loop"
120
inname1$ = drive1$ + infile$ + ".elm"
outname1$ = drive1a$ + infile$ + ".orb"
outname2$ = drive1a$ + infile$ + ".txt"
outname3$ = drive1a$ + infile$ + ".txt"
outname4$ = drive1a$ + infile$ + ".dat"
outname5$ = drive1a$ + infile$ + ".geo"
PRINT "Choose the formats of the files to be created" PRINT "1. Basic orbital data ASCII text file" PRINT "2. ASCII Lotus 1-2-3 .TXT file" PRINT "3. ASCII Excel 97 .TXT file" PRINT "4. ASCII text file with groundtrack" PRINT "5. Text data for GEO objects" PRINT "6. EXCEL data for GEO objects" PRINT "7. Shortened one-line file"
PRINT "Choose an option 1, 2, 3, 4, 5 or 6:" 130
PRINT "WARNING - INVALID OPTION CHOSEN !!"
199
REM----------------------------------------------------------------------------
1000
REM This subroutine creates a file
or series of
files of orbital
REM data based upon a specified set of TLEs.
REM Screen display of file being processed
and the file
(s
) being
inname1$ = drive1a$ + infile$ + ".elm"
outname1$ = drive1a$ + infile$ + ".orb"
outname2$ = drive1a$ + infile$ + ".txt"
outname3$ = drive1a$ + infile$ + ".txt"
outname4$ = drive1a$ + infile$ + ".dat"
outname5$ = drive1a$ + infile$ + ".geo"
1010
REM----------------------------------------------------------------------------
2000
REM Subroutine which displays the
screen while TLEs are being processed
PRINT "TLE file being processed:" PRINT "File(s) being created:" PRINT "Catalogue number being processed:"
REM----------------------------------------------------------------------------
3100
oldnum = 0
REM----------------------------------------------------------------------------
3400
oldnum = 0
REM----------------------------------------------------------------------------
3500
oldnum = 0
REM----------------------------------------------------------------------------
4000
REM the orbital
data. The lines of the element set are defined
as
REM Extract the satellite number being processed.
catnum$
= MID$(tleline1$
, 3, 5)
REM Extract the required
data from the element set.
tleyear$
= STR$(tleyear#
)
REM Epoch day
and decimal of a day
tlepoch$
= MID$(tleline1$
, 21, 12)
REM Transform epoch
to month
and days equivalent.
tleincl$
= MID$(tleline2$
, 9, 8)
tlenode$
= MID$(tleline2$
, 18, 8)
REM Eccentricity
- remember that the element set omits the decimal
point.
tlee$
= MID$(tleline2$
, 27, 7)tlee#
= VAL(tlee$
) / 10000000
tleaop$
= MID$(tleline2$
, 35, 8)
tlema$
= MID$(tleline2$
, 44, 8)
tlemm$
= MID$(tleline2$
, 53, 12)
tlerevs$
= MID$(tleline2$
, 67, 2)
period# = 1440 / tlemm#
semi# = r24# * tlemm# ^ (-2 / 3)
perigee# = semi# * (1 - tlee#) - re#
perigee$
= STR$(perigee#
)
apogee# = semi# * (1 + tlee#) - re#
REM Precession of the nodes
ndot#
= -j2#
* tlemm#
^ (7 / 3) * COS(fact#
* tleincl#
) / (1 - tlee#
^ 2) ^ 2
aopdot#
= j2#
* tlemm#
^ (7 / 3) * (2 - 2.5 * (SIN(fact#
* tleincl#
)) ^ 2) / (1 - tlee#
^ 2) ^ 2
gtrack# = (360.9856# - ndot#) / (tlemm# + naop# / 360)
REM The following code
is applicable in the real world
only for REM satellites which are in geosynchronous orbit.
Using the TLE the
REM "sub-satellte longitude is calculated, although of course this is REM not applicable to non-GEO orbits.
REM First, calculate the longitude of the Sun for the epoch date
testyear# = (tleyear# - 1956) / 4 - INT((tleyear# - 1956) / 4)
SELECT CASE testyear#
CASE IS = 0
deltayr# = (tleyear# - 1960) / 4
lsun0# = 278.679
CASE IS = .25
deltayr# = (tleyear# - 1957) / 4
lsun0# = 279.396
CASE IS = .5
deltayr# = (tleyear# - 1958) / 4
lsun0# = 279.158
CASE IS = .75
deltayr# = (tleyear# - 1959) / 4
lsun0# = 278.918
CASE ELSE
END SELECT
lsun# = lsun0# + (.0307# * deltayr#) + (.98565# * tlepoch#)
REM Now calculate the GEO sub-satellite longitue.
geolong# = tlenode# + tleaop# + tlema# - 180 - lsun# - 360.98565# * (tlepoch# - INT(tlepoch#))
REM Ensure that the longitude is within the range 0-360 deg
4010
IF geolong# < 0 THEN geolong# = geolong# + 360: GOTO 4010
4020
IF geolong# > 360 THEN geolong# = geolong# - 360: GOTO 4020
REM Drift rate arond the GEO orbit.
drift# = 360 * (tlemm# - drift0#)
RETURN
REM----------------------------------------------------------------------------
4100
REM Subroutine which prints basic orbital data to a text file.
REM Optionss 1 and 1a. Option 1a differs from Option 1 in that it
REM allows a more accurate orbital period to be output.
IF oldnum <> newnum THEN PRINT #2, gap$
PRINT #2, catnum$;
PRINT #2, " ";
PRINT #2, tleyear#; month$;
PRINT #2, USING "##.###"; day#;
IF option$ = "1a" THEN GOTO 4110
PRINT #2, " ";
PRINT #2, USING "###.##"; tleincl#;
PRINT #2, " ";
PRINT #2, USING "##,###.##"; period#;
PRINT #2, " ";
GOTO 4120
4110
PRINT #2, " ";
PRINT #2, USING "###.###"; tleincl#;
PRINT #2, " ";
PRINT #2, USING "##,###.###"; period#;
PRINT #2, " ";
4120
PRINT #2, USING "##,###"; perigee#;
PRINT #2, " ";
PRINT #2, USING "###,###"; apogee#;
PRINT #2, " ";
PRINT #2, USING "###"; tleaop#
oldnum = newnum
RETURN
REM----------------------------------------------------------------------------
4200
REM Subroutine which prints data to a text file formatted for Lotus 1-2-3.
REM Option 2.
out1$ = catnum$ + " " + tleyear$ + " " + tlepoch$ + " " + "0" + " "
PRINT #3, catnum$;
PRINT #3, " ";
PRINT #3, tleyear$;
PRINT #3, " ";
PRINT #3, tlepoch$;
PRINT #3, " ";
PRINT #3, "0";
PRINT #3, " ";
PRINT #3, USING "###.####"; tleincl#;
PRINT #3, " ";
PRINT #3, USING "####.#####"; period#;
PRINT #3, " ";
PRINT #3, USING "#####.####"; perigee#;
PRINT #3, " ";
PRINT #3, USING "#####.####"; apogee#;
PRINT #3, " ";
PRINT #3, USING "###.###"; tleaop#
RETURN
REM----------------------------------------------------------------------------
4300
REM Subroutine which prints data to a text file formatted for Excel.
REM Option 3.
REM out1$ = catnum$ + " " + tleyear$ + "-" + MID$(month$, 1, 3) + "-"
REM out2$ = MID$(STR$(INT(day#)), 2, 2) + " " + STR$(0) + " " + tleincl$ + " "
REM out3$ = period$ + " " + perigee$ + " " + apogee$ + " " + tleaop$
REM out$ = out1$ + out2$ + out3$
REM PRINT #4, out$
REM Excel cannot handle dates properly ! Therefore the tle epoch date/time
REM must be converted to a decimal of a year.
REM Check if the year is a leap year: if it is then divide by 366#,
REM otherwise divide by 365. Then convert epoch to decimals of a year.
IF ABS(tleyear# / 4# - INT(tleyear# / 4#)) < .01# THEN divday# = 366# ELSE divday# = 365#
decdate# = (tlepoch# - 1) / divday#
decyear# = tleyear# + decdate#
PRINT #4, catnum$; " "; tleyear#; " ";
PRINT #4, USING "###.########"; tlepoch#;
PRINT #4, " ";
PRINT #4, USING "####.############"; decyear#;
PRINT #4, " "; " ";
PRINT #4, USING "###.####"; tleincl#;
PRINT #4, " ";
PRINT #4, USING "####.####"; period#;
PRINT #4, " ";
PRINT #4, USING "#####.####"; perigee#;
PRINT #4, " ";
PRINT #4, USING "#####.####"; apogee#;
PRINT #4, " ";
PRINT #4, USING "###.####"; tleaop#
RETURN
REM----------------------------------------------------------------------------
4400
REM Subroutine which prints data including precession and groundtrack
REM values to a text file:
REM Option 4.
IF oldnum <> newnum THEN PRINT #5, gap$
PRINT #5, catnum$;
PRINT #5, " ";
PRINT #5, tleyear#; month$;
PRINT #5, USING "##.###"; day#;
PRINT #5, " ";
IF option$ = "4a" THEN GOTO 4405
PRINT #5, USING "###.##"; tleincl#;
PRINT #5, " ";
GOTO 4407
4405
PRINT #5, USING "###.###"; tleincl#;
PRINT #5, " ";
4407
PRINT #5, USING "###.##"; tlenode#;
PRINT #5, " ";
PRINT #5, USING "###.####"; ndot#;
IF option$ = "4a" THEN GOTO 4410
PRINT #5, " ";
PRINT #5, USING "####.##"; period#;
GOTO 4420
4410
PRINT #5, " ";
PRINT #5, USING "####.###"; period#;
4420
PRINT #5, " ";
PRINT #5, USING "#####"; perigee#;
PRINT #5, " ";
PRINT #5, USING "######"; apogee#;
PRINT #5, " ";
PRINT #5, USING "###"; tleaop#;
PRINT #5, " ";
PRINT #5, USING "###.####"; aopdot#;
PRINT #5, " ";
PRINT #5, USING "###.###"; gtrack#
oldnum = newnum
RETURN
REM----------------------------------------------------------------------------
4500
REM Subroutine which prints data for GEO objects to a text file.
REM Option 5.
IF oldnum <> newnum THEN PRINT #6, gap$
PRINT #6, catnum$;
PRINT #6, " ";
PRINT #6, tleyear#; month$;
PRINT #6, USING "##.###"; day#;
PRINT #6, " ";
PRINT #6, USING "###.##"; tleincl#;
PRINT #6, " ";
PRINT #6, USING "#,###.##"; period#;
PRINT #6, " ";
PRINT #6, USING "##,###"; perigee#;
PRINT #6, " ";
PRINT #6, USING "###,###"; apogee#;
PRINT #6, " ";
PRINT #6, USING "###"; tleaop#;
IF period# < 1200# THEN GOTO 4510
PRINT #6, " ";
PRINT #6, USING "###.#"; geolong#;
PRINT #6, " ";
PRINT #6, USING "+##.###"; drift#
oldnum = newnum
GOTO 4520
4510
REM PRINT #6, ""
4520
RETURN
REM----------------------------------------------------------------------------
4600
REM Subroutine which prints data for GEO objects to a text file.
REM Option 6.
IF oldnum <> newnum THEN PRINT #6, gap$
PRINT #6, catnum$;
PRINT #6, " ";
PRINT #6, tleyear#;
PRINT #6, " ";
PRINT #6, USING "###.####"; tlepoch#;
PRINT #6, " ";
decyear# = tleyear# + tlepoch# / 367#
PRINT #6, USING "####.#####"; decyear#;
PRINT #6, " ";
PRINT #6, USING "###.##"; tleincl#;
PRINT #6, " ";
PRINT #6, USING "####.##"; period#;
PRINT #6, " ";
PRINT #6, USING "#####"; perigee#;
PRINT #6, " ";
PRINT #6, USING "######"; apogee#;
PRINT #6, " ";
PRINT #6, USING "###"; tleaop#;
IF period# < 1200# THEN GOTO 4510
PRINT #6, " ";
PRINT #6, USING "###.#"; geolong#;
PRINT #6, " ";
PRINT #6, USING "+##.###"; drift#
oldnum = newnum
GOTO 4620
4610
REM PRINT #6, ""
4620
RETURN
REM----------------------------------------------------------------------------
4700
REM Subroutine which writes data to a shortened version of the one-line
REM element set for use in spreadsheets.
REM Option 6.
REM Extract international designator from the elment set.
ides$ = MID$(tleline1$, 10, 8)
outline1$ = "1 " + catnum$ + " " + ides$ + " " + tleyear$ + " "
outline2$ = tlepoch$ + " " + " " + tleincl$ + " " + tlenode$ + " "
outline3$ = tlee$ + " " + tleaop$ + " " + tlema$ + " " + tlemm$
outline$ = outline1$ + outline2$ + outline3$
PRINT #4, outline$
RETURN
REM----------------------------------------------------------------------------
5000
REM Subroutine which converts from TLE format epoch to YYYY MMM DD.dd
REM format.
REM Test whether a leap year is being dealt with.
diff = INT(tleyear# / 4) - tleyear# / 4
IF diff = 0 THEN GOTO 5010
REM Not a leap year
IF tlepoch# < 32 THEN month$ = "Jan ": month# = 1: day# = tlepoch#: GOTO 5020
IF tlepoch# < 60 THEN month$ = "Feb ": month# = 2: day# = tlepoch# - 31: GOTO 5020
IF tlepoch# < 91 THEN month$ = "Mar ": month# = 3: day# = tlepoch# - 59: GOTO 5020
IF tlepoch# < 121 THEN month$ = "Apr ": month# = 4: day# = tlepoch# - 90: GOTO 5020
IF tlepoch# < 152 THEN month$ = "May ": month# = 5: day# = tlepoch# - 120: GOTO 5020
IF tlepoch# < 182 THEN month$ = "Jun ": month# = 6: day# = tlepoch# - 151: GOTO 5020
IF tlepoch# < 213 THEN month$ = "Jul ": month# = 7: day# = tlepoch# - 181: GOTO 5020
IF tlepoch# < 244 THEN month$ = "Aug ": month# = 8: day# = tlepoch# - 212: GOTO 5020
IF tlepoch# < 274 THEN month$ = "Sep ": month# = 9: day# = tlepoch# - 243: GOTO 5020
IF tlepoch# < 305 THEN month$ = "Oct ": month# = 10: day# = tlepoch# - 273: GOTO 5020
IF tlepoch# < 335 THEN month$ = "Nov ": month# = 11: day# = tlepoch# - 304: GOTO 5020
month$ = "Dec ": month# = 12: day# = tlepoch# - 334: GOTO 5020
5010
REM Leap year
IF tlepoch# < 32 THEN month$ = "Jan ": month# = 1: day# = tlepoch#: GOTO 5020
IF tlepoch# < 61 THEN month$ = "Feb ": month# = 2: day# = tlepoch# - 31: GOTO 5020
IF tlepoch# < 92 THEN month$ = "Mar ": month# = 3: day# = tlepoch# - 60: GOTO 5020
IF tlepoch# < 122 THEN month$ = "Apr ": month# = 4: day# = tlepoch# - 91: GOTO 5020
IF tlepoch# < 153 THEN month$ = "May ": month# = 5: day# = tlepoch# - 121: GOTO 5020
IF tlepoch# < 183 THEN month$ = "Jun ": month# = 6: day# = tlepoch# - 152: GOTO 5020
IF tlepoch# < 214 THEN month$ = "Jul ": month# = 7: day# = tlepoch# - 182: GOTO 5020
IF tlepoch# < 245 THEN month$ = "Aug ": month# = 8: day# = tlepoch# - 213: GOTO 5020
IF tlepoch# < 275 THEN month$ = "Sep ": month# = 9: day# = tlepoch# - 244: GOTO 5020
IF tlepoch# < 306 THEN month$ = "Oct ": month# = 10: day# = tlepoch# - 274: GOTO 5020
IF tlepoch# < 336 THEN month$ = "Nov ": month# = 11: day# = tlepoch# - 305: GOTO 5020
month$ = "Dec ": month# = 12: day# = tlepoch# - 335
5020
RETURN
REM----------------------------------------------------------------------------
6000
REM Subroutine which allows the default output drive to be set.
IF option$ = "F" THEN drive1$ = drivef1$: drive2$ = drivef2$: GOTO 6010
IF option$ = "C" THEN drive1$ = drivec1$: drive2$ = drivec2$: GOTO 6010
IF option$ = "H" THEN drive1$ = drivec1$: drive2$ = drivec2$: GOTO 6010
6010
LOCATE 2, 63
PRINT drive2$
RETURN
REM----------------------------------------------------------------------------
10000
REM Subroutine which prints the header across the top of the screen.
CLS
LOCATE 1, 12
PRINT "************************ ***********************"
LOCATE 2, 12
PRINT "** PROGRAM TLEORBIT
** ** Output Drive:
**" LOCATE 3, 12
PRINT "************************ ***********************"
LOCATE 2, 63
PRINT drive2$
RETURN