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

CLAS grid interpolation for troposphere and STEC. More...

#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "mrtklib/mrtk_clas.h"
#include "mrtklib/mrtk_const.h"
#include "mrtklib/mrtk_geoid.h"
#include "mrtklib/mrtk_mat.h"
#include "mrtklib/mrtk_station.h"
#include "mrtklib/mrtk_time.h"
#include "mrtklib/mrtk_trace.h"
Include dependency graph for mrtk_clas_grid.c:

Go to the source code of this file.

Classes

struct  grid_info

Macros

#define MAX_GRID_CACHE   20 /* candidate grids sorted by distance */
#define MAX_DIST   120.0 /* max distance to grid (km) */
#define MAXAGESSR_TROP   120.0 /* max age of trop correction (s) */
#define MAXAGESSR_IONO   120.0 /* max age of iono correction (s) */
#define SQR(x)
#define MIN(x, y)
#define MAX(x, y)

Functions

static double Interp1 (const double *x, const double *y, int nx, int ny, double xi)
static int get_mops (const double lat, const double doy, double *pre, double *temp, double *wpre, double *ltemp, double *wvap)
static double get_Tdv (const double lat, const double Hs, const double Ps)
static double get_Twv (const double Ts, const double es)
int get_stTv (gtime_t t, const double lat, const double hs, const double hg, double *tdv, double *twv)
static int pickup_candidates_of_grid (const clas_ctx_t *ctx, grid_info *gridinfo, const int network, const double *pos, int ch)
static int find_grid_surround_pos (grid_info **gridindex, int n, grid_info *gridinfo)
static void calc_3points_weight (double *weight, const double *pos, grid_info **gridindex)
static int is_exists_inside (const double *pos, int n, grid_info **gridindex, grid_info *nearestgrid)
static void calc_grid_weight (double *weight, const double *pos, int n, grid_info **gridindex)
static void output_selected_grid (const double *pos, int n, grid_info **gridindex, double *weight)
int clas_get_grid_index (clas_ctx_t *ctx, const double *pos, clas_grid_t *grid, int gridsel, gtime_t obstime)
 Select surrounding grid points and compute interpolation weights.
static int stec_data (stec_t *stec, gtime_t time, int sat, double *iono, double *rate, double *rms, double *quality, int *slip)
int clas_stec_grid_data (clas_corr_t *corr, const int *index, gtime_t time, int sat, int n, const double *weight, const double *Gmat, const double *Emat, double *iono, double *rate, double *var, int *brk)
 Interpolate STEC (ionosphere delay) from grid points.
static int trop_data (zwd_t *z, gtime_t time, double *ztd, double *zwd, double *quality, int idx, int *valid)
int clas_trop_grid_data (clas_corr_t *corr, const int *index, gtime_t time, int n, const double *weight, const double *Gmat, const double *Emat, double *zwd, double *ztd, int *tbrk)
 Interpolate troposphere delay from grid points.
void clas_init_oload (clas_ctx_t *ctx)
 Initialize ocean loading data in context.
int readblqgrid (const char *file, clas_ctx_t *ctx)
 Read BLQ ocean tide loading parameters for CLAS grid points.

Detailed Description

CLAS grid interpolation for troposphere and STEC.

References: [1] IS-QZSS-L6-006, QZSS L6 Signal CLAS IF Specification

History: 2026/03/02 1.0 ported from claslib grid.c / stec.c / rtkcmn.c

  • singleton globals replaced by clas_ctx_t context
  • nav_t dependency replaced by clas_corr_t
  • MOPS standard atmosphere helpers embedded as static

Definition in file mrtk_clas_grid.c.

Macro Definition Documentation

◆ MAX

#define MAX ( x,
y )
Value:
((x) > (y) ? (x) : (y))

Definition at line 51 of file mrtk_clas_grid.c.

Referenced by pickup_candidates_of_grid().

◆ MAX_DIST

#define MAX_DIST   120.0 /* max distance to grid (km) */

Definition at line 45 of file mrtk_clas_grid.c.

Referenced by pickup_candidates_of_grid().

◆ MAX_GRID_CACHE

#define MAX_GRID_CACHE   20 /* candidate grids sorted by distance */

Definition at line 44 of file mrtk_clas_grid.c.

Referenced by clas_get_grid_index(), and pickup_candidates_of_grid().

◆ MAXAGESSR_IONO

#define MAXAGESSR_IONO   120.0 /* max age of iono correction (s) */

Definition at line 47 of file mrtk_clas_grid.c.

Referenced by stec_data().

◆ MAXAGESSR_TROP

#define MAXAGESSR_TROP   120.0 /* max age of trop correction (s) */

Definition at line 46 of file mrtk_clas_grid.c.

Referenced by trop_data().

