MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_obs.h File Reference

MRTKLIB Observation Module — Observation data types and utility functions. More...

Include dependency graph for mrtk_obs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  obsd_t
 Observation data record. More...
struct  obs_t
 Observation data collection. More...
struct  snrmask_t
 SNR mask type. More...
struct  mrtk_signal_t
 Signal specification: physical band + optional preferred code. More...
struct  mrtk_sigcfg_t
struct  mrtk_sig_priority_t
 Signal priority entry: band + priority-ordered code list. More...

Macros

#define MRTK_MAXSIG_PER_SYS   7 /* max signals per constellation */
 Per-constellation signal configuration.
#define MRTK_NSYS   7 /* number of constellations */
#define MRTK_MAX_SIG_PRIORITY   15
 Maximum number of codes in a priority list.
#define MRTK_SIGCFG_NOOPINION   (-2)
 mrtk_sigcfg_freq_idx() sentinel: this constellation has no sigcfg entry, so the caller should fall back to its default (-R/-G/...) option logic. Distinct from -1 (drop) and from valid slot indices.

Functions

uint8_t obs2code (const char *obs)
 Convert obs code type string to obs code.
char * code2obs (uint8_t code)
 Convert obs code to obs code string.
int code2freq_num (uint8_t code)
 Extract frequency number from obs code.
int code2freq_idx (int sys, uint8_t code)
 Convert system and obs code to frequency index (obsdef-based).
double code2freq (int sys, uint8_t code, int fcn)
 Convert system and obs code to carrier frequency.
int getcodepri (int sys, uint8_t code, const char *opt)
 Get code priority for multiple codes in a frequency.
int sortobs (obs_t *obs)
 Sort observation data by time, receiver, and satellite.
void signal_replace (obsd_t *obs, int idx, char f, char *c)
 Replace signal type in observation data.
int screent (gtime_t time, gtime_t ts, gtime_t te, double tint)
 Screen data by time range and interval.
int testsnr (int base, int idx, double el, double snr, const snrmask_t *mask)
 Test SNR mask.
int testelmask (const double *azel, const int16_t *elmask)
 Test elevation mask.
void freeobs (obs_t *obs)
 Free observation data memory.
mrtk_band_t mrtk_rinex_freq_to_band (int sys, int rinex_freq_id)
 Convert RINEX frequency digit to physical band for a given system.
const uint8_t * mrtk_get_signal_priority (int sys, mrtk_band_t band)
 Get priority-ordered code list for a (system, band) pair.
void mrtk_use_claslib_qzs_l1_priority (int on)
 Toggle the claslib-compatible QZSS L1 signal priority (C>S>L>X>Z).
double mrtk_band2freq_hz (mrtk_band_t band)
 Convert physical band to base carrier frequency (Hz).
int mrtk_band_to_freq_num (int sys, mrtk_band_t band)
 Convert physical band back to RINEX frequency number for a given system.
int mrtk_parse_signal_str (const char *str, int *sys, mrtk_band_t *band, uint8_t *code)
 Parse a RINEX3-style signal string (e.g., "G1C") into components.
int mrtk_sigcfg_from_signals (const char **sigs, int nsig, mrtk_sigcfg_t *cfg, int *nf)
 Build per-constellation signal config from a signal string array.
int mrtk_sigcfg_to_obsdef (const mrtk_sigcfg_t *cfg)
 Apply signal config to obsdef tables (bridge to existing system).
int mrtk_sigcfg_freq_idx (int sys, uint8_t code, const mrtk_sigcfg_t *cfg, int nex)
 Resolve the observation slot for a decoded (sys, code) from sigcfg.

Detailed Description

MRTKLIB Observation Module — Observation data types and utility functions.

This header provides the fundamental GNSS observation data types (obsd_t, obs_t, snrmask_t) and observation utility functions extracted from rtklib.h/rtkcmn.c with zero algorithmic changes.

Note
Functions declared here are implemented in mrtk_obs.c.

Definition in file mrtk_obs.h.

Macro Definition Documentation

◆ MRTK_MAX_SIG_PRIORITY

#define MRTK_MAX_SIG_PRIORITY   15

Maximum number of codes in a priority list.

Definition at line 206 of file mrtk_obs.h.

Referenced by getcodepri().

◆ MRTK_MAXSIG_PER_SYS

#define MRTK_MAXSIG_PER_SYS   7 /* max signals per constellation */

Per-constellation signal configuration.

Definition at line 193 of file mrtk_obs.h.

Referenced by mrtk_sigcfg_from_signals().

◆ MRTK_NSYS

#define MRTK_NSYS   7 /* number of constellations */

Definition at line 194 of file mrtk_obs.h.

Referenced by mrtk_sigcfg_from_signals(), and mrtk_sigcfg_to_obsdef().

◆ MRTK_SIGCFG_NOOPINION

#define MRTK_SIGCFG_NOOPINION   (-2)

mrtk_sigcfg_freq_idx() sentinel: this constellation has no sigcfg entry, so the caller should fall back to its default (-R/-G/...) option logic. Distinct from -1 (drop) and from valid slot indices.

Definition at line 291 of file mrtk_obs.h.

Referenced by mrtk_sigcfg_freq_idx(), and sig2idx().

Function Documentation

◆ code2freq()

double code2freq ( int sys,
uint8_t code,
int fcn )

Convert system and obs code to carrier frequency.

Parameters
[in]sysSatellite system (SYS_???)
[in]codeObs code (CODE_???)
[in]fcnFrequency channel number for GLONASS
Returns
Carrier frequency (Hz) (0.0: error)

Definition at line 236 of file mrtk_obs.c.

Referenced by sat2freq().

Here is the caller graph for this function:

◆ code2freq_idx()

int code2freq_idx ( int sys,
uint8_t code )

Convert system and obs code to frequency index (obsdef-based).

Parameters
[in]sysSatellite system (SYS_???)
[in]codeObs code (CODE_???)
Returns
Frequency index (-1: error)

Definition at line 225 of file mrtk_obs.c.

References code2freq_num(), and freq_num2freq_idx().

Referenced by code_on_same_freq(), decode_bnx_7f_05_obs(), decode_track_stat(), mrtk_sigcfg_freq_idx(), save_msm_obs(), set_index(), setopt_obstype(), sig2idx(), sig2idx(), sig_idx(), and sort_obstype().

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

◆ code2freq_num()

int code2freq_num ( uint8_t code)

Extract frequency number from obs code.

Parameters
[in]codeObs code (CODE_???)
Returns
Frequency number (1,2,5,...) (0: error)

Definition at line 201 of file mrtk_obs.c.

References code2obs().

Referenced by clas_osr_zdres(), code2freq(), code2freq_idx(), getcodepri(), and mrtk_sigcfg_freq_idx().

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

◆ code2obs()

char * code2obs ( uint8_t code)

Convert obs code to obs code string.

Parameters
[in]codeObs code (CODE_???)
Returns
Obs code string ("1C","1P",...)

Definition at line 190 of file mrtk_obs.c.

Referenced by code2freq_num(), getcodepri(), and signal_replace().

Here is the caller graph for this function:

◆ freeobs()

void freeobs ( obs_t * obs)

Free observation data memory.

Parameters
[in,out]obsObservation data

Definition at line 433 of file mrtk_obs.c.

References obs_t::data, free, obs_t::n, and obs_t::nmax.

◆ getcodepri()

int getcodepri ( int sys,
uint8_t code,
const char * opt )

Get code priority for multiple codes in a frequency.

Parameters
[in]sysSystem (SYS_???)
[in]codeObs code (CODE_???)
[in]optCode options (NULL:no option)
Returns
Priority (15:highest-1:lowest, 0:error)

Definition at line 276 of file mrtk_obs.c.

References code2freq_num(), code2obs(), MRTK_BAND_UNKNOWN, mrtk_get_signal_priority(), MRTK_MAX_SIG_PRIORITY, mrtk_rinex_freq_to_band(), SYS_BD2, SYS_CMP, SYS_GAL, SYS_GLO, SYS_GPS, SYS_IRN, SYS_QZS, and SYS_SBS.

