MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_peph.c File Reference

MRTKLIB Precise Ephemeris Module — Earth rotation parameter I/O, precise ephemeris/clock computation, and satellite antenna offset functions. More...

#include "mrtklib/mrtk_peph.h"
#include <stdio.h>
#include <stdlib.h>
#include "mrtklib/mrtk_antenna.h"
#include "mrtklib/mrtk_astro.h"
#include "mrtklib/mrtk_mat.h"
#include "mrtklib/mrtk_nav.h"
#include "mrtklib/mrtk_sys.h"
#include <math.h>
#include <string.h>
#include "mrtklib/mrtk_trace.h"
Include dependency graph for mrtk_peph.c:

Go to the source code of this file.

Macros

#define PI   3.1415926535897932 /* pi */
#define D2R   (PI / 180.0) /* deg to rad */
#define AS2R   (D2R / 3600.0) /* arc sec to radian */
#define CLIGHT   299792458.0 /* speed of light (m/s) */
#define OMGE   7.2921151467E-5 /* earth angular velocity (IS-GPS) (rad/s) */
#define SQR(x)
#define SYS_NONE   0x00
#define SYS_GPS   0x01
#define SYS_SBS   0x02
#define SYS_GLO   0x04
#define SYS_GAL   0x08
#define SYS_QZS   0x10
#define SYS_CMP   0x20
#define SYS_IRN   0x40
#define SYS_LEO   0x80
#define FREQ1   1.57542E9 /* L1/E1/B1C frequency (Hz) */
#define FREQ2   1.22760E9 /* L2 frequency (Hz) */
#define FREQ5   1.17645E9 /* L5/E5a/B2a frequency (Hz) */
#define FREQ7   1.20714E9 /* E5b frequency (Hz) */
#define FREQ9   2.492028E9 /* S frequency (Hz) */
#define FREQ1_CMP   1.561098E9 /* BDS B1I frequency (Hz) */
#define FREQ2_CMP   1.20714E9 /* BDS B2I/B2b frequency (Hz) */
#define NMAX   10 /* order of polynomial interpolation */
#define MAXDTE   900.0 /* max time difference to ephem time (s) */
#define EXTERR_CLK   1E-3 /* extrapolation error for clock (m/s) */
#define EXTERR_EPH   5E-7 /* extrapolation error for ephem (m/s^2) */

Functions

int satsys_bd2 (int sat, int *prn)
int freq_idx2freq_num (int sys, int freq_idx)
double freq_num2freq (int sys, int freq_num, int fcn)
int freq_idx2ant_idx (int sys, int freq_idx)
int readerp (const char *file, erp_t *erp)
 Read earth rotation parameters from IGS ERP file (ver.2).
int geterp (const erp_t *erp, gtime_t time, double *erpv)
 Get earth rotation parameter values at specified time.
static int code2sys (char code)
static int readsp3h (FILE *fp, gtime_t *time, char *type, int *sats, double *bfact, char *tsys)
static int addpeph (nav_t *nav, peph_t *peph)
static void readsp3b (FILE *fp, char type, int *sats, int ns, double *bfact, char *tsys, int index, int opt, nav_t *nav)
static int cmppeph (const void *p1, const void *p2)
static void combpeph (nav_t *nav, int opt)
void readsp3 (const char *file, nav_t *nav, int opt)
 Read sp3 precise ephemeris file.
int readsap (const char *file, gtime_t time, nav_t *nav)
 Read satellite antenna parameters.
static int readdcbf (const char *file, nav_t *nav, const sta_t *sta)
int readdcb (const char *file, nav_t *nav, const sta_t *sta)
 Read differential code bias (DCB) parameters.
static double interppol (const double *x, double *y, int n)
static int pephpos (gtime_t time, int sat, const nav_t *nav, double *rs, double *dts, double *vare, double *varc)
static int pephclk (gtime_t time, int sat, const nav_t *nav, double *dts, double *varc)
void satantoff (gtime_t time, const double *rs, int sat, const nav_t *nav, double *dant)
 Compute satellite antenna phase center offset in ecef.
int peph2pos (gtime_t time, int sat, const nav_t *nav, int opt, double *rs, double *dts, double *var)
 Compute satellite position/clock with precise ephemeris/clock.

Detailed Description

MRTKLIB Precise Ephemeris Module — Earth rotation parameter I/O, precise ephemeris/clock computation, and satellite antenna offset functions.

This file contains the ERP functions extracted from rtkcmn.c, plus all precise ephemeris functions absorbed from preceph.c with zero algorithmic changes (pure cut-and-paste).

Definition in file mrtk_peph.c.

Macro Definition Documentation

◆ AS2R

#define AS2R   (D2R / 3600.0) /* arc sec to radian */

Definition at line 53 of file mrtk_peph.c.

◆ CLIGHT

#define CLIGHT   299792458.0 /* speed of light (m/s) */

Definition at line 54 of file mrtk_peph.c.

◆ D2R

#define D2R   (PI / 180.0) /* deg to rad */

Definition at line 52 of file mrtk_peph.c.

◆ EXTERR_CLK

#define EXTERR_CLK   1E-3 /* extrapolation error for clock (m/s) */

Definition at line 82 of file mrtk_peph.c.

Referenced by pephclk(), and pephpos().

◆ EXTERR_EPH

#define EXTERR_EPH   5E-7 /* extrapolation error for ephem (m/s^2) */

Definition at line 83 of file mrtk_peph.c.

Referenced by pephpos().

◆ FREQ1

#define FREQ1   1.57542E9 /* L1/E1/B1C frequency (Hz) */

Definition at line 71 of file mrtk_peph.c.

◆ FREQ1_CMP

#define FREQ1_CMP   1.561098E9 /* BDS B1I frequency (Hz) */

Definition at line 76 of file mrtk_peph.c.

◆ FREQ2

#define FREQ2   1.22760E9 /* L2 frequency (Hz) */

Definition at line 72 of file mrtk_peph.c.

◆ FREQ2_CMP

#define FREQ2_CMP   1.20714E9 /* BDS B2I/B2b frequency (Hz) */

Definition at line 77 of file mrtk_peph.c.

◆ FREQ5

#define FREQ5   1.17645E9 /* L5/E5a/B2a frequency (Hz) */

Definition at line 73 of file mrtk_peph.c.

◆ FREQ7

#define FREQ7   1.20714E9 /* E5b frequency (Hz) */

Definition at line 74 of file mrtk_peph.c.

◆ FREQ9

#define FREQ9   2.492028E9 /* S frequency (Hz) */

Definition at line 75 of file mrtk_peph.c.

◆ MAXDTE

#define MAXDTE   900.0 /* max time difference to ephem time (s) */

Definition at line 81 of file mrtk_peph.c.

Referenced by pephclk(), and pephpos().

◆ NMAX

#define NMAX   10 /* order of polynomial interpolation */

Definition at line 80 of file mrtk_peph.c.

Referenced by pephpos().

◆ OMGE

#define OMGE   7.2921151467E-5 /* earth angular velocity (IS-GPS) (rad/s) */

Definition at line 55 of file mrtk_peph.c.

◆ PI

#define PI   3.1415926535897932 /* pi */

Definition at line 51 of file mrtk_peph.c.

◆ SQR

#define SQR ( x)
Value:
((x) * (x))

Definition at line 57 of file mrtk_peph.c.

Referenced by pephclk(), pephpos(), and satantoff().

◆ SYS_CMP

#define SYS_CMP   0x20

Definition at line 66 of file mrtk_peph.c.

◆ SYS_GAL

#define SYS_GAL   0x08

Definition at line 64 of file mrtk_peph.c.

◆ SYS_GLO

#define SYS_GLO   0x04

Definition at line 63 of file mrtk_peph.c.

◆ SYS_GPS

#define SYS_GPS   0x01

Definition at line 61 of file mrtk_peph.c.

◆ SYS_IRN

#define SYS_IRN   0x40

Definition at line 67 of file mrtk_peph.c.

◆ SYS_LEO

#define SYS_LEO   0x80

Definition at line 68 of file mrtk_peph.c.

◆ SYS_NONE

#define SYS_NONE   0x00

Definition at line 60 of file mrtk_peph.c.

◆ SYS_QZS

#define SYS_QZS   0x10

Definition at line 65 of file mrtk_peph.c.

◆ SYS_SBS

#define SYS_SBS   0x02

Definition at line 62 of file mrtk_peph.c.

Function Documentation

◆ addpeph()

int addpeph ( nav_t * nav,
peph_t * peph )
static

Definition at line 272 of file mrtk_peph.c.

References free, nav_s::ne, nav_s::nemax, nav_s::peph, and trace().

Referenced by readsp3b().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cmppeph()

int cmppeph ( const void * p1,
const void * p2 )
static

Definition at line 392 of file mrtk_peph.c.

References peph_t::index, gtime_t::time, peph_t::time, and timediff().

Referenced by combpeph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ code2sys()

int code2sys ( char code)
static

Definition at line 201 of file mrtk_peph.c.

References SYS_CMP, SYS_GAL, SYS_GLO, SYS_GPS, SYS_IRN, SYS_LEO, SYS_NONE, and SYS_QZS.

Referenced by readsp3b(), and readsp3h().

Here is the caller graph for this function:

◆ combpeph()

void combpeph ( nav_t * nav,
int opt )
static

Definition at line 398 of file mrtk_peph.c.

References cmppeph(), MAXSAT, nav_s::ne, norm(), nav_s::peph, peph_t::pos, peph_t::std, peph_t::time, timediff(), trace(), peph_t::vel, and peph_t::vst.

Referenced by readsp3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ freq_idx2ant_idx()

int freq_idx2ant_idx ( int sys,
int freq_idx )
extern

Definition at line 743 of file mrtk_nav.c.

Referenced by satantoff().

Here is the caller graph for this function:

◆ freq_idx2freq_num()

int freq_idx2freq_num ( int sys,
int freq_idx )
extern

Definition at line 649 of file mrtk_nav.c.

Referenced by satantoff().

Here is the caller graph for this function:

◆ freq_num2freq()

double freq_num2freq ( int sys,
int freq_num,
int fcn )
extern

Definition at line 680 of file mrtk_nav.c.

Referenced by satantoff().

Here is the caller graph for this function:

◆ geterp()

int geterp ( const erp_t * erp,
gtime_t time,
double * erpv )
extern

Get earth rotation parameter values at specified time.

Parameters
[in]erpEarth rotation parameters
[in]timeTime (GPST)
[out]erpvERP values {xp,yp,ut1_utc,lod} (rad,rad,s,s/d)
Returns
Status (1:ok, 0:error)

Definition at line 146 of file mrtk_peph.c.

References erp_t::data, epoch2time(), gpst2utc(), erpd_t::lod, erpd_t::mjd, erp_t::n, timediff(), trace(), erpd_t::ut1_utc, erpd_t::xp, erpd_t::xpr, erpd_t::yp, and erpd_t::ypr.

Referenced by clas_osr_zdres(), and tidedisp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ interppol()

double interppol ( const double * x,
double * y,
int n )
static

Definition at line 614 of file mrtk_peph.c.

Referenced by pephpos().

Here is the caller graph for this function:

◆ peph2pos()

int peph2pos ( gtime_t time,
int sat,
const nav_t * nav,
int opt,
double * rs,
double * dts,
double * var )
extern

Compute satellite position/clock with precise ephemeris/clock.

Parameters
[in]timeTime (GPST)
[in]satSatellite number
[in]navNavigation data
[in]optSat position option (0:center of mass, 1:antenna phase center)
[out]rsSat position and velocity (ecef) {x,y,z,vx,vy,vz} (m|m/s)
[out]dtsSat clock {bias,drift} (s|s/s)
[out]varSat position and clock error variance (m^2) (NULL: no output)
Returns
Status (1:ok, 0:error or data outage)

Definition at line 864 of file mrtk_peph.c.

References CLIGHT, dot(), MAXSAT, pephclk(), pephpos(), satantoff(), time_str(), timeadd(), and trace().

Referenced by satpos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pephclk()

int pephclk ( gtime_t time,
int sat,
const nav_t * nav,
double * dts,
double * varc )
static

Definition at line 717 of file mrtk_peph.c.

References CLIGHT, pclk_t::clk, EXTERR_CLK, MAXDTE, nav_s::nc, nav_s::pclk, SQR, pclk_t::std, pclk_t::time, time_str(), timediff(), and trace().

Referenced by peph2pos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pephpos()

int pephpos ( gtime_t time,
int sat,
const nav_t * nav,
double * rs,
double * dts,
double * vare,
double * varc )
static

Definition at line 625 of file mrtk_peph.c.

References CLIGHT, EXTERR_CLK, EXTERR_EPH, interppol(), MAXDTE, nav_s::ne, NMAX, norm(), OMGE, nav_s::peph, peph_t::pos, SQR, peph_t::std, peph_t::time, time_str(), timediff(), and trace().

Referenced by peph2pos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readdcb()

int readdcb ( const char * file,
nav_t * nav,
const sta_t * sta )
extern

Read differential code bias (DCB) parameters.

Parameters
[in]fileDCB parameters file (wild-card * expanded)
[in,out]navNavigation data
[in]staStation info data to import receiver DCB (NULL: no use)
Returns
Status (1:ok, 0:error)

Definition at line 583 of file mrtk_peph.c.

References nav_s::cbias, expath(), free, malloc, MAXEXFILE, MAXSAT, readdcbf(), and trace().

Referenced by execses().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readdcbf()

int readdcbf ( const char * file,
nav_t * nav,
const sta_t * sta )
static

Definition at line 527 of file mrtk_peph.c.

References nav_s::cbias, CLIGHT, MAXRCV, nav_s::rbias, satid2no(), str2num(), and trace().

Referenced by readdcb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readerp()

int readerp ( const char * file,
erp_t * erp )
extern

Read earth rotation parameters from IGS ERP file (ver.2).

Parameters
[in]fileIGS ERP file path
[out]erpEarth rotation parameters
Returns
Status (1:ok, 0:file open error)

Definition at line 99 of file mrtk_peph.c.

References AS2R, erp_t::data, free, erpd_t::lod, erpd_t::mjd, erp_t::n, erp_t::nmax, trace(), erpd_t::ut1_utc, erpd_t::xp, erpd_t::xpr, erpd_t::yp, and erpd_t::ypr.

Referenced by execses().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readsap()

int readsap ( const char * file,
gtime_t time,
nav_t * nav )
extern

Read satellite antenna parameters.

Parameters
[in]fileAntenna parameter file
[in]timeTime (GPST)
[in,out]navNavigation data
Returns
Status (1:ok, 0:error)

Definition at line 508 of file mrtk_peph.c.

References free, MAXSAT, pcvs_t::pcv, nav_s::pcvs, readpcv(), searchpcv(), time_str(), and trace().

Here is the call graph for this function:

◆ readsp3()

void readsp3 ( const char * file,
nav_t * nav,
int opt )
extern

Read sp3 precise ephemeris file.

Parameters
[in]fileSP3 precise ephemeris file (wild-card * expanded)
[in,out]navNavigation data
[in]optOptions (1:only observed + 2:only predicted + 4:not combined)

Definition at line 450 of file mrtk_peph.c.

References combpeph(), expath(), free, malloc, MAXEXFILE, MAXSAT, nav_s::ne, readsp3b(), readsp3h(), and trace().

Referenced by decodefile(), and readpreceph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readsp3b()

void readsp3b ( FILE * fp,
char type,
int * sats,
int ns,
double * bfact,
char * tsys,
int index,
int opt,
nav_t * nav )
static

Definition at line 290 of file mrtk_peph.c.

References addpeph(), code2sys(), peph_t::cov, peph_t::index, MAXSAT, peph_t::pos, satno(), peph_t::std, str2num(), str2time(), SYS_GPS, SYS_QZS, SYS_SBS, peph_t::time, trace(), utc2gpst(), peph_t::vco, peph_t::vel, and peph_t::vst.

Referenced by readsp3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readsp3h()

int readsp3h ( FILE * fp,
gtime_t * time,
char * type,
int * sats,
double * bfact,
char * tsys )
static

Definition at line 226 of file mrtk_peph.c.

References code2sys(), MAXSAT, satno(), str2num(), str2time(), and trace().

Referenced by readsp3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ satantoff()

void satantoff ( gtime_t time,
const double * rs,
int sat,
const nav_t * nav,
double * dant )
extern

Compute satellite antenna phase center offset in ecef.

Parameters
[in]timeTime (GPST)
[in]rsSatellite position and velocity (ecef) {x,y,z,vx,vy,vz} (m|m/s)
[in]satSatellite number
[in]navNavigation data
[out]dantSatellite antenna phase center offset (ecef) {dx,dy,dz} (m)

Definition at line 785 of file mrtk_peph.c.

References CODE_L1C, CODE_L2C, cross3(), freq_idx2ant_idx(), freq_idx2freq_num(), freq_num2freq(), gpst2utc(), normv3(), pcv_t::off, nav_s::pcvs, sat2freq(), satsys_bd2(), SQR, sunmoonpos(), SYS_GLO, time_str(), and trace().

Referenced by peph2pos(), and satpos_ssr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ satsys_bd2()

int satsys_bd2 ( int sat,
int * prn )
extern

Definition at line 159 of file mrtk_nav.c.

Referenced by satantoff().

Here is the caller graph for this function: