libpredict  2.0.0
A satellite orbit prediction library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Data Structures | Macros | Typedefs | Enumerations | Functions
predict.h File Reference
#include <time.h>
#include <stdbool.h>
Include dependency graph for predict.h:

Go to the source code of this file.

Data Structures

struct  predict_orbital_elements_t
 Container for processed TLE data from TLE strings. More...
 
struct  predict_position
 Predicted orbital values for satellite at a given time. More...
 
struct  predict_observer_t
 Observation point/ground station (QTH). More...
 
struct  predict_observation
 Data relevant for a relative observation of an orbit or similar with respect to an observation point. More...
 

Macros

#define PREDICT_VERSION_MAJOR   2
 
#define PREDICT_VERSION_MINOR   0
 
#define PREDICT_VERSION_PATCH   0
 
#define PREDICT_VERSION   (PREDICT_VERSION_MAJOR * 100 * 100 + PREDICT_VERSION_MINOR * 100 + PREDICT_VERSION_PATCH)
 
#define PREDICT_VERSION_STRING   "2.0.0"
 

Typedefs

typedef double predict_julian_date_t
 The representation of time used by libpredict: The number of days since 31Dec79 00:00:00 UTC. More...
 

Enumerations

enum  predict_ephemeris { EPHEMERIS_SGP4 = 0, EPHEMERIS_SDP4 = 1, EPHEMERIS_SGP8 = 2, EPHEMERIS_SDP8 = 3 }
 Simplified perturbation models used in modeling the satellite orbits. More...
 

Functions

int predict_version_major ()
 Get the major version number of the library. More...
 
int predict_version_minor ()
 Get the minor version number of the library. More...
 
int predict_version_patch ()
 Get the patch version number of the library. More...
 
int predict_version ()
 Get the version number of the library. More...
 
char * predict_version_string ()
 Get the version number string of the library. More...
 
predict_julian_date_t predict_to_julian (time_t time)
 Convert time_t in UTC to Julian date in UTC. More...
 
time_t predict_from_julian (predict_julian_date_t date)
 Convert Julian date in UTC back to a time_t in UTC. More...
 
predict_orbital_elements_tpredict_parse_tle (const char *tle_line_1, const char *tle_line_2)
 Create predict_orbital_elements_t from TLE strings. More...
 
void predict_destroy_orbital_elements (predict_orbital_elements_t *orbital_elements)
 Free memory allocated in orbital elements structure. More...
 
int predict_orbit (const predict_orbital_elements_t *orbital_elements, struct predict_position *x, predict_julian_date_t time)
 Main prediction function. More...
 
bool predict_is_geosynchronous (const predict_orbital_elements_t *orbital_elements)
 Find whether an orbit is geosynchronous. More...
 
double predict_apogee (const predict_orbital_elements_t *x)
 Get apogee of satellite orbit. More...
 
double predict_perigee (const predict_orbital_elements_t *x)
 Get perigee of satellite orbit. More...
 
bool predict_aos_happens (const predict_orbital_elements_t *x, double latitude)
 Find whether an AOS can ever happen on the given latitude. More...
 
predict_observer_tpredict_create_observer (const char *name, double lat, double lon, double alt)
 Create observation point (QTH). More...
 
void predict_destroy_observer (predict_observer_t *obs)
 Free observer. More...
 
void predict_observe_orbit (const predict_observer_t *observer, const struct predict_position *orbit, struct predict_observation *obs)
 Find relative position of satellite with respect to an observer. More...
 
void predict_observe_moon (const predict_observer_t *observer, predict_julian_date_t time, struct predict_observation *obs)
 Estimate relative position of the moon. More...
 
double predict_moon_ra (predict_julian_date_t time)
 Calculate right ascension of the moon. More...
 
double predict_moon_declination (predict_julian_date_t time)
 Calculate declination of the moon. More...
 
double predict_moon_gha (predict_julian_date_t time)
 Calculate the greenwich hour angle (longitude) of the moon. More...
 
void predict_observe_sun (const predict_observer_t *observer, predict_julian_date_t time, struct predict_observation *obs)
 Estimate relative position of the sun. More...
 
double predict_sun_ra (predict_julian_date_t time)
 Calculate right ascension of the sun. More...
 
double predict_sun_declination (predict_julian_date_t time)
 Calculate declination of the sun. More...
 
double predict_sun_gha (predict_julian_date_t time)
 Calculate the greenwich hour angle (longitude) of the sun. More...
 
