Importing Two Line Element Sets

Top  Previous  Next

FreeFlyer provides the capability to read TLE files via the Spacecraft, TwoLineElement, Formation, and TLECatalog objects.

 

All the examples in this section use this sample Three-Line Element file. Three-Line Element files are simply TLEs with an additional first line for the name of the Spacecraft:

 

threeStates.tle

0 AQUA

1 27424U 02022A   15020.82218866  .00000465  00000-0  11324-3 0  2491

2 27424 098.2255 323.8633 0001418 088.0133 006.7657 14.57093363676367

0 ISS (ZARYA)

1 25544U 98067A   15021.59242667  .00016124  00000-0  25567-3 0  7585

2 25544 051.6481 095.9241 0005737 283.2820 218.1353 15.53529390925229

0 GPM

1 39574U 14009C   15020.55092466  .00016648  00000-0  23883-3 0  3702

2 39574 065.0186 028.2192 0010836 269.4707 090.5196 15.56224760 50848

 

 

Spacecraft


Through the Spacecraft.LoadTLE method, the user is able to load a spacecraft state from a TLE file given the file name and either an index or the name of the spacecraft to load. The state of the ISS can be loaded with the following script:

 

Note: If a Spacecraft name is specified, the TLE file must be in the Three-Line Element format and the name must match the name in the file exactly (i.e. the search is case sensitive).

 

String threeStatesFile = "threeStates.tle";

Variable spacecraftIdx = 1; // 0-based index of spacecraft

 

Spacecraft ISS;

 

ISS.LoadTLE(threeStatesFile, "ISS (ZARYA)");

 

/*** OR ***/

 

ISS.LoadTLE(threeStatesFile, spacecraftIdx);

 

The Spacecraft.LoadTLE method also provides the capability of reading the SGP4 derived state from a StringArray object. This specific overload may be useful when loading SGP4 states through a socket connection or by other means where reading a file is not necessary. Once again, the state of the ISS can be loaded from a StringArray object with the following script:

 

StringArray tleContents;

tleContents.ReadFromFile(threeStatesFile);

 

Spacecraft ISS;

 

ISS.LoadTLE(tleContents[3:5]); // The ISS state is in indices 3 through 5

 

Note: See the StringArray properties and methods page for more information on reading text files through the StringArray object.

 

 

TwoLineElement


The TwoLineElement object gives access to a suite of tools used for TLE generation and reading (among other capabilities). The TwoLineElement.LoadTLE method provides similar functionality as the Spacecraft.LoadTLE method while additionally reading components of the TLE that are not used by the Spacecraft such as International Designator, B* dot, B* double dot, and element set number. The examples below are similar to those given above, re-written with the TwoLineElement object:

 

String threeStatesFile = "threeStates.tle";

Variable spacecraftIdx = 1; // 0-based index of spacecraft

 

TwoLineElement IssTwoLineElement;

 

IssTwoLineElement.LoadTLE(threeStatesFile, "ISS (ZARYA)");

 

/*** OR ***/

 

IssTwoLineElement.LoadTLE(threeStatesFile, spacecraftIdx);

 

Note: The SGP4StateEstimator object (used for TLE generation) owns a TwoLineElement object named TLEHandler. See the section on generating TLEs using the SGP4StateEstimator.

 

The TwoLineElement can also be initialized from the state of an existing Spacecraft object:

 

Spacecraft ISS;

 

IssTwoLineElement.InitializeTLEFromSpacecraft(ISS);

 

To apply a loaded state to a Spacecraft object, use the TwoLineElement.SetSpacecraftStateFromTLE method like so (this example assumes the SGP4 state has already been loaded into the TwoLineElement object as in the example above):

 

Spacecraft ISS;

 

IssTwoLineElement.SetSpacecraftStateFromTLE(ISS);

 

 

Formation


Using the Formation.LoadTLE method, a text file containing multiple SGP4 states can be imported into a Formation object. Using the sample file 'threeStates.tle' given above, the syntax to load all three states into a Formation object is:

 

String threeStatesFile = "threeStates.tle";

 

Formation LEOSet;

 

LEOSet.LoadTLE(threeStatesFile);

 

 

TLECatalog


The TLECatalog object is a container for one or more TwoLineElement objects. TLECatalogs are a specialized version of a List of TwoLineElements (you can create a List of most FreeFlyer objects). The benefit of a TLECatalog over a List of TwoLineElements is that the TLECatalog gives the user the ability to load a large list of SGP4 states and manipulate them in a central location. To load a list of SGP4 states, the same syntax from the Formation.LoadTLE method can be used. For example, the syntax to load all three states into the TLECatalog object is:

 

String threeStatesFile = "threeStates.tle";

 

TLECatalog simpleCatalog;

 

simpleCatalog.LoadTLE(threeStatesFile);

 

Once the states have been loaded into the TLECatalog object, the user can set an individual state to a Spacecraft object in the same fashion described above with the TwoLineElement.SetSpacecraftStateFromTLE method. Assuming the TLECatalog has been loaded, the syntax to load a specific state to a Spacecraft object is:

 

Spacecraft ISS;

Variable spacecraftIdx = 1; // 0-based index of spacecraft

 

simpleCatalog[spacecraftIdx].SetSpacecraftStateFromTLE(ISS);

 

 

See Also


Two-Line Element Set File

Spacecraft Properties and Methods

Formation Properties and Methods

TwoLineElement Properties and Methods

TLECatalog Properties and Methods