JSatellite

object JSatellite {
     constructor JSatellite( string name ); // set a name, can be anything
     int getNorad();
     bool setTLE( line1, line2 );  // set the two TLE lines (not the name)
     object getPosition([optional delay in seconds]) ; returns object { 'longitude' : number, 'latitude' : number, 'distance' : number }
     object getLookAngle( observer [, optional delay in seconds] ) ; returns object { 'azimuth' : number, 'elevation' : number, 'range' : number, 'in_view' : boolean }

     Array predictPasses( observer, hours_ahead ) ; returns array of object
        [{
            'timestamp' : number,          // AOS start in milliseconds since 01/01/1970
            'aos' : 'dd/mm/yyyy hh:MM:ss', // date time of AOS
            'aos_secs' : number of secs,   // seconds since now to AOS
            'los' : 'dd/mm/yyyy hh:MM:ss', // date time of LOS
            'los_secs' : number of secs,   // seconds since now to LOS
            'max_elevation' : number,       // maximum elevation (degs) for observer for the pass
            'pass_duration' : number   // duration of the pass in secons
         },
         ...
        ]

     Array getDopplerEstimation( observer, center_freq_hz, [offset in seconds in the future from now] );
     returns array of object
        {
            'doppler_min' : number in Hz,
            'doppler_max' : number in Hz,
            'doppler_avg' : number in Hz
         }

     bool getPassDetails( obsever, offset_secs, length_sec );
        [{
            'when' : 'dd/mm/yyyy hh:MM:ss', // date time
            'dt' : number of secs,   // seconds after first element (relative time offset)
            'az' : number, // azimuth in degrees
            'el' : number , // elevation in degrees
            'range' : number,       // distance from observer, in meters
            'dopp1Ghz' : number   // doppler for a receiver at observer, assuming tx freq is 1 GHz
         },
         ...
        ]
     bool waitInView( observer, timeout millisecs , min_elevation)
  }

.setTLE

Define 2-lines TLE for a given object.

setTLE(TLE1, TLE2);

* Example :

var loaded = ISS.setTLE('1 25544U 98067A   20262.17917074  .00000067  00000-0  93590-5 0  9992',
            '2 25544  51.6432 248.2943 0000854 102.9022 344.0032 15.48951196246432');

.getNorad

Get NORAD ID from object

.getNorad()

.getPosition

Returns JSON-type object describing actual position of satellite.
To get a position in future, provide optional parameter offset_seconds.

.getPosition(offset_seconds);
  • Output :
{ 'longitude' : number, 'latitude' : number, 'distance' : number }
  • Example :
var ISS = new Satellite('ISS');
var loaded = ISS.setTLE('1 25544U 98067A   20262.17917074  .00000067  00000-0  93590-5 0  9992','2 25544  51.6432 248.2943 0000854 102.9022 344.0032 15.48951196246432');
var currentPosition = ISS.getPosition();
print( JSON.stringify( currentPosition ));

.getLookAngle

Returns information on the satellite observation conditions either immediately or within [offset] minutes (optional)

getLookAngle(observer_position, [offset temps en secondes]);

Input datas :

  • observer_position :
    object :
    { 'longitude' : number, 'latitude' : number, 'asl' : number }
  • optional parameter offset : number of seconds in future

Output :

{ 'azimuth' : number, 'elevation' : number, 'range' : number, 'in_view' : boolean }

.predictPasses

Predict the passages of the Satellite object for the observer given as a parameter, up to [calculation period] hours.

predictPasses( Object observer, [number calculation_period] );

Returns following elements (JSON string) :

        [{
            'aos' : 'dd/mm/yyyy hh:MM:ss', // date time of AOS
            'aos_secs' : number of secs,   // seconds since now to AOS
            'los' : 'dd/mm/yyyy hh:MM:ss', // date time of LOS
            'los_secs' : number of secs,   // seconds since now to LOS
            'max_elevation' : number,       // maximum elevation (degs) for observer for the pass
            'pass_duration' : number   // duration of the pass in secons
         },
         ...
        ]
  • Example:
var home = new Observer('home');
home.setPosition( { 'longitude' : 0.029079, 'latitude' : 45.643868, 'asl' : 163 } );

var ISS = new Satellite('ISS');
var loaded = ISS.setTLE('1 25544U 98067A   20262.17917074  .00000067  00000-0  93590-5 0  9992','2 25544  51.6432 248.2943 0000854 102.9022 344.0032 15.48951196246432');

var passes = ISS.predictPasses( home, 24.0 ) ; // predic passes for the next 24 hours
// print the next passes
print( JSON.stringify( passes ));

.getDopplerEstimation

  • Provide a doppler estimation for a satellite, at a frequency of center_freq_hz and for a given observer location

  • Parameter seconds_offset is optional to get an estimation in the future at T + seconds_offset

  • Doppler value is computed for a given period of 5 seconds, by 500 msecs steps. 10 values are processed.
    Output will return average doppler, max and mins values for the interval

.getDopplerEstimation( observer, center_freq_hz, [seconds_offset ] );
  • Returned JSON object :
{'doppler_min' : number in Hz, 'doppler_max' : number in Hz, 'doppler_avg' : number in Hz }
  • Example:
var ISS = new Satellite('ISS');
var loaded = ISS.setTLE('1 25544U 98067A   20262.17917074  .00000067  00000-0  93590-5 0  9992','2 25544  51.6432 248.2943 0000854 102.9022 344.0032 15.48951196246432');

var home = new Observer('home');
home.setPosition( { 'longitude' : 1.829079, 'latitude' : 48.643868, 'asl' : 163 } );

    // Estimate doppler now
    var doppnow = ISS.getDopplerEstimation( home, 437.0e6 );
    print( JSON.stringify( doppnow ));
    // Doppler at T + 5seconds
    var futuredopp = ISS.getDopplerEstimation( home, 437.0e6 , 5);
    print( JSON.stringify( futuredopp ));

.getPassDetails

Provide details for a given pass

getPassDetails( observer, offset_secs, length_sec );

Returns following values, 1 second stepping.

        [{
            'when' : 'dd/mm/yyyy hh:MM:ss', // date time
            'dt' : number of secs,   // seconds after first element (relative time offset)
            'az' : number, // azimuth in degrees
            'el' : number , // elevation in degrees
            'range' : number,       // distance from observer, in meters
            'dopp1Ghz' : number   // doppler for a receiver at observer, assuming tx freq is 1 GHz
         },
         ...
        ]
  • Example: display 10 minutes of a pass occuring over the next 80 minutes (4800 seconds).
var pass = ISS.getPassDetails( home, 4800, 300 );
print(JSON.stringify(pass));

.waitInView

Waits for the satellite to be in view from observer location. In view means elevation above horizon (0 degree), or above specified minimal elevation.

If no delay is given, the function returns immediatly with a boolean value indicating if the satellite is or isn't above the specified elevation.

  • Additional waiting delay may be provided as parameter, acting as a timeout.
  • Returned value is boolean : TRUE if satelite is in view, FALSE if expired delay (satellite is not visible).
waitInView( <observer>, [ optional time out x milliseconds ] , [ optional minimum elevation angle)] ) ;
  • Example : Wait maximum for 5 secs (5000 millis) for the ISS to be above the horizon.
while( ISS.waitInView( home, 5000 ) == false ) {
    print('not yet...');
    currentPosition = ISS.getPosition();
    print('Distance (km) : '+currentPosition.distance/1e3);
}
  • Example : Just check for visibility above horizon
while( ISS.waitInView( home ) == false ) {
    print('not yet...');
    currentPosition = ISS.getPosition();
    print('Distance (km) : '+currentPosition.distance/1e3);
}
  • Example : Just check for visibility above specified elevation (10 degrees here)
while( ISS.waitInView( home, 0, 10 ) == false ) {
    print('not yet...');
    currentPosition = ISS.getPosition();
    print('Distance (km) : '+currentPosition.distance/1e3);
}

ISS example

Predict next passes for ISS :

var home = new Observer('home');
home.setPosition( { 'longitude' : 1.833807, 'latitude' : 48.650696, 'asl' : 207 } ); //Rambouillet

var found = false ;
var tleData ;
var ISS;
var satlist =TLE.loadTLE('https://www.celestrak.com/NORAD/elements/amateur.txt' ) ;
print('We have loaded ' + satlist.length + ' sat definitions.');

for(var j=0 ; j < satlist.length ; j++ ) {
    tleData=satlist[j];
    if(tleData.name=="ISS (ZARYA)"){
      ISS = new Satellite(satlist[j].name);
      ISS.setTLE( tleData.L1, tleData.L2 );
      print (JSON.stringify(tleData));
      print(tleData.name);
      found = true ;
      break;
    }
}

if( found == false ) {
    print('Could not load TLE from this dataset.');
    exit();
}

var k;

var passes = ISS.predictPasses( home, 96 ) ; // predict passes for the next 4 days
// print the next passes
for( var i=0 ; i < passes.length ; i++ ) {
     var next = passes[i] ;
     print('--------------------------------------------------------------------------------');
     print('Pass #'+i) ;
     print('  AOS : ' + next.aos + ', LOS : ' + next.los + ', duration: ' + next.pass_duration + ' secondes');
     print('  MAX Elev : ' + next.max_elevation );
}
Last update: May 29, 2023