◆ MIN

#define MIN ( x,
y )
Value:
((x) < (y) ? (x) : (y))

Definition at line 50 of file mrtk_clas_grid.c.

Referenced by pickup_candidates_of_grid().

◆ SQR

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

Definition at line 49 of file mrtk_clas_grid.c.

Referenced by clas_stec_grid_data().

Function Documentation

◆ calc_3points_weight()

void calc_3points_weight ( double * weight,
const double * pos,
grid_info ** gridindex )
static

Definition at line 340 of file mrtk_clas_grid.c.

References free, mat(), matinv(), matmul(), grid_info::pos, R2D, trace(), and tracemat().

Referenced by calc_grid_weight().

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

◆ calc_grid_weight()

void calc_grid_weight ( double * weight,
const double * pos,
int n,
grid_info ** gridindex )
static

Definition at line 395 of file mrtk_clas_grid.c.

References calc_3points_weight(), and grid_info::weight.

Referenced by clas_get_grid_index().

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

◆ clas_get_grid_index()

int clas_get_grid_index ( clas_ctx_t * ctx,
const double * pos,
clas_grid_t * grid,
int gridsel,
gtime_t obstime )
extern

Select surrounding grid points and compute interpolation weights.

Parameters
[in,out]ctxCLAS context (grid_pos, grid_stat)
[in]posReceiver position {lat,lon,hgt} (rad,m)
[out]gridInterpolation result (weights, indices, matrix)
[in]gridselGrid selection threshold (m), 0=always multi-grid
[in]obstimeObservation time (reserved)
Returns
Number of selected grids (0=error, 1/3/4=ok)

Definition at line 459 of file mrtk_clas_grid.c.

References calc_grid_weight(), CLAS_CH_NUM, clas_grid_t::Emat, find_grid_surround_pos(), free, clas_grid_t::Gmat, clas_grid_t::index, grid_info::index, is_exists_inside(), mat(), matcpy(), matinv(), MAX_GRID_CACHE, clas_grid_t::network, grid_info::network, clas_grid_t::num, output_selected_grid(), pickup_candidates_of_grid(), grid_info::pos, R2D, trace(), tracemat(), and clas_grid_t::weight.

Referenced by clas_ssr2osr(), and ppp_rtk_pos().

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

◆ clas_init_oload()

void clas_init_oload ( clas_ctx_t * ctx)
extern

Initialize ocean loading data in context.

Parameters
[in,out]ctxCLAS context

Definition at line 824 of file mrtk_clas_grid.c.

References CLAS_MAX_NETWORK, clas_oload_t::gridnum, and clas_ctx_t::oload.

◆ clas_stec_grid_data()

int clas_stec_grid_data ( clas_corr_t * corr,
const int * index,
gtime_t time,
int sat,
int n,
const double * weight,
const double * Gmat,
const double * Emat,
double * iono,
double * rate,
double * var,
int * brk )
extern

Interpolate STEC (ionosphere delay) from grid points.

Parameters
[in]corrMerged correction snapshot
[in]indexSelected grid point indices
[in]timeTime (GPST)
[in]satSatellite number
[in]nNumber of grids (1-4)
[in]weightInterpolation weights
[in]GmatInterpolation matrix (4x4, can be NULL)
[in]EmatBasis vector (4x1, can be NULL)
[out]ionoInterpolated L1 ionosphere delay (m)
[out]rateInterpolated ionosphere rate (m/s)
[out]varInterpolated variance (m^2)
[out]brkSlip break flag
Returns
1=ok, 0=error

Definition at line 588 of file mrtk_clas_grid.c.

References dot(), free, mat(), matmul(), SQR, clas_corr_t::stec, and stec_data().

Referenced by clas_osr_corrmeas().

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

◆ clas_trop_grid_data()

int clas_trop_grid_data ( clas_corr_t * corr,
const int * index,
gtime_t time,
int n,
const double * weight,
const double * Gmat,
const double * Emat,
double * zwd,
double * ztd,
int * tbrk )
extern

Interpolate troposphere delay from grid points.

Parameters
[in]corrMerged correction snapshot
[in]indexSelected grid point indices
[in]timeTime (GPST)
[in]nNumber of grids (1-4)
[in]weightInterpolation weights
[in]GmatInterpolation matrix (4x4, can be NULL)
[in]EmatBasis vector (4x1, can be NULL)
[out]zwdInterpolated zenith wet delay
[out]ztdInterpolated zenith total delay
[out]tbrkValidity flag (0=all valid, 1=partial)
Returns
1=ok, 0=error

Definition at line 749 of file mrtk_clas_grid.c.

References dot(), free, imat(), mat(), matmul(), trop_data(), and clas_corr_t::zwd.

Referenced by clas_osr_zdres().

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

◆ find_grid_surround_pos()

int find_grid_surround_pos ( grid_info ** gridindex,
int n,
grid_info * gridinfo )
static

Definition at line 267 of file mrtk_clas_grid.c.

References D2R, dot(), grid_info::network, norm(), grid_info::pos, and trace().

Referenced by clas_get_grid_index().

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

◆ get_mops()

int get_mops ( const double lat,
const double doy,
double * pre,
double * temp,
double * wpre,
double * ltemp,
double * wvap )
static

Definition at line 88 of file mrtk_clas_grid.c.

References Interp1(), PI, and R2D.

Referenced by get_stTv().

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

◆ get_stTv()

int get_stTv ( gtime_t t,
const double lat,
const double hs,
const double hg,
double * tdv,
double * twv )

Definition at line 163 of file mrtk_clas_grid.c.

References get_mops(), get_Tdv(), get_Twv(), and time2doy().

Referenced by clas_osr_prectrop(), and trop_data().

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

◆ get_Tdv()

double get_Tdv ( const double lat,
const double Hs,
const double Ps )
static

Definition at line 145 of file mrtk_clas_grid.c.

Referenced by get_stTv().

Here is the caller graph for this function:

◆ get_Twv()

double get_Twv ( const double Ts,
const double es )
static

Definition at line 150 of file mrtk_clas_grid.c.

Referenced by get_stTv().

Here is the caller graph for this function:

◆ Interp1()

double Interp1 ( const double * x,
const double * y,
int nx,
int ny,
double xi )
static

Definition at line 73 of file mrtk_clas_grid.c.

Referenced by get_mops().

Here is the caller graph for this function:

◆ is_exists_inside()

int is_exists_inside ( const double * pos,
int n,
grid_info ** gridindex,
grid_info * nearestgrid )
static

Definition at line 371 of file mrtk_clas_grid.c.

References grid_info::index, grid_info::network, grid_info::pos, trace(), and grid_info::weight.

Referenced by clas_get_grid_index().

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

◆ output_selected_grid()

void output_selected_grid ( const double * pos,
int n,
grid_info ** gridindex,
double * weight )
static

Definition at line 413 of file mrtk_clas_grid.c.

References D2R, grid_info::index, grid_info::network, and trace().

Referenced by clas_get_grid_index().

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

◆ pickup_candidates_of_grid()

int pickup_candidates_of_grid ( const clas_ctx_t * ctx,
grid_info * gridinfo,
const int network,
const double * pos,
int ch )
static

Definition at line 199 of file mrtk_clas_grid.c.

References CLAS_MAX_GP, CLAS_MAX_NETWORK, D2R, clas_ctx_t::grid_pos, clas_ctx_t::grid_stat, grid_info::index, MAX, MAX_DIST, MAX_GRID_CACHE, MIN, grid_info::network, norm(), grid_info::pos, RE_WGS84, trace(), and grid_info::weight.

Referenced by clas_get_grid_index().

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

◆ readblqgrid()

int readblqgrid ( const char * file,
clas_ctx_t * ctx )
extern

Read BLQ ocean tide loading parameters for CLAS grid points.

Parameters
[in]fileBLQ grid file
[in,out]ctxCLAS context (oload[] populated)
Returns
1:ok, 0:file open error

Definition at line 839 of file mrtk_clas_grid.c.

References CLAS_MAX_GP, CLAS_MAX_NETWORK, clas_oload_t::gridnum, clas_oload_t::odisp, clas_ctx_t::oload, clas_oload_t::pos, readblqrecord(), and trace().

Referenced by execses().

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

◆ stec_data()

int stec_data ( stec_t * stec,
gtime_t time,
int sat,
double * iono,
double * rate,
double * rms,
double * quality,
int * slip )
static

Definition at line 537 of file mrtk_clas_grid.c.

References stec_t::data, stecd_t::iono, MAXAGESSR_IONO, stec_t::n, stecd_t::quality, stecd_t::rate, stecd_t::rms, stecd_t::sat, stecd_t::slip, stecd_t::time, time_str(), timediff(), and trace().

Referenced by clas_stec_grid_data().

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

◆ trop_data()

int trop_data ( zwd_t * z,
gtime_t time,
double * ztd,
double * zwd,
double * quality,
int idx,
int * valid )
static

Definition at line 698 of file mrtk_clas_grid.c.

References CSSR_INVALID_VALUE, D2R, zwd_t::data, geoidh(), get_stTv(), MAXAGESSR_TROP, zwd_t::n, zwd_t::pos, zwdd_t::quality, zwdd_t::time, time_str(), timediff(), trace(), zwdd_t::valid, zwdd_t::ztd, and zwdd_t::zwd.

Referenced by clas_trop_grid_data().

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