Referenced by decode_bnx_7f_05_obs(), set_index(), sigindex(), and sort_obstype().

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

◆ mrtk_band2freq_hz()

double mrtk_band2freq_hz ( mrtk_band_t band)

◆ mrtk_band_to_freq_num()

int mrtk_band_to_freq_num ( int sys,
mrtk_band_t band )

Convert physical band back to RINEX frequency number for a given system.

Parameters
[in]sysSatellite system (SYS_???)
[in]bandPhysical frequency band
Returns
RINEX frequency number (1,2,5,...) or 0 on error

Definition at line 938 of file mrtk_obs.c.

References MRTK_BAND_BDS_B1C, MRTK_BAND_BDS_B1I, MRTK_BAND_BDS_B2a, MRTK_BAND_BDS_B2ab, MRTK_BAND_BDS_B2b, MRTK_BAND_BDS_B3, MRTK_BAND_GAL_E1, MRTK_BAND_GAL_E5a, MRTK_BAND_GAL_E5ab, MRTK_BAND_GAL_E5b, MRTK_BAND_GAL_E6, MRTK_BAND_GLO_G1, MRTK_BAND_GLO_G2, MRTK_BAND_GLO_G3, MRTK_BAND_GPS_L1, MRTK_BAND_GPS_L2, MRTK_BAND_GPS_L5, MRTK_BAND_IRN_L5, MRTK_BAND_IRN_S, MRTK_BAND_QZS_L1, MRTK_BAND_QZS_L2, MRTK_BAND_QZS_L5, MRTK_BAND_QZS_L6, MRTK_BAND_SBS_L1, MRTK_BAND_SBS_L5, SYS_CMP, SYS_GAL, SYS_GLO, SYS_GPS, SYS_IRN, SYS_QZS, and SYS_SBS.

Referenced by mrtk_sigcfg_freq_idx(), and mrtk_sigcfg_to_obsdef().

Here is the caller graph for this function:

◆ mrtk_get_signal_priority()

const uint8_t * mrtk_get_signal_priority ( int sys,
mrtk_band_t band )

Get priority-ordered code list for a (system, band) pair.

Parameters
[in]sysSatellite system (SYS_???)
[in]bandPhysical frequency band
Returns
Pointer to priority-ordered code array (MRTK_MAX_SIG_PRIORITY elements), or NULL if no match

Definition at line 914 of file mrtk_obs.c.

References MRTK_BAND_MAX, MRTK_BAND_QZS_L1, MRTK_BAND_UNKNOWN, qzs_l1_claslib, QZS_L1_PRIORITY_CLASLIB, SIG_PRIORITY_TABLE, and SYS_QZS.

Referenced by getcodepri().

Here is the caller graph for this function:

◆ mrtk_parse_signal_str()

int mrtk_parse_signal_str ( const char * str,
int * sys,
mrtk_band_t * band,
uint8_t * code )

Parse a RINEX3-style signal string (e.g., "G1C") into components.

Parameters
[in]strSignal string (3 chars: {sys}{freq}{attr})
[out]sysSatellite system (SYS_???)
[out]bandPhysical frequency band
[out]codeObservation code (CODE_???)
Returns
0: success, -1: error

Definition at line 1039 of file mrtk_obs.c.

References CODE_NONE, MRTK_BAND_UNKNOWN, mrtk_rinex_freq_to_band(), obs2code(), SYS_CMP, SYS_GAL, SYS_GLO, SYS_GPS, SYS_IRN, SYS_QZS, and SYS_SBS.

Referenced by mrtk_sigcfg_from_signals().

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

◆ mrtk_rinex_freq_to_band()

mrtk_band_t mrtk_rinex_freq_to_band ( int sys,
int rinex_freq_id )

Convert RINEX frequency digit to physical band for a given system.

Parameters
[in]sysSatellite system (SYS_???)
[in]rinex_freq_idRINEX frequency digit (1,2,3,4,5,6,7,8,9)
Returns
Physical band (MRTK_BAND_UNKNOWN on error)

Definition at line 806 of file mrtk_obs.c.

References MRTK_BAND_BDS_B1C, MRTK_BAND_BDS_B1I, MRTK_BAND_BDS_B2a, MRTK_BAND_BDS_B2ab, MRTK_BAND_BDS_B2b, MRTK_BAND_BDS_B3, MRTK_BAND_GAL_E1, MRTK_BAND_GAL_E5a, MRTK_BAND_GAL_E5ab, MRTK_BAND_GAL_E5b, MRTK_BAND_GAL_E6, MRTK_BAND_GLO_G1, MRTK_BAND_GLO_G2, MRTK_BAND_GLO_G3, MRTK_BAND_GPS_L1, MRTK_BAND_GPS_L2, MRTK_BAND_GPS_L5, MRTK_BAND_IRN_L5, MRTK_BAND_IRN_S, MRTK_BAND_QZS_L1, MRTK_BAND_QZS_L2, MRTK_BAND_QZS_L5, MRTK_BAND_QZS_L6, MRTK_BAND_SBS_L1, MRTK_BAND_SBS_L5, MRTK_BAND_UNKNOWN, SYS_CMP, SYS_GAL, SYS_GLO, SYS_GPS, SYS_IRN, SYS_QZS, and SYS_SBS.

Referenced by getcodepri(), and mrtk_parse_signal_str().

Here is the caller graph for this function:

◆ mrtk_sigcfg_freq_idx()

int mrtk_sigcfg_freq_idx ( int sys,
uint8_t code,
const mrtk_sigcfg_t * cfg,
int nex )

Resolve the observation slot for a decoded (sys, code) from sigcfg.

#189: lets [positioning].signals (sigcfg) drive raw-decoder code selection, so e.g. GLONASS L2C/A can be placed in the iono-free 2nd frequency without the legacy -RL2C receiver option. obsdef is band-level (cannot distinguish L2C from L2P); sigcfg carries the per-band preferred code, which this consults.

Parameters
[in]sysSatellite system (SYS_???)
[in]codeObservation code (CODE_???) just decoded
[in]cfgPer-constellation signal config array [MRTK_NSYS]
[in]nexNumber of extra observation slots available (NEXOBS)
Returns
main slot 0..NFREQ-1 (code selected for its band); -1 to drop (code not selected, or its band not configured for this system); MRTK_SIGCFG_NOOPINION if this system has no sigcfg entry.

Definition at line 1224 of file mrtk_obs.c.

References mrtk_signal_t::band, code2freq_idx(), code2freq_num(), mrtk_band_to_freq_num(), MRTK_SIGCFG_NOOPINION, mrtk_sigcfg_t::nsig, mrtk_signal_t::preferred_code, mrtk_sigcfg_t::sig, and sys2sigcfg_idx().

Referenced by sig2idx().

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

◆ mrtk_sigcfg_from_signals()

int mrtk_sigcfg_from_signals ( const char ** sigs,
int nsig,
mrtk_sigcfg_t * cfg,
int * nf )

Build per-constellation signal config from a signal string array.

Parameters
[in]sigsArray of signal strings (e.g., "G1C", "E5Q")
[in]nsigNumber of signal strings
[out]cfgPer-constellation signal config array [MRTK_NSYS]
[out]nfDerived number of frequencies (max signals per constellation)
Returns
0: success, -1: error

Definition at line 1128 of file mrtk_obs.c.

References mrtk_signal_t::band, MRTK_MAXSIG_PER_SYS, MRTK_NSYS, mrtk_parse_signal_str(), mrtk_sigcfg_t::nsig, mrtk_signal_t::preferred_code, mrtk_sigcfg_t::sig, sys2sigcfg_idx(), and trace().

Referenced by buff2sysopts().

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

◆ mrtk_sigcfg_to_obsdef()

int mrtk_sigcfg_to_obsdef ( const mrtk_sigcfg_t * cfg)

Apply signal config to obsdef tables (bridge to existing system).

Parameters
[in]cfgPer-constellation signal config array [MRTK_NSYS]
Returns
0: success, -1: error