struct predict_observation predict_next_aos (const predict_observer_t *observer, const predict_orbital_elements_t *orbital_elements, predict_julian_date_t start_time)
 Find next acquisition of signal (AOS) of satellite (when the satellite rises above the horizon). More...
 
struct predict_observation predict_next_los (const predict_observer_t *observer, const predict_orbital_elements_t *orbital_elements, predict_julian_date_t start_time)
 Find next loss of signal (LOS) of satellite (when the satellite goes below the horizon). More...
 
struct predict_observation predict_at_max_elevation (const predict_observer_t *observer, const predict_orbital_elements_t *orbital_elements, predict_julian_date_t start_time)
 Find maximum elevation of next or current pass. More...
 
double predict_doppler_shift (const struct predict_observation *observation, double downlink_frequency)
 Calculate doppler shift of a given downlink frequency with respect to an observer. More...
 
double predict_squint_angle (const predict_observer_t *observer, const struct predict_position *orbit, double alon, double alat)
 Calculate squint angle for satellite, i.e. More...
 
double predict_refraction (double el)
 Calculate refraction angle. More...
 
double predict_refraction_ext (double el, double pressure, double temp)
 Calculate refraction angle. More...
 
double predict_refraction_from_apparent (double apparent_el)
 Calculate refraction angle from apparent elevation. More...
 
double predict_refraction_from_apparent_ext (double apparent_el, double pressure, double temp)
 Calculate refraction angle from apparent elevation. More...
 
double predict_refraction_rate (double el, double el_rate)
 Calculate refraction rate of change. More...
 
double predict_refraction_rate_ext (double el, double el_rate, double pressure, double temp)
 Calculate refraction rate of change. More...
 
double predict_apparent_elevation (double el)
 Calculate apparent elevation from true elevation. More...
 
double predict_apparent_elevation_ext (double el, double pressure, double temp)
 Calculate apparent elevation from true elevation. More...
 
double predict_apparent_elevation_rate (double el, double el_rate)
 Calculate apparent elevation rate. More...
 
double predict_apparent_elevation_rate_ext (double el, double el_rate, double pressure, double temp)
 Calculate apparent elevation rate. More...
 

Macro Definition Documentation

#define PREDICT_VERSION   (PREDICT_VERSION_MAJOR * 100 * 100 + PREDICT_VERSION_MINOR * 100 + PREDICT_VERSION_PATCH)
#define PREDICT_VERSION_MAJOR   2
#define PREDICT_VERSION_MINOR   0
#define PREDICT_VERSION_PATCH   0
#define PREDICT_VERSION_STRING   "2.0.0"

Typedef Documentation

typedef double predict_julian_date_t

The representation of time used by libpredict: The number of days since 31Dec79 00:00:00 UTC.

Enumeration Type Documentation

Simplified perturbation models used in modeling the satellite orbits.

Enumerator
EPHEMERIS_SGP4 
EPHEMERIS_SDP4 
EPHEMERIS_SGP8 
EPHEMERIS_SDP8 

Function Documentation

bool predict_aos_happens ( const predict_orbital_elements_t x,
double  latitude 
)

Find whether an AOS can ever happen on the given latitude.

Parameters
xOrbital elements
latitudeLatitude of ground station in radians
Returns
true if AOS can happen, otherwise false
double predict_apogee ( const predict_orbital_elements_t x)

Get apogee of satellite orbit.

Parameters
xOrbital elements
Returns
Apogee of orbit
double predict_apparent_elevation ( double  el)

Calculate apparent elevation from true elevation.

Parameters
elTrue elevation angle (rad).
Returns
Apparent elevation (rad).
double predict_apparent_elevation_ext ( double  el,
double  pressure,
double  temp 
)

Calculate apparent elevation from true elevation.

Corrects for different atmospheric pressures and temperatures.

Parameters
elTrue elevation angle (rad).
pressureAtmospheric pressure (kPa).
tempTemperature (deg C).
Returns
Apparent elevation (rad).
double predict_apparent_elevation_rate ( double  el,
double  el_rate 
)

Calculate apparent elevation rate.

Parameters
elTrue elevation angle (rad).
el_rateRate of change of true elevation angle (rad/s).
Returns
Rate of change of apparent elevation (rad/s).
double predict_apparent_elevation_rate_ext ( double  el,
double  el_rate,
double  pressure,
double  temp 
)

Calculate apparent elevation rate.

Corrects for different atmospheric pressures and temperatures.

Parameters
elTrue elevation angle (rad).
el_rateRate of change of true elevation angle (rad/s).
pressureAtmospheric pressure (kPa).
tempTemperature (deg C).
Returns
Rate of change of apparent elevation (rad/s).
struct predict_observation predict_at_max_elevation ( const predict_observer_t observer,
const predict_orbital_elements_t orbital_elements,
predict_julian_date_t  start_time 
)

Find maximum elevation of next or current pass.

Parameters
observerGround station
orbital_elementsOrbital elements of satellite
start_timeSearch time. If elevation is negative, max elevation is sought from the start_time and on. If elevation is positive, max elevation is searched for within the current pass
Returns
Observed properties at maximum elevation
predict_observer_t* predict_create_observer ( const char *  name,
double  lat,
double  lon,
double  alt 
)

Create observation point (QTH).

Parameters
nameName of observation point
latLatitude in radians (easting/northing)
lonLongitude in radians (easting/northing)
altAltitude in meters
Returns
Allocated observation point
void predict_destroy_observer ( predict_observer_t obs)

Free observer.

Parameters
obsObserver to be freed.
void predict_destroy_orbital_elements ( predict_orbital_elements_t orbital_elements)

Free memory allocated in orbital elements structure.

Parameters
orbital_elementsOrbit to free
double predict_doppler_shift ( const struct predict_observation observation,
double  downlink_frequency 
)

Calculate doppler shift of a given downlink frequency with respect to an observer.

Parameters
observationObservation of a satellite orbit
downlink_frequencyDownlink frequency of the satellite
Returns
The frequency difference from the original frequency
time_t predict_from_julian ( predict_julian_date_t  date)

Convert Julian date in UTC back to a time_t in UTC.

Parameters
dateJulian date in UTC
Returns
Time in UTC
bool predict_is_geosynchronous ( const predict_orbital_elements_t orbital_elements)

Find whether an orbit is geosynchronous.

This function uses the definition of geosynchronous orbits found in "Classification of geosynchronous objects", Issue 17, 28 March 2015, from the European Space Agency:

  • Eccentricity smaller than 0.2
  • Mean motion between 0.9 and 1.1
  • Inclination lower than 70 degrees

The function is mainly used internally for avoiding long iteration loops in functions like predict_at_max_elevation() and predict_next_aos(). The wider definition of a geosynchronous orbits is appropriate here. The definition of a geostationary satellite would be stricter, but is not considered here.

Parameters
orbital_elementsOrbital elements
Returns
true if orbit is geosynchronous, false otherwise
double predict_moon_declination ( predict_julian_date_t  time)

Calculate declination of the moon.

Parameters
timeTime
Returns
Declination in radians
double predict_moon_gha ( predict_julian_date_t  time)

Calculate the greenwich hour angle (longitude) of the moon.

Parameters
timeTime
Returns
GHA in radians
double predict_moon_ra ( predict_julian_date_t  time)

Calculate right ascension of the moon.

Parameters
timeTime
Returns
RA in radians
struct predict_observation predict_next_aos ( const predict_observer_t observer,
const predict_orbital_elements_t orbital_elements,
predict_julian_date_t  start_time 
)

Find next acquisition of signal (AOS) of satellite (when the satellite rises above the horizon).

Ignores previous AOS of current pass if the satellite is in range at the start time.

Parameters
observerPoint of observation
orbital_elementsOrbital elements
start_timeStart time for AOS search
Returns
Observation of the AOS
struct predict_observation predict_next_los ( const predict_observer_t observer,
const predict_orbital_elements_t orbital_elements,
predict_julian_date_t  start_time 
)

Find next loss of signal (LOS) of satellite (when the satellite goes below the horizon).

Finds LOS of the current pass if the satellite currently is in range, finds LOS of next pass if not.

Parameters
observerPoint of observation
orbital_elementsOrbital elements
start_timeStart time for LOS search
Returns
Observation of the LOS
void predict_observe_moon ( const predict_observer_t observer,
predict_julian_date_t  time,
struct predict_observation obs 
)

Estimate relative position of the moon.

Parameters
observerPoint of observation
timeTime of observation
obsReturn object for position of the moon relative to the observer
void predict_observe_orbit ( const predict_observer_t observer,
const struct predict_position orbit,
struct predict_observation obs 
)

Find relative position of satellite with respect to an observer.

Calculates range, azimuth, elevation and relative velocity.

Parameters
observerPoint of observation
orbitSatellite orbit
obsReturn of object for position of the satellite relative to the observer.
void predict_observe_sun ( const predict_observer_t observer,
predict_julian_date_t  time,
struct predict_observation obs 
)

Estimate relative position of the sun.

Parameters
observerPoint of observation
timeTime of observation
obsReturn object for position of the sun relative to the observer
int predict_orbit ( const predict_orbital_elements_t orbital_elements,
struct predict_position x,
predict_julian_date_t  time 
)

Main prediction function.

Predict satellite orbit at given time.

Parameters
orbital_elementsOrbital elements
xPredicted orbit
timeJulian day in UTC
Returns
0 if everything went fine
predict_orbital_elements_t* predict_parse_tle ( const char *  tle_line_1,
const char *  tle_line_2 
)

Create predict_orbital_elements_t from TLE strings.

Parameters
tle_line_1First line of NORAD two-line element set string
tle_line_2Second line of NORAD two-line element set string
Returns
Processed TLE parameters
double predict_perigee ( const predict_orbital_elements_t x)

Get perigee of satellite orbit.

Parameters
xOrbital elements
Returns
Perigee of orbit
double predict_refraction ( double  el)

Calculate refraction angle.

This function assumes atmospheric pressure of 101.0kPa and temperature 10deg celsius.

Parameters
elTrue elevation angle (rad).
Returns
Refraction angle (rad).
double predict_refraction_ext ( double  el,
double  pressure,
double  temp 
)

Calculate refraction angle.

Corrects for different atmospheric pressure and temperature.

Parameters
elTrue elevation angle in rads.
pressureAtmospheric pressure in kPa.
tempTemperature in deg celsius.
Returns
Refraction angle (rad).
double predict_refraction_from_apparent ( double  apparent_el)

Calculate refraction angle from apparent elevation.

This function assumes atmospheric pressure of 101.0kPa and temperature 10deg celsius.

Parameters
apparent_elApparent elevation angle (rad).
Returns
Refraction angle (rad).
double predict_refraction_from_apparent_ext ( double  apparent_el,
double  pressure,
double  temp 
)

Calculate refraction angle from apparent elevation.

Corrects for different atmospheric pressure and temperature.

Parameters
apparent_elApparent elevation angle (rad).
pressureAtmospheric pressure in kPa.
tempTemperature in deg celsius.
Returns
Refraction angle (rad).
double predict_refraction_rate ( double  el,
double  el_rate 
)

Calculate refraction rate of change.

Parameters
elTrue elevation angle (rad).
el_rateRate of change of true elevation angle (rad/s).
Returns
Refraction rate of change (rad/s).
double predict_refraction_rate_ext ( double  el,
double  el_rate,
double  pressure,
double  temp 
)

Calculate refraction rate of change.

Corrects for different atmospheric pressure and temerature.

Parameters
elTrue elevation angle (rad).
el_rateRate of change of true elevation angle (rad/s).
pressureAtmospheric pressure in kPa.
tempTemperature in deg celsius.
Returns
Apparent elevation (rad).
double predict_squint_angle ( const predict_observer_t observer,
const struct predict_position orbit,
double  alon,
double  alat 
)

Calculate squint angle for satellite, i.e.

angle between the satellite antenna and the QTH antenna.

Parameters
observerPoint of observation
orbitCurrent state of satellite orbit
alonAttitude longitude in radians (describes orientation of the satellite at apogee)
alatAttidue latitude in radians (see above)
Returns
Squint angle in radians. Will output nan if the satellite is not an SDP4 satellite
double predict_sun_declination ( predict_julian_date_t  time)

Calculate declination of the sun.

Parameters
observerPoint of observation
timeTime of observation
Returns
Declination in radians
double predict_sun_gha ( predict_julian_date_t  time)

Calculate the greenwich hour angle (longitude) of the sun.

Parameters
timeTime
Returns
GHA in radians
double predict_sun_ra ( predict_julian_date_t  time)

Calculate right ascension of the sun.

Parameters
observerPoint of observation
timeTime of observation
Returns
RA in radians
predict_julian_date_t predict_to_julian ( time_t  time)

Convert time_t in UTC to Julian date in UTC.

Parameters
timeTime in UTC
Returns
Julian day in UTC
int predict_version ( )

Get the version number of the library.

Returns
2 digit major, 2 digit minor, 2 digit patch decimal version number
int predict_version_major ( )

Get the major version number of the library.

Returns
Major version number
int predict_version_minor ( )

Get the minor version number of the library.

Returns
Minor version number
int predict_version_patch ( )

Get the patch version number of the library.

Returns
Patch version number
char* predict_version_string ( )

Get the version number string of the library.

Returns
Version number string ("major.minor.patch")