DEV Community

Alex Mages
Alex Mages

Posted on

Using TLE.JS Library for Satellite Position and Dish Pointing

Earlier last year I, blew the dust off my satellite communication textbook and attempted to write a dish pointing app for my company that's in the satellite communications realm.

I quickly discovered that the math was involved, and after several days of exhausting math and Python code writing, I came up a (barely) usable app:

GitHub logo Awmages / dish-pointer

Parabolic Dish Pointing software

dish-pointer

the dish-pointer project a rough protoype of the equations required for Parabolic Dish Pointing software for GEO satellites.

Getting Started

the dish-pointer should work on all OS that support Python 3.6

Requirements

main.py was written in Python 3.6, and has the following dependecies:

Package Description Version Install
matplotlib Graphing and math Library 3.03 pip install matplotlib

Installing

Included in the project is a pip freeze of the needed libraries To install requirements using pip freeze

1. Open Command Line
2. cd to where dish-pointer project is cloned
3. Enter "pip install -r dish-pointer_pip_freeze.txt

Exectuion

To run main.py

1. Open Command Line
2. cd to where dish-pointer project is cloned
3. python main.py

Example Operation

Enter Earth Station Longitude, for West use '-': -97.33
Enter Earth Station Latitude, for South use '-': 37.68
Enter Satellite subpoint Longitude, for West use '-': -123
Antenna azimuth is 218.2°
Antenna look angle 38.7°

Recently, I came back to this project wanting to port it over to a React app and dreaded refactoring the math, that is, until I discovered Two-Line Elements(TLE) set and the tle.js library.

What is TLE

According to wikipedia.org the two-line element is

... a data format encoding a list of orbital elements of an Earth-orbiting object for a given point in time, the epoch. Using suitable prediction formula, the state (position and velocity) at any point in the past or future can be estimated to some accuracy.

below is an example TLE of the International Space Station

ISS (ZARYA)
1 25544U 98067A 20220.25765183 .00031791 00000-0 57938-3 0 9999
2 25544 51.6453 95.7043 0001117 20.0719 119.8247 15.49172948239931

TLEs give a series of mathematical numbers to plot the orbit of the space object, which can be utilized to find the predicted Latitude and Longitude (among other things).

TLE's can be obtained from multiple sites such as celestrak.com space-track.org, and other websites.

What is TLE.js

During research for my web application, I discovered the TLE.js library. TLE.js is a JavaScript library that processes the tle data with easy to use functions.

GitHub logo davidcalhoun / tle.js

Satellite TLE tools: get lat/lon of satellites, get look angles, plot orbit lines, extract individual TLE elements

tle.js

Build Status npm downloads

Satellite TLE tools in JavaScript

Installation

npm add tle.js or yarn add tle.js

Introduction

tle.js is designed to simplify satellite TLEs and SGP4 with a friendly interface, with satellite.js doing the heavy lifting behind the scenes.

The origin of TLEs goes back to the punchcard days! A TLE, or two-line element set, is used by SGP4 propagators to determine spacecraft positioning information, taking into account gravity perturbations (the moon, etc).

Most users will probably want to simply get the latitude/longitude of a satellite (see getLatLngObj) or get the look angles from a ground position, which can be used to track where in the sky a satellite is visible (see getSatelliteInfo). Users may also want to plot orbit lines (see getGroundTracks).

Users may also be interested in grabbing specific values from a TLE. In this case, you can use one of the TLE getters, for…

TLE.js Example 1: Satellite Position

Installation

npm install tle.js or yarn add tle.js

Import

in our index.js file import getLatLngObj

const { getLatLngObj } = require("tle.js/dist/tlejs.cjs");

Usage

create a constant of a string

const { getLatLngObj } = require("tle.js/dist/tlejs.cjs");

const tle = `ISS (ZARYA)
1 25544U 98067A   17206.18396726  .00001961  00000-0  36771-4 0  9993
2 25544  51.6400 208.9163 0006317  69.9862  25.2906 15.54225995 67660`;

then console log the results

const { getLatLngObj } = require("tle.js/dist/tlejs.cjs");

const tle = `ISS (ZARYA)
1 25544U 98067A   17206.18396726  .00001961  00000-0  36771-4 0  9993
2 25544  51.6400 208.9163 0006317  69.9862  25.2906 15.54225995 67660`;

console.log(getLatLngObj(tle));

Console Log:

{ lat: 32.69293160995973, lng: -164.48496742284183 }

Note in our example Lng is a negative value; this means the satellite is currently in the Western Hemisphere, a positive value means would mean it is in the Eastern Hemisphere. If the Lat value is negative, then the satellite is in the Southern Hemisphere, if positive then the Northern Hemisphere.

const { getLatLngObj } = require("tle.js/dist/tlejs.cjs");

const tle = `ISS (ZARYA)
1 25544U 98067A   17206.18396726  .00001961  00000-0  36771-4 0  9993
2 25544  51.6400 208.9163 0006317  69.9862  25.2906 15.54225995 67660`;

let satPos = getLatLngObj(tle);
let lat = "N";
let lng = "E";

if (satPos.lat < 0) {
  lat = "S";
}
if (satPos.lng < 0) {
  lng = "W";
}
console.log(
  "Latitude: " + Math.abs(satPos.lat) + " " + lat + ", " + "Longitude: ",
  Math.abs(satPos.lng) + " " + lng
);

Console Log

Latitude: 50.59794614813468 N, Longitude:  91.89917475916603 W

TLE.js Example 2: Dish Pointing

To get azimuth and elevation directions from tle.js, use getSatelliteInfo(). getSatelliteInfo() variables are getSatelliteInfo(tle, optionalTimestamp, observerLat, observerLng, oberserverElevation) note that the timestamp is optional.

Grab the desired lat/long coordinates of the observer site, and paste into the correct constants.

const { getSatelliteInfo } = require("tle.js/dist/tlejs.cjs");

const tle = `ISS (ZARYA)
1 25544U 98067A   17206.18396726  .00001961  00000-0  36771-4 0  9993
2 25544  51.6400 208.9163 0006317  69.9862  25.2906 15.54225995 67660`;

const observerLat = 37.709203;
const observerLng = -97.427754;

run getSatelliteInfo(). If not using optionalTimestamp enter null, if on the ground enter 0 for elevation.

const { getSatelliteInfo } = require("tle.js/dist/tlejs.cjs");

const tle = `ISS (ZARYA)
1 25544U 98067A   17206.18396726  .00001961  00000-0  36771-4 0  9993
2 25544  51.6400 208.9163 0006317  69.9862  25.2906 15.54225995 67660`;

const observerLat = 37.709203;
const observerLng = -97.427754;

console.log(getSatelliteInfo(tle, null, observerLat, observerLng, 0))

Console Log

{
  lng: -103.77041233731748,
  lat: 48.083145374941935,
  elevation: 11.084527491294315,
  azimuth: 337.91719541768254,
  range: 1357.0378375655516,
  height: 393.729417250428,
  velocity: 7.679154118414166
}
  • lng is the longitudinal position of the satellite
  • lat is the latitudinal position of the satellite
  • elevation is the dish's pointing elevation
  • azimuth is the dish's needed direction to point the satellite

getSattelliteInfo() doesn't take in consideration the line of sight of the dish, and whether the satellite is observable for that use getVisibleSattelites().

Conclusion

By utilizing the tle.js library, modern engineers can quickly deploy web or mobile applications that can track satellites, provide satellite dish look angles, and provide a list of visible satellites. With just a bit of searching
you can find great libraries, like tle.js, that significantly reduce the headache and time spent on small components of much larger projects.

Example Code

Top comments (0)