Definition at line 1187 of file mrtk_obs.c.

References MAXFREQ, mrtk_band_to_freq_num(), MRTK_NSYS, mrtk_sigcfg_t::nsig, set_obsdef(), SYS_CMP, SYS_GAL, SYS_GLO, SYS_GPS, SYS_IRN, SYS_QZS, SYS_SBS, and trace().

Referenced by buff2sysopts().

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

◆ mrtk_use_claslib_qzs_l1_priority()

void mrtk_use_claslib_qzs_l1_priority ( int on)

Toggle the claslib-compatible QZSS L1 signal priority (C>S>L>X>Z).

Enable only for CLAS processing; upstream claslib and MADOCALIB disagree on the QZSS L1 order, so the claslib order must not affect other engines.

Parameters
[in]on1: claslib order, 0: MRTK default order

Definition at line 906 of file mrtk_obs.c.

References qzs_l1_claslib.

◆ obs2code()

uint8_t obs2code ( const char * obs)

Convert obs code type string to obs code.

Parameters
[in]obsObs code string ("1C","1P","1Y",...)
Returns
Obs code (CODE_???)

Definition at line 173 of file mrtk_obs.c.

Referenced by mrtk_parse_signal_str().

Here is the caller graph for this function:

◆ screent()

int screent ( gtime_t time,
gtime_t ts,
gtime_t te,
double tint )

Screen data by time range and interval.

Parameters
[in]timeTime to check (GPST)
[in]tsStart time (GPST) (ts.time==0: no start limit)
[in]teEnd time (GPST) (te.time==0: no end limit)
[in]tintTime interval (s) (0.0: no interval limit)
Returns
1:on, 0:off

Definition at line 424 of file mrtk_obs.c.

References DTTOL, gtime_t::time, time2gpst(), and timediff().

Referenced by avepos(), convnav(), convsbs(), inputsol(), outsolexs(), outsols(), readbnxfp(), readmsgs(), readrnxobs(), and readsolstatdata().

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

◆ signal_replace()

void signal_replace ( obsd_t * obs,
int idx,
char f,
char * c )

Replace signal type in observation data.

Parameters
[in,out]obsObservation data record
[in]idxFrequency index
[in]fFrequency character
[in,out]cSignal code string

Definition at line 388 of file mrtk_obs.c.

References obsd_t::code, code2obs(), obsd_t::D, obsd_t::L, obsd_t::LLI, obsd_t::P, and obsd_t::SNR.

Here is the call graph for this function:

◆ sortobs()

int sortobs ( obs_t * obs)

Sort observation data by time, receiver, and satellite.

Parameters
[in,out]obsObservation data to sort
Returns
Number of epochs

Definition at line 350 of file mrtk_obs.c.

References cmpobs(), obs_t::data, DTTOL, obs_t::n, obsd_t::rcv, obsd_t::sat, obsd_t::time, timediff(), and trace().

Referenced by readobsnav(), and update_obs().

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

◆ testelmask()

int testelmask ( const double * azel,
const int16_t * elmask )

Test elevation mask.

Parameters
[in]azelAzimuth/elevation angle {az,el} (rad)
[in]elmaskElevation mask vector (360 x 1) (0.1 deg)
Returns
Status (1:masked, 0:unmasked)

Definition at line 160 of file mrtk_obs.c.

References R2D.

Referenced by zdres().

Here is the caller graph for this function:

◆ testsnr()

int testsnr ( int base,
int idx,
double el,
double snr,
const snrmask_t * mask )

Test SNR mask.

Parameters
[in]baseRover or base-station (0:rover, 1:base station)
[in]idxFrequency index (0:L1, 1:L2, 2:L3,...)
[in]elElevation angle (rad)
[in]snrC/N0 (dBHz)
[in]maskSNR mask
Returns
Status (1:masked, 0:unmasked)

Definition at line 132 of file mrtk_obs.c.

References snrmask_t::ena, snrmask_t::mask, and R2D.

Referenced by clas_osr_zdres(), snrmask(), zdres_sat(), and zdres_sat().

Here is the caller graph for this function: