Exporting Two Line Element Sets

Top  Previous  Next

In addition to providing the capability to import TLE files, FreeFlyer allows the user to export SGP4 states from the TwoLineElement, TLECatalog, Spacecraft, and Formation objects.

 

 

TwoLineElement and TLECatalog


The SGP4StateEstimator owns a TwoLineElement object called TLEHandler. Once the SGP4 state is generated from the SGP4StateEstimator, the user is able to modify certain properties of the TLEHandler in order to write out the data in the TLE format. For example, assuming that an SGP4StateEstimator object has a valid SGP4 state, the following syntax generates a TLE file containing a single SGP4 state of the ISS:

 

SGP4StateEstimator IssStateEstimator;

 

String outFile = "states.tle";

 

// Option to specify whether or not the spacecraft name will be written

// i.e. whether to write a two-line element set or a three-line element set

Variable writeSCName = 1; 

 

// Option to specify whether or not to append the TLE to an existing file

Variable appendToFile = 1; 

 

IssStateEstimator.TLEHandler.Classification = 'U'// Set classification of object

IssStateEstimator.TLEHandler.SatelliteNumber = 25544; // Set catalog ID of object

IssStateEstimator.TLEHandler.InternationalDesignator = "98067A"// Set international designator of object

 

/*** Script used to generate SGP4 state will go here ***/

 

IssStateEstimator.TLEHandler.WriteToFile(writeSCName, outFile);

 

/*** OR ***/

 

IssStateEstimator.TLEHandler.WriteToFile(writeSCName, outFile, appendToFile);

 

In addition to writing to a file, the SGP4 state can be written to a pair of String objects (one for each line in the two-line element set):

 

String tleLine1;

String tleLine2;

 

IssStateEstimator.TLEHandler.GenerateTwoLineStrings(tleLine1, tleLine2);

 

The TLECatalog object allows the user to export a collection of TwoLineElement objects to a file via the TLECatalog.WriteToFile method:

 

TLECatalog fullCatalog;

 

String scName;

String tleLine1;

String tleLine2;

 

// Flag indicating whether or not there are Spacecraft objects that need to be processed

Variable scLeftToProcess = 1;

Variable writeSCName = 1; 

 

While (scLeftToProcess == 1);

 

    /*** Script used to generate SGP4 state will go here, updating scLeftToProcess ***/

    /*** Assume the SGP4StateEstimator object is used to generate the SGP4 state ***/

 

    // Cache SGP4 state

    scName = sgp4Estimator.TLEHandler.SpacecraftName;

    sgp4Estimator.TLEHandler.GenerateTwoLineStrings(tleLine1, tleLine2);

 

    // Increment number of catalog objects

    fullCatalog.Count++;

 

    // Add SGP4 state to catalog

    fullCatalog[fullCatalog.Count - 1].InitializeFromStrings(scName, tleLine1, tleLine2);

 

End;

 

String outFile = "fullCatalog.tle";

fullCatalog.WriteToFile(writeSCName, outFile);

 

 

Spacecraft and Formation


The TwoLineElement and TLECatalog objects can also be used to write the state of a Spacecraft or Formation object to a TLE file. Once the user has initialized the TwoLineElement or TLECatalog from a Spacecraft or Formation, the WriteToFile method is used to export the TLE.

 

To write a Spacecraft state to a TLE file using a TwoLineElement object, the following syntax can be used:

 

Spacecraft ISS;

String tleFilename = "singleState.tle"

 

TwoLineElement IssTwoLineElement;

IssTwoLineElement.InitializeTLEFromSpacecraft(ISS);

 

IssTwoLineElement.WriteToFile(1, tleFilename); // Write TLE to file with spacecraft name

 

A similar technique can be used with a Formation object and the TLECatalog obejct:

 

Formation LEOSet;

Variable i;

 

// Fill LEOSet in with different states

 

String tleFilename = "singleState.tle";

 

TLECatalog tleCatalog;

tleCatalog.Count = LEOSet.Count;

 

For i = 0 to LEOSet.Count - 1;

 

    tleCatalog[i].InitializeTLEFromSpacecraft(LEOSet[i]);

 

End;

 

tleCatalog.WriteToFile(1, tleFilename); // Write TLE to file with spacecraft names

 

 

See Also


Two-Line Element Set File

TwoLineElement Properties and Methods

TLECatalog Properties and Methods

SGP4StateEstimator Properties and Methods