├── src ├── base │ ├── baseobs.c │ └── basecmn.c ├── qc │ ├── detClockJump.c │ ├── qc.h │ └── detCycleSlip.c ├── net │ ├── uck │ │ ├── logZtd_u.c │ │ ├── outProduct_u.c │ │ ├── logIon_u.c │ │ ├── logRes_u.c │ │ ├── logAmb_u.c │ │ ├── logCob_u.c │ │ ├── logUpd_u.c │ │ └── udStates_u.c │ ├── dck │ │ ├── logZtd_d.c │ │ ├── logAmb_d.c │ │ ├── outProduct_d.c │ │ ├── logRes_d.c │ │ ├── udStates_d.c │ │ └── dck.h │ └── logDtm.c ├── user │ ├── ppp │ │ ├── logRclk_p.c │ │ ├── logZtd_p.c │ │ ├── logIon_p.c │ │ ├── logRes_p.c │ │ ├── logAmb_p.c │ │ ├── userMWAmbResol_cnes.c │ │ ├── userUdStates_p.c │ │ ├── userAmbResol_cnes2.c │ │ ├── ppp.h │ │ └── userRTKPos_p.c │ ├── dckp │ │ ├── logRes_dp.c │ │ ├── logZtd_dp.c │ │ ├── logRclk_dp.c │ │ ├── logAmb_dp.c │ │ ├── dckp.h │ │ ├── userUdStates_dp.c │ │ ├── userPPPos_dp.c │ │ └── userRTKPos_dp.c │ ├── userCmnPPP.c │ ├── userSession.c │ ├── interBias.c │ └── user.h ├── io │ ├── readerp.c │ ├── readblq.c │ ├── readdcb.c │ ├── readsnx.c │ ├── readrnx_clk.c │ ├── io.h │ ├── readcob.c │ ├── readBias.c │ ├── readpcv.c │ └── readdck.c ├── sat │ ├── sateph_s.c │ ├── sat.h │ ├── satant.c │ └── sateph_r.c ├── corr │ ├── corr.h │ ├── dcb.c │ └── phw.c └── main.c ├── doc └── Cube Users Guide_1.0.pdf ├── script ├── server.py ├── user.py ├── conf_net.conf └── conf_ppp.conf ├── README.md ├── LICENSE.txt ├── .gitignore └── data └── apm21440.list /src/base/baseobs.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liush18/Cube/HEAD/src/base/baseobs.c -------------------------------------------------------------------------------- /src/qc/detClockJump.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liush18/Cube/HEAD/src/qc/detClockJump.c -------------------------------------------------------------------------------- /doc/Cube Users Guide_1.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liush18/Cube/HEAD/doc/Cube Users Guide_1.0.pdf -------------------------------------------------------------------------------- /src/qc/qc.h: -------------------------------------------------------------------------------- 1 | #ifndef _QC_H 2 | #define _QC_H 3 | 4 | #include "base/base.h" 5 | 6 | extern void detClockJump(ssat_t *ssat, int *jumpc, obsd_t* obs, const int n, 7 | const nav_t* nav, const char *rcv); 8 | extern void detCycleSlip(const prcopt_t *opt, ssat_t *ssat, obsd_t *obs, 9 | const int n, const nav_t *nav, const char *rcv, const double tt, int *jumpc); 10 | 11 | 12 | #endif /* _QC_H */ 13 | -------------------------------------------------------------------------------- /script/server.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | import subprocess, datetime 4 | 5 | 6 | def network(): 7 | for i in range(len(dow)): 8 | t1 = datetime.datetime.now() 9 | cmd = CMD_EXE % (week[i], dow[i]) 10 | print(cmd) 11 | subprocess.run(cmd) 12 | t2 = datetime.datetime.now() 13 | print(f'({t1})-({t2})={t2-t1}\n') 14 | 15 | 16 | dow = [0] 17 | week = [2144 for i in range(7)] 18 | 19 | EXE = r'Cube.exe -conf conf_net.conf ' 20 | CMD_EXE = EXE + r'-week %04d -dow %d' 21 | network() 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /script/user.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | import subprocess, datetime 4 | 5 | doy = [i for i in range(38,39)] 6 | day = [i for i in range(7,14)] 7 | month= [2 for i in range(7)] 8 | year = [2021 for i in range(7)] 9 | 10 | CMD_EXE= r'Cube.exe -conf %s -ts %s 00:00:00 -te %s 23:59:30' 11 | CONF = r'conf_ppp.conf' 12 | 13 | for i in range(len(doy)): 14 | t1 = datetime.datetime.now() 15 | 16 | ts = '%04d/%02d/%02d' % (year[i], month[i], day[i]) 17 | cmd = CMD_EXE % (CONF, ts, ts) 18 | print(cmd) 19 | 20 | subprocess.run(cmd) 21 | 22 | t2 = datetime.datetime.now() 23 | print(f'({t1})-({t2})={t2-t1}\n') 24 | 25 | 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cube 2 | 3 | 4 | Cube is a secondary development based on RTKLIB and mainly composed of two modules, satellite clock/decoupled clock estimation (the server end) and PPP/PPP-AR (the user end). At present, only GPS observations can be processed, and we only experimented with Cube on Windows system. However, benefiting from the C language, Cube can be easily transplanted to other operating systems, such as Linux and Macintosh. At the server end, Cube can estimate IGS legacy clocks, IGS legacy clocks with satellite code bias (SCB) extraction and decoupled clocks using undifferenced observations. Additionally, PPP-AR based on the IRC model and the DCK model can be implemented at the user end. Furthermore, the crucial parameters, such as receiver coordinates, the zenith tropospheric delays (ZTDs), ambiguities and residuals, are all output into formatted files, which is very convenient for additional applications and for post-analyses of the results. 5 | 6 | ## History 7 | 2021/10/15 1.0 new 8 | 9 | ## Contact 10 | 11 | Shuai Liu 12 | 13 | [lsnav@foxmail.com](mailto:lsnav@foxmail.com) 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/net/uck/logZtd_u.c: -------------------------------------------------------------------------------- 1 | 2 | #include "uck.h" 3 | 4 | #define SQRT(x) ((x)<=0.0||(x)!=(x)?0.0:sqrt(x)) 5 | 6 | static FILE *fpZtd=NULL; /* file pointer of ztd */ 7 | 8 | /* open ztd file -------------------------------------------------------------*/ 9 | extern int openZtdLog_u(const char *file) 10 | { 11 | createdir(file); 12 | if (!(fpZtd=fopen(file,"w"))) { 13 | trace(2,"openZtdLog: file open error path=%s\n",file); 14 | return 0; 15 | } 16 | return 1; 17 | } 18 | /* close ztd file ------------------------------------------------------------*/ 19 | extern void closeZtdLog_u(void) 20 | { 21 | if (fpZtd) fclose(fpZtd); 22 | fpZtd=NULL; 23 | } 24 | /* output ztd ---------------------------------------------------------------- 25 | * time rcv ztd (gn ge) ztd std (gn_std ge_std) -----------------------------*/ 26 | extern void logZtd_u(net_t *uck, rcv_t *rcv, const int n) 27 | { 28 | const prcopt_t *opt=&uck->opt; 29 | double *x,*P; 30 | int i,j,k,nx=uck->nx; 31 | 32 | if (!fpZtd) return; 33 | 34 | x=uck->x; P=uck->P; 35 | for (i=0;itime,rcv[i].sta.name); 39 | for (k=0;ksol; 15 | double ep[6]; 16 | char id[8],time[32]; 17 | int i,j; 18 | 19 | if (sol->stat==SOLQ_NONE) return; 20 | 21 | time2epoch(sol->time,ep); 22 | sprintf(time,"%4d %02d %02d %02d %02d%10.6f", 23 | (int)ep[0],(int)ep[1],(int)ep[2],(int)ep[3],(int)ep[4],ep[5]); 24 | 25 | /* output receiver clock solution */ 26 | for (i=0;iopt); 29 | fprintf(fp,"AR %4s %26s%3d ",rcv[i].sta.name,time,2); 30 | fprintf(fp,"%19.12E ",net->x[j]*1E-9); 31 | fprintf(fp,"%19.12E ",SQRT(net->P[j+j*net->nx])*1E-9); 32 | fprintf(fp,"\n"); 33 | } 34 | /* output satellite clock solution */ 35 | for (i=0;ioutc[i]) continue; 37 | j=UISC(i+1,&net->opt); 38 | satno2id(i+1,id); 39 | fprintf(fp,"AS %-4s %26s%3d ",id,time,2); 40 | fprintf(fp,"%19.12E ",net->x[j]*1E-9); 41 | fprintf(fp,"%19.12E ",SQRT(net->P[j+j*net->nx])*1E-9); 42 | fprintf(fp,"\n"); 43 | } 44 | fflush(fp); 45 | } -------------------------------------------------------------------------------- /src/net/uck/logIon_u.c: -------------------------------------------------------------------------------- 1 | 2 | #include "uck.h" 3 | 4 | #define SQRT(x) ((x)<=0.0||(x)!=(x)?0.0:sqrt(x)) 5 | 6 | static FILE *fpIon=NULL; /* file pointer of ion */ 7 | 8 | /* open ion file -------------------------------------------------------------*/ 9 | extern int openIonLog_u(const char *file) 10 | { 11 | createdir(file); 12 | if (!(fpIon=fopen(file, "w"))) { 13 | trace(2,"openIONLog: file open error path=%s\n",file); 14 | return 0; 15 | } 16 | return 1; 17 | } 18 | /* close ion file ------------------------------------------------------------*/ 19 | extern void closeIonLog_u(void) 20 | { 21 | if (fpIon) fclose(fpIon); 22 | fpIon=NULL; 23 | } 24 | /* output slant ionospheric delay at L1 --------------------------------------*/ 25 | extern void logIon_u(net_t *uck, rcv_t *rcv, const int n) 26 | { 27 | const prcopt_t *opt=&uck->opt; 28 | double *x,*P; 29 | char id[8]; 30 | int i,j,k,sat,nx=uck->nx; 31 | 32 | if (!fpIon) return; 33 | if (opt->ionoopt!=IONOOPT_EST) return; 34 | 35 | x=uck->x; P=uck->P; 36 | for (i=0;itime,rcv[i].sta.name,id,rcv[i].ssat[sat-1].azel[0]*R2D, 43 | rcv[i].ssat[sat-1].azel[1]*R2D,x[k],SQRT(P[k+k*nx])); 44 | fprintf(fpIon,"%3d\n",rcv[i].datum[sat-1]); 45 | } 46 | } 47 | fflush(fpIon); 48 | } -------------------------------------------------------------------------------- /src/net/uck/logRes_u.c: -------------------------------------------------------------------------------- 1 | 2 | #include "uck.h" 3 | 4 | 5 | static FILE *fpRes=NULL; /* file pointer of residuals */ 6 | 7 | /* open residuals file -------------------------------------------------------*/ 8 | extern int openResLog_u(const char *file) 9 | { 10 | createdir(file); 11 | if (!(fpRes=fopen(file, "w"))) { 12 | trace(2,"res_open: file open error path=%s\n",file); 13 | return 0; 14 | } 15 | return 1; 16 | } 17 | /* close residuals file ------------------------------------------------------*/ 18 | extern void closeResLog_u(void) 19 | { 20 | if (fpRes) fclose(fpRes); 21 | fpRes=NULL; 22 | } 23 | /* output residuals ---------------------------------------------------------- 24 | * time rcv sat resp resc (resp resc) el -------------------------------------*/ 25 | extern void logRes_u(net_t *uck, rcv_t *rcv, const int n) 26 | { 27 | ssat_t *ssat; 28 | char id[8]; 29 | int i,j,k,sat; 30 | 31 | if (!fpRes) return; 32 | 33 | for (i=0;itime,rcv[i].sta.name,id); 46 | for (k=0;kopt);k++) { 47 | fprintf(fpRes,"%12.4f%12.4f",ssat->resp[k],ssat->resc[k]); 48 | } 49 | fprintf(fpRes,"%12.4f\n",ssat->azel[1]*R2D); 50 | } 51 | } 52 | 53 | fflush(fpRes); 54 | } -------------------------------------------------------------------------------- /src/net/uck/logAmb_u.c: -------------------------------------------------------------------------------- 1 | 2 | #include "uck.h" 3 | 4 | #define SQRT(x) ((x)<=0.0||(x)!=(x)?0.0:sqrt(x)) 5 | 6 | static FILE *fpAmb=NULL; /* file pointer of ambiguity */ 7 | 8 | /* open ambiguity file -------------------------------------------------------*/ 9 | extern int openAmbLog_u(const char *file) 10 | { 11 | createdir(file); 12 | if (!(fpAmb=fopen(file, "w"))) { 13 | trace(2,"amb_open: file open error path=%s\n",file); 14 | return 0; 15 | } 16 | return 1; 17 | } 18 | /* close ambiguity file ------------------------------------------------------*/ 19 | extern void closeAmbLog_u(void) 20 | { 21 | if (fpAmb) fclose(fpAmb); 22 | fpAmb=NULL; 23 | } 24 | /* output float and fixed ambiguity ------------------------------------------*/ 25 | extern void logAmb_u(net_t *uck, rcv_t *rcv, const int n) 26 | { 27 | const prcopt_t *opt=&uck->opt; 28 | double *x,*P; 29 | char id[8]; 30 | int i,j,f,k,sat,nx=uck->nx; 31 | 32 | if (!fpAmb) return; 33 | 34 | x=uck->x; P=uck->P; 35 | for (i=0;itime,rcv[i].sta.name,id); 41 | for (f=0;fopt; 37 | double *x=rtk->x,*P=rtk->P,*xa=rtk->xa,*Pa=rtk->Pa,fact=1E-9; 38 | int i,nx=rtk->nx,stat=rtk->sol.stat; 39 | 40 | if (!fpRclk_p) return; 41 | 42 | i=PIC(1,opt); /* only GPS */ 43 | fprintf(fpRclk_p,"%22s%6d",rtk->cTime,stat); 44 | fprintf(fpRclk_p,"%20.12E",x[i]*fact); 45 | fprintf(fpRclk_p,"%20.12E",SQRT(P[i+i*nx])*fact); 46 | fprintf(fpRclk_p,"%20.12E",stat==1?xa[i]*fact:0.0); 47 | fprintf(fpRclk_p,"%20.12E",stat==1?SQRT(Pa[i+i*nx])*fact:0.0); 48 | fprintf(fpRclk_p,"\n"); 49 | fflush(fpRclk_p); 50 | } 51 | -------------------------------------------------------------------------------- /src/net/uck/logCob_u.c: -------------------------------------------------------------------------------- 1 | 2 | #include "uck.h" 3 | 4 | #define SQRT(x) ((x)<=0.0||(x)!=(x)?0.0:sqrt(x)) 5 | 6 | static FILE *fpCob=NULL; /* file pointer of code bias file */ 7 | 8 | /* open code bias file -------------------------------------------------------*/ 9 | extern int openCobLog_u(const char *file) 10 | { 11 | createdir(file); 12 | if (!(fpCob=fopen(file, "w"))) { 13 | trace(2,"openCobLog: file open error path=%s\n",file); 14 | return 0; 15 | } 16 | return 1; 17 | } 18 | /* close code bias file ------------------------------------------------------*/ 19 | extern void closeCobLog_u(void) 20 | { 21 | if (fpCob) fclose(fpCob); 22 | fpCob=NULL; 23 | } 24 | /* output code bias of receiver and satellite ---------------------------------- 25 | * time rcv/sat cob1 cob2 ... 26 | * ----------------------------------------------------------------------------*/ 27 | extern void logCob_u(net_t *uck, rcv_t *rcv, const int n) 28 | { 29 | const prcopt_t *opt=&uck->opt; 30 | double *x,*P; 31 | char id[8]; 32 | int i,f,k,nx=uck->nx; 33 | 34 | if (!fpCob) return; 35 | if (!opt->scb&&!opt->rcb) return; 36 | 37 | x=uck->x; P=uck->P; 38 | if (opt->rcb) for (i=0;itime,rcv[i].sta.name); 41 | for (f=0;fscb) for (i=0;ioutc[i]) continue; 49 | satno2id(i+1,id); 50 | fprintf(fpCob,"%-25s%5s",uck->time,id); 51 | for (f=0;fopt; 37 | ssat_t *ssat; 38 | char id[8]; 39 | int i,nx=rtk->nx,sat; 40 | 41 | if (!fpRes_dp) return; 42 | 43 | fprintf(fpRes_dp,"%22s%6d%10.2f\n",rtk->cTime,rtk->sol.stat,rtk->sol.ratio); 44 | for (i=0;issat+sat-1; 48 | 49 | fprintf(fpRes_dp,"%5s",id); 50 | fprintf(fpRes_dp,"%14.4f%14.4f%14.4f",ssat->resp[0],ssat->resc[0], 51 | ssat->resw[0]); 52 | 53 | fprintf(fpRes_dp,"%14.2f",ssat->azel[0]*R2D); 54 | fprintf(fpRes_dp,"%14.2f",ssat->azel[1]*R2D); 55 | fprintf(fpRes_dp,"%14d",ssat->outc[0]); 56 | fprintf(fpRes_dp,"\n"); 57 | } 58 | fprintf(fpRes_dp,"\n"); 59 | fflush(fpRes_dp); 60 | } -------------------------------------------------------------------------------- /src/net/dck/logZtd_d.c: -------------------------------------------------------------------------------- 1 | 2 | #include "dck.h" 3 | 4 | #define SQRT(x) ((x)<=0.0||(x)!=(x)?0.0:sqrt(x)) 5 | 6 | static FILE *fpZtd_d=NULL; /* file pointer of ztd */ 7 | 8 | /* open ztd file -------------------------------------------------------------*/ 9 | extern int openZtdLog_d(const char *file, int opt) 10 | { 11 | createdir(file); 12 | if (!(fpZtd_d=fopen(file,"w"))) { 13 | trace(2,"ztd_open: file open error path=%s\n",file); 14 | return 0; 15 | } 16 | 17 | fprintf(fpZtd_d,"%-22s","% TIME(GPST)"); 18 | fprintf(fpZtd_d,"%5s", "RCV"); 19 | fprintf(fpZtd_d,"%14s", "ZTD"); 20 | if (opt==TROPOPT_ESTG) { 21 | fprintf(fpZtd_d,"%14s","GRAD_N"); 22 | fprintf(fpZtd_d,"%14s","GRAD_E"); 23 | } 24 | fprintf(fpZtd_d,"%9s", "STD_ZTD"); 25 | if (opt==TROPOPT_ESTG) { 26 | fprintf(fpZtd_d,"%9s","STD_GN"); 27 | fprintf(fpZtd_d,"%9s","STD_GE"); 28 | } 29 | fprintf(fpZtd_d,"%6s","OUTC"); 30 | fprintf(fpZtd_d,"\n"); 31 | 32 | return 1; 33 | } 34 | /* close ztd file ------------------------------------------------------------*/ 35 | extern void closeZtdLog_d(void) 36 | { 37 | if (fpZtd_d) fclose(fpZtd_d); 38 | fpZtd_d=NULL; 39 | } 40 | /* output ztd ----------------------------------------------------------------*/ 41 | extern void logZtd_d(net_t *dck, rcv_t *rcv, const int n) 42 | { 43 | double *x,*P; 44 | int i,j,k,nx=dck->nx; 45 | 46 | x=dck->x; P=dck->P; 47 | 48 | for (i=0;iopt); 50 | fprintf(fpZtd_d,"%22s",dck->time); 51 | fprintf(fpZtd_d,"%5s",rcv[i].sta.name); 52 | for (k=0;kopt);k++) { 53 | fprintf(fpZtd_d,"%14.6f",x[j+k]); 54 | } 55 | for (k=0;kopt);k++) { 56 | fprintf(fpZtd_d,"%9.4f",SQRT(P[(j+k)+(j+k)*nx])); 57 | } 58 | fprintf(fpZtd_d,"%6d\n",rcv[i].outc); 59 | } 60 | fflush(fpZtd_d); 61 | } -------------------------------------------------------------------------------- /src/io/readerp.c: -------------------------------------------------------------------------------- 1 | 2 | #include "io.h" 3 | 4 | 5 | /* read earth rotation parameters ---------------------------------------------- 6 | * read earth rotation parameters 7 | * args :char *file I IGS ERP file (IGS ERP ver.2) 8 | * erp_t *erp O earth rotation parameters 9 | * return:status (1:ok,0:file open error) 10 | *-----------------------------------------------------------------------------*/ 11 | extern int readerp(const char* file, erp_t* erp) 12 | { 13 | FILE* fp; 14 | erpd_t* erp_data; 15 | double v[14]={ 0 }; 16 | char buff[256]; 17 | 18 | trace(3, "readerp: file=%s\n", file); 19 | 20 | if (!(fp=fopen(file, "r"))) { 21 | trace(2, "erp file open error: file=%s\n", file); 22 | return 0; 23 | } 24 | while (fgets(buff, sizeof(buff), fp)) { 25 | if (sscanf(buff, "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", 26 | v, v+1, v+2, v+3, v+4, v+5, v+6, v+7, v+8, v+9, v+10, v+11, v+12, v+13)<5) { 27 | continue; 28 | } 29 | if (erp->n>=erp->nmax) { 30 | erp->nmax=erp->nmax<=0?128:erp->nmax*2; 31 | erp_data=(erpd_t*)realloc(erp->data, sizeof(erpd_t)*erp->nmax); 32 | if (!erp_data) { 33 | free(erp->data); erp->data=NULL; erp->n=erp->nmax=0; 34 | fclose(fp); 35 | return 0; 36 | } 37 | erp->data=erp_data; 38 | } 39 | erp->data[erp->n].mjd=v[0]; 40 | erp->data[erp->n].xp=v[1]*1E-6*AS2R; 41 | erp->data[erp->n].yp=v[2]*1E-6*AS2R; 42 | erp->data[erp->n].ut1_utc=v[3]*1E-7; 43 | erp->data[erp->n].lod=v[4]*1E-7; 44 | erp->data[erp->n].xpr=v[12]*1E-6*AS2R; 45 | erp->data[erp->n++].ypr=v[13]*1E-6*AS2R; 46 | } 47 | fclose(fp); 48 | return 1; 49 | } -------------------------------------------------------------------------------- /src/net/dck/logAmb_d.c: -------------------------------------------------------------------------------- 1 | 2 | #include "dck.h" 3 | 4 | #define SQRT(x) ((x)<=0.0||(x)!=(x)?0.0:sqrt(x)) 5 | 6 | static FILE *fpAmb_d=NULL; /* file pointer of ambiguity */ 7 | 8 | /* open ambiguity file -------------------------------------------------------*/ 9 | extern int openAmbLog_d(const char *file) 10 | { 11 | createdir(file); 12 | if (!(fpAmb_d=fopen(file, "w"))) { 13 | trace(2,"amb_open: file open error path=%s\n",file); 14 | return 0; 15 | } 16 | fprintf(fpAmb_d,"%-22s","% TIME(GPST)"); 17 | fprintf(fpAmb_d,"%5s", "RCV"); 18 | fprintf(fpAmb_d,"%5s", "SAT"); 19 | fprintf(fpAmb_d,"%14s", "NARR"); 20 | fprintf(fpAmb_d,"%14s", "WIDE"); 21 | fprintf(fpAmb_d,"%9s", "STD_N"); 22 | fprintf(fpAmb_d,"%9s", "STD_W"); 23 | fprintf(fpAmb_d,"%6s", "DTM"); 24 | fprintf(fpAmb_d,"%6s", "OUTC"); 25 | fprintf(fpAmb_d,"\n"); 26 | 27 | return 1; 28 | } 29 | /* close ambiguity file ------------------------------------------------------*/ 30 | extern void closeAmbLog_d(void) 31 | { 32 | if (fpAmb_d) fclose(fpAmb_d); 33 | fpAmb_d=NULL; 34 | } 35 | extern void logAmb_d(net_t *dck, rcv_t *rcv, const int n) 36 | { 37 | const prcopt_t *opt=&dck->opt; 38 | double *x,*P; 39 | char id[8]; 40 | int i,j,k1,k2,sat,nx=dck->nx; 41 | 42 | x=dck->x; P=dck->P; 43 | for (i=0;itime); 50 | fprintf(fpAmb_d,"%5s",rcv[i].sta.name); 51 | fprintf(fpAmb_d,"%5s",id); 52 | fprintf(fpAmb_d,"%14.4f%14.4f",x[k1],x[k2]); 53 | fprintf(fpAmb_d,"%9.4f%9.4f",SQRT(P[k1+k1*nx]),SQRT(P[k2+k2*nx])); 54 | fprintf(fpAmb_d,"%6d",rcv[i].datum[sat-1]); 55 | fprintf(fpAmb_d,"%6d\n",rcv[i].ssat[sat-1].outc[0]); 56 | } 57 | } 58 | fflush(fpAmb_d); 59 | } -------------------------------------------------------------------------------- /src/sat/sateph_s.c: -------------------------------------------------------------------------------- 1 | /* SBAS, ephemeris to satellite clock and position */ 2 | #include "sat.h" 3 | 4 | /* sbas ephemeris to satellite clock bias -------------------------------------- 5 | * compute satellite clock bias with sbas ephemeris 6 | * args :gtime_t time I time by satellite clock (gpst) 7 | * seph_t *seph I sbas ephemeris 8 | * return:satellite clock bias (s) 9 | * notes :see ref [3] 10 | *-----------------------------------------------------------------------------*/ 11 | extern double seph2clk(gtime_t time, const seph_t *seph) 12 | { 13 | double t; 14 | int i; 15 | 16 | trace(4,"seph2clk: time=%s sat=%2d\n",time_str(time,3),seph->sat); 17 | 18 | t=timediff(time,seph->t0); 19 | 20 | for (i=0;i<2;i++) { 21 | t-=seph->af0+seph->af1*t; 22 | } 23 | return seph->af0+seph->af1*t; 24 | } 25 | /* sbas ephemeris to satellite position and clock bias ------------------------- 26 | * compute satellite position and clock bias with sbas ephemeris 27 | * args :gtime_t time I time (gpst) 28 | * seph_t *seph I sbas ephemeris 29 | * double *rs O satellite position {x,y,z} (ecef) (m) 30 | * double *dts O satellite clock bias (s) 31 | * double *var O satellite position and clock variance (m^2) 32 | * return:none 33 | * notes :see ref [3] 34 | *-----------------------------------------------------------------------------*/ 35 | extern void seph2pos(gtime_t time, const seph_t *seph, double *rs, double *dts, 36 | double *var) 37 | { 38 | double t; 39 | int i; 40 | 41 | trace(4,"seph2pos: time=%s sat=%2d\n",time_str(time,3),seph->sat); 42 | 43 | t=timediff(time,seph->t0); 44 | 45 | for (i=0;i<3;i++) { 46 | rs[i]=seph->pos[i]+seph->vel[i]*t+seph->acc[i]*t*t/2.0; 47 | } 48 | *dts=seph->af0+seph->af1*t; 49 | 50 | *var=var_uraeph(SYS_SBS,seph->sva); 51 | } -------------------------------------------------------------------------------- /src/sat/sat.h: -------------------------------------------------------------------------------- 1 | #ifndef _SAT_H 2 | #define _SAT_H 3 | 4 | #include "base/base.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif /* __cplusplus */ 9 | 10 | #ifdef WIN_DLL 11 | #define EXPORT __declspec(dllexport) /* for Windows DLL */ 12 | #else 13 | #define EXPORT 14 | #endif /* WIN_DLL */ 15 | 16 | EXPORT void satantoff(gtime_t time, const double *rs, int sat, 17 | const nav_t *nav, double *dant); 18 | EXPORT int peph2pos(gtime_t time, int sat, const nav_t *nav, int opt, 19 | double *rs, double *dts, double *var); 20 | EXPORT int peph_to_pos(gtime_t time, int sat, const nav_t *nav, int opt, 21 | double *rs, double *dts, double *vars, double *varc); 22 | 23 | EXPORT double var_uraeph(int sys, int ura); 24 | EXPORT double eph2clk(gtime_t time, const eph_t *eph); 25 | EXPORT void eph2pos(gtime_t time, const eph_t *eph, double *rs, double *dts, 26 | double *var); 27 | EXPORT double geph2clk(gtime_t time, const geph_t *geph); 28 | EXPORT void geph2pos(gtime_t time, const geph_t *geph, double *rs, double *dts, 29 | double *var); 30 | EXPORT double seph2clk(gtime_t time, const seph_t *seph); 31 | EXPORT void seph2pos(gtime_t time, const seph_t *seph, double *rs, double *dts, 32 | double *var); 33 | EXPORT int ephclk(gtime_t time, gtime_t teph, int sat, const nav_t *nav, 34 | double *dts); 35 | EXPORT int ephpos(gtime_t time, gtime_t teph, int sat, const nav_t *nav, 36 | int iode, double *rs, double *dts, double *var, int *svh); 37 | EXPORT int getseleph(int sys); 38 | 39 | EXPORT void satposs(gtime_t teph, const obsd_t *obs, int n, const nav_t *nav, 40 | int ephopt, double *rs, double *dts, double *var, int *svh); 41 | EXPORT void sat_poss(gtime_t teph, char *rcv, const obsd_t *obs, int n, 42 | const nav_t *nav, double *rs, double *dts, double *vars, double *varc, 43 | int *svh); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif /* __cplusplus */ 48 | #endif /* _SAT_H */ 49 | -------------------------------------------------------------------------------- /src/user/ppp/logZtd_p.c: -------------------------------------------------------------------------------- 1 | 2 | #include "ppp.h" 3 | 4 | #define SQRT(x) ((x)<=0.0||(x)!=(x)?0.0:sqrt(x)) 5 | 6 | static FILE *fpZtd_p=NULL; /* file pointer of ztd */ 7 | 8 | /* open ztd file -------------------------------------------------------------*/ 9 | extern int logZtdOpen_p(const char *file, const prcopt_t *opt) 10 | { 11 | createdir(file); 12 | if (!(fpZtd_p=fopen(file,"w"))) { 13 | trace(2,"%s: file open error path=%s\n",__func__,file); 14 | return 0; 15 | } 16 | fprintf(fpZtd_p,"%-22s%6s","% TIME","SOL"); 17 | fprintf(fpZtd_p,"%14s","ZTD(m)"); 18 | if (PNT(opt)>1) fprintf(fpZtd_p,"%14s%14s","GN","GE"); 19 | fprintf(fpZtd_p,"%14s","ZTD_STD"); 20 | if (PNT(opt)>1) fprintf(fpZtd_p,"%9s%9s","GN_STD","GE_STD"); 21 | 22 | fprintf(fpZtd_p,"%14s","ZTD_FIX"); 23 | if (PNT(opt)>1) fprintf(fpZtd_p,"%14s%14s","GN_FIX","GE_FIX"); 24 | fprintf(fpZtd_p,"%14s","ZTD_STD"); 25 | if (PNT(opt)>1) fprintf(fpZtd_p,"%9s%9s","GN_STD","GE_STD"); 26 | fprintf(fpZtd_p,"\n"); 27 | fflush(fpZtd_p); 28 | 29 | return 1; 30 | } 31 | /* close ztd file ------------------------------------------------------------*/ 32 | extern void logZtdClose_p(void) 33 | { 34 | if (fpZtd_p) fclose(fpZtd_p); 35 | fpZtd_p=NULL; 36 | } 37 | /* output ztd ----------------------------------------------------------------*/ 38 | extern void logZtd_p(rtk_t *rtk) 39 | { 40 | const prcopt_t *opt=&rtk->opt; 41 | double *x=rtk->x,*P=rtk->P,*xa=rtk->xa,*Pa=rtk->Pa; 42 | int i,j,nx=rtk->nx,stat=rtk->sol.stat; 43 | 44 | if (!fpZtd_p) return; 45 | 46 | i=PIT(opt); 47 | fprintf(fpZtd_p,"%22s%6d",rtk->cTime,stat); 48 | for (j=0;jopt; 17 | const netsol_t *sol=&dck->sol; 18 | double ep[6],*x,*P,fact; 19 | char id[4],time[32]; 20 | const int ref=dck->opt.ircv; 21 | int i,j,k; 22 | 23 | if (sol->stat==SOLQ_NONE) return; 24 | x=dck->x; P=dck->P; 25 | 26 | time2epoch(sol->time,ep); 27 | sprintf(time,"%4d%3d%3d%3d%3d%10.6f", 28 | (int)ep[0],(int)ep[1],(int)ep[2],(int)ep[3],(int)ep[4],ep[5]); 29 | 30 | /* output rcv clock solution */ 31 | for (i=0;ix[k]*fact); 39 | } 40 | for (j=0;jP[k+k*dck->nx])*fact); 44 | } 45 | fprintf(fp,"\n"); 46 | } 47 | /* output sat clock solution */ 48 | for (i=0;ioutc[i]) continue; 50 | satno2id(i+1,id); 51 | 52 | fprintf(fp,"AS %-4s %26s%3d ",id,time,CLK_NUM(opt)*2); 53 | for (j=0;jx[k]*fact); 57 | } 58 | for (j=0;jP[k+k*dck->nx])*fact); 62 | } 63 | fprintf(fp,"\n"); 64 | } 65 | fflush(fp); 66 | } -------------------------------------------------------------------------------- /src/user/dckp/logZtd_dp.c: -------------------------------------------------------------------------------- 1 | 2 | #include "dckp.h" 3 | 4 | #define SQRT(x) ((x)<=0.0||(x)!=(x)?0.0:sqrt(x)) 5 | 6 | static FILE *fpZtd_dp=NULL; /* file pointer of ztd */ 7 | 8 | /* open ztd file -------------------------------------------------------------*/ 9 | extern int logZtdOpen_dp(const char *file, const prcopt_t *opt) 10 | { 11 | createdir(file); 12 | if (!(fpZtd_dp=fopen(file,"w"))) { 13 | trace(2,"%s: file open error path=%s\n",__func__,file); 14 | return 0; 15 | } 16 | fprintf(fpZtd_dp,"%-22s%6s","% TIME","SOL"); 17 | fprintf(fpZtd_dp,"%14s","ZTD"); 18 | if (DPNT(opt)>1) fprintf(fpZtd_dp,"%14s%14s","GN","GE"); 19 | fprintf(fpZtd_dp,"%9s", "ZTD_STD"); 20 | if (DPNT(opt)>1) fprintf(fpZtd_dp,"%9s%9s","GN_STD","GE_STD"); 21 | 22 | fprintf(fpZtd_dp,"%14s","ZTD_FIX"); 23 | if (DPNT(opt)>1) fprintf(fpZtd_dp,"%14s%14s","GN_FIX","GE_FIX"); 24 | fprintf(fpZtd_dp,"%9s", "ZTD_STD"); 25 | if (DPNT(opt)>1) fprintf(fpZtd_dp,"%9s%9s","GN_STD","GE_STD"); 26 | fprintf(fpZtd_dp,"\n"); 27 | fflush(fpZtd_dp); 28 | 29 | return 1; 30 | } 31 | /* close ztd file ------------------------------------------------------------*/ 32 | extern void logZtdClose_dp(void) 33 | { 34 | if (fpZtd_dp) fclose(fpZtd_dp); 35 | fpZtd_dp=NULL; 36 | } 37 | /* output ztd ----------------------------------------------------------------*/ 38 | extern void logZtd_dp(rtk_t *rtk) 39 | { 40 | const prcopt_t *opt=&rtk->opt; 41 | double *x=rtk->x,*P=rtk->P,*xa=rtk->xa,*Pa=rtk->Pa; 42 | int i,j,nx=rtk->nx,stat=rtk->sol.stat; 43 | 44 | if (!fpZtd_dp) return; 45 | 46 | i=DPIT(opt); 47 | fprintf(fpZtd_dp,"%22s%6d",rtk->cTime,stat); 48 | for (j=0;jionoopt==IONOOPT_IFLC) return 0; 12 | createdir(file); 13 | if (!(fpIon_p=fopen(file, "w"))) { 14 | trace(2,"%s: file open error path=%s\n",__func__,file); 15 | return 0; 16 | } 17 | 18 | fprintf(fpIon_p,"%-5s","% SAT"); 19 | fprintf(fpIon_p,"%14s","ION(m)"); 20 | fprintf(fpIon_p,"%14s","ION_STD"); 21 | fprintf(fpIon_p,"%14s","ION_FIXED(m)"); 22 | fprintf(fpIon_p,"%14s","ION_STD_FIXED"); 23 | fprintf(fpIon_p,"%14s","AZI(deg)"); 24 | fprintf(fpIon_p,"%14s","ELE(deg)"); 25 | fprintf(fpIon_p,"\n"); 26 | fflush(fpIon_p); 27 | 28 | return 1; 29 | } 30 | /* close ionosphere file -----------------------------------------------------*/ 31 | extern void logIonClose_p(void) 32 | { 33 | if (fpIon_p) fclose(fpIon_p); 34 | fpIon_p=NULL; 35 | } 36 | extern void logIon_p(rtk_t *rtk, const obsd_t *obs, int n) 37 | { 38 | prcopt_t *opt=&rtk->opt; 39 | ssat_t *ssat; 40 | double *x=rtk->x,*P=rtk->P,*xa=rtk->xa,*Pa=rtk->Pa; 41 | char id[8]; 42 | int i,k,nx=rtk->nx,sat,stat=rtk->sol.stat; 43 | 44 | if (!fpIon_p) return; 45 | 46 | fprintf(fpIon_p,"%22s%6d%10.2f\n",rtk->cTime,stat,rtk->sol.ratio); 47 | for (i=0;issat+sat-1; 52 | 53 | fprintf(fpIon_p,"%5s", id); 54 | fprintf(fpIon_p,"%14.4f",x[k]); 55 | fprintf(fpIon_p,"%14.4f",SQRT(P[k+k*nx])); 56 | fprintf(fpIon_p,"%14.4f",stat==1?xa[k]:0.0); 57 | fprintf(fpIon_p,"%14.4f",stat==1?Pa[k+k*nx]:0.0); 58 | 59 | fprintf(fpIon_p,"%14.2f",ssat->azel[0]*R2D); 60 | fprintf(fpIon_p,"%14.2f",ssat->azel[1]*R2D); 61 | fprintf(fpIon_p,"\n"); 62 | } 63 | fprintf(fpIon_p,"\n"); 64 | fflush(fpIon_p); 65 | } -------------------------------------------------------------------------------- /src/net/uck/logUpd_u.c: -------------------------------------------------------------------------------- 1 | 2 | #include "uck.h" 3 | 4 | #define SQRT(x) ((x)<=0.0||(x)!=(x)?0.0:sqrt(x)) 5 | 6 | static FILE *fpUpd=NULL; /* file pointer of delay */ 7 | 8 | /* open satellite and receiver delay file ------------------------------------*/ 9 | extern int openUPDLog_u(const char *file) 10 | { 11 | createdir(file); 12 | if (!(fpUpd=fopen(file, "w"))) { 13 | trace(2,"openDlyLog: file open error path=%s\n",file); 14 | return 0; 15 | } 16 | return 1; 17 | } 18 | /* close delay file ----------------------------------------------------------*/ 19 | extern void closeUPDLog_c(void) 20 | { 21 | if (fpUpd) fclose(fpUpd); 22 | fpUpd=NULL; 23 | } 24 | /* output delay -------------------------------------------------------------- 25 | * time | rcv/sat | delay | std -----------------------------------------------*/ 26 | extern void logUPD_u(net_t *uck, rcv_t *rcv, const int n) 27 | { 28 | const prcopt_t *opt=&uck->opt; 29 | double *x,*P; 30 | char id[8]; 31 | int i,f,k,nx=uck->nx; 32 | 33 | /* no bias for ionosphere free model */ 34 | if (!fpUpd) return; 35 | if (opt->ionoopt!=IONOOPT_EST) return; 36 | 37 | x=uck->x; P=uck->P; 38 | /* output receiver delay */ 39 | for (i=0;itime,rcv[i].sta.name); 45 | for (f=0;foutc[i]) continue; 61 | 62 | satno2id(i+1,id); 63 | fprintf(fpUpd,"%-25s%5s",uck->time,id); 64 | for (f=0;fopt; 50 | ssat_t *ssat; 51 | char id[8]; 52 | int i,j,nx=rtk->nx,sat; 53 | 54 | if (!fpRes_p) return; 55 | 56 | fprintf(fpRes_p,"%22s%6d%10.2f\n",rtk->cTime,rtk->sol.stat,rtk->sol.ratio); 57 | for (i=0;issat+sat-1; 61 | 62 | fprintf(fpRes_p,"%5s",id); 63 | for (j=0;jresp[j],ssat->resc[j]); 65 | } 66 | 67 | fprintf(fpRes_p,"%14.2f",ssat->azel[0]*R2D); 68 | fprintf(fpRes_p,"%14.2f",ssat->azel[1]*R2D); 69 | for (j=0;joutc[j]); 70 | fprintf(fpRes_p,"\n"); 71 | } 72 | fprintf(fpRes_p,"\n"); 73 | fflush(fpRes_p); 74 | } -------------------------------------------------------------------------------- /src/net/dck/logRes_d.c: -------------------------------------------------------------------------------- 1 | 2 | #include "dck.h" 3 | 4 | static FILE *fpRes_d=NULL; /* file pointer of residuals */ 5 | 6 | #define PRINT_RES_VAR 0 7 | 8 | /* open residuals file -------------------------------------------------------*/ 9 | extern int openResLog_d(const char *file) 10 | { 11 | createdir(file); 12 | if (!(fpRes_d=fopen(file,"w"))) { 13 | trace(2,"res_open: file open error path=%s\n",file); 14 | return 0; 15 | } 16 | fprintf(fpRes_d,"%-22s","% TIME(GPST)"); 17 | fprintf(fpRes_d,"%5s", "RCV"); 18 | fprintf(fpRes_d,"%5s", "SAT"); 19 | fprintf(fpRes_d,"%14s", "CODE"); 20 | fprintf(fpRes_d,"%14s", "PHASE"); 21 | fprintf(fpRes_d,"%14s", "WIDE_LANE"); 22 | #if PRINT_RES_VAR 23 | fprintf(fpRes_d,"%9s", "STD_C"); 24 | fprintf(fpRes_d,"%9s", "STD_P"); 25 | fprintf(fpRes_d,"%9s", "STD_WL"); 26 | #endif 27 | fprintf(fpRes_d,"%9s", "AZ"); 28 | fprintf(fpRes_d,"%9s", "EL"); 29 | fprintf(fpRes_d,"%6s", "DTM"); 30 | fprintf(fpRes_d,"%6s", "OUTC"); 31 | fprintf(fpRes_d,"\n"); 32 | 33 | return 1; 34 | } 35 | /* close residuals file ------------------------------------------------------*/ 36 | extern void closeResLog_d(void) 37 | { 38 | if (fpRes_d) fclose(fpRes_d); 39 | fpRes_d=NULL; 40 | } 41 | /* output residuals ----------------------------------------------------------*/ 42 | extern int logRes_d(net_t *dck, rcv_t *rcv, const int n) 43 | { 44 | ssat_t *ssat; 45 | char id[4]; 46 | int i,j,sat; 47 | 48 | for (i=0;itime); 57 | fprintf(fpRes_d,"%5s",rcv[i].sta.name); 58 | fprintf(fpRes_d,"%5s",id); 59 | fprintf(fpRes_d,"%14.4f",ssat->resp[0]); 60 | fprintf(fpRes_d,"%14.4f",ssat->resc[0]); 61 | fprintf(fpRes_d,"%14.4f",ssat->resw[0]); 62 | #if PRINT_RES_VAR 63 | fprintf(fpRes_d,"%9.4f",sqrt(ssat->resp[1])); 64 | fprintf(fpRes_d,"%9.4f",sqrt(ssat->resc[1])); 65 | fprintf(fpRes_d,"%9.4f",sqrt(ssat->resw[1])); 66 | #endif 67 | fprintf(fpRes_d,"%9.2f",ssat->azel[0]*R2D); 68 | fprintf(fpRes_d,"%9.2f",ssat->azel[1]*R2D); 69 | fprintf(fpRes_d,"%6d",rcv[i].datum[sat-1]); 70 | fprintf(fpRes_d,"%6d\n",rcv[i].ssat[sat-1].outc[0]); 71 | } 72 | } 73 | 74 | fflush(fpRes_d); 75 | return 0; 76 | } -------------------------------------------------------------------------------- /src/user/dckp/logRclk_dp.c: -------------------------------------------------------------------------------- 1 | 2 | #include "dckp.h" 3 | 4 | #define SQRT(x) ((x)<=0.0||(x)!=(x)?0.0:sqrt(x)) 5 | 6 | static FILE *fpRclk_dp=NULL; /* file pointer of ztd */ 7 | 8 | /* open clk file -------------------------------------------------------------*/ 9 | extern int logRclkOpen_dp(const char *file, const prcopt_t *opt) 10 | { 11 | createdir(file); 12 | if (!(fpRclk_dp=fopen(file,"w"))) { 13 | trace(2,"%s: file open error path=%s\n",__func__,file); 14 | return 0; 15 | } 16 | fprintf(fpRclk_dp,"%-22s%6s","% TIME","SOL"); 17 | fprintf(fpRclk_dp,"%20s","RCLK_CODE(s)"); 18 | fprintf(fpRclk_dp,"%20s","RCLK_PHASE(s)"); 19 | fprintf(fpRclk_dp,"%20s","RCLK_WL(c)"); 20 | fprintf(fpRclk_dp,"%20s","CODE_STD"); 21 | fprintf(fpRclk_dp,"%20s","PHASE_STD"); 22 | fprintf(fpRclk_dp,"%20s","WL_STD"); 23 | 24 | fprintf(fpRclk_dp,"%20s","RCLK_CODE_FIX(s)"); 25 | fprintf(fpRclk_dp,"%20s","RCLK_PHASE_FIX(s)"); 26 | fprintf(fpRclk_dp,"%20s","RCLK_WL_FIX(c)"); 27 | fprintf(fpRclk_dp,"%20s","CODE_STD_FIX"); 28 | fprintf(fpRclk_dp,"%20s","PHASE_STD_FIX"); 29 | fprintf(fpRclk_dp,"%20s","WL_STD_FIX"); 30 | fprintf(fpRclk_dp,"\n"); 31 | fflush(fpRclk_dp); 32 | 33 | return 1; 34 | } 35 | /* close clk file ------------------------------------------------------------*/ 36 | extern void logRclkClose_dp(void) 37 | { 38 | if (fpRclk_dp) fclose(fpRclk_dp); 39 | fpRclk_dp=NULL; 40 | } 41 | /* output clk ----------------------------------------------------------------*/ 42 | extern void logRclk_dp(rtk_t *rtk) 43 | { 44 | const prcopt_t *opt=&rtk->opt; 45 | double *x=rtk->x,*P=rtk->P,*xa=rtk->xa,*Pa=rtk->Pa,fact; 46 | int i,j,nx=rtk->nx,stat=rtk->sol.stat; 47 | 48 | if (!fpRclk_dp) return; 49 | 50 | fprintf(fpRclk_dp,"%22s%6d",rtk->cTime,stat); 51 | for (i=0;imode&&popt->mode<=PMODE_FIXED; 61 | 62 | for (i=0;i<(mode?2:1);i++) { 63 | readblq(file,sta[i].name,popt->odisp[i]); 64 | } 65 | } -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | The Cube software is a secondary development based on RTKLIB and inherits the 3 | license of RTKLIB. 4 | 5 | -------------------------------------------------------------------------------- 6 | 7 | Copyright (c) 2021-2021, APM, CAS, All rights reserved. 8 | 9 | -------------------------------------------------------------------------------- 10 | 11 | The RTKLIB software package is distributed under the following BSD 2-clause 12 | license. Users are permitted to develop, produce or sell their own non- 13 | commercial or commercial products utilizing, linking or including RTKLIB as long 14 | as they comply with the license. 15 | 16 | -------------------------------------------------------------------------------- 17 | 18 | Copyright (c) 2007-2020, T. Takasu, All rights reserved. 19 | 20 | Redistribution and use in source and binary forms, with or without modification, 21 | are permitted provided that the following conditions are met: 22 | 23 | Redistributions of source code must retain the above copyright notice, this list 24 | of conditions and the following disclaimer. Redistributions in binary form must 25 | reproduce the above copyright notice, this list of conditions and the following 26 | disclaimer in the documentation and/or other materials provided with the 27 | distribution. 28 | 29 | The software package includes some companion executive binaries or shared 30 | libraries necessary to execute APs on Windows. These licenses succeed to the 31 | original ones of these software. 32 | 33 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 34 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 35 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 36 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 37 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 38 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 39 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 40 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 41 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 42 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 43 | 44 | -------------------------------------------------------------------------------- 45 | 46 | Notes: 47 | Previous versions of RTKLIB until ver. 2.4.1 had been distributed under GPLv3 48 | license. 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/corr/corr.h: -------------------------------------------------------------------------------- 1 | #ifndef _CORR_H 2 | #define _CORR_h 3 | 4 | #include "base\base.h" 5 | 6 | /* dcb.c */ 7 | extern int corrObsMeasurement(const obsd_t *obs, const nav_t *nav, const double *azel, 8 | const prcopt_t *opt, const double *dantr, const double *dants, double phw, 9 | double *L, double *P, double *Lc, double *Pc); 10 | extern void corr_meas(const obsd_t *obs, const nav_t *nav, const double *azel, 11 | const prcopt_t *opt, const double *dantr, const double *dants, double phw, 12 | double *L, double *P, double *Lc, double *Pc); 13 | 14 | /* pcv.c */ 15 | extern void antmodel(const pcv_t* pcv, const double* del, const double* azel, 16 | int opt, double* dant); 17 | extern void satantpcv(const double* rs, const double* rr, const pcv_t* pcv, 18 | double* dant); 19 | extern pcv_t* searchpcv(int sat, const char *type, gtime_t time, 20 | const pcvs_t *pcvs); 21 | extern void posSetpcv(gtime_t time, prcopt_t *popt, nav_t *nav, 22 | const pcvs_t *pcvs, const pcvs_t *pcvr, const sta_t *sta); 23 | 24 | /* phw.c */ 25 | extern int model_phw(gtime_t time, int sat, const char* type, int opt, 26 | const double* rs, const double* rr, double* phw); 27 | extern void windupcorr(gtime_t time, const double *rs, const double *rr, 28 | double *phw); 29 | 30 | /* trop.c */ 31 | extern double tropmodel(gtime_t time, const double *pos, const double* azel, 32 | double humi); 33 | extern double tropMops(gtime_t time, const double *pos, const double *azel, 34 | double *var); 35 | extern double tropNMF(gtime_t time, const double *pos, const double *azel, 36 | double *mapfw); 37 | extern void tropModel(gtime_t time, const double *pos, const double *azel, 38 | const double *x, double *dtdx, double *dtrp, double *var); 39 | //extern double tropModel2(gtime_t time, const double *pos, const double *azel, 40 | // double *m_w, double *zhd, double *var); 41 | 42 | /* iono.c */ 43 | extern double ionmodel(gtime_t t, const double *ion, const double *pos, 44 | const double *azel); 45 | extern double ionmapf(const double *pos, const double *azel); 46 | extern double ionppp(const double *pos, const double *azel, double re, 47 | double hion, double *posp); 48 | extern int iontec(gtime_t time, const nav_t *nav, const double *pos, 49 | const double *azel, int opt, double *delay, double *var); 50 | 51 | /* tide.c */ 52 | extern int geterp(const erp_t* erp, gtime_t time, double* erpv); 53 | extern void tidedisp(gtime_t tutc, const double *rr, int opt, const erp_t *erp, 54 | const double *odisp, double *dr); 55 | 56 | 57 | #endif /* _CORR_H */ 58 | -------------------------------------------------------------------------------- /src/user/dckp/logAmb_dp.c: -------------------------------------------------------------------------------- 1 | 2 | #include "dckp.h" 3 | 4 | #define SQRT(x) ((x)<=0.0||(x)!=(x)?0.0:sqrt(x)) 5 | #define ROUND(x) (int)floor((x)+0.5) 6 | 7 | static FILE *fpAmb_dp=NULL; /* file pointer of ambiguity */ 8 | 9 | /* open ambiguity file -------------------------------------------------------*/ 10 | extern int logAmbOpen_dp(const char *file, const prcopt_t *opt) 11 | { 12 | createdir(file); 13 | if (!(fpAmb_dp=fopen(file, "w"))) { 14 | trace(2,"%s: file open error path=%s\n",__func__,file); 15 | return 0; 16 | } 17 | fprintf(fpAmb_dp,"%5s","% SAT"); 18 | 19 | fprintf(fpAmb_dp,"%6s","AR"); 20 | fprintf(fpAmb_dp,"%14s","WL_AMB"); 21 | fprintf(fpAmb_dp,"%14s","STD"); 22 | fprintf(fpAmb_dp,"%14s","WL_AMB_FIX"); 23 | 24 | fprintf(fpAmb_dp,"%6s","AR"); 25 | fprintf(fpAmb_dp,"%14s","NL_AMB"); 26 | fprintf(fpAmb_dp,"%14s","STD"); 27 | fprintf(fpAmb_dp,"%14s","NL_AMB_FIX"); 28 | 29 | fprintf(fpAmb_dp,"%14s", "AZIMUTH"); 30 | fprintf(fpAmb_dp,"%14s", "ELEVATION"); 31 | fprintf(fpAmb_dp,"\n"); 32 | fflush(fpAmb_dp); 33 | 34 | return 1; 35 | } 36 | /* close ambiguity file ------------------------------------------------------*/ 37 | extern void logAmbClose_dp(void) 38 | { 39 | if (fpAmb_dp) fclose(fpAmb_dp); 40 | fpAmb_dp=NULL; 41 | } 42 | extern void logAmb_dp(rtk_t *rtk, const obsd_t *obs, int n) 43 | { 44 | prcopt_t *opt=&rtk->opt; 45 | ambt_t *amb; 46 | ssat_t *ssat; 47 | double *x=rtk->x,*P=rtk->P,fixed; 48 | char id[8]; 49 | int i,nl_k,wl_k,nx=rtk->nx,sat,stat=rtk->sol.stat; 50 | 51 | if (!fpAmb_dp) return; 52 | 53 | fprintf(fpAmb_dp,"%22s%6d%10.2f\n",rtk->cTime,stat,rtk->sol.ratio); 54 | for (i=0;iamb+sat-1; 60 | ssat=rtk->ssat+sat-1; 61 | /* satllite */ 62 | fprintf(fpAmb_dp,"%5s", id); 63 | 64 | /* wide-lane */ 65 | if (amb->flag[1]) fixed=(double)amb->value[1]; 66 | else fixed=0.0; 67 | fprintf(fpAmb_dp,"%6d",amb->flag[1]); 68 | fprintf(fpAmb_dp,"%14.4f",x[wl_k]); 69 | fprintf(fpAmb_dp,"%14.4f",SQRT(P[wl_k+wl_k*nx])); 70 | fprintf(fpAmb_dp,"%14.4f", fixed); 71 | /* narr-lane */ 72 | if (amb->flag[0]) fixed=(double)amb->value[0]; 73 | else fixed=0; 74 | fprintf(fpAmb_dp,"%6d",amb->flag[0]); 75 | fprintf(fpAmb_dp,"%14.4f",x[nl_k]); 76 | fprintf(fpAmb_dp,"%14.4f",SQRT(P[nl_k+nl_k*nx])); 77 | fprintf(fpAmb_dp,"%14.4f",fixed); 78 | /* azimuth and elevation */ 79 | fprintf(fpAmb_dp,"%14.2f",ssat->azel[0]*R2D); 80 | fprintf(fpAmb_dp,"%14.2f",ssat->azel[1]*R2D); 81 | fprintf(fpAmb_dp,"\n"); 82 | } 83 | fflush(fpAmb_dp); 84 | } -------------------------------------------------------------------------------- /src/io/readdcb.c: -------------------------------------------------------------------------------- 1 | 2 | #include "io.h" 3 | 4 | /* read DCB parameters file --------------------------------------------------*/ 5 | static int readdcbf(const char *file, nav_t *nav, const sta_t *sta) 6 | { 7 | FILE *fp; 8 | double cbias; 9 | char buff[256],str1[32],str2[32]=""; 10 | int i,j,sat,type=0; 11 | 12 | trace(3,"readdcbf: file=%s\n",file); 13 | 14 | if (!(fp=fopen(file,"r"))) { 15 | trace(2,"dcb parameters file open error: %s\n",file); 16 | return 0; 17 | } 18 | while (fgets(buff,sizeof(buff),fp)) { 19 | 20 | if (strstr(buff,"DIFFERENTIAL (P1-P2) CODE BIASES")) type=1; 21 | else if (strstr(buff,"DIFFERENTIAL (P1-C1) CODE BIASES")) type=2; 22 | else if (strstr(buff,"DIFFERENTIAL (P2-C2) CODE BIASES")) type=3; 23 | 24 | if (!type||sscanf(buff,"%s %s",str1,str2)<1) continue; 25 | 26 | if ((cbias=str2num(buff,26,9))==0.0) continue; 27 | 28 | if (sta&&(!strcmp(str1,"G")||!strcmp(str1,"R"))) { /* receiver DCB */ 29 | for (i=0;irbias[i][j][type-1]=cbias*1E-9*CLIGHT; /* ns -> m */ 35 | } 36 | } 37 | else if ((sat=satid2no(str1))) { /* satellite dcb */ 38 | nav->cbias[sat-1][type-1]=cbias*1E-9*CLIGHT; /* ns -> m */ 39 | } 40 | } 41 | fclose(fp); 42 | 43 | return 1; 44 | } 45 | /* read DCB parameters --------------------------------------------------------- 46 | * read differential code bias (DCB) parameters 47 | * args : char *file I DCB parameters file (wild-card * expanded) 48 | * nav_t *nav IO navigation data 49 | * sta_t *sta I station info data to inport receiver DCB 50 | * (NULL: no use) 51 | * return : status (1:ok,0:error) 52 | * notes : currently only support P1-P2, P1-C1, P2-C2, bias in DCB file 53 | *-----------------------------------------------------------------------------*/ 54 | extern int readdcb(const char *file, nav_t *nav, const sta_t *sta) 55 | { 56 | int i,j,n; 57 | char *efiles[MAXEXFILE]={0}; 58 | 59 | trace(3,"readdcb : file=%s\n",file); 60 | 61 | for (i=0;icbias[i][j]=0.0; 63 | } 64 | for (i=0;i=0;i--) free(efiles[i]); 67 | return 0; 68 | } 69 | } 70 | n=expath(file,efiles,MAXEXFILE); 71 | 72 | for (i=0;iionoopt!=IONOOPT_IFLC) return 0; 12 | createdir(file); 13 | if (!(fpAmb_p=fopen(file, "w"))) { 14 | trace(2,"%s: file open error path=%s\n",__func__,file); 15 | return 0; 16 | } 17 | 18 | fprintf(fpAmb_p,"%-5s","% SAT"); 19 | fprintf(fpAmb_p,"%14s","WL_AMB(c)"); 20 | fprintf(fpAmb_p,"%14s","WL_N"); 21 | 22 | fprintf(fpAmb_p,"%14s","WL_SDAMB(c)"); 23 | fprintf(fpAmb_p,"%14s","STD"); 24 | fprintf(fpAmb_p,"%14s","WL_SDAMB_FIX"); 25 | 26 | fprintf(fpAmb_p,"%14s","NL_SDAMB(c)"); 27 | fprintf(fpAmb_p,"%14s","STD"); 28 | fprintf(fpAmb_p,"%14s","NL_SDAMB_FIX"); 29 | 30 | fprintf(fpAmb_p,"%14s","IF_AMB(m)"); 31 | fprintf(fpAmb_p,"%14s","STD"); 32 | fprintf(fpAmb_p,"%14s","IF_AMB_FIX"); 33 | 34 | fprintf(fpAmb_p,"%14s","AZI(deg)"); 35 | fprintf(fpAmb_p,"%14s","ELE(deg)"); 36 | fprintf(fpAmb_p,"\n"); 37 | fflush(fpAmb_p); 38 | 39 | return 1; 40 | } 41 | /* close ambiguity file ------------------------------------------------------*/ 42 | extern void logAmbClose_p(void) 43 | { 44 | if (fpAmb_p) fclose(fpAmb_p); 45 | fpAmb_p=NULL; 46 | } 47 | extern void logAmb_p(rtk_t *rtk, const obsd_t *obs, int n) 48 | { 49 | prcopt_t *opt=&rtk->opt; 50 | ambc_t *amb; 51 | ambr_t *ambr; 52 | ssat_t *ssat; 53 | double *x=rtk->x,*P=rtk->P,*xa=rtk->xa,*Pa=rtk->Pa,fixed; 54 | char id[8],time[32]; 55 | int i,k,nx=rtk->nx,sat; 56 | 57 | if (!fpAmb_p) return; 58 | 59 | time2str(obs[0].time,time,2); 60 | fprintf(fpAmb_p,"%22s%6d%10.2f\n",time,rtk->sol.stat,rtk->sol.ratio); 61 | for (i=0;iambc+sat-1; 66 | ambr=rtk->ambr+sat-1; 67 | ssat=rtk->ssat+sat-1; 68 | 69 | fprintf(fpAmb_p,"%5s", id); 70 | fprintf(fpAmb_p,"%14.4f",amb->LC[0]); 71 | fprintf(fpAmb_p,"%14d", amb->n[0]); 72 | /* wide-lane */ 73 | fprintf(fpAmb_p,"%14.4f",ambr->floamb[0]); 74 | fprintf(fpAmb_p,"%14.4f",ambr->flostd[0]); 75 | fprintf(fpAmb_p,"%14d", ambr->fixamb[0]); 76 | /* narr-lane */ 77 | fprintf(fpAmb_p,"%14.4f",ambr->floamb[1]); 78 | fprintf(fpAmb_p,"%14.4f",ambr->flostd[1]); 79 | fprintf(fpAmb_p,"%14d", ambr->fixamb[1]); 80 | /* if ambiguity */ 81 | fprintf(fpAmb_p,"%14.4f",x[k]); 82 | fprintf(fpAmb_p,"%14.4f",SQRT(P[k+k*nx])); 83 | if (ambr->fixflag) fixed=xa[k]; 84 | else fixed=0.0; 85 | fprintf(fpAmb_p,"%14.4f",fixed); 86 | 87 | fprintf(fpAmb_p,"%14.2f",ssat->azel[0]*R2D); 88 | fprintf(fpAmb_p,"%14.2f",ssat->azel[1]*R2D); 89 | fprintf(fpAmb_p,"\n"); 90 | } 91 | fprintf(fpAmb_p,"\n"); 92 | fflush(fpAmb_p); 93 | } -------------------------------------------------------------------------------- /src/sat/satant.c: -------------------------------------------------------------------------------- 1 | 2 | #include "sat.h" 3 | 4 | #define SQR(x) ((x)*(x)) 5 | 6 | /* satellite antenna phase center offset --------------------------------------- 7 | * compute satellite antenna phase center offset in ecef 8 | * args : gtime_t time I time (gpst) 9 | * double *rs I satellite position and velocity (ecef) 10 | * {x,y,z,vx,vy,vz} (m|m/s) 11 | * int sat I satellite number 12 | * nav_t *nav I navigation data 13 | * double *dant I satellite antenna phase center offset (ecef) 14 | * {dx,dy,dz} (m) (iono-free LC value) 15 | * return : none 16 | * notes : iono-free LC frequencies defined as follows: 17 | * GPS/QZSS : L1-L2 18 | * GLONASS : G1-G2 19 | * Galileo : E1-E5b 20 | * BDS : B1I-B2I 21 | * NavIC : L5-S 22 | *-----------------------------------------------------------------------------*/ 23 | extern void satantoff(gtime_t time, const double *rs, int sat, const nav_t *nav, 24 | double *dant) 25 | { 26 | const pcv_t *pcv=nav->pcvs+sat-1; 27 | double ex[3],ey[3],ez[3],es[3],r[3],rsun[3],gmst,erpv[5]={0},freq[2]; 28 | double C1,C2,dant1,dant2; 29 | int i,sys; 30 | 31 | trace(4,"satantoff: time=%s sat=%2d\n",time_str(time,3),sat); 32 | 33 | dant[0]=dant[1]=dant[2]=0.0; 34 | 35 | /* sun position in ecef */ 36 | sunmoonpos(gpst2utc(time),erpv,rsun,NULL,&gmst); 37 | 38 | /* unit vectors of satellite fixed coordinates */ 39 | for (i=0;i<3;i++) r[i]=-rs[i]; 40 | if (!normv3(r,ez)) return; 41 | for (i=0;i<3;i++) r[i]=rsun[i]-rs[i]; 42 | if (!normv3(r,es)) return; 43 | cross3(ez,es,r); 44 | if (!normv3(r,ey)) return; 45 | cross3(ey,ez,ex); 46 | 47 | /* iono-free LC coefficients */ 48 | sys=satsys(sat,NULL); 49 | if (sys==SYS_GPS||sys==SYS_QZS) { /* L1-L2 */ 50 | freq[0]=FREQ1; 51 | freq[1]=FREQ2; 52 | } 53 | else if (sys==SYS_GLO) { /* G1-G2 */ 54 | freq[0]=sat2freq(sat,CODE_L1C,nav); 55 | freq[1]=sat2freq(sat,CODE_L2C,nav); 56 | } 57 | else if (sys==SYS_GAL) { /* E1-E5b */ 58 | freq[0]=FREQ1; 59 | freq[1]=FREQ7; 60 | } 61 | else if (sys==SYS_CMP) { /* B1I-B2I */ 62 | freq[0]=FREQ1_CMP; 63 | freq[1]=FREQ2_CMP; 64 | } 65 | else if (sys==SYS_IRN) { /* B1I-B2I */ 66 | freq[0]=FREQ5; 67 | freq[1]=FREQ9; 68 | } 69 | else return; 70 | 71 | C1= SQR(freq[0])/(SQR(freq[0])-SQR(freq[1])); 72 | C2=-SQR(freq[1])/(SQR(freq[0])-SQR(freq[1])); 73 | 74 | /* iono-free LC */ 75 | for (i=0;i<3;i++) { 76 | dant1=pcv->off[0][0]*ex[i]+pcv->off[0][1]*ey[i]+pcv->off[0][2]*ez[i]; 77 | dant2=pcv->off[1][0]*ex[i]+pcv->off[1][1]*ey[i]+pcv->off[1][2]*ez[i]; 78 | dant[i]=C1*dant1+C2*dant2; 79 | } 80 | } -------------------------------------------------------------------------------- /src/net/logDtm.c: -------------------------------------------------------------------------------- 1 | 2 | #include "net.h" 3 | 4 | static FILE *fpDatum=NULL; /* file pointer of ambiguity datum */ 5 | 6 | /* open ambiguity datum file -------------------------------------------------*/ 7 | extern int openDtmLog(const char* file) 8 | { 9 | createdir(file); /* by ls */ 10 | if (!(fpDatum=fopen(file, "w"))) { 11 | trace(2,"datum_open: file open error path=%s\n",file); 12 | return 0; 13 | } 14 | 15 | return 1; 16 | } 17 | /* close ambiguity datum file ------------------------------------------------*/ 18 | extern void closeDtmLog(void) 19 | { 20 | if (fpDatum) fclose(fpDatum); 21 | fpDatum=NULL; 22 | } 23 | extern void logDatumRcvPos(rcv_t *rcv, const int n) 24 | { 25 | double pos[3]; 26 | char cst_str[32]="RCV/POSITION"; 27 | int i; 28 | 29 | fprintf(fpDatum,"+%s\n",cst_str); 30 | for (i=0;i %s\n",str); 49 | 50 | /* receiver and satellite position */ 51 | fprintf(fpDatum,"+%s\n",cst_str1); 52 | rs=zeros(3,MAXSAT); 53 | for (i=0;i1.0) 59 | matcpy(rs+(sat-1)*3,rcv[i].rs+j*6,3,1); 60 | } 61 | } 62 | for (i=0;iopt; 12 | double pos[3],azel[]={0.0,PI/2.0},ztd,var; 13 | int i,j,k,nx=dck->nx; 14 | 15 | for (i=0;iopt); 18 | if (dck->x[k]==0.0||(int)rcv[i].outc>GAP_RESTROP) { 19 | ecef2pos(rcv[i].sta.pos,pos); 20 | ztd=tropMops(rcv[i].time,pos,azel,&var); /* zenith total delay */ 21 | initxNet(dck,ztd,var,k); 22 | 23 | for (j=k+1;jP[k*(nx+1)]+=opt->prn[1]*fabs(rcv[i].tt); 27 | for (j=k+1;jP[j*(nx+1)]+=SQR(0.1)*opt->prn[1]*fabs(rcv[i].tt); 29 | } 30 | } 31 | } 32 | } 33 | /* update states of ambiguities ------------------------------------------------ 34 | * notes: once receiver outlock in the network, reset 35 | * once satellite out lock in the network, reset 36 | * ---------------------------------------------------------------------------*/ 37 | static void updateAmb_d(net_t *dck, rcv_t *rcv, int n) 38 | { 39 | const prcopt_t *opt=&dck->opt; 40 | const int nx=dck->nx; 41 | int i,j,k,f,sat,slip; 42 | 43 | /* reset ambiguity of outlock receiver in previous epoch */ 44 | for (i=0;ioutc[j]) { 53 | for (i=0;i=MAXSATOUT) { 63 | initxNet(dck,0.0,0.0,DIAMB(i+1,j+1,f+1,opt)); 64 | rcv[i].amb[j].count[f]=0; 65 | } 66 | } 67 | } 68 | 69 | /* reset ambiguity if cycle slip in current epoch */ 70 | for (i=0;ix[k]!=0.0&&!slip) { 77 | dck->P[k+k*nx]+=opt->prn[3]*fabs(rcv[i].tt); 78 | } 79 | else { 80 | initxNet(dck,0.0,0.0,k); 81 | rcv[i].amb[sat-1].count[f]=0; 82 | } 83 | } 84 | } 85 | } 86 | /* update decoupled model states ---------------------------------------------*/ 87 | extern void udStates_d(net_t *dck, rcv_t *rcv, int n) 88 | { 89 | trace(3,"udStates_d\n"); 90 | 91 | updateTrop_d(dck,rcv,n); 92 | updateAmb_d (dck,rcv,n); 93 | } -------------------------------------------------------------------------------- /src/corr/dcb.c: -------------------------------------------------------------------------------- 1 | 2 | #include "corr.h" 3 | 4 | #define SQR(x) ((x)*(x)) 5 | 6 | 7 | /* antenna corrected measurements --------------------------------------------*/ 8 | extern int corrObsMeasurement(const obsd_t *obs, const nav_t *nav, const double *azel, 9 | const prcopt_t *opt, const double *dantr, const double *dants, double phw, 10 | double *L, double *P, double *Lc, double *Pc) 11 | { 12 | double freq[NFREQ]={0},C1,C2,P1_P2=30.0; 13 | int i,sys=satsys(obs->sat,NULL); 14 | 15 | for (i=0;isat,obs->code[i],nav); 18 | if (freq[i]==0.0||obs->L[i]==0.0||obs->P[i]==0.0) continue; 19 | if (testsnr(0,0,azel[1],obs->SNR[i]*SNR_UNIT,&opt->snrmask)) continue; 20 | 21 | /* antenna phase center and phase windup correction */ 22 | L[i]=obs->L[i]*CLIGHT/freq[i]-dants[i]-dantr[i]-phw*CLIGHT/freq[i]; 23 | P[i]=obs->P[i]-dants[i]-dantr[i]; 24 | 25 | /* P1-C1,P2-C2 dcb correction (C1->P1,C2->P2) */ 26 | if (sys==SYS_GPS||sys==SYS_GLO) { 27 | if (obs->code[i]==CODE_L1C) P[i]+=nav->cbias[obs->sat-1][1]; 28 | if (obs->code[i]==CODE_L2C) P[i]+=nav->cbias[obs->sat-1][2]; 29 | } 30 | } 31 | if (fabs(P[0]-P[1])>P1_P2) { 32 | trace(2,"%s reject sat=%d by P1_P2 detection\n", 33 | time_str(obs->time,2),obs->sat); 34 | return 0; 35 | } 36 | /* iono-free LC */ 37 | if (freq[0]==0.0||freq[1]==0.0) return 0; 38 | C1= SQR(freq[0])/(SQR(freq[0])-SQR(freq[1])); 39 | C2=-SQR(freq[1])/(SQR(freq[0])-SQR(freq[1])); 40 | if (L[0]!=0.0&&L[1]!=0.0) *Lc=C1*L[0]+C2*L[1]; 41 | if (P[0]!=0.0&&P[1]!=0.0) *Pc=C1*P[0]+C2*P[1]; 42 | 43 | return 1; 44 | } 45 | /* antenna corrected measurements --------------------------------------------*/ 46 | extern void corr_meas(const obsd_t *obs, const nav_t *nav, const double *azel, 47 | const prcopt_t *opt, const double *dantr, const double *dants, double phw, 48 | double *L, double *P, double *Lc, double *Pc) 49 | { 50 | double freq[NFREQ]={0},C1,C2; 51 | int i,sys=satsys(obs->sat,NULL); 52 | 53 | for (i=0;isat,obs->code[i],nav); 56 | if (freq[i]==0.0||obs->L[i]==0.0||obs->P[i]==0.0) continue; 57 | if (testsnr(0,0,azel[1],obs->SNR[i]*SNR_UNIT,&opt->snrmask)) continue; 58 | 59 | /* antenna phase center and phase windup correction */ 60 | L[i]=obs->L[i]*CLIGHT/freq[i]-dants[i]-dantr[i]-phw*CLIGHT/freq[i]; 61 | P[i]=obs->P[i]-dants[i]-dantr[i]; 62 | 63 | /* P1-C1,P2-C2 dcb correction (C1->P1,C2->P2) */ 64 | if (sys==SYS_GPS||sys==SYS_GLO) { 65 | if (obs->code[i]==CODE_L1C) P[i]+=nav->cbias[obs->sat-1][1]; 66 | if (obs->code[i]==CODE_L2C) P[i]+=nav->cbias[obs->sat-1][2]; 67 | } 68 | } 69 | /* iono-free LC */ 70 | *Lc=*Pc=0.0; 71 | if (freq[0]==0.0||freq[1]==0.0) return; 72 | C1= SQR(freq[0])/(SQR(freq[0])-SQR(freq[1])); 73 | C2=-SQR(freq[1])/(SQR(freq[0])-SQR(freq[1])); 74 | 75 | if (L[0]!=0.0&&L[1]!=0.0) *Lc=C1*L[0]+C2*L[1]; 76 | if (P[0]!=0.0&&P[1]!=0.0) *Pc=C1*P[0]+C2*P[1]; 77 | } -------------------------------------------------------------------------------- /src/user/ppp/userMWAmbResol_cnes.c: -------------------------------------------------------------------------------- 1 | 2 | #include "ppp.h" 3 | 4 | #define SQR(x) ((x)*(x)) 5 | #define SQRT(x) ((x)<=0.0||(x)!=(x)?0.0:sqrt(x)) 6 | #define ROUND(x) (int)floor((x)+0.5) 7 | #define MAX_AMB_ROUND_STD 0.15 /* max ambiguity std cycle in round ar */ 8 | #define MAX_AMB_ROUND_FRAC 0.15 /* max difference from an integer drop cycle */ 9 | #define CONST_AMB 0.001 /* constraint to fixed ambiguity */ 10 | #define CONSFIXED 5 /* continuous fixed times of ambiguity hold */ 11 | #define MIN_SAT_SUBSET 4 /* minimum number of ambiguity subset */ 12 | 13 | /* fixed solution ------------------------------------------------------------*/ 14 | static int fixWideAmbSol(const rtk_t *rtk, int n, const int *sats, double *x, 15 | double *P) 16 | { 17 | double *v,*H,*R; 18 | const int nw=rtk->nw; 19 | int i,j,info,stat=1; 20 | 21 | /* no fixed wide-lane ambiguity */ 22 | if (n==0) return 0; 23 | 24 | v=zeros(n,1); H=zeros(nw,n); R=zeros(n,n); 25 | /* integer ambiguity constraint */ 26 | for (i=0;icTime,info); 37 | stat=0; 38 | } 39 | 40 | free(v); free(H); free(R); 41 | return stat; 42 | } 43 | /* fix wide-lane ambiguity ---------------------------------------------------*/ 44 | extern int userMWAmbResol_cnes(rtk_t *rtk, const obsd_t *obs, int n, 45 | const int *exc, double *x, double *P) 46 | { 47 | ambt_t *amb; 48 | const int nw=rtk->nw; 49 | double value; 50 | int i,j,m,k,sat,sats[MAXOBS]={0}; 51 | 52 | /* reset mw ambiguity fixed flag */ 53 | for (i=0;iamb[i].flag[1]=0; 55 | rtk->amb[i].value[1]=0; 56 | } 57 | /* fix wide-lane ambiguity */ 58 | for (i=m=0;iMAX_AMB_ROUND_STD|| 63 | fabs(ROUND(x[j])-x[j])>MAX_AMB_ROUND_FRAC) continue; 64 | sats[m++]=sat; 65 | } 66 | 67 | /* tracking */ 68 | for (i=0;iamb+sat-1; 71 | value=ROUND(x[sat-1]); 72 | 73 | /* count times fixing to the same value */ 74 | if (amb->track[1]==value) amb->count[1]++; 75 | else { 76 | sats[i]=0; 77 | amb->track[1]=(int)value; 78 | amb->count[1]=1; 79 | } 80 | } 81 | 82 | /* count fixed sats */ 83 | for (i=k=0;icTime,k); 90 | return 0; 91 | } 92 | 93 | /* fixed ambiguity */ 94 | for (i=0;iamb+sat-1; 97 | if (amb->count[1]>CONSFIXED) { 98 | amb->flag[1]|=1; 99 | amb->value[1]=amb->track[1]; 100 | } 101 | } 102 | 103 | if (!fixWideAmbSol(rtk,k,sats,x,P)) { 104 | for (i=0;iamb[i].flag[1]=0; 106 | rtk->amb[i].value[1]=0; 107 | } 108 | return 0; 109 | } 110 | 111 | return 1; 112 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | #PYTHON 55 | # Byte-compiled / optimized / DLL files 56 | __pycache__/ 57 | *.py[cod] 58 | *$py.class 59 | 60 | # C extensions 61 | *.so 62 | 63 | # Distribution / packaging 64 | .Python 65 | build/ 66 | develop-eggs/ 67 | dist/ 68 | downloads/ 69 | eggs/ 70 | .eggs/ 71 | lib/ 72 | lib64/ 73 | parts/ 74 | sdist/ 75 | var/ 76 | wheels/ 77 | pip-wheel-metadata/ 78 | share/python-wheels/ 79 | *.egg-info/ 80 | .installed.cfg 81 | *.egg 82 | MANIFEST 83 | 84 | # PyInstaller 85 | # Usually these files are written by a python script from a template 86 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 87 | *.manifest 88 | *.spec 89 | 90 | # Installer logs 91 | pip-log.txt 92 | pip-delete-this-directory.txt 93 | 94 | # Unit test / coverage reports 95 | htmlcov/ 96 | .tox/ 97 | .nox/ 98 | .coverage 99 | .coverage.* 100 | .cache 101 | nosetests.xml 102 | coverage.xml 103 | *.cover 104 | *.py,cover 105 | .hypothesis/ 106 | .pytest_cache/ 107 | 108 | # Translations 109 | *.mo 110 | *.pot 111 | 112 | # Django stuff: 113 | *.log 114 | local_settings.py 115 | db.sqlite3 116 | db.sqlite3-journal 117 | 118 | # Flask stuff: 119 | instance/ 120 | .webassets-cache 121 | 122 | # Scrapy stuff: 123 | .scrapy 124 | 125 | # Sphinx documentation 126 | docs/_build/ 127 | 128 | # PyBuilder 129 | target/ 130 | 131 | # Jupyter Notebook 132 | .ipynb_checkpoints 133 | 134 | # IPython 135 | profile_default/ 136 | ipython_config.py 137 | 138 | # pyenv 139 | .python-version 140 | 141 | # pipenv 142 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 143 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 144 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 145 | # install all needed dependencies. 146 | #Pipfile.lock 147 | 148 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 149 | __pypackages__/ 150 | 151 | # Celery stuff 152 | celerybeat-schedule 153 | celerybeat.pid 154 | 155 | # SageMath parsed files 156 | *.sage.py 157 | 158 | # Environments 159 | .env 160 | .venv 161 | env/ 162 | venv/ 163 | ENV/ 164 | env.bak/ 165 | venv.bak/ 166 | 167 | # Spyder project settings 168 | .spyderproject 169 | .spyproject 170 | 171 | # Rope project settings 172 | .ropeproject 173 | 174 | # mkdocs documentation 175 | /site 176 | 177 | # mypy 178 | .mypy_cache/ 179 | .dmypy.json 180 | dmypy.json 181 | 182 | # Pyre type checker 183 | .pyre/ -------------------------------------------------------------------------------- /src/user/dckp/dckp.h: -------------------------------------------------------------------------------- 1 | #ifndef _DCKP_H 2 | #define _DCKP_H 3 | 4 | #include "user/user.h" 5 | 6 | /* number and index of states */ 7 | #define DPNF(opt) (2) /* ambiguity number of dck model */ 8 | #define DPCK(opt) (3) /* clock number of dck model */ 9 | #define DPNP(opt) (3) /* position */ 10 | #define DPNC(opt) (DPCK(opt)*NSYS) /* clocks */ 11 | #define DPNT(opt) ((opt)->tropopttropopt==TROPOPT_EST?1:3)) /* troposphere */ 12 | #define DPNR(opt) (DPNP(opt)+DPNC(opt)+DPNT(opt)) /* number for receiver */ 13 | #define DPNB(opt) (DPNF(opt)*MAXSAT) /* ambiguity */ 14 | #define DPNX(opt) (DPNR(opt)+DPNB(opt)) /* total */ 15 | 16 | #define DPIC(sys,n,opt) (DPNP(opt)+(sys-1)*DPCK(opt)+(n-1)) /* sys (GPS:1) */ 17 | #define DPIT(opt) (DPNP(opt)+DPNC(opt)) 18 | #define DPIB(s,f,opt) (DPNR(opt)+(s-1)*DPNF(opt)+(f-1)) /* 1:narr, 2:wide */ 19 | 20 | 21 | #define TRACE_PPP 0 22 | 23 | 24 | /* userPostPos_dp.c ----------------------------------------------------------*/ 25 | extern int userPostPos_dp(gtime_t ts, gtime_t te, double ti, double tu, 26 | const prcopt_t *popt, const solopt_t *sopt, const filopt_t *fopt); 27 | 28 | /* userRTKPos_dp -------------------------------------------------------------*/ 29 | extern int userRTKPos_dp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav); 30 | 31 | /* userPPPos_dp.c ------------------------------------------------------------*/ 32 | extern int userPPPnx_dp(const prcopt_t *opt); 33 | extern void userPPPos_dp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav); 34 | 35 | /* userPPPRes_dp -------------------------------------------------------------*/ 36 | extern int userPPPRes_dp(int post, const obsd_t *obs, int n, const double *rs, 37 | const double *dts, const double *var_rs, const double *var_dt, 38 | const int *svh, const double *dr, int *exc, const nav_t *nav, 39 | const double *xp, double *Pp, rtk_t *rtk, double *vl, double *HL, 40 | double *DL, double *vp, double *HP, double *DP, double *azel, int *ix, 41 | int *nc); 42 | 43 | /* userUdStates_dp.c ---------------------------------------------------------*/ 44 | extern void userUdStates_dp(rtk_t *rtk, const obsd_t *obs, int n, 45 | const nav_t *nav); 46 | 47 | /* userAmbResol_dp.c ---------------------------------------------------------*/ 48 | extern int userAmbResol_dp(rtk_t *rtk, const obsd_t *obs, int n, const int *exc, 49 | const double *azel, double *x, double *P); 50 | 51 | /* logRclk_dp.c --------------------------------------------------------------*/ 52 | extern int logRclkOpen_dp(const char *file, const prcopt_t *opt); 53 | extern void logRclkClose_dp(void); 54 | extern void logRclk_dp(rtk_t *rtk); 55 | 56 | /* logZtd_dp.c ---------------------------------------------------------------*/ 57 | extern int logZtdOpen_dp(const char *file, const prcopt_t *opt); 58 | extern void logZtdClose_dp(void); 59 | extern void logZtd_dp(rtk_t *rtk); 60 | 61 | /* logAmb_dp.c ---------------------------------------------------------------*/ 62 | extern int logAmbOpen_dp(const char *file, const prcopt_t *opt); 63 | extern void logAmbClose_dp(void); 64 | extern void logAmb_dp(rtk_t *rtk, const obsd_t *obs, int n); 65 | 66 | /* logRes_dp.c ---------------------------------------------------------------*/ 67 | extern int logResOpen_dp(const char *file, const prcopt_t *opt); 68 | extern void logResClose_dp(void); 69 | extern void logRes_dp(rtk_t *rtk, const obsd_t *obs, int n); 70 | 71 | 72 | #endif /* _DCKP_H */ 73 | -------------------------------------------------------------------------------- /src/io/readsnx.c: -------------------------------------------------------------------------------- 1 | 2 | #if 0 3 | 4 | #include "io.h" 5 | 6 | 7 | /* get coordinate for stations -----------------------------------------------*/ 8 | extern int readsnx(const char *file, rcv_t *rcv, const int n) 9 | { 10 | FILE *fp; 11 | char buff[1024],stalist[MAXRCV*5+1],code[5],*p; 12 | int i,flag=0; 13 | 14 | trace(3,"readsnx:file=%s\n",file); 15 | 16 | if (!(fp=fopen(file,"r"))) { 17 | trace(2,"snx file open error: %s\n",file); 18 | return 0; 19 | } 20 | 21 | p=stalist; 22 | for (i=0;itropopt==TROPOPT_EST?1:3) /* number of troposphere delay for single station */ 12 | #define DNAMB(opt) (DNF(opt)*MAXSAT) /* number of ambiguity for single station */ 13 | #define DNR(opt) (DNRC(opt)+DNT(opt)+DNAMB(opt)) /* number of parameters except satellite clocks for single station */ 14 | 15 | /* s for satellite number (from 1), r for station number (from 1), n for equation number (from 1) */ 16 | #define DISC(s,n,opt) ((s-1)*CLK_NUM(opt)+(n-1)) /* index of satellite clock or clock like */ 17 | #define DIRC(r,n,opt) (DNSC(opt)+(r-1)*DNR(opt)+(n-1)) /* index of receiver clock or clock like */ 18 | #define DIT(r,opt) (DNSC(opt)+(r-1)*DNR(opt)+DNRC(opt)) /* index of tropsphere delay */ 19 | #define DIAMB(r,s,n,opt) (DNSC(opt)+(r-1)*DNR(opt)+DNRC(opt)+DNT(opt)+DNF(opt)*(s-1)+(n-1)) /* index of ambiguity */ 20 | 21 | /* functions -----------------------------------------------------------------*/ 22 | 23 | /* dckPost.c -----------------------------------------------------------------*/ 24 | extern int dckPost(const prcopt_t *popt, const solopt_t *sopt, 25 | const filopt_t *fopt); 26 | 27 | /* outProduct_d.c ------------------------------------------------------------*/ 28 | extern void outProduct_d(FILE *fp, const net_t *dck, const rcv_t *rcv, int n); 29 | 30 | /* estProduct_d.c ------------------------------------------------------------*/ 31 | extern int estProduct_d(net_t *dck, rcv_t *rcv, int n, const nav_t *nav, 32 | int flag); 33 | 34 | /* udStates_d.c --------------------------------------------------------------*/ 35 | extern void udStates_d(net_t *dck, rcv_t *rcv, int n); 36 | 37 | /* dckRes.c ------------------------------------------------------------------*/ 38 | extern int dckRes(int post, const net_t *dck, rcv_t *rcv, int n, 39 | const nav_t *nav, const double *x, const double *P, int *ix, double *vl, 40 | double *HL, double *DL, double *vp, double *HP, double *DP, int *nc, 41 | int tnv, int flag, int *outr, int *outs); 42 | 43 | /* dckNetAr.c ----------------------------------------------------------------*/ 44 | extern void udAmbDatum_d(const prcopt_t *opt, rcv_t *rcv, int n); 45 | extern void udTrackAmb_d(net_t *dck, rcv_t *rcv, int n, int ar); 46 | extern int dckNetAr(const net_t *dck, rcv_t *rcv, int n, double *x, double *P); 47 | 48 | /* logRes_d.c ----------------------------------------------------------------*/ 49 | extern int openResLog_d(const char *file); 50 | extern void closeResLog_d(void); 51 | extern int logRes_d(net_t *dck,rcv_t *rcv,const int n); 52 | 53 | /* logZtd_d.c ----------------------------------------------------------------*/ 54 | extern int openZtdLog_d(const char *file, int opt); 55 | extern void closeZtdLog_d(void); 56 | extern void logZtd_d(net_t *dck,rcv_t *rcv,const int n); 57 | 58 | /* logAmb_d.c ----------------------------------------------------------------*/ 59 | extern int openAmbLog_d(const char *file); 60 | extern void closeAmbLog_d(void); 61 | extern void logAmb_d(net_t *dck,rcv_t *rcv,const int n); 62 | 63 | /* record_d.c ----------------------------------------------------------------*/ 64 | extern void recordOutFile_d(const char *file); 65 | extern void openRecord_d(int lastEp); 66 | extern void closeRecord_d(int lastEp); 67 | extern void record_d(int type, const char *time, const char *rcv, int sat, 68 | int frq, int trp, int datum, double value, int lastEp); 69 | extern void recordVar_d(const double *DP, int nc, int lastEp); 70 | extern int getRecord_d(net_t *uck, const char *fileIndex, const char *fileValue); 71 | extern int copyConstraint_d(net_t *uck, rcv_t *rcv, int n); 72 | 73 | #endif /* _DCK_H */ -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "net/dck/dck.h" 4 | #include "net/uck/uck.h" 5 | #include "user/ppp/ppp.h" 6 | #include "user/dckp/dckp.h" 7 | 8 | static char conf[1024]="F:\\conf_net.conf"; 9 | 10 | /* begin to uck net solving --------------------------------------------------*/ 11 | static void processing(int argc,char **argv) 12 | { 13 | prcopt_t popt; 14 | solopt_t sopt; 15 | filopt_t fopt; 16 | double sec; 17 | char stime[64],*p; 18 | int i,week; 19 | 20 | /* load options from configuration file */ 21 | for (i=1;i=PMODE_PPP_KINEMA||popt.mode<=PMODE_PPP_FIXED) { 76 | if (popt.dck) { 77 | userPostPos_dp(popt.ts,popt.te,popt.ti,popt.tu,&popt,&sopt,&fopt); 78 | } 79 | else { 80 | userPostPos_p(popt.ts,popt.te,popt.ti,popt.tu,&popt,&sopt,&fopt); 81 | } 82 | } 83 | else { 84 | printf("error mode=%d\n",popt.mode); 85 | } 86 | } 87 | /* main ----------------------------------------------------------------------*/ 88 | int main(int argc, char **argv) 89 | { 90 | long t1,t2; 91 | 92 | t1=clock(); 93 | processing(argc,argv); 94 | t2=clock(); 95 | 96 | printf("\ntotal time: %6.3f seconds\n",(double)(t2-t1)/CLOCKS_PER_SEC); 97 | if (argc==1) system("pause"); 98 | return 0; 99 | } 100 | /* test main -----------------------------------------------------------------*/ 101 | void main2() 102 | { 103 | setsysopts(NULL,NULL,NULL); 104 | saveopts("F:\\confprn.conf","w","configure file",sysopts); 105 | system("pause"); 106 | } 107 | void main3() 108 | { 109 | nav_t nav={0}; 110 | sta_t sta[10]={{0}}; 111 | obs_t obs={0}; 112 | char file[]="C:\\Users\\Lenovo\\Desktop\\uc_test\\*.20o"; 113 | 114 | readrnx(file,1,"",&obs,&nav,sta); 115 | } 116 | void main4() 117 | { 118 | char file[]="C:\\Users\\Lenovo\\Desktop\\uc_test\\*.sp3"; 119 | nav_t nav={0}; 120 | readsp3(file,&nav,0); 121 | } 122 | void main5() 123 | { 124 | rcv_t rcv[3]={0}; 125 | char file[]="C:\\Users\\Lenovo\\Desktop\\path.txt"; 126 | getMultiOBS(rcv,file); 127 | } 128 | void main6() 129 | { 130 | printf("%*.*e\n",15,8,0.00000078); 131 | system("pause"); 132 | } 133 | -------------------------------------------------------------------------------- /src/sat/sateph_r.c: -------------------------------------------------------------------------------- 1 | /* GLO, ephemeris to satellite clock and position */ 2 | #include "sat.h" 3 | 4 | #define SQR(x) ((x)*(x)) 5 | 6 | #define RE_GLO 6378136.0 /* radius of earth (m) ref [2] */ 7 | #define MU_GLO 3.9860044E14 /* gravitational constant ref [2] */ 8 | #define J2_GLO 1.0826257E-3 /* 2nd zonal harmonic of geopot ref [2] */ 9 | #define OMGE_GLO 7.292115E-5 /* earth angular velocity (rad/s) ref [2] */ 10 | #define ERREPH_GLO 5.0 /* error of glonass ephemeris (m) */ 11 | #define TSTEP 60.0 /* integration step glonass ephemeris (s) */ 12 | 13 | /* glonass orbit differential equations --------------------------------------*/ 14 | static void deq(const double *x, double *xdot, const double *acc) 15 | { 16 | double a,b,c,r2=dot(x,x,3),r3=r2*sqrt(r2),omg2=SQR(OMGE_GLO); 17 | 18 | if (r2<=0.0) { 19 | xdot[0]=xdot[1]=xdot[2]=xdot[3]=xdot[4]=xdot[5]=0.0; 20 | return; 21 | } 22 | /* ref [2] A.3.1.2 with bug fix for xdot[4],xdot[5] */ 23 | a=1.5*J2_GLO*MU_GLO*SQR(RE_GLO)/r2/r3; /* 3/2*J2*mu*Ae^2/r^5 */ 24 | b=5.0*x[2]*x[2]/r2; /* 5*z^2/r^2 */ 25 | c=-MU_GLO/r3-a*(1.0-b); /* -mu/r^3-a(1-b) */ 26 | xdot[0]=x[3]; xdot[1]=x[4]; xdot[2]=x[5]; 27 | xdot[3]=(c+omg2)*x[0]+2.0*OMGE_GLO*x[4]+acc[0]; 28 | xdot[4]=(c+omg2)*x[1]-2.0*OMGE_GLO*x[3]+acc[1]; 29 | xdot[5]=(c-2.0*a)*x[2]+acc[2]; 30 | } 31 | /* glonass position and velocity by numerical integration --------------------*/ 32 | static void glorbit(double t, double *x, const double *acc) 33 | { 34 | double k1[6],k2[6],k3[6],k4[6],w[6]; 35 | int i; 36 | 37 | deq(x,k1,acc); for (i=0;i<6;i++) w[i]=x[i]+k1[i]*t/2.0; 38 | deq(w,k2,acc); for (i=0;i<6;i++) w[i]=x[i]+k2[i]*t/2.0; 39 | deq(w,k3,acc); for (i=0;i<6;i++) w[i]=x[i]+k3[i]*t; 40 | deq(w,k4,acc); 41 | for (i=0;i<6;i++) x[i]+=(k1[i]+2.0*k2[i]+2.0*k3[i]+k4[i])*t/6.0; 42 | } 43 | /* glonass ephemeris to satellite clock bias ----------------------------------- 44 | * compute satellite clock bias with glonass ephemeris 45 | * args : gtime_t time I time by satellite clock (gpst) 46 | * geph_t *geph I glonass ephemeris 47 | * return : satellite clock bias (s) 48 | * notes : see ref [2] 49 | *-----------------------------------------------------------------------------*/ 50 | extern double geph2clk(gtime_t time, const geph_t *geph) 51 | { 52 | double t,ts; 53 | int i; 54 | 55 | trace(4,"geph2clk: time=%s sat=%2d\n",time_str(time,3),geph->sat); 56 | 57 | t=ts=timediff(time,geph->toe); 58 | 59 | for (i=0;i<2;i++) { 60 | t=ts-(-geph->taun+geph->gamn*t); 61 | } 62 | return -geph->taun+geph->gamn*t; 63 | } 64 | /* glonass ephemeris to satellite position and clock bias ---------------------- 65 | * compute satellite position and clock bias with glonass ephemeris 66 | * args :gtime_t time I time (gpst) 67 | * geph_t *geph I glonass ephemeris 68 | * double *rs O satellite position {x,y,z} (ecef) (m) 69 | * double *dts O satellite clock bias (s) 70 | * double *var O satellite position and clock variance (m^2) 71 | * return:none 72 | * notes :see ref [2] 73 | *-----------------------------------------------------------------------------*/ 74 | extern void geph2pos(gtime_t time, const geph_t *geph, double *rs, double *dts, 75 | double *var) 76 | { 77 | double t,tt,x[6]; 78 | int i; 79 | 80 | trace(4,"geph2pos: time=%s sat=%2d\n",time_str(time,3),geph->sat); 81 | 82 | t=timediff(time,geph->toe); 83 | 84 | *dts=-geph->taun+geph->gamn*t; 85 | 86 | for (i=0;i<3;i++) { 87 | x[i ]=geph->pos[i]; 88 | x[i+3]=geph->vel[i]; 89 | } 90 | for (tt=t<0.0?-TSTEP:TSTEP;fabs(t)>1E-9;t-=tt) { 91 | if (fabs(t)acc); 93 | } 94 | for (i=0;i<3;i++) rs[i]=x[i]; 95 | 96 | *var=SQR(ERREPH_GLO); 97 | } -------------------------------------------------------------------------------- /data/apm21440.list: -------------------------------------------------------------------------------- 1 | F:\2021\038\21o\NRC100CAN_R_20210380000_01D_30S_MO.21o 2 | F:\2021\038\21o\USN700USA_R_20210380000_01D_30S_MO.21o 3 | F:\2021\038\21o\NLIB00USA_R_20210380000_01D_30S_MO.21o 4 | F:\2021\038\21o\DUBO00CAN_R_20210380000_01D_30S_MO.21o 5 | F:\2021\038\21o\STJO00CAN_R_20210380000_01D_30S_MO.21o 6 | F:\2021\038\21o\SCUB00CUB_R_20210380000_01D_30S_MO.21o 7 | F:\2021\038\21o\PRDS00CAN_R_20210380000_01D_30S_MO.21o 8 | F:\2021\038\21o\YELL00CAN_R_20210380000_01D_30S_MO.21o 9 | F:\2021\038\21o\ABMF00GLP_R_20210380000_01D_30S_MO.21o 10 | F:\2021\038\21o\ALBH00CAN_R_20210380000_01D_30S_MO.21o 11 | F:\2021\038\21o\GOLD00USA_R_20210380000_01D_30S_MO.21o 12 | F:\2021\038\21o\QUIN00USA_R_20210380000_01D_30S_MO.21o 13 | F:\2021\038\21o\JPLM00USA_R_20210380000_01D_30S_MO.21o 14 | F:\2021\038\21o\BOGT00COL_R_20210380000_01D_30S_MO.21o 15 | F:\2021\038\21o\FAIR00USA_R_20210380000_01D_30S_MO.21o 16 | F:\2021\038\21o\NYAL00NOR_S_20210380000_01D_30S_MO.21o 17 | F:\2021\038\21o\NYA100NOR_S_20210380000_01D_30S_MO.21o 18 | F:\2021\038\21o\CEBR00ESP_R_20210380000_01D_30S_MO.21o 19 | F:\2021\038\21o\KIRU00SWE_R_20210380000_01D_30S_MO.21o 20 | F:\2021\038\21o\KIR800SWE_R_20210380000_01D_30S_MO.21o 21 | F:\2021\038\21o\BRUX00BEL_R_20210380000_01D_30S_MO.21o 22 | F:\2021\038\21o\ONSA00SWE_R_20210380000_01D_30S_MO.21o 23 | F:\2021\038\21o\WAB200CHE_R_20210380000_01D_30S_MO.21o 24 | F:\2021\038\21o\ZIM200CHE_R_20210380000_01D_30S_MO.21o 25 | F:\2021\038\21o\VIS000SWE_R_20210380000_01D_30S_MO.21o 26 | F:\2021\038\21o\POTS00DEU_R_20210380000_01D_30S_MO.21o 27 | F:\2021\038\21o\IENG00ITA_R_20210380000_01D_30S_MO.21o 28 | F:\2021\038\21o\METG00FIN_R_20210380000_01D_30S_MO.21o 29 | F:\2021\038\21o\BOR100POL_R_20210380000_01D_30S_MO.21o 30 | F:\2021\038\21o\GOP600CZE_R_20210380000_01D_30S_MO.21o 31 | F:\2021\038\21o\MEDI00ITA_R_20210380000_01D_30S_MO.21o 32 | F:\2021\038\21o\JOZE00POL_R_20210380000_01D_30S_MO.21o 33 | F:\2021\038\21o\JOZ200POL_R_20210380000_01D_30S_MO.21o 34 | F:\2021\038\21o\MATE00ITA_R_20210380000_01D_30S_MO.21o 35 | F:\2021\038\21o\KOKB00USA_R_20210380000_01D_30S_MO.21o 36 | F:\2021\038\21o\KOKV00USA_R_20210380000_01D_30S_MO.21o 37 | F:\2021\038\21o\YKRO00CIV_R_20210380000_01D_30S_MO.21o 38 | F:\2021\038\21o\CHPG00BRA_R_20210380000_01D_30S_MO.21o 39 | F:\2021\038\21o\CHPI00BRA_R_20210380000_01D_30S_MO.21o 40 | F:\2021\038\21o\ANKR00TUR_R_20210380000_01D_30S_MO.21o 41 | F:\2021\038\21o\SANT00CHL_R_20210380000_01D_30S_MO.21o 42 | F:\2021\038\21o\NKLG00GAB_R_20210380000_01D_30S_MO.21o 43 | F:\2021\038\21o\GAMB00PYF_R_20210380000_01D_30S_MO.21o 44 | F:\2021\038\21o\STHL00GBR_R_20210380000_01D_30S_MO.21o 45 | F:\2021\038\21o\TASH00UZB_R_20210380000_01D_30S_MO.21o 46 | F:\2021\038\21o\URUM00CHN_R_20210380000_01D_30S_MO.21o 47 | F:\2021\038\21o\USUD00JPN_R_20210380000_01D_30S_MO.21o 48 | F:\2021\038\21o\FALK00FLK_R_20210380000_01D_30S_MO.21o 49 | F:\2021\038\21o\RIO200ARG_R_20210380000_01D_30S_MO.21o 50 | F:\2021\038\21o\RGDG00ARG_R_20210380000_01D_30S_MO.21o 51 | F:\2021\038\21o\GMSD00JPN_R_20210380000_01D_30S_MO.21o 52 | F:\2021\038\21o\MAJU00MHL_R_20210380000_01D_30S_MO.21o 53 | F:\2021\038\21o\NIUM00NIU_R_20210380000_01D_30S_MO.21o 54 | F:\2021\038\21o\PALM00ATA_R_20210380000_01D_30S_MO.21o 55 | F:\2021\038\21o\HKSL00HKG_R_20210380000_01D_30S_MO.21o 56 | F:\2021\038\21o\IISC00IND_R_20210380000_01D_30S_MO.21o 57 | F:\2021\038\21o\SOLO00SLB_R_20210380000_01D_30S_MO.21o 58 | F:\2021\038\21o\PNGM00PNG_R_20210380000_01D_30S_MO.21o 59 | F:\2021\038\21o\DGAR00GBR_R_20210380000_01D_30S_MO.21o 60 | F:\2021\038\21o\NTUS00SGP_R_20210380000_01D_30S_MO.21o 61 | F:\2021\038\21o\REUN00REU_R_20210380000_01D_30S_MO.21o 62 | F:\2021\038\21o\TOW200AUS_R_20210380000_01D_30S_MO.21o 63 | F:\2021\038\21o\MCM400ATA_R_20210380000_01D_30S_MO.21o 64 | F:\2021\038\21o\DARW00AUS_R_20210380000_01D_30S_MO.21o 65 | F:\2021\038\21o\BAKO00IDN_R_20210380000_01D_30S_MO.21o 66 | F:\2021\038\21o\MAC100AUS_R_20210380000_01D_30S_MO.21o 67 | F:\2021\038\21o\MOBS00AUS_R_20210380000_01D_30S_MO.21o 68 | F:\2021\038\21o\MAW100ATA_R_20210380000_01D_30S_MO.21o 69 | F:\2021\038\21o\KARR00AUS_R_20210380000_01D_30S_MO.21o 70 | F:\2021\038\21o\YAR200AUS_R_20210380000_01D_30S_MO.21o 71 | -------------------------------------------------------------------------------- /src/user/dckp/userUdStates_dp.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "dckp.h" 4 | 5 | #define ROUND(x) (int)floor((x)+0.5) 6 | 7 | #define SQR(x) (x*x) 8 | #define VAR_POS SQR(100.0) /* init variance position (m^2) */ 9 | #define VAR_GRA SQR(0.01) /* init variance gradient (m^2) */ 10 | #define GAP_RESION 120 /* default gap to reset ionos parameters (ep) */ 11 | #define MAX_SAT_OUTC 5 /* obs outage count to reset bias */ 12 | 13 | 14 | /* temporal update of position -----------------------------------------------*/ 15 | static void udPos(rtk_t *rtk) 16 | { 17 | int i; 18 | 19 | /* fixed mode */ 20 | if (rtk->opt.mode==PMODE_PPP_FIXED) { 21 | for (i=0;i<3;i++) userInitX_dp(rtk,rtk->opt.ru[i],1E-8,i); 22 | return; 23 | } 24 | /* initialize position for first epoch */ 25 | if (norm(rtk->x,3)<=0.0) { 26 | for (i=0;i<3;i++) userInitX_dp(rtk,rtk->sol.rr[i],VAR_POS,i); 27 | } 28 | /* static ppp mode */ 29 | if (rtk->opt.mode==PMODE_PPP_STATIC) { 30 | for (i=0;i<3;i++) { 31 | rtk->P[i*(1+rtk->nx)]+=rtk->opt.prn[0]*fabs(rtk->tt); 32 | } 33 | return; 34 | } 35 | /* kinmatic mode */ 36 | for (i=0;i<3;i++) userInitX_dp(rtk,rtk->sol.rr[i],VAR_POS,i); 37 | } 38 | /* temporal update of tropospheric parameters --------------------------------*/ 39 | static void udTrop(rtk_t *rtk) 40 | { 41 | const prcopt_t *opt=&rtk->opt; 42 | double pos[3],azel[]={0.0,PI/2.0},ztd,var; 43 | int j,k=DPIT(&rtk->opt),nx=rtk->nx; 44 | 45 | if (rtk->x[k]==0.0) { 46 | ecef2pos(rtk->sol.rr,pos); 47 | /* zenith total tropospheric delay (m) */ 48 | ztd=tropMops(rtk->sol.time,pos,azel,&var); 49 | userInitX_dp(rtk,ztd,var,k); 50 | if (opt->tropopt==TROPOPT_ESTG) { 51 | for (j=k+1;jP[k*(nx+1)]+=opt->prn[1]*fabs(rtk->tt); 56 | if (opt->tropopt==TROPOPT_ESTG) { 57 | for (j=k+1;jP[j*(nx+1)]+=SQR(0.1)*opt->prn[1]*fabs(rtk->tt); 59 | } 60 | } 61 | } 62 | } 63 | /* temporal update of ambiguity ----------------------------------------------*/ 64 | static void udAmb(rtk_t *rtk, const obsd_t *obs, int n) 65 | { 66 | prcopt_t *opt=&rtk->opt; 67 | int i,k1,k2,sat,slip,clk_jump=0; 68 | 69 | /* handle day-boundary clock jump, our decoupled clocks are not is 70 | discontinuous, so clk_jump is necessary */ 71 | clk_jump=ROUND(time2gpst(obs[0].time,NULL)*10)%864000==0; 72 | 73 | /* reset phase-bias if expire obs outage counter */ 74 | for (i=0;issat[i].outc[0]>MAX_SAT_OUTC||opt->modear==ARMODE_INST|| 76 | clk_jump) { 77 | userInitX_dp(rtk,0.0,0.0,DPIB(i+1,1,opt)); /* narr */ 78 | userInitX_dp(rtk,0.0,0.0,DPIB(i+1,2,opt)); /* wide */ 79 | } 80 | } 81 | 82 | for (i=0;issat[sat-1].slip[0]||rtk->ssat[sat-1].slip[1]; 86 | 87 | k1=DPIB(sat,1,opt); k2=DPIB(sat,2,opt); 88 | if ((rtk->x[k1]!=0.0)&&(rtk->x[k2]!=0.0)&&!slip) { 89 | rtk->P[k1*(rtk->nx+1)]+=rtk->opt.prn[3]*fabs(rtk->tt); 90 | rtk->P[k2*(rtk->nx+1)]+=rtk->opt.prn[3]*fabs(rtk->tt); 91 | continue; 92 | } 93 | userInitX_dp(rtk,0.0,0.0,k1); 94 | userInitX_dp(rtk,0.0,0.0,k2); 95 | } 96 | } 97 | /* temporal update of states -------------------------------------------------*/ 98 | extern void userUdStates_dp(rtk_t *rtk, const obsd_t *obs, int n, 99 | const nav_t *nav) 100 | { 101 | trace(3,"userUdStates_dp: n=%d\n",n); 102 | 103 | /* temporal update of position */ 104 | udPos(rtk); 105 | 106 | /* temporal update of troposphere */ 107 | if (rtk->opt.tropopt==TROPOPT_EST||rtk->opt.tropopt==TROPOPT_ESTG) { 108 | udTrop(rtk); 109 | } 110 | 111 | /* temporal update of ambiguity */ 112 | udAmb(rtk,obs,n); 113 | } -------------------------------------------------------------------------------- /src/user/userCmnPPP.c: -------------------------------------------------------------------------------- 1 | 2 | #include "user.h" 3 | 4 | #define MIN_NSAT_SOL 4 /* min satellite number for solution */ 5 | 6 | /* set ambiguity datum or check datum for ppp --------------------------------*/ 7 | extern void userSetAmbDatum(const rtk_t *rtk, const obsd_t *obs, int n, 8 | const int *exc, const double *azel, int *datum) 9 | { 10 | double satel[MAXOBS]={0}; 11 | int i,j,sat,slip; 12 | 13 | if (datum[MAXSAT]) return; 14 | 15 | /* get datum sat */ 16 | for (i=sat=0;issat[sat-1].slip[0]||rtk->ssat[sat-1].slip[1]; 22 | for (i=0,j=-1;iopt; 47 | double dantr[NFREQ]={0},dants[NFREQ]={0}; 48 | const int sat=obs->sat; 49 | 50 | /* satellite and receiver antenna model */ 51 | satantpcv(rs,rr,nav->pcvs+sat-1,dants); 52 | antmodel(opt->pcvr,opt->antdel[0],azel,1,dantr); 53 | 54 | /* phase windup model */ 55 | windupcorr(rtk->sol.time,rs,rr,&rtk->ssat[sat-1].phw); 56 | 57 | /* corrected phase and code measurements */ 58 | corr_meas(obs,nav,azel,opt,dantr,dants,rtk->ssat[sat-1].phw,L,P,Lc,Pc); 59 | } 60 | /* update solution status ----------------------------------------------------*/ 61 | extern void userUdSolution(rtk_t *rtk, const obsd_t *obs, int n, int stat) 62 | { 63 | const prcopt_t *opt=&rtk->opt; 64 | int i,j; 65 | 66 | /* test # of valid satellites */ 67 | rtk->sol.ns=0; 68 | for (i=0;inf;j++) { 70 | if (!rtk->ssat[obs[i].sat-1].vsat[j]) continue; 71 | rtk->ssat[obs[i].sat-1].lock[j]++; 72 | rtk->ssat[obs[i].sat-1].outc[j]=0; 73 | if (j==0) rtk->sol.ns++; 74 | } 75 | } 76 | rtk->sol.stat=rtk->sol.nssol.stat==SOLQ_FIX) { 79 | for (i=0;i<3;i++) { 80 | rtk->sol.rr[i]=rtk->xa[i]; 81 | rtk->sol.qr[i]=(float)rtk->Pa[i+i*rtk->na]; 82 | } 83 | rtk->sol.qr[3]=(float)rtk->Pa[1]; 84 | rtk->sol.qr[4]=(float)rtk->Pa[1+2*rtk->na]; 85 | rtk->sol.qr[5]=(float)rtk->Pa[2]; 86 | } 87 | else { 88 | for (i=0;i<3;i++) { 89 | rtk->sol.rr[i]=rtk->x[i]; 90 | rtk->sol.qr[i]=(float)rtk->P[i+i*rtk->nx]; 91 | } 92 | rtk->sol.qr[3]=(float)rtk->P[1]; 93 | rtk->sol.qr[4]=(float)rtk->P[2+rtk->nx]; 94 | rtk->sol.qr[5]=(float)rtk->P[2]; 95 | rtk->nfix=0; 96 | } 97 | //rtk->sol.dtr[0]=rtk->x[IC(0,opt)]; 98 | //rtk->sol.dtr[1]=rtk->x[IC(1,opt)]-rtk->x[IC(0,opt)]; 99 | 100 | for (i=0;inf;j++) { 101 | rtk->ssat[obs[i].sat-1].snr[j]=obs[i].SNR[j]; 102 | } 103 | for (i=0;inf;j++) { 104 | if (rtk->ssat[i].slip[j]&3) rtk->ssat[i].slipc[j]++; 105 | if (rtk->ssat[i].fix[j]==2&&stat!=SOLQ_FIX) rtk->ssat[i].fix[j]=1; 106 | } 107 | } 108 | /* initialize state and covariance -------------------------------------------*/ 109 | extern void userInitX_dp(rtk_t *rtk, double xi, double var, int i) 110 | { 111 | int j; 112 | rtk->x[i]=xi; 113 | for (j=0;jnx;j++) { 114 | rtk->P[i+j*rtk->nx]=rtk->P[j+i*rtk->nx]=i==j?var:0.0; 115 | } 116 | } -------------------------------------------------------------------------------- /src/user/dckp/userPPPos_dp.c: -------------------------------------------------------------------------------- 1 | 2 | #include "dckp.h" 3 | 4 | #define MAX_ITER 8 /* max number of iterations */ 5 | 6 | /* number of estimated states ------------------------------------------------*/ 7 | extern int userPPPnx_dp(const prcopt_t *opt) 8 | { 9 | return DPNX(opt); 10 | } 11 | /* not estimate datum parameters -----------------------------------------------*/ 12 | static void rejEstAmbDatum(const rtk_t *rtk, const int *datum, int *ix) 13 | { 14 | const prcopt_t *opt=&rtk->opt; 15 | int i,k,sat; 16 | 17 | if (datum[MAXSAT]) return; 18 | 19 | /* get datum sat */ 20 | for (i=sat=0;iopt; 34 | double *xp,*Pp,*vl,*HL,*DL,*vp,*HP,*DP; 35 | double *rs,*dts,*vars,*varc,*azel,dr[3]={0}; 36 | const int nx=rtk->nx; 37 | int svh[MAXOBS],exc[MAXOBS]={0},datum[MAXSAT+1],stat=SOLQ_SINGLE; 38 | int i,j,nv,nc,info,*ix; 39 | 40 | trace(3,"userPPPos_dp: time=%s nx=%d n=%d\n",rtk->cTime,nx,n); 41 | 42 | rs=mat(6,n);dts=mat(3,n);vars=mat(1,n);varc=zeros(3,n);azel=zeros(2,n); 43 | 44 | for (i=0;inf;j++) rtk->ssat[i].fix[j]=0; 45 | 46 | userUdStates_dp(rtk,obs,n,nav); 47 | 48 | /* satellite positions and clocks */ 49 | sat_poss(obs[0].time,"ppp",obs,n,nav,rs,dts,vars,varc,svh); 50 | 51 | /* exclude measurements of eclipsing satellite (block IIA) */ 52 | testeclipse(obs,n,nav,rs); 53 | 54 | /* earth tides correction */ 55 | tidedisp(gpst2utc(obs[0].time),rtk->x,7,&nav->erp,opt->odisp[0],dr); 56 | 57 | nv=DPCK(opt)*n;nc=DPNX(opt); 58 | ix=imat(nx,1);xp=mat(nx,1);Pp=mat(nx,nx); 59 | vl=mat(nv,1);HL=mat(nx,nv);DL=mat(nv,nv); 60 | vp=mat(nc,1);HP=mat(nx,nc);DP=mat(nc,nc); 61 | 62 | for (i=0;ix,nx,1); 65 | matcpy(Pp,rtk->P,nx,nx); 66 | imatcpy(datum,rtk->datum,MAXSAT+1,1); 67 | 68 | /* prefit residuals */ 69 | if (!(nv=userPPPRes_dp(0,obs,n,rs,dts,vars,varc,svh,dr,exc,nav,xp,Pp, 70 | rtk,vl,HL,DL,vp,HP,DP,azel,ix,&nc))) { 71 | trace(2,"%s ppp (%d) no valid obs data\n",rtk->cTime,i+1); 72 | break; 73 | } 74 | 75 | /* set ambiguity datum for decoupled model */ 76 | userSetAmbDatum(rtk,obs,n,exc,azel,datum); 77 | /* not estimate datum parameters */ 78 | rejEstAmbDatum(rtk,datum,ix); 79 | 80 | /* measurement update of ekf states */ 81 | if ((info=lsqBlock(xp,Pp,ix,vl,HL,DL,vp,HP,DP,nx,nv,nc))) { 82 | trace(2,"%s ppp (%d) filter error info=%d\n",rtk->cTime,i+1,info); 83 | break; 84 | } 85 | 86 | /* get increment */ 87 | for (j=0;jx[j]; 88 | 89 | /* postfit residuals */ 90 | if (userPPPRes_dp(i+1,obs,n,rs,dts,vars,varc,svh,dr,exc,nav,xp,Pp,rtk, 91 | vl,HL,DL,vp,HP,DP,azel,ix,&nc)) { 92 | matcpy(rtk->x,xp,nx,1); 93 | matcpy(rtk->P,Pp,nx,nx); 94 | imatcpy(rtk->datum,datum,MAXSAT+1,1); 95 | stat=SOLQ_PPP; 96 | break; 97 | } 98 | } 99 | if (i>=MAX_ITER) { 100 | trace(2,"%s ppp (%d) iteration overflows\n",rtk->cTime,i); 101 | } 102 | if (stat==SOLQ_PPP) { 103 | if (userAmbResol_dp(rtk,obs,n,exc,azel,xp,Pp)&& 104 | userPPPRes_dp(MAX_ITER+1,obs,n,rs,dts,vars,varc,svh,dr,exc,nav,xp,Pp, 105 | rtk,vl,HL,DL,vp,HP,DP,azel,ix,&nc)) { 106 | matcpy(rtk->xa,xp,nx,1); 107 | matcpy(rtk->Pa,Pp,nx,nx); 108 | #if 0 109 | /* hold ambiguity */ 110 | matcpy(rtk->x,xp,nx,1); 111 | matcpy(rtk->P,Pp,nx,nx); 112 | #endif 113 | stat=SOLQ_FIX; 114 | } 115 | 116 | /* update solution status */ 117 | userUdSolution(rtk,obs,n,stat); 118 | logRclk_dp(rtk); 119 | logZtd_dp(rtk); 120 | logAmb_dp(rtk,obs,n); 121 | logRes_dp(rtk,obs,n); 122 | } 123 | free(rs);free(dts);free(vars);free(varc);free(azel); 124 | free(xp);free(Pp);free(ix); 125 | free(vl);free(HL);free(DL); 126 | free(vp);free(HP);free(DP); 127 | } 128 | -------------------------------------------------------------------------------- /src/user/userSession.c: -------------------------------------------------------------------------------- 1 | 2 | #include "user.h" 3 | 4 | 5 | /* open procssing session ----------------------------------------------------*/ 6 | extern int userOpenSession(const prcopt_t *popt, const filopt_t *fopt, 7 | nav_t *nav, pcvs_t *pcv) 8 | { 9 | gtime_t ptime[3]; 10 | char file[1024]; 11 | int i; 12 | 13 | trace(3,"userOpenSession:\n"); 14 | 15 | ptime[1]=popt->ts; 16 | ptime[0]=timeadd(ptime[1],-86400.0); 17 | ptime[2]=timeadd(ptime[1], 86400.0); 18 | 19 | /* read ephemeris files */ 20 | if (popt->ts.time>0) reppath(fopt->nav,file,popt->ts); 21 | else strcpy(file,fopt->nav); 22 | if (readrnx(file,0,"",NULL,nav,NULL)<0) { 23 | trace(1,"readnav insufficient memory\n"); 24 | return 0; 25 | } 26 | if (nav->n<=0&&nav->ng<=0&&nav->ns<=0) { 27 | trace(2,"no nav data\n"); 28 | return 0; 29 | } 30 | /* delete duplicated ephemeris */ 31 | uniqnav(nav); 32 | 33 | /* read dcoupled clock files */ 34 | if (popt->ts.time>0) reppath(fopt->clk,file,popt->ts); 35 | else strcpy(file,fopt->clk); 36 | if (popt->dck&&readdck(file,SYS_GPS,nav)<0) { 37 | trace(1,"readdck insufficient memory\n"); 38 | return 0; 39 | } 40 | /* read precise clock files */ 41 | if (!popt->dck&&!readrnxc(file,nav)) { 42 | trace(1,"readclk insufficient memory\n"); 43 | return 0; 44 | } 45 | if (nav->nc<=0) { 46 | trace(2,"no clk data\n"); 47 | return 0; 48 | } 49 | /* read precise ephemeris files */ 50 | #if 1 51 | if (popt->ts.time>0) for (i=0;i<3;i++) { 52 | reppath(fopt->sp3,file,ptime[i]); 53 | fprintf(stdout,"read: %s\n",file); 54 | readsp3(file,nav,0); 55 | } 56 | else { 57 | strcpy(file,fopt->sp3); 58 | fprintf(stdout,"read: %s\n",file); 59 | readsp3(file,nav,0); 60 | } 61 | #else 62 | if (popt->ts.time>0) reppath(fopt->sp3,file,popt->ts); 63 | else strcpy(file,fopt->sp3); 64 | readsp3(file,nav,0); 65 | #endif 66 | if (nav->ne<=0) { 67 | trace(2,"no sp3 data\n"); 68 | return 0; 69 | } 70 | /* read code bias file */ 71 | if (popt->ts.time>0) reppath(fopt->cob,file,popt->ts); 72 | else strcpy(file,fopt->cob); 73 | if (popt->scb&&!readcob(file,1,popt->nf,nav)) { 74 | trace(2,"read code bias file error\n"); 75 | return 0; 76 | } 77 | /* read carrier-phase bias */ 78 | if (popt->ts.time>0) reppath(fopt->bis,file,popt->ts); 79 | else strcpy(file,fopt->bis); 80 | if (popt->ionoopt==IONOOPT_EST&&popt->modear>ARMODE_OFF&& 81 | !readBias(file,1,nav)) { 82 | trace(2,"read carrier-phase bias error\n"); 83 | return 0; 84 | } 85 | /* read receiver and satellite antenna parameters */ 86 | if (*fopt->atx&&!readpcv(fopt->atx,pcv)) { 87 | trace(2,"sat antenna pcv read error: %s\n",fopt->atx); 88 | return 0; 89 | } 90 | /* use satellite L2 offset if L5 offset does not exists */ 91 | for (i=0;in;i++) { 92 | if (norm(pcv->pcv[i].off[2],3)>0.0) continue; 93 | matcpy(pcv->pcv[i].off[2],pcv->pcv[i].off[1],3,1); 94 | matcpy(pcv->pcv[i].var[2],pcv->pcv[i].var[1],19,1); 95 | } 96 | 97 | /* read erp data */ 98 | if (popt->ts.time>0) reppath(fopt->erp,file,popt->ts); 99 | else strcpy(file,fopt->erp); 100 | if (file&&!readerp(file,&nav->erp)) { 101 | trace(2,"no erp data %s\n",file); 102 | return 0; 103 | } 104 | /* read dcb parameters */ 105 | if (popt->ts.time>0) reppath(fopt->dcb,file,popt->ts); 106 | else strcpy(file,fopt->dcb); 107 | if (file&&!readdcb(file,nav,NULL)) { 108 | trace(2,"no dcb data %s\n",file); 109 | return 0; 110 | } 111 | 112 | return 1; 113 | } 114 | /* close procssing session ---------------------------------------------------*/ 115 | extern void userCloseSession(nav_t *nav,pcvs_t *pcv) 116 | { 117 | trace(3,"closeses:\n"); 118 | 119 | free(nav->eph ); nav->eph =NULL; nav->n =nav->nmax =0; 120 | free(nav->geph); nav->geph=NULL; nav->ng=nav->ngmax=0; 121 | free(nav->seph); nav->seph=NULL; nav->ns=nav->nsmax=0; 122 | free(nav->peph); nav->peph=NULL; nav->ne=nav->nemax=0; 123 | free(nav->pclk); nav->pclk=NULL; nav->nc=nav->ncmax=0; 124 | free(nav->tec) ; nav->tec =NULL; nav->nt=nav->ntmax=0; 125 | free(nav->bias); nav->bias=NULL; nav->nb=nav->nbmax=0; 126 | free(nav->ucd); nav->ucd =NULL; nav->nd=nav->ndmax=0; 127 | free(nav->erp.data); nav->erp.data=NULL; nav->erp.n=nav->erp.nmax=0; 128 | 129 | free(pcv->pcv); pcv->pcv=NULL; pcv->n=pcv->nmax=0; 130 | 131 | /* close solution statistics and debug trace */ 132 | //closeOutSolution(); 133 | //traceclose(); 134 | } -------------------------------------------------------------------------------- /src/io/readrnx_clk.c: -------------------------------------------------------------------------------- 1 | 2 | #include "io.h" 3 | 4 | /* compare precise clock -----------------------------------------------------*/ 5 | static int cmppclk(const void *p1, const void *p2) 6 | { 7 | pclk_t *q1=(pclk_t *)p1,*q2=(pclk_t *)p2; 8 | double tt=timediff(q1->time,q2->time); 9 | return tt<-1E-9?-1:(tt>1E-9?1:q1->index-q2->index); 10 | } 11 | /* combine precise clock -----------------------------------------------------*/ 12 | static void combpclk(nav_t *nav) 13 | { 14 | pclk_t *nav_pclk; 15 | int i,j,k; 16 | 17 | trace(3,"combpclk: nc=%d\n",nav->nc); 18 | 19 | if (nav->nc<=0) return; 20 | 21 | qsort(nav->pclk,nav->nc,sizeof(pclk_t),cmppclk); 22 | 23 | for (i=0,j=1;jnc;j++) { 24 | if (fabs(timediff(nav->pclk[i].time,nav->pclk[j].time))<1E-9) { 25 | for (k=0;kpclk[j].clk[k][0]==0.0) continue; 27 | nav->pclk[i].clk[k][0]=nav->pclk[j].clk[k][0]; 28 | nav->pclk[i].std[k][0]=nav->pclk[j].std[k][0]; 29 | } 30 | } 31 | else if (++ipclk[i]=nav->pclk[j]; 32 | } 33 | nav->nc=i+1; 34 | 35 | if (!(nav_pclk=(pclk_t *)realloc(nav->pclk,sizeof(pclk_t)*nav->nc))) { 36 | free(nav->pclk); nav->pclk=NULL; nav->nc=nav->ncmax=0; 37 | trace(1,"combpclk malloc error nc=%d\n",nav->nc); 38 | return; 39 | } 40 | nav->pclk=nav_pclk; 41 | nav->ncmax=nav->nc; 42 | 43 | trace(4,"combpclk: nc=%d\n",nav->nc); 44 | } 45 | /* read RINEX clock ----------------------------------------------------------*/ 46 | extern int readrnxclk(FILE *fp, const char *opt, int index, nav_t *nav) 47 | { 48 | pclk_t *nav_pclk; 49 | gtime_t time; 50 | double data[2]; 51 | int i,j,sat,mask; 52 | char buff[MAXRNXLEN],satid[8]=""; 53 | 54 | trace(3,"readrnxclk: index=%d\n", index); 55 | 56 | if (!nav) return 0; 57 | 58 | /* set system mask */ 59 | mask=set_sysmask(opt); 60 | 61 | while (fgets(buff,sizeof(buff),fp)) { 62 | 63 | if (str2time(buff,8,26,&time)) { 64 | trace(2,"rinex clk invalid epoch: %34.34s\n",buff); 65 | continue; 66 | } 67 | strncpy(satid,buff+3,4); 68 | 69 | /* only read AS (satellite clock) record */ 70 | if (strncmp(buff,"AS",2)||!(sat=satid2no(satid))) continue; 71 | 72 | if (!(satsys(sat,NULL)&mask)) continue; 73 | 74 | for (i=0,j=40;i<2;i++,j+=20) data[i]=str2num(buff,j,19); 75 | 76 | if (nav->nc>=nav->ncmax) { 77 | nav->ncmax+=1024; 78 | if (!(nav_pclk=(pclk_t *)realloc(nav->pclk,sizeof(pclk_t)*(nav->ncmax)))) { 79 | trace(1,"readrnxclk malloc error: nmax=%d\n",nav->ncmax); 80 | free(nav->pclk); nav->pclk=NULL; nav->nc=nav->ncmax=0; 81 | return -1; 82 | } 83 | nav->pclk=nav_pclk; 84 | } 85 | if (nav->nc<=0||fabs(timediff(time,nav->pclk[nav->nc-1].time))>1E-9) { 86 | nav->nc++; 87 | nav->pclk[nav->nc-1].time =time; 88 | nav->pclk[nav->nc-1].index=index; 89 | for (i=0;ipclk[nav->nc-1].clk[i][0]=0.0; 91 | nav->pclk[nav->nc-1].std[i][0]=0.0f; 92 | } 93 | } 94 | nav->pclk[nav->nc-1].clk[sat-1][0]=data[0]; 95 | nav->pclk[nav->nc-1].std[sat-1][0]=(float)data[1]; 96 | } 97 | return nav->nc>0; 98 | } 99 | /* read RINEX clock files ------------------------------------------------------ 100 | * read RINEX clock files 101 | * args : char *file I file (wild-card * expanded) 102 | * nav_t *nav IO navigation data (NULL: no input) 103 | * return : number of precise clock 104 | *-----------------------------------------------------------------------------*/ 105 | extern int readrnxc(const char *file, nav_t *nav) 106 | { 107 | gtime_t t={0}; 108 | int i,n,index=0,stat=1; 109 | char *files[MAXEXFILE]={0},type; 110 | 111 | trace(3,"readrnxc: file=%s\n",file); 112 | 113 | for (i=0;i=0;i--) free(files[i]); 116 | return 0; 117 | } 118 | } 119 | /* expand wild-card */ 120 | n=expath(file,files,MAXEXFILE); 121 | 122 | /* read rinex clock files */ 123 | for (i=0;inc; 138 | } -------------------------------------------------------------------------------- /src/io/io.h: -------------------------------------------------------------------------------- 1 | #ifndef _IO_H 2 | #define _IO_H 3 | 4 | #include "base/base.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif /* __cplusplus */ 9 | 10 | #ifdef WIN_DLL 11 | #define EXPORT __declspec(dllexport) /* for Windows DLL */ 12 | #else 13 | #define EXPORT 14 | #endif /* WIN_DLL */ 15 | 16 | #define NAVEXP "D" /* exponent letter in RINEX NAV */ 17 | #define NUMSYS 7 /* number of systems */ 18 | #define MAXRNXLEN (16*MAXOBSTYPE+4) /* max RINEX record length */ 19 | #define MAXPOSHEAD 1024 /* max head line position */ 20 | #define MINFREQ_GLO -7 /* min frequency number GLONASS */ 21 | #define MAXFREQ_GLO 13 /* max frequency number GLONASS */ 22 | #define NINCOBS 262144 /* incremental number of obs data */ 23 | 24 | 25 | /* options.c */ 26 | EXPORT opt_t sysopts[]; /* system options table */ 27 | EXPORT opt_t *searchopt(const char *name, const opt_t *opts); 28 | EXPORT int str2opt(opt_t *opt, const char *str); 29 | EXPORT int opt2str(const opt_t *opt, char *str); 30 | EXPORT int opt2buf(const opt_t *opt, char *buff); 31 | EXPORT int loadopts(const char *file, opt_t *opts); 32 | EXPORT int saveopts(const char *file, const char *mode, const char *comment, 33 | const opt_t *opts); 34 | EXPORT void resetsysopts(void); 35 | EXPORT void getsysopts(prcopt_t *popt, solopt_t *sopt, filopt_t *fopt); 36 | EXPORT void setsysopts(const prcopt_t *prcopt, const solopt_t *solopt, 37 | const filopt_t *filopt); 38 | 39 | 40 | /* readblq.c */ 41 | EXPORT int readblq(const char* file, const char* sta, double* odisp); 42 | EXPORT void readotl_pos(prcopt_t *popt, const char *file, const sta_t *sta); 43 | 44 | /* readclk.c */ 45 | //EXPORT int readrnxc(const char* file, const int mask, nav_t* nav); 46 | 47 | /* readdcb.c */ 48 | EXPORT int readdcb(const char* file, nav_t* nav, const sta_t* sta); 49 | 50 | /* readerp.c */ 51 | EXPORT int readerp(const char* file, erp_t* erp); 52 | 53 | /* readpcv.c */ 54 | EXPORT int readpcv(const char* file, pcvs_t* pcvs); 55 | 56 | /* readsnx.c */ 57 | 58 | 59 | /* readsp3.c -----------------------------------------------------------------*/ 60 | EXPORT void combpeph(nav_t* nav, int opt); 61 | EXPORT void readsp3(const char *file, nav_t *nav, int opt); 62 | 63 | /* readtec.c -----------------------------------------------------------------*/ 64 | EXPORT int readtec(const char *file, nav_t *nav, int opt); 65 | 66 | 67 | /* readrnx.c -----------------------------------------------------------------*/ 68 | EXPORT void uniqnav(nav_t *nav); 69 | EXPORT int sortobs(obs_t *obs); 70 | EXPORT int screent(gtime_t time, gtime_t ts, gtime_t te, double tint); 71 | EXPORT int set_sysmask(const char *opt); 72 | EXPORT int readrnxfile(const char *file, gtime_t ts, gtime_t te, double tint, 73 | const char *opt, int flag, int index, char *type, obs_t *obs, nav_t *nav, 74 | sta_t *sta); 75 | EXPORT int readrnxt(const char *file, int rcv, gtime_t ts, gtime_t te, 76 | double tint, const char *opt, obs_t *obs, nav_t *nav, sta_t *sta); 77 | EXPORT int readrnx(const char *file, int rcv, const char *opt, obs_t *obs, 78 | nav_t *nav, sta_t *sta); 79 | EXPORT int readrnxh(FILE *fp, double *ver, char *type, int *sys, int *tsys, 80 | char tobs[][MAXOBSTYPE][4], nav_t *nav, sta_t *sta); 81 | 82 | /* readrnx_nav.c -------------------------------------------------------------*/ 83 | EXPORT void decode_navh(char *buff, nav_t *nav); 84 | EXPORT void decode_gnavh(char *buff, nav_t *nav); 85 | EXPORT void decode_hnavh(char *buff, nav_t *nav); 86 | EXPORT int readrnxnav(FILE *fp, const char *opt, double ver, int sys, nav_t *nav); 87 | 88 | /* readrnx_obs.c -------------------------------------------------------------*/ 89 | EXPORT void decode_obsh(FILE *fp, char *buff, double ver, int *tsys, 90 | char tobs[][MAXOBSTYPE][4], nav_t *nav, sta_t *sta); 91 | EXPORT int readrnxobs(FILE *fp, gtime_t ts, gtime_t te, double tint, 92 | const char *opt, int rcv, double ver, int *tsys, char tobs[][MAXOBSTYPE][4], 93 | obs_t *obs, sta_t *sta); 94 | EXPORT int readrnxobsb(FILE *fp, const char *opt, double ver, int *tsys, 95 | char tobs[][MAXOBSTYPE][4], int *flag, obsd_t *data, sta_t *sta); 96 | EXPORT void saveslips(uint8_t slips[][NFREQ+NEXOBS], obsd_t *data); 97 | EXPORT void restslips(uint8_t slips[][NFREQ+NEXOBS], obsd_t *data); 98 | 99 | /* readrnx_clk.c -------------------------------------------------------------*/ 100 | EXPORT int readrnxclk(FILE *fp, const char *opt, int index, nav_t *nav); 101 | EXPORT int readrnxc(const char *file, nav_t *nav); 102 | 103 | /* readdck.c -----------------------------------------------------------------*/ 104 | EXPORT int readdck(const char *file, const int mask, nav_t *nav); 105 | 106 | /* readBias.c ----------------------------------------------------------------*/ 107 | EXPORT int readBias(const char *file, const int mask, nav_t *nav); 108 | 109 | /* readcob.c -----------------------------------------------------------------*/ 110 | EXPORT int readcob(const char *file, int mask, int nf, nav_t *nav); 111 | 112 | #ifdef __cplusplus 113 | } 114 | #endif /* __cplusplus */ 115 | #endif /* _IO_H */ 116 | -------------------------------------------------------------------------------- /src/qc/detCycleSlip.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "qc.h" 4 | 5 | #define MIN(x,y) ((x)<(y)?(x):(y)) 6 | 7 | /* set gf coefficient (m) ----------------------------------------------------*/ 8 | static double GFCoef(const double tint) 9 | { 10 | if (tint<= 1.0) return 0.05; 11 | else if (tint<= 20.0) return (0.1/20.0*tint+0.05); 12 | else if (tint<= 60.0) return 0.15; 13 | else if (tint<= 100.0) return 0.25; 14 | else return 0.35; 15 | } 16 | /* set mw coefficient (cycle) ------------------------------------------------*/ 17 | static double MWCoef(const double tint) 18 | { 19 | if (tint<= 1.0) return 2.5; 20 | else if (tint<=20.0) return (2.5/20.0*tint+2.5); 21 | else if (tint<=60.0) return 5.0; 22 | else return 7.5; 23 | } 24 | /* L1/L2 geometry-free phase measurement -------------------------------------*/ 25 | static double GFMeas(const obsd_t *obs, const nav_t *nav) 26 | { 27 | double freq1,freq2; 28 | 29 | freq1=sat2freq(obs->sat,obs->code[0],nav); 30 | freq2=sat2freq(obs->sat,obs->code[1],nav); 31 | if (freq1==0.0||freq2==0.0||obs->L[0]==0.0||obs->L[1]==0.0) return 0.0; 32 | return (obs->L[0]/freq1-obs->L[1]/freq2)*CLIGHT; 33 | } 34 | /* L1/L2 wide-lane phase measurement -----------------------------------------*/ 35 | static double MWMeas(const obsd_t *obs, const nav_t *nav) 36 | { 37 | double freq1,freq2; 38 | 39 | freq1=sat2freq(obs->sat,obs->code[0],nav); 40 | freq2=sat2freq(obs->sat,obs->code[1],nav); 41 | 42 | if (freq1==0.0||freq2==0.0||obs->L[0]==0.0||obs->L[1]==0.0|| 43 | obs->P[0]==0.0||obs->P[1]==0.0) return 0.0; 44 | 45 | return (obs->L[0]-obs->L[1])- 46 | (freq1-freq2)/CLIGHT*(freq1*obs->P[0]+freq2*obs->P[1])/(freq1+freq2); 47 | } 48 | /* detect cycle slip by LLI --------------------------------------------------*/ 49 | static void detCycleSlip_LLI(const prcopt_t *opt, ssat_t *ssat, const obsd_t *obs, 50 | const int n, const char *rcv) 51 | { 52 | int i,j; 53 | 54 | trace(4,"detslp_ll: n=%d\n",n); 55 | 56 | for (i=0;ielmin*R2D) continue; 77 | thres=elev>15.0?gfcoef:(-elev/15.0+2)*gfcoef; 78 | thres=MIN(thres,1.5); 79 | 80 | g0=ssat[sat-1].gf; 81 | if (g0!=0.0&&fabs(g1-g0)>thres) 82 | { 83 | for (j=0;jelmin*R2D) continue; 104 | thres=elev>20.0?mwcoef:(-0.1*elev+3)*mwcoef; 105 | thres=MIN(thres,6.0); 106 | 107 | w0=ssat[sat-1].mw; 108 | if (w0!=0.0&&fabs(w1-w0)>thres) { 109 | for (j=0;jMIN_ARC_GAP) { 117 | ssat[sat-1].mw=0.0; 118 | ssat[sat-1].imw=0; 119 | } 120 | if(ssat[sat-1].imw==0) { 121 | ssat[sat-1].mw=w1; 122 | ssat[sat-1].imw++; 123 | ssat[sat-1].pt[0][0]=obs[i].time; 124 | } 125 | else { 126 | j=ssat[sat-1].imw; 127 | ssat[sat-1].mw=(w0*j+w1)/((double)j+1); 128 | ssat[sat-1].imw++; 129 | ssat[sat-1].pt[0][0]=obs[i].time; 130 | } 131 | } 132 | } 133 | /* detect cycle slip ---------------------------------------------------------*/ 134 | extern void detCycleSlip(const prcopt_t *opt, ssat_t *ssat, obsd_t *obs, 135 | const int n, const nav_t *nav, const char *rcv, const double tt, int *jumpc) 136 | { 137 | int i,j; 138 | 139 | for (i=0;iopt.mode==PMODE_PPP_FIXED) { 21 | for (i=0;i<3;i++) userInitX_dp(rtk,rtk->opt.ru[i],1E-8,i); 22 | return; 23 | } 24 | /* initialize position for first epoch */ 25 | if (norm(rtk->x,3)<=0.0) { 26 | for (i=0;i<3;i++) userInitX_dp(rtk,rtk->sol.rr[i],VAR_POS,i); 27 | } 28 | /* static ppp mode */ 29 | if (rtk->opt.mode==PMODE_PPP_STATIC) { 30 | for (i=0;i<3;i++) { 31 | rtk->P[i*(1+rtk->nx)]+=rtk->opt.prn[0]*fabs(rtk->tt); 32 | } 33 | return; 34 | } 35 | /* kinmatic mode */ 36 | for (i=0;i<3;i++) userInitX_dp(rtk,rtk->sol.rr[i],VAR_POS,i); 37 | } 38 | /* temporal update of tropospheric parameters --------------------------------*/ 39 | static void udTrop(rtk_t *rtk) 40 | { 41 | const prcopt_t *opt=&rtk->opt; 42 | double pos[3],azel[]={0.0,PI/2.0},ztd,var; 43 | int j,k=PIT(&rtk->opt),nx=rtk->nx; 44 | 45 | if (rtk->x[k]==0.0) { 46 | ecef2pos(rtk->sol.rr,pos); 47 | /* zenith total tropospheric delay (m) */ 48 | ztd=tropMops(rtk->sol.time,pos,azel,&var); 49 | userInitX_dp(rtk,ztd,var,k); 50 | if (opt->tropopt==TROPOPT_ESTG) { 51 | for (j=k+1;jP[k*(nx+1)]+=opt->prn[1]*fabs(rtk->tt); 56 | if (opt->tropopt==TROPOPT_ESTG) { 57 | for (j=k+1;jP[j*(nx+1)]+=SQR(0.1)*opt->prn[1]*fabs(rtk->tt); 59 | } 60 | } 61 | } 62 | } 63 | /* temporal update of ionospheric parameters ----------------------------------- 64 | * notes : constrains in lsq filter determine the parameter estimation method 65 | * in udIon, ion can be estimated as white noise or random walk 66 | * stats-prnion < 0.0 means ion is esitmated as white noise 67 | * more details in userPPPRes_p 68 | * ----------------------------------------------------------------------------*/ 69 | static void udIon(rtk_t *rtk, const obsd_t *obs, int n) 70 | { 71 | int i,k; 72 | 73 | for (i=0;iopt); 75 | if (rtk->x[k]!=0.0&&(int)rtk->ssat[obs[i].sat-1].outc[0]>GAP_RESION) { 76 | userInitX_dp(rtk,0.0,0.0,k); 77 | } 78 | else rtk->P[k*(rtk->nx+1)]+=rtk->opt.prn[2]*fabs(rtk->tt); 79 | } 80 | } 81 | /* temporal update of ambiguity ----------------------------------------------*/ 82 | static void udAmb(rtk_t *rtk, const obsd_t *obs, int n) 83 | { 84 | prcopt_t *opt=&rtk->opt; 85 | int i,j,f,sat,slip,clk_jump=0; 86 | 87 | /* handle day-boundary clock jump, our decoupled clocks are not is 88 | discontinuous, so clk_jump is necessary */ 89 | clk_jump=ROUND(time2gpst(obs[0].time,NULL)*10)%864000==0; 90 | 91 | for (f=0;fssat[i].outc[f]>MAX_SAT_OUTC|| 95 | opt->modear==ARMODE_INST||clk_jump) { 96 | userInitX_dp(rtk,0.0,0.0,PIB(i+1,f+1,opt)); 97 | } 98 | } 99 | 100 | for (i=0;iionoopt==IONOOPT_IFLC) { 104 | slip=rtk->ssat[sat-1].slip[0]||rtk->ssat[sat-1].slip[1]; 105 | } 106 | else slip=rtk->ssat[sat-1].slip[f]; 107 | 108 | j=PIB(sat,f+1,opt); 109 | /* x!=0.0 and not slip */ 110 | if (rtk->x[j]!=0.0&&!slip) { 111 | rtk->P[j*(rtk->nx+1)]+=rtk->opt.prn[3]*fabs(rtk->tt); 112 | continue; 113 | } 114 | userInitX_dp(rtk,0.0,0.0,j); 115 | } 116 | } 117 | } 118 | /* temporal update of receiver phase bias ------------------------------------*/ 119 | static void udBias(rtk_t *rtk) 120 | { 121 | int i,j; 122 | 123 | for (i=0;iopt);i++) { 124 | j=PID(i+1,&rtk->opt); 125 | if (rtk->x[j]!=0.0) { 126 | rtk->P[j*(rtk->nx+1)]+=rtk->opt.prn[4]*fabs(rtk->tt); 127 | } 128 | } 129 | } 130 | /* temporal update of states -------------------------------------------------*/ 131 | extern void userUdStates_p(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) 132 | { 133 | trace(3,"userUdStates_p: n=%d\n",n); 134 | 135 | /* temporal update of position */ 136 | udPos(rtk); 137 | 138 | /* temporal update of troposphere */ 139 | if (rtk->opt.tropopt==TROPOPT_EST|| 140 | rtk->opt.tropopt==TROPOPT_ESTG) udTrop(rtk); 141 | 142 | /* temporal update of ionosphere */ 143 | if (rtk->opt.ionoopt==IONOOPT_EST) udIon(rtk,obs,n); 144 | 145 | /* temporal update of ambiguity */ 146 | udAmb(rtk,obs,n); 147 | 148 | /* temporal update of phase-bias */ 149 | if (UCK(&rtk->opt)) udBias(rtk); 150 | } -------------------------------------------------------------------------------- /src/user/ppp/userAmbResol_cnes2.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * userAmbResol_cnes.c : ppp ambiguity resolution based cnes model 3 | *-----------------------------------------------------------------------------*/ 4 | 5 | #include "ppp.h" 6 | 7 | #define CONST_AMB 0.001 /* constraint to fixed ambiguity */ 8 | #define SQR(x) ((x)*(x)) 9 | #define SQRT(x) ((x)<=0.0||(x)!=(x)?0.0:sqrt(x)) 10 | #define ROUND(x) (int)floor((x)+0.5) 11 | #define MIN(x,y) ((x)<(y)?(x):(y)) 12 | 13 | #define MIN_RATIO 2.0 /* ratio threshold */ 14 | #define MIN_SUCRATE 0.99 /* success rate threshold */ 15 | #define MIN_AMB_PAIR 4 /* min ambiguity pairs, sat difference */ 16 | #define MAX_POS_STD_TO_FIX 0.5 /* ar when position std less than 0.5 */ 17 | #define MAX_AMB_STD_TO_FIX 1.5 /* ar when amb std less than 1.5 */ 18 | #define MAX_AMB_ROUND_STD 0.15 /* max ambiguity std cycle in round ar */ 19 | #define MAX_AMB_ROUND_FRAC 0.50 /* max difference from an integer drop cycle */ 20 | 21 | #define AMBID_IF 1 22 | #define MIN_ARC_GAP 300.0 /* min arc gap (s) */ 23 | 24 | 25 | /* fixed solution ------------------------------------------------------------*/ 26 | static int fix_sol(rtk_t *rtk, const int *sats, int n, double *x, double *P) 27 | { 28 | double *v,*H,*R; 29 | const int nx=rtk->nx; 30 | int i,j,info; 31 | 32 | if (n<=0) return 0; 33 | 34 | v=zeros(n,1); H=zeros(nx,n); R=zeros(n,n); 35 | /* constraints to fixed ambiguities */ 36 | for (i=0;iopt); 38 | v[i]=(double)rtk->amb[sats[i]-1].value[0]-x[j]; 39 | H[j+i*nx]=1.0; 40 | R[i+i*n]=SQR(CONST_AMB); 41 | } 42 | /* update states with constraints */ 43 | if ((info=filter(x,P,H,v,R,nx,n))) { 44 | trace(1,"filter error (info=%d)\n",info); 45 | free(v); free(H); free(R); 46 | return 0; 47 | } 48 | 49 | free(v); free(H); free(R); 50 | return 1; 51 | } 52 | /* fix narrow-lane ambiguity by ILS ------------------------------------------*/ 53 | static int fix_amb_ILS(rtk_t *rtk, const int *sats, int n, double *x, double *P) 54 | { 55 | double *a,*F,*Qa,test[2]; 56 | const int nx=rtk->nx; 57 | int i,j,stat=0,index[MAXOBS]={0}; 58 | 59 | for (i=0;iopt); 61 | } 62 | a=mat(n,1);Qa=mat(n,n);F=mat(n,2); 63 | /* obtain narr-lane ambiguity values and co-variances */ 64 | for (i=0;iopt.thresar[1]; 71 | /* integer least square */ 72 | if (!lambdaAR(n,2,a,Qa,F,test)) { 73 | trace(2,"lambda error\n"); 74 | } 75 | else { 76 | /* varidation by ratio-test */ 77 | if (test[0]opt.thresar[0]) { 78 | trace(2,"%s varidation error : n=%d ratio=%.2f rate=%.2f%%\n", 79 | rtk->cTime,n,test[0],test[1]*100.0); 80 | } 81 | else { 82 | stat=1; 83 | rtk->sol.ratio=(float)test[0]; 84 | rtk->sol.rate =(float)(test[1]*100.0); 85 | trace(2,"%s varidation ok : n=%d ratio=%.2f rate=%.2f%%\n", 86 | rtk->cTime,n,test[0],test[1]*100.0); 87 | } 88 | } 89 | 90 | if (stat) stat=fix_sol(rtk,sats,n,x,P); 91 | 92 | free(a);free(Qa);free(F); 93 | return stat?n:-1; 94 | } 95 | /* fixing narrow-lane ambiguities by lambda ----------------------------------*/ 96 | static int fixNarrAmb(rtk_t *rtk, int *sats, int n, double *x, double *P) 97 | { 98 | double std[MAXOBS]={0}; 99 | int i,j,k,m; 100 | 101 | /* record narrow-lane ambiguity std */ 102 | for (i=0;iopt); 104 | std[i]=SQRT(P[j+j*rtk->nx]); 105 | } 106 | 107 | m=n; 108 | while (1) { 109 | 110 | j=fix_amb_ILS(rtk,sats,m,x,P); 111 | if (j<0) { 112 | i=d_max(std,m); 113 | if (i<0) return 0; 114 | sats[i]=0; std[i]=0.0; 115 | 116 | for (i=k=0;icTime,m); 124 | return 0; 125 | } 126 | continue; 127 | } 128 | else if (j==0) return 0; 129 | else break; 130 | } 131 | 132 | return 1; 133 | } 134 | /* select ambiguities to fix -------------------------------------------------*/ 135 | static int selAmb(const rtk_t *rtk, const obsd_t *obs, int n, const int *exc, 136 | const double *azel, int *sats) 137 | { 138 | const prcopt_t *opt=&rtk->opt; 139 | double elmask; 140 | int i,sat,m; 141 | 142 | elmask=opt->elmaskar>0.0?opt->elmaskar:opt->elmin; 143 | for (i=m=0;idatum[obs[i].sat-1]) continue; 146 | 147 | sat=obs[i].sat; 148 | /* not fixing narrow-lane ambiguity if wide-lane not fixed */ 149 | if (!rtk->amb[sat-1].flag[1]) continue; 150 | sats[m]=obs[i].sat; 151 | m++; 152 | } 153 | 154 | if (mcTime,m); 156 | return 0; 157 | } 158 | 159 | return m; 160 | } 161 | /* ambiguity resolution in integer clock model -------------------------------*/ 162 | extern int userAmbResol_cnes2(rtk_t *rtk, const obsd_t *obs, int n, 163 | const int *exc, const double *azel, double *x, double *P) 164 | { 165 | int m,sats[MAXOBS]={0}; 166 | 167 | if (rtk->opt.modear==ARMODE_OFF) return 0; 168 | 169 | /* select ambiguity subset for ar */ 170 | if (!(m=selAmb(rtk,obs,n,exc,azel,sats))) return 0; 171 | 172 | if (!fixNarrAmb(rtk,sats,m,x,P)) return 0; 173 | 174 | /* 0:no fix, 1:fixed */ 175 | return 1; 176 | } 177 | -------------------------------------------------------------------------------- /src/user/ppp/ppp.h: -------------------------------------------------------------------------------- 1 | #ifndef _PPP_H 2 | #define _PPP_H 3 | 4 | #include "user/user.h" 5 | 6 | /* number and index of states */ 7 | #if 0 8 | #define NF(opt) ((opt)->ionoopt==IONOOPT_IFLC?1:(opt)->nf) 9 | #define NP(opt) ((opt)->dynamics?9:3) 10 | #define NC(opt) (NSYS) 11 | #define NT(opt) ((opt)->tropopttropopt==TROPOPT_EST?1:3)) 12 | #define NI(opt) ((opt)->ionoopt==IONOOPT_EST?MAXSAT:0) 13 | #define ND(opt) ((opt)->nf>=3?1:0) 14 | #define NR(opt) (NP(opt)+NC(opt)+NT(opt)+NI(opt)+ND(opt)) 15 | #define NB(opt) (NF(opt)*MAXSAT) 16 | #define NX(opt) (NR(opt)+NB(opt)) 17 | #define IC(s,opt) (NP(opt)+(s)) 18 | #define IT(opt) (NP(opt)+NC(opt)) 19 | #define II(s,opt) (NP(opt)+NC(opt)+NT(opt)+(s)-1) 20 | #define ID(opt) (NP(opt)+NC(opt)+NT(opt)+NI(opt)) 21 | #define IB(s,f,opt) (NR(opt)+MAXSAT*(f)+(s)-1) 22 | #else 23 | #define UCK(opt) (((opt)->ionoopt==IONOOPT_EST&&(opt)->modear>ARMODE_OFF)?1:0) 24 | #define PNF(opt) ((opt)->ionoopt==IONOOPT_IFLC?1:(opt)->nf) 25 | #define PNP(opt) (3) 26 | #define PNC(opt) (NSYS) 27 | #define PNT(opt) ((opt)->tropopttropopt==TROPOPT_EST?1:3)) 28 | #define PNI(opt) ((opt)->ionoopt==IONOOPT_EST?MAXSAT:0) 29 | #define PND(opt) (UCK(opt)?PNF(opt):0) 30 | #define PNR(opt) (PNP(opt)+PNC(opt)+PNT(opt)+PNI(opt)+PND(opt)) 31 | #define PNB(opt) (PNF(opt)*MAXSAT) 32 | #define PNX(opt) (PNR(opt)+PNB(opt)) 33 | 34 | #define PIC(s,opt) (PNP(opt)+(s-1)) /* s->sys (GPS:1) */ 35 | #define PIT(opt) (PNP(opt)+PNC(opt)) 36 | #define PII(s,opt) (PNP(opt)+PNC(opt)+PNT(opt)+(s)-1) 37 | #define PID(f,opt) (PNP(opt)+PNC(opt)+PNT(opt)+PNI(opt)+(f-1)) /* receiver phase bias */ 38 | #define PIB(s,f,opt) (PNR(opt)+(s-1)*PNF(opt)+(f-1)) 39 | #endif 40 | 41 | #define TRACE_PPP 0 42 | 43 | /* userPostpos_p.c -----------------------------------------------------------*/ 44 | extern int userPostPos_p(gtime_t ts, gtime_t te, double ti, double tu, 45 | const prcopt_t* popt, const solopt_t* sopt, const filopt_t* fopt); 46 | 47 | /* userRTKPos_p.c ------------------------------------------------------------*/ 48 | extern int userRTKPos_p(rtk_t *rtk, obsd_t *obs, int n, const nav_t *nav); 49 | 50 | /* userPPPos_p.c -------------------------------------------------------------*/ 51 | extern int userPPPnx_p(const prcopt_t *opt); 52 | extern void userPPPos_p(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav); 53 | 54 | /* userUdStates_p.c ----------------------------------------------------------*/ 55 | extern void userUdStates_p(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav); 56 | 57 | /* userMWEst_cnes.c ----------------------------------------------------------*/ 58 | extern void userMWEst_cnes(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav, 59 | const double *rs, const double *var_rs, const int *svh, const double *dr, 60 | int *exc); 61 | 62 | /* userMWAmbResol_cnes.c -----------------------------------------------------*/ 63 | extern int userMWAmbResol_cnes(rtk_t *rtk, const obsd_t *obs, int n, 64 | const int *exc, double *x, double *P); 65 | extern int userAmbResol_cnes2(rtk_t *rtk, const obsd_t *obs, int n, 66 | const int *exc, const double *azel, double *x, double *P); 67 | 68 | /* userPPPRes_p.c ------------------------------------------------------------*/ 69 | extern int userPPPRes_p(int post, const obsd_t *obs, int n, const double *rs, 70 | const double *dts, const double *var_rs, const double *var_dt, 71 | const int *svh, const double *dr, int *exc, const nav_t *nav, 72 | const double *xp, double *Pp, rtk_t *rtk, double *vl, double *HL, 73 | double *DL, double *vp, double *HP, double *DP, double *azel, int *ix, 74 | int *nc); 75 | 76 | /* userAmbResol_uup.c --------------------------------------------------------*/ 77 | extern int userAmbResol_cnes(rtk_t *rtk, const obsd_t *obs, int n, 78 | const nav_t *nav, const int *exc, const double *azel, double *x, double *P); 79 | extern int userAmbResol_uup(rtk_t *rtk, const obsd_t *obs, int n, 80 | const nav_t *nav, const int *exc, const double *azel, double *x, double *P); 81 | 82 | /* userOutSolStat_p.c --------------------------------------------------------*/ 83 | extern int userOpenSolStat_p(const char *file, int level); 84 | extern void userCloseSolStat_p(void); 85 | extern void userOutSolStat_p(rtk_t *rtk); 86 | 87 | /* logRclk_p.c ---------------------------------------------------------------*/ 88 | extern int logRclkOpen_p(const char *file, const prcopt_t *opt); 89 | extern void logRclkClose_p(void); 90 | extern void logRclk_p(rtk_t *rtk); 91 | 92 | /* logZtd_p.c ----------------------------------------------------------------*/ 93 | extern int logZtdOpen_p(const char *file, const prcopt_t *opt); 94 | extern void logZtdClose_p(void); 95 | extern void logZtd_p(rtk_t *rtk); 96 | 97 | /* logIon_p.c ----------------------------------------------------------------*/ 98 | extern int logIonOpen_p(const char *file, const prcopt_t *opt); 99 | extern void logIonClose_p(void); 100 | extern void logIon_p(rtk_t *rtk, const obsd_t *obs, int n); 101 | 102 | /* logAmb_p.c ----------------------------------------------------------------*/ 103 | extern int logAmbOpen_p(const char *file, const prcopt_t *opt); 104 | extern void logAmbClose_p(void); 105 | extern void logAmb_p(rtk_t *rtk, const obsd_t *obs, int n); 106 | 107 | /* logRes_p.c ----------------------------------------------------------------*/ 108 | extern int logResOpen_p(const char *file, const prcopt_t *opt); 109 | extern void logResClose_p(void); 110 | extern void logRes_p(rtk_t *rtk, const obsd_t *obs, int n); 111 | 112 | #endif /* _PPP_H */ 113 | -------------------------------------------------------------------------------- /src/corr/phw.c: -------------------------------------------------------------------------------- 1 | 2 | #include "corr.h" 3 | 4 | /* nominal yaw-angle ---------------------------------------------------------*/ 5 | static double yaw_nominal(double beta, double mu) 6 | { 7 | if (fabs(beta)<1E-12&&fabs(mu)<1E-12) return PI; 8 | return atan2(-tan(beta), sin(mu))+PI; 9 | } 10 | /* yaw-angle of satellite ----------------------------------------------------*/ 11 | extern int yaw_angle(int sat, const char* type, int opt, double beta, double mu, 12 | double* yaw) 13 | { 14 | *yaw=yaw_nominal(beta, mu); 15 | return 1; 16 | } 17 | /* satellite attitude model --------------------------------------------------*/ 18 | static int sat_yaw(gtime_t time, int sat, const char* type, int opt, 19 | const double* rs, double* exs, double* eys) 20 | { 21 | double rsun[3], ri[6], es[3], esun[3], n[3], p[3], en[3], ep[3], ex[3], E, beta, mu; 22 | double yaw, cosy, siny, erpv[5]={ 0 }; 23 | int i; 24 | 25 | sunmoonpos(gpst2utc(time), erpv, rsun, NULL, NULL); 26 | 27 | /* beta and orbit angle */ 28 | matcpy(ri, rs, 6, 1); 29 | ri[3]-=OMGE*ri[1]; 30 | ri[4]+=OMGE*ri[0]; 31 | cross3(ri, ri+3, n); 32 | cross3(rsun, n, p); 33 | if (!normv3(rs, es)||!normv3(rsun, esun)||!normv3(n, en) || 34 | !normv3(p, ep)) return 0; 35 | beta=PI/2.0-acos(dot(esun, en, 3)); 36 | E=acos(dot(es, ep, 3)); 37 | mu=PI/2.0+(dot(es, esun, 3)<=0?-E:E); 38 | if (mu<-PI/2.0) mu+=2.0*PI; 39 | else if (mu>=PI/2.0) mu-=2.0*PI; 40 | 41 | /* yaw-angle of satellite */ 42 | if (!yaw_angle(sat, type, opt, beta, mu, &yaw)) return 0; 43 | 44 | /* satellite fixed x,y-vector */ 45 | cross3(en, es, ex); 46 | cosy=cos(yaw); 47 | siny=sin(yaw); 48 | for (i=0; i<3; i++) { 49 | exs[i]=-siny*en[i]+cosy*ex[i]; 50 | eys[i]=-cosy*en[i]-siny*ex[i]; 51 | } 52 | return 1; 53 | } 54 | /* phase windup model --------------------------------------------------------*/ 55 | extern int model_phw(gtime_t time, int sat, const char* type, int opt, 56 | const double* rs, const double* rr, double* phw) 57 | { 58 | double exs[3], eys[3], ek[3], exr[3], eyr[3], eks[3], ekr[3], E[9]; 59 | double dr[3], ds[3], drs[3], r[3], pos[3], cosp, ph; 60 | int i; 61 | 62 | if (opt<=0) return 1; /* no phase windup */ 63 | 64 | /* satellite yaw attitude model */ 65 | if (!sat_yaw(time, sat, type, opt, rs, exs, eys)) return 0; 66 | 67 | /* unit vector satellite to receiver */ 68 | for (i=0; i<3; i++) r[i]=rr[i]-rs[i]; 69 | if (!normv3(r, ek)) return 0; 70 | 71 | /* unit vectors of receiver antenna */ 72 | ecef2pos(rr, pos); 73 | xyz2enu(pos, E); 74 | exr[0]=E[1]; exr[1]=E[4]; exr[2]=E[7]; /* x=north */ 75 | eyr[0]=-E[0]; eyr[1]=-E[3]; eyr[2]=-E[6]; /* y=west */ 76 | 77 | /* phase windup effect */ 78 | cross3(ek, eys, eks); 79 | cross3(ek, eyr, ekr); 80 | for (i=0; i<3; i++) { 81 | ds[i]=exs[i]-ek[i]*dot(ek, exs, 3)-eks[i]; 82 | dr[i]=exr[i]-ek[i]*dot(ek, exr, 3)+ekr[i]; 83 | } 84 | cosp=dot(ds, dr, 3)/norm(ds, 3)/norm(dr, 3); 85 | if (cosp<-1.0) cosp=-1.0; 86 | else if (cosp>1.0) cosp=1.0; 87 | ph=acos(cosp)/2.0/PI; 88 | cross3(ds, dr, drs); 89 | if (dot(ek, drs, 3)<0.0) ph=-ph; 90 | 91 | *phw=ph+floor(*phw-ph+0.5); /* in cycle */ 92 | return 1; 93 | } 94 | /* phase windup correction ----------------------------------------------------- 95 | * phase windup correction (ref [7] 5.1.2) 96 | * args :gtime_t time I time (GPST) 97 | * double *rs I satellite position (ecef) {x,y,z} (m) 98 | * double *rr I receiver position (ecef) {x,y,z} (m) 99 | * double *phw IO phase windup correction (cycle) 100 | * return:none 101 | * notes :the previous value of phase windup correction should be set to *phw 102 | * as an input. the function assumes windup correction has no jump more 103 | * than 0.5 cycle. 104 | *-----------------------------------------------------------------------------*/ 105 | extern void windupcorr(gtime_t time, const double *rs, const double *rr, 106 | double *phw) 107 | { 108 | double ek[3],exs[3],eys[3],ezs[3],ess[3],exr[3],eyr[3],eks[3],ekr[3],E[9]; 109 | double dr[3],ds[3],drs[3],r[3],pos[3],rsun[3],cosp,ph,erpv[5]={0}; 110 | int i; 111 | 112 | trace(4,"windupcorr: time=%s\n",time_str(time,0)); 113 | 114 | /* sun position in ecef */ 115 | sunmoonpos(gpst2utc(time),erpv,rsun,NULL,NULL); 116 | 117 | /* unit vector satellite to receiver */ 118 | for (i=0;i<3;i++) r[i]=rr[i]-rs[i]; 119 | if (!normv3(r,ek)) return; 120 | 121 | /* unit vectors of satellite antenna */ 122 | for (i=0;i<3;i++) r[i]=-rs[i]; 123 | if (!normv3(r,ezs)) return; 124 | for (i=0;i<3;i++) r[i]=rsun[i]-rs[i]; 125 | if (!normv3(r,ess)) return; 126 | cross3(ezs,ess,r); 127 | if (!normv3(r,eys)) return; 128 | cross3(eys,ezs,exs); 129 | 130 | /* unit vectors of receiver antenna */ 131 | ecef2pos(rr,pos); 132 | xyz2enu(pos,E); 133 | exr[0]= E[1]; exr[1]= E[4]; exr[2]= E[7]; /* x=north */ 134 | eyr[0]=-E[0]; eyr[1]=-E[3]; eyr[2]=-E[6]; /* y=west */ 135 | 136 | /* phase windup effect */ 137 | cross3(ek,eys,eks); 138 | cross3(ek,eyr,ekr); 139 | for (i=0;i<3;i++) { 140 | ds[i]=exs[i]-ek[i]*dot(ek,exs,3)-eks[i]; 141 | dr[i]=exr[i]-ek[i]*dot(ek,exr,3)+ekr[i]; 142 | } 143 | cosp=dot(ds,dr,3)/norm(ds,3)/norm(dr,3); 144 | if (cosp<-1.0) cosp=-1.0; 145 | else if (cosp> 1.0) cosp= 1.0; 146 | ph=acos(cosp)/2.0/PI; 147 | cross3(ds,dr,drs); 148 | if (dot(ek,drs,3)<0.0) ph=-ph; 149 | 150 | *phw=ph+floor(*phw-ph+0.5); /* in cycle */ 151 | } -------------------------------------------------------------------------------- /src/user/dckp/userRTKPos_dp.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * rtkpos.c : precise positioning 3 | * 4 | * Copyright (C) 2007-2018 by T.TAKASU, All rights reserved. 5 | * 6 | * version : $Revision: 1.1 $ $Date: 2008/07/17 21:48:06 $ 7 | *-----------------------------------------------------------------------------*/ 8 | 9 | #include "dckp.h" 10 | 11 | /* save error message --------------------------------------------------------*/ 12 | static void errmsg(rtk_t *rtk, const char *format, ...) 13 | { 14 | char buff[256],tstr[32]; 15 | int n; 16 | va_list ap; 17 | time2str(rtk->sol.time,tstr,2); 18 | n=sprintf(buff,"%s: ",tstr+11); 19 | va_start(ap,format); 20 | n+=vsprintf(buff+n,format,ap); 21 | va_end(ap); 22 | n=nneb?n:MAXERRMSG-rtk->neb; 23 | memcpy(rtk->errbuf+rtk->neb,buff,n); 24 | rtk->neb+=n; 25 | trace(2,"%s",buff); 26 | } 27 | /* precise positioning --------------------------------------------------------- 28 | * input observation data and navigation message, compute rover position by 29 | * precise positioning 30 | * args : rtk_t *rtk IO rtk control/result struct 31 | * rtk->sol IO solution 32 | * .time O solution time 33 | * .rr[] IO rover position/velocity 34 | * (I:fixed mode,O:single mode) 35 | * .dtr[0] O receiver clock bias (s) 36 | * .dtr[1] O receiver glonass-gps time offset (s) 37 | * .Qr[] O rover position covarinace 38 | * .stat O solution status (SOLQ_???) 39 | * .ns O number of valid satellites 40 | * .age O age of differential (s) 41 | * .ratio O ratio factor for ambiguity validation 42 | * rtk->rb[] IO base station position/velocity 43 | * (I:relative mode,O:moving-base mode) 44 | * rtk->nx I number of all states 45 | * rtk->na I number of integer states 46 | * rtk->ns O number of valid satellite 47 | * rtk->tt O time difference between current and previous (s) 48 | * rtk->x[] IO float states pre-filter and post-filter 49 | * rtk->P[] IO float covariance pre-filter and post-filter 50 | * rtk->xa[] O fixed states after AR 51 | * rtk->Pa[] O fixed covariance after AR 52 | * rtk->ssat[s] IO sat(s+1) status 53 | * .sys O system (SYS_???) 54 | * .az [r] O azimuth angle (rad) (r=0:rover,1:base) 55 | * .el [r] O elevation angle (rad) (r=0:rover,1:base) 56 | * .vs [r] O data valid single (r=0:rover,1:base) 57 | * .resp [f] O freq(f+1) pseudorange residual (m) 58 | * .resc [f] O freq(f+1) carrier-phase residual (m) 59 | * .vsat [f] O freq(f+1) data vaild (0:invalid,1:valid) 60 | * .fix [f] O freq(f+1) ambiguity flag 61 | * (0:nodata,1:float,2:fix,3:hold) 62 | * .slip [f] O freq(f+1) slip flag 63 | * (bit8-7:rcv1 LLI, bit6-5:rcv2 LLI, 64 | * bit2:parity unknown, bit1:slip) 65 | * .lock [f] IO freq(f+1) carrier lock count 66 | * .outc [f] IO freq(f+1) carrier outage count 67 | * .slipc[f] IO freq(f+1) cycle slip count 68 | * .rejc [f] IO freq(f+1) data reject count 69 | * .gf IO geometry-free phase (L1-L2) (m) 70 | * .gf2 IO geometry-free phase (L1-L5) (m) 71 | * rtk->nfix IO number of continuous fixes of ambiguity 72 | * rtk->neb IO bytes of error message buffer 73 | * rtk->errbuf IO error message buffer 74 | * rtk->tstr O time string for debug 75 | * rtk->opt I processing options 76 | * obsd_t *obs I observation data for an epoch 77 | * obs[i].rcv=1:rover,2:reference 78 | * sorted by receiver and satellte 79 | * int n I number of observation data 80 | * nav_t *nav I navigation messages 81 | * return : status (0:no solution,1:valid solution) 82 | * notes : before calling function, base station position rtk->sol.rb[] should 83 | * be properly set for relative mode except for moving-baseline 84 | *-----------------------------------------------------------------------------*/ 85 | extern int userRTKPos_dp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) 86 | { 87 | prcopt_t *opt=&rtk->opt; 88 | sol_t solb={{0}}; 89 | gtime_t time; 90 | int i,nu; 91 | char msg[128]=""; 92 | 93 | trace(3,"rtkpos : time=%s n=%d\n",rtk->cTime,n); 94 | 95 | /* set base staion position */ 96 | for (i=0;i<6;i++) rtk->rb[i]=i<3?opt->ru[i]:0.0; 97 | /* count rover/base station observations */ 98 | for (nu=0;nusol.time; 101 | 102 | /* rover position by single point positioning */ 103 | if (!pntpos(obs,nu,nav,&rtk->opt,&rtk->sol,NULL,rtk->ssat,msg)) { 104 | errmsg(rtk,"point pos error (%s)\n",msg); 105 | //outSolutionStat_dp(rtk); 106 | return 0; 107 | } 108 | if (time.time!=0) rtk->tt=timediff(rtk->sol.time,time); 109 | 110 | /* precise point positioning */ 111 | if (opt->mode>=PMODE_PPP_KINEMA) { 112 | userPPPos_dp(rtk,obs,nu,nav); 113 | //outSolutionStat_dp(rtk); 114 | } 115 | return 1; 116 | } 117 | -------------------------------------------------------------------------------- /src/user/ppp/userRTKPos_p.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * rtkpos.c : precise positioning 3 | * 4 | * Copyright (C) 2007-2018 by T.TAKASU, All rights reserved. 5 | * 6 | * version : $Revision: 1.1 $ $Date: 2008/07/17 21:48:06 $ 7 | *-----------------------------------------------------------------------------*/ 8 | 9 | #include "ppp.h" 10 | 11 | /* save error message --------------------------------------------------------*/ 12 | static void errmsg(rtk_t *rtk, const char *format, ...) 13 | { 14 | char buff[256],tstr[32]; 15 | int n; 16 | va_list ap; 17 | time2str(rtk->sol.time,tstr,2); 18 | n=sprintf(buff,"%s: ",tstr+11); 19 | va_start(ap,format); 20 | n+=vsprintf(buff+n,format,ap); 21 | va_end(ap); 22 | n=nneb?n:MAXERRMSG-rtk->neb; 23 | memcpy(rtk->errbuf+rtk->neb,buff,n); 24 | rtk->neb+=n; 25 | trace(2,"%s",buff); 26 | } 27 | /* precise positioning --------------------------------------------------------- 28 | * input observation data and navigation message, compute rover position by 29 | * precise positioning 30 | * args : rtk_t *rtk IO rtk control/result struct 31 | * rtk->sol IO solution 32 | * .time O solution time 33 | * .rr[] IO rover position/velocity 34 | * (I:fixed mode,O:single mode) 35 | * .dtr[0] O receiver clock bias (s) 36 | * .dtr[1] O receiver glonass-gps time offset (s) 37 | * .Qr[] O rover position covarinace 38 | * .stat O solution status (SOLQ_???) 39 | * .ns O number of valid satellites 40 | * .age O age of differential (s) 41 | * .ratio O ratio factor for ambiguity validation 42 | * rtk->rb[] IO base station position/velocity 43 | * (I:relative mode,O:moving-base mode) 44 | * rtk->nx I number of all states 45 | * rtk->na I number of integer states 46 | * rtk->ns O number of valid satellite 47 | * rtk->tt O time difference between current and previous (s) 48 | * rtk->x[] IO float states pre-filter and post-filter 49 | * rtk->P[] IO float covariance pre-filter and post-filter 50 | * rtk->xa[] O fixed states after AR 51 | * rtk->Pa[] O fixed covariance after AR 52 | * rtk->ssat[s] IO sat(s+1) status 53 | * .sys O system (SYS_???) 54 | * .az [r] O azimuth angle (rad) (r=0:rover,1:base) 55 | * .el [r] O elevation angle (rad) (r=0:rover,1:base) 56 | * .vs [r] O data valid single (r=0:rover,1:base) 57 | * .resp [f] O freq(f+1) pseudorange residual (m) 58 | * .resc [f] O freq(f+1) carrier-phase residual (m) 59 | * .vsat [f] O freq(f+1) data vaild (0:invalid,1:valid) 60 | * .fix [f] O freq(f+1) ambiguity flag 61 | * (0:nodata,1:float,2:fix,3:hold) 62 | * .slip [f] O freq(f+1) slip flag 63 | * (bit8-7:rcv1 LLI, bit6-5:rcv2 LLI, 64 | * bit2:parity unknown, bit1:slip) 65 | * .lock [f] IO freq(f+1) carrier lock count 66 | * .outc [f] IO freq(f+1) carrier outage count 67 | * .slipc[f] IO freq(f+1) cycle slip count 68 | * .rejc [f] IO freq(f+1) data reject count 69 | * .gf IO geometry-free phase (L1-L2) (m) 70 | * .gf2 IO geometry-free phase (L1-L5) (m) 71 | * rtk->nfix IO number of continuous fixes of ambiguity 72 | * rtk->neb IO bytes of error message buffer 73 | * rtk->errbuf IO error message buffer 74 | * rtk->tstr O time string for debug 75 | * rtk->opt I processing options 76 | * obsd_t *obs I observation data for an epoch 77 | * obs[i].rcv=1:rover,2:reference 78 | * sorted by receiver and satellte 79 | * int n I number of observation data 80 | * nav_t *nav I navigation messages 81 | * return : status (0:no solution,1:valid solution) 82 | * notes : before calling function, base station position rtk->sol.rb[] should 83 | * be properly set for relative mode except for moving-baseline 84 | *-----------------------------------------------------------------------------*/ 85 | extern int userRTKPos_p(rtk_t *rtk, obsd_t *obs, int n, const nav_t *nav) 86 | { 87 | prcopt_t *opt=&rtk->opt; 88 | sol_t solb={{0}}; 89 | gtime_t time; 90 | int i,nu; 91 | char msg[128]=""; 92 | 93 | trace(3,"userRTKPos_p: time=%s n=%d\n",time_str(obs[0].time,3),n); 94 | 95 | /* set base staion position */ 96 | for (i=0;i<6;i++) rtk->rb[i]=i<3?opt->ru[i]:0.0; 97 | /* count rover/base station observations */ 98 | for (nu=0;nusol.time; 101 | 102 | /* rover position by single point positioning */ 103 | if (!pntpos(obs,nu,nav,&rtk->opt,&rtk->sol,NULL,rtk->ssat,msg)) { 104 | errmsg(rtk,"point pos error (%s)\n",msg); 105 | return 0; 106 | } 107 | if (time.time!=0) rtk->tt=timediff(rtk->sol.time,time); 108 | 109 | detCycleSlip(opt,rtk->ssat,obs,n,nav,"",rtk->tt,&rtk->jumpc); 110 | 111 | /* precise point positioning */ 112 | if (opt->mode>=PMODE_PPP_KINEMA) { 113 | userPPPos_p(rtk,obs,nu,nav); 114 | } 115 | return 1; 116 | } 117 | -------------------------------------------------------------------------------- /src/io/readcob.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * readcob.c : read uncalibrated code delay 3 | *-----------------------------------------------------------------------------*/ 4 | 5 | #include "io.h" 6 | 7 | #define MAXRNXLEN (16*MAXOBSTYPE+4) /* max rinex record length */ 8 | #define MAXPOSHEAD 1024 /* max head line position */ 9 | 10 | /* compare ucd ---------------------------------------------------------------*/ 11 | static int cmpUCD(const void *p1, const void *p2) 12 | { 13 | bias_t *q1=(bias_t*)p1,*q2=(bias_t*)p2; 14 | double tt=timediff(q1->time,q2->time); 15 | return tt<-1E-9?-1:(tt>1E-9?1:q1->index-q2->index); 16 | } 17 | /* combine ucd ---------------------------------------------------------------*/ 18 | static void combineUCD(nav_t *nav) 19 | { 20 | bias_t *nav_bias; 21 | int i,j,k; 22 | 23 | trace(3,"combineBias: nb=%d\n",nav->nd); 24 | 25 | if (nav->nd<=0) return; 26 | qsort(nav->ucd,nav->nd,sizeof(bias_t),cmpUCD); 27 | 28 | for (i=0,j=1;jnd;j++) { 29 | if (fabs(timediff(nav->ucd[i].time,nav->ucd[j].time))<1E-9) { 30 | for (k=0;kucd[j].bias[k][0]==0.0) continue; 32 | nav->ucd[i].bias[k][0]=nav->ucd[j].bias[k][0]; 33 | nav->ucd[i].std [k][0]=nav->ucd[j].std [k][0]; 34 | } 35 | } 36 | else if (++iucd[i]=nav->ucd[j]; 37 | } 38 | nav->nd=i+1; 39 | 40 | if (!(nav_bias=(bias_t*)realloc(nav->ucd,sizeof(bias_t)*nav->nd))) { 41 | free(nav->ucd);nav->ucd=NULL;nav->nd=nav->ncmax=0; 42 | trace(1,"combpclk malloc error nc=%d\n",nav->nd); 43 | return; 44 | } 45 | nav->ucd=nav_bias; 46 | nav->ndmax=nav->nd; 47 | 48 | trace(4,"combineUCD: nb=%d\n",nav->nd); 49 | } 50 | /* read ucd file body --------------------------------------------------------*/ 51 | static int readUCDBody(FILE *fp, const int mask, int index, int nf, nav_t *nav) 52 | { 53 | bias_t* nav_ucd; 54 | gtime_t time; 55 | double data[4],ep[6]; 56 | int i,j,sat; 57 | char buff[MAXRNXLEN],satid[8]=""; 58 | 59 | trace(3,"readUCDBody: index=%d\n",index); 60 | 61 | while (fgets(buff,sizeof(buff),fp)) { 62 | 63 | if (sscanf(buff,"%lf/%lf/%lf %lf:%lf:%lf %s",ep,ep+1,ep+2, 64 | ep+3,ep+4,ep+5,satid)<7) { 65 | trace(2,"invalid ucd buff=%s\n",buff); 66 | return 0; 67 | } 68 | time=epoch2time(ep); 69 | 70 | /* only read satellite ucd record */ 71 | if (!(sat=satid2no(satid))) continue; 72 | 73 | /* skip system not in mask */ 74 | if (!(satsys(sat,NULL)&mask)) continue; 75 | 76 | for (i=0,j=30;i<2*nf;i++,j+=12) data[i]=str2num(buff,j,12); 77 | 78 | if (nav->nd>=nav->ndmax) { 79 | nav->ndmax+=1024; 80 | if (!(nav_ucd=(bias_t*)realloc(nav->ucd,sizeof(bias_t)*(nav->ndmax)))) { 81 | trace(1,"readUCDBody malloc error: nmax=%d\n",nav->ndmax); 82 | free(nav->ucd);nav->ucd=NULL;nav->nd=nav->ndmax=0; 83 | return -1; 84 | } 85 | nav->ucd=nav_ucd; 86 | } 87 | if (nav->nd<=0||fabs(timediff(time,nav->ucd[nav->nd-1].time))>1E-9) { 88 | nav->nd++; 89 | nav->ucd[nav->nd-1].time=time; 90 | nav->ucd[nav->nd-1].index=index; 91 | for (i=0;iucd[nav->nd-1].bias[i][j]=0.0; 93 | nav->ucd[nav->nd-1].std [i][j]=0.0f; 94 | } 95 | } 96 | for (i=0;iucd[nav->nd-1].bias[sat-1][i]=data[i]; 98 | nav->ucd[nav->nd-1].std [sat-1][i]=(float)data[i+nf]; 99 | } 100 | } 101 | return nav->nd>0; 102 | } 103 | /* read single cob file ------------------------------------------------------*/ 104 | static int readcobfile(const char *file, const int mask, int index, int nf, 105 | nav_t *nav) 106 | { 107 | trace(3,"readcobfile: file=%s index=%d\n",file,index); 108 | 109 | FILE* fp; 110 | int stat; 111 | 112 | if (!(fp=fopen(file,"r"))) { 113 | trace(2,"ucd file open error: %s\n",file); 114 | return 0; 115 | } 116 | 117 | /* read ucd file body */ 118 | stat=readUCDBody(fp,mask,index,nf,nav); 119 | 120 | fclose(fp); 121 | return stat; 122 | } 123 | /* read code delay ------------------------------------------------------------- 124 | * read uncalibrated code delay 125 | * args : char *file I file (wild-card * expanded) 126 | * const int mask I system mask 127 | * int nf I number of data frequency 128 | * nav_t *nav IO navigation data 129 | * return : epoch number of ucd 130 | *-----------------------------------------------------------------------------*/ 131 | extern int readcob(const char *file, int mask, int nf, nav_t *nav) 132 | { 133 | int i,n,index=0,stat=1; 134 | char* files[MAXEXFILE]={ 0 }; 135 | 136 | trace(3,"readcob: file=%s mask=%d\n",file,mask); 137 | 138 | for (i=0;i=0;i--) free(files[i]); 141 | return -1; 142 | } 143 | } 144 | /* expand wild-card */ 145 | n=expath(file,files,MAXEXFILE); 146 | 147 | /* read ucd files */ 148 | for (i=0;ind; 162 | } -------------------------------------------------------------------------------- /src/user/interBias.c: -------------------------------------------------------------------------------- 1 | 2 | #include "user.h" 3 | 4 | #define SQR(x) ((x)*(x)) 5 | #define MAXDTE 900.0 /* max time difference to phase bias time (s) */ 6 | #define EXTERR_BIAS 1E-6 /* extrapolation error for bias (cycle/s) */ 7 | 8 | /* satellite carrier-phase bias interpolation ---------------------------------- 9 | * compute satellite carrier-phase bias and variance 10 | * args : prcopt_t *opt I options 11 | * gtime_t time I interpolation time 12 | * int sat I satellite number 13 | * nav_t *nav I navigation data 14 | * double *bias O carrier-phase bias 15 | * double *varBias O carrier-phase std 16 | * return : (0:error, 1:ok) 17 | * notes : bias [0:nf] = sat carrier-phase bias for nf frequencies (cycle) 18 | * varBias[0:nf] = sat carrier-phase bias std (cycle) 19 | *-----------------------------------------------------------------------------*/ 20 | extern int interpol_phasebias(const prcopt_t *opt, gtime_t time, int sat, 21 | const nav_t *nav, double *bias, double *varBias) 22 | { 23 | double t[2],b[2],std; 24 | char str[32],id[8]; 25 | int i,j,k,index; 26 | 27 | time2str(time,str,2); 28 | trace(4,"interpol_phasebias: time=%s sat=%2d\n",str,sat); 29 | 30 | if (nav->nb<2|| 31 | timediff(time,nav->bias[0].time)<-MAXDTE|| 32 | timediff(time,nav->bias[nav->nb-1].time)>MAXDTE) { 33 | satno2id(sat,id); 34 | trace(2,"no carrier-phase bias %s sat=%s\n",str,id); 35 | return 0; 36 | } 37 | /* binary search */ 38 | for (i=0,j=nav->nb-1;ibias[k].time,time)<0.0) i=k+1; else j=k; 41 | } 42 | index=i<=0?0:i-1; 43 | 44 | /* linear interpolation for clock */ 45 | t[0]=timediff(time,nav->bias[index ].time); 46 | t[1]=timediff(time,nav->bias[index+1].time); 47 | 48 | /* carrier-phase bias for each frequency */ 49 | for (i=0;inf;i++) { 50 | 51 | bias[i]=0.0; 52 | varBias[i]=0.0; 53 | 54 | b[0]=nav->bias[index ].bias[sat-1][i]; 55 | b[1]=nav->bias[index+1].bias[sat-1][i]; 56 | 57 | if (t[0]<=0.0) { /* before interpolation interval */ 58 | if ((bias[i]=b[0])==0.0) return 0; 59 | std=nav->bias[index].std[sat-1][i]-EXTERR_BIAS*t[0]; 60 | } 61 | else if (t[1]>=0.0) { /* after interpolation interval */ 62 | if ((bias[i]=b[1])==0.0) return 0; 63 | std=nav->bias[index+1].std[sat-1][i]+EXTERR_BIAS*t[1]; 64 | } 65 | else if (b[0]!=0.0&&b[1]!=0.0) { 66 | bias[i]=(b[1]*t[0]-b[0]*t[1])/(t[0]-t[1]); 67 | k=t[0]<-t[1]?0:1; /* the nearest */ 68 | std=nav->bias[index+k].std[sat-1][i]+EXTERR_BIAS*fabs(t[k]); 69 | } 70 | else { 71 | trace(2,"carrier-phase bias outage %s sat=%s\n",str,id); 72 | return 0; 73 | } 74 | varBias[i]=SQR(std); 75 | } 76 | return 1; 77 | } 78 | 79 | /* satellite code bias interpolation ------------------------------------------- 80 | * compute satellite code bias and variance 81 | * args : prcopt_t *opt I options 82 | * gtime_t time I interpolation time 83 | * int sat I satellite number 84 | * nav_t *nav I navigation data 85 | * double *ucd O code bias drift 86 | * double *varUcd O code bias drift std 87 | * return : (0:error, 1:ok) 88 | * notes : ucd [0:nf] = sat code bias for nf frequencies (cycle) 89 | * varUcd[0:nf] = sat code bias std (cycle) 90 | *-----------------------------------------------------------------------------*/ 91 | extern int interpol_codebias(const prcopt_t *opt, gtime_t time, int sat, 92 | const nav_t *nav, double *ucd, double *varUcd) 93 | { 94 | double t[2],b[2],std; 95 | char str[32],id[8]; 96 | int i,j,k,index; 97 | 98 | time2str(time,str,2); 99 | trace(4,"interpol_codebias: time=%s sat=%2d\n",str,sat); 100 | 101 | if (nav->nd<2|| 102 | timediff(time,nav->ucd[0].time)<-MAXDTE|| 103 | timediff(time,nav->ucd[nav->nd-1].time)>MAXDTE) { 104 | satno2id(sat,id); 105 | trace(2,"%s no ucd sat=%s\n",str,id); 106 | return -1; 107 | } 108 | /* binary search */ 109 | for (i=0,j=nav->nd-1;iucd[k].time,time)<0.0) i=k+1; else j=k; 112 | } 113 | index=i<=0?0:i-1; 114 | 115 | /* linear interpolation for clock */ 116 | t[0]=timediff(time,nav->ucd[index ].time); 117 | t[1]=timediff(time,nav->ucd[index+1].time); 118 | 119 | /* carrier-phase ucd for each frequency */ 120 | for (i=0;inf;i++) { 121 | 122 | ucd[i]=0.0; 123 | varUcd[i]=0.0; 124 | 125 | b[0]=nav->ucd[index ].bias[sat-1][i]; 126 | b[1]=nav->ucd[index+1].bias[sat-1][i]; 127 | 128 | if (t[0]<=0.0) { /* before interpolation interval */ 129 | if ((ucd[i]=b[0])==0.0) return 0; 130 | std=nav->ucd[index].std[sat-1][i]-EXTERR_BIAS*t[0]; 131 | } 132 | else if (t[1]>=0.0) { /* after interpolation interval */ 133 | if ((ucd[i]=b[1])==0.0) return 0; 134 | std=nav->ucd[index+1].std[sat-1][i]+EXTERR_BIAS*t[1]; 135 | } 136 | else if (b[0]!=0.0&&b[1]!=0.0) { 137 | ucd[i]=(b[1]*t[0]-b[0]*t[1])/(t[0]-t[1]); 138 | k=t[0]<-t[1]?0:1; /* the nearest */ 139 | std=nav->ucd[index+k].std[sat-1][i]+EXTERR_BIAS*fabs(t[k]); 140 | } 141 | else { 142 | trace(2,"ucd outage %s sat=%s\n",str,id); 143 | return -1; 144 | } 145 | varUcd[i]=SQR(std); 146 | } 147 | return 1; 148 | } 149 | -------------------------------------------------------------------------------- /src/io/readBias.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * readbias.c : read carrier-phase bias for AR in un-differenced and uncombined 3 | *-----------------------------------------------------------------------------*/ 4 | 5 | #include "io.h" 6 | 7 | #define MAXRNXLEN (16*MAXOBSTYPE+4) /* max rinex record length */ 8 | #define MAXPOSHEAD 1024 /* max head line position */ 9 | 10 | /* compare carrier-phase bias ------------------------------------------------*/ 11 | static int cmpBias(const void *p1, const void *p2) 12 | { 13 | bias_t *q1=(bias_t*)p1,*q2=(bias_t*)p2; 14 | double tt=timediff(q1->time,q2->time); 15 | return tt<-1E-9?-1:(tt>1E-9?1:q1->index-q2->index); 16 | } 17 | /* combine carrier-phase bias ------------------------------------------------*/ 18 | static void combineBias(nav_t *nav) 19 | { 20 | bias_t *nav_bias; 21 | int i,j,k; 22 | 23 | trace(3,"combineBias: nb=%d\n",nav->nb); 24 | 25 | if (nav->nb<=0) return; 26 | qsort(nav->bias,nav->nb,sizeof(bias_t),cmpBias); 27 | 28 | for (i=0,j=1;jnb;j++) { 29 | if (fabs(timediff(nav->bias[i].time,nav->bias[j].time))<1E-9) { 30 | for (k=0;kbias[j].bias[k][0]==0.0) continue; 32 | nav->bias[i].bias[k][0]=nav->bias[j].bias[k][0]; 33 | nav->bias[i].std [k][0]=nav->bias[j].std [k][0]; 34 | } 35 | } 36 | else if (++ibias[i]=nav->bias[j]; 37 | } 38 | nav->nb=i+1; 39 | 40 | if (!(nav_bias=(bias_t*)realloc(nav->bias,sizeof(bias_t)*nav->nb))) { 41 | free(nav->bias);nav->bias=NULL;nav->nb=nav->ncmax=0; 42 | trace(1,"combpclk malloc error nc=%d\n",nav->nb); 43 | return; 44 | } 45 | nav->bias=nav_bias; 46 | nav->nbmax=nav->nb; 47 | 48 | trace(4,"combineBias: nb=%d\n",nav->nb); 49 | } 50 | /* read bias file body -------------------------------------------------------*/ 51 | static int readBiasBody(FILE *fp, const int mask, int index, nav_t *nav) 52 | { 53 | bias_t* nav_bias; 54 | gtime_t time; 55 | double data[4],ep[6]; 56 | int i,j,sat; 57 | char buff[MAXRNXLEN],satid[8]=""; 58 | 59 | trace(3,"readBiasBody: index=%d\n",index); 60 | 61 | while (fgets(buff,sizeof(buff),fp)) { 62 | 63 | if (sscanf(buff,"%lf/%lf/%lf %lf:%lf:%lf %s",ep,ep+1,ep+2, 64 | ep+3,ep+4,ep+5,satid)<7) { 65 | trace(2,"invalid carrier-phase bias buff=%s\n",buff); 66 | return 0; 67 | } 68 | time=epoch2time(ep); 69 | 70 | /* only read satellite bias record */ 71 | if (!(sat=satid2no(satid))) continue; 72 | 73 | /* skip system not in mask */ 74 | if (!(satsys(sat,NULL)&mask)) continue; 75 | 76 | for (i=0,j=30;i<4;i++,j+=12) data[i]=str2num(buff,j,12); 77 | 78 | if (nav->nb>=nav->nbmax) { 79 | nav->nbmax+=1024; 80 | if (!(nav_bias=(bias_t*)realloc(nav->bias,sizeof(bias_t)*(nav->nbmax)))) { 81 | trace(1,"readBiasBody malloc error: nmax=%d\n",nav->nbmax); 82 | free(nav->bias);nav->bias=NULL;nav->nb=nav->nbmax=0; 83 | return -1; 84 | } 85 | nav->bias=nav_bias; 86 | } 87 | if (nav->nb<=0||fabs(timediff(time,nav->bias[nav->nb-1].time))>1E-9) { 88 | nav->nb++; 89 | nav->bias[nav->nb-1].time=time; 90 | nav->bias[nav->nb-1].index=index; 91 | for (i=0;ibias[nav->nb-1].bias[i][j]=0.0; 93 | nav->bias[nav->nb-1].std [i][j]=0.0f; 94 | } 95 | } 96 | /* only two frequencies now */ 97 | nav->bias[nav->nb-1].bias[sat-1][0]=data[0]; 98 | nav->bias[nav->nb-1].bias[sat-1][1]=data[1]; 99 | nav->bias[nav->nb-1].std [sat-1][0]=(float)data[2]; 100 | nav->bias[nav->nb-1].std [sat-1][1]=(float)data[3]; 101 | } 102 | return nav->nb>0; 103 | } 104 | /* read single bias file -----------------------------------------------------*/ 105 | static int readBiasFile(const char *file, const int mask, int index, nav_t *nav) 106 | { 107 | trace(3,"readBiasFile: file=%s index=%d\n",file,index); 108 | 109 | FILE* fp; 110 | int stat; 111 | 112 | if (!(fp=fopen(file,"r"))) { 113 | trace(2,"bias file open error: %s\n",file); 114 | return 0; 115 | } 116 | 117 | /* read bias file body */ 118 | stat=readBiasBody(fp,mask,index,nav); 119 | 120 | fclose(fp); 121 | return stat; 122 | } 123 | /* read carrier phase bias --------------------------------------------------- 124 | * read carrier phase bias for AR 125 | * args : char *file I file (wild-card * expanded) 126 | * const int mask I system mask 127 | * nav_t *nav IO navigation data 128 | * return : number of biases 129 | *-----------------------------------------------------------------------------*/ 130 | extern int readBias(const char *file, const int mask, nav_t *nav) 131 | { 132 | int i,n,index=0,stat=1; 133 | char* files[MAXEXFILE]={ 0 }; 134 | 135 | trace(3,"readbias: file=%s mask=%d\n",file,mask); 136 | 137 | for (i=0;i=0;i--) free(files[i]); 140 | return -1; 141 | } 142 | } 143 | /* expand wild-card */ 144 | n=expath(file,files,MAXEXFILE); 145 | 146 | /* read bias files */ 147 | for (i=0;inb; 161 | } -------------------------------------------------------------------------------- /src/base/basecmn.c: -------------------------------------------------------------------------------- 1 | 2 | #include "base.h" 3 | 4 | /* constants -----------------------------------------------------------------*/ 5 | const double chisqr[100]={ /* chi-sqr(n) (alpha=0.001) */ 6 | 10.8,13.8,16.3,18.5,20.5,22.5,24.3,26.1,27.9,29.6, 7 | 31.3,32.9,34.5,36.1,37.7,39.3,40.8,42.3,43.8,45.3, 8 | 46.8,48.3,49.7,51.2,52.6,54.1,55.5,56.9,58.3,59.7, 9 | 61.1,62.5,63.9,65.2,66.6,68.0,69.3,70.7,72.1,73.4, 10 | 74.7,76.0,77.3,78.6,80.0,81.3,82.6,84.0,85.4,86.7, 11 | 88.0,89.3,90.6,91.9,93.3,94.7,96.0,97.4,98.7,100 , 12 | 101 ,102 ,103 ,104 ,105 ,107 ,108 ,109 ,110 ,112 , 13 | 113 ,114 ,115 ,116 ,118 ,119 ,120 ,122 ,123 ,125 , 14 | 126 ,127 ,128 ,129 ,131 ,132 ,133 ,134 ,135 ,137 , 15 | 138 ,139 ,140 ,142 ,143 ,144 ,145 ,147 ,148 ,149 16 | }; 17 | const prcopt_t prcopt_default={ /* defaults processing options */ 18 | {0},{0},0.0,0.0, /* ts,te,ti,tu */ 19 | {0},1, /* network processing time */ 20 | PMODE_SINGLE,0,2,SYS_GPS, /* mode,soltype,nf,navsys */ 21 | 15.0*D2R,{{0,0}}, /* elmin,snrmask */ 22 | EPHOPT_PREC,ARMODE_CONT, /* sateph,modear */ 23 | IONOOPT_EST,TROPOPT_EST, /* estion,esttrop */ 24 | 0.0, /* elmaskar */ 25 | 30.0, /* maxgdop */ 26 | 0, /* rovpos */ 27 | {100.0,100.0}, /* eratio[] */ 28 | {100.0,0.003,0.003,0.0,1.0},/* err[] */ 29 | {0.0,1E-7,100.0,0.0,0.0,0.0,100.0,100.0}, /* prn */ 30 | {3.0,0.9999,0.25,0.1,0.05}, /* thresar */ 31 | {0}, /* ru */ 32 | {"",""},{{0}}, /* anttype, antdel */ 33 | {{0}},{{0}}, /* pcvr,exsats */ 34 | {"",""},{{0}},{""}, /* rnxopt, odisp, ppopt */ 35 | 1,0,1,0, /* ircv, inh, estclk, datumType */ 36 | 0,0,0 /* rcb, scb, dck */ 37 | }; 38 | 39 | const solopt_t solopt_default={ /* defaults solution output options */ 40 | SOLF_XYZ,TIMES_GPST,1,2, /* posf,times,timef,timeu */ 41 | 0,1,1,0,0,0,0, /* degf,outhead,outopt,outvel,datum,height,geoid */ 42 | 0,0,0, /* solstatic,sstat,trace */ 43 | {0.0,0.0}, /* nmeaintv */ 44 | " ","",0.0 /* separator/program name */ 45 | }; 46 | 47 | /* execute command ------------------------------------------------------------- 48 | * execute command line by operating system shell 49 | * args : char *cmd I command line 50 | * return : execution status (0:ok,0>:error) 51 | *-----------------------------------------------------------------------------*/ 52 | extern int execcmd(const char *cmd) 53 | { 54 | #ifdef WIN32 55 | PROCESS_INFORMATION info; 56 | STARTUPINFO si={0}; 57 | DWORD stat; 58 | char cmds[1024]; 59 | 60 | trace(3,"execcmd: cmd=%s\n",cmd); 61 | 62 | si.cb=sizeof(si); 63 | sprintf(cmds,"cmd /c %s",cmd); 64 | if (!CreateProcess(NULL,(LPTSTR)cmds,NULL,NULL,FALSE,CREATE_NO_WINDOW,NULL, 65 | NULL,&si,&info)) return -1; 66 | WaitForSingleObject(info.hProcess,INFINITE); 67 | if (!GetExitCodeProcess(info.hProcess,&stat)) stat=-1; 68 | CloseHandle(info.hProcess); 69 | CloseHandle(info.hThread); 70 | return (int)stat; 71 | #else 72 | trace(3,"execcmd: cmd=%s\n",cmd); 73 | 74 | return system(cmd); 75 | #endif 76 | } 77 | /* uncompress file ------------------------------------------------------------- 78 | * uncompress (uncompress/unzip/uncompact hatanaka-compression/tar) file 79 | * args : char *file I input file 80 | * char *uncfile O uncompressed file 81 | * return : status (-1:error,0:not compressed file,1:uncompress completed) 82 | * note : creates uncompressed file in tempolary directory 83 | * gzip, tar and crx2rnx commands have to be installed in commands path 84 | *-----------------------------------------------------------------------------*/ 85 | extern int rtk_uncompress(const char *file, char *uncfile) 86 | { 87 | int stat=0; 88 | char *p,cmd[64+2048]="",tmpfile[1024]="",buff[1024],*fname,*dir=""; 89 | 90 | trace(3,"rtk_uncompress: file=%s\n",file); 91 | 92 | strcpy(tmpfile,file); 93 | if (!(p=strrchr(tmpfile,'.'))) return 0; 94 | 95 | /* uncompress by gzip */ 96 | if (!strcmp(p,".z" )||!strcmp(p,".Z" )|| 97 | !strcmp(p,".gz" )||!strcmp(p,".GZ" )|| 98 | !strcmp(p,".zip")||!strcmp(p,".ZIP")) { 99 | 100 | strcpy(uncfile,tmpfile); uncfile[p-tmpfile]='\0'; 101 | sprintf(cmd,"gzip -f -d -c \"%s\" > \"%s\"",tmpfile,uncfile); 102 | 103 | if (execcmd(cmd)) { 104 | remove(uncfile); 105 | return -1; 106 | } 107 | strcpy(tmpfile,uncfile); 108 | stat=1; 109 | } 110 | /* extract tar file */ 111 | if ((p=strrchr(tmpfile,'.'))&&!strcmp(p,".tar")) { 112 | 113 | strcpy(uncfile,tmpfile); uncfile[p-tmpfile]='\0'; 114 | strcpy(buff,tmpfile); 115 | fname=buff; 116 | #ifdef WIN32 117 | if ((p=strrchr(buff,'\\'))) { 118 | *p='\0'; dir=fname; fname=p+1; 119 | } 120 | sprintf(cmd,"set PATH=%%CD%%;%%PATH%% & cd /D \"%s\" & tar -xf \"%s\"", 121 | dir,fname); 122 | #else 123 | if ((p=strrchr(buff,'/'))) { 124 | *p='\0'; dir=fname; fname=p+1; 125 | } 126 | sprintf(cmd,"tar -C \"%s\" -xf \"%s\"",dir,tmpfile); 127 | #endif 128 | if (execcmd(cmd)) { 129 | if (stat) remove(tmpfile); 130 | return -1; 131 | } 132 | if (stat) remove(tmpfile); 133 | stat=1; 134 | } 135 | /* extract hatanaka-compressed file by cnx2rnx */ 136 | else if ((p=strrchr(tmpfile,'.'))&& 137 | ((strlen(p)>3&&(*(p+3)=='d'||*(p+3)=='D'))|| 138 | !strcmp(p,".crx")||!strcmp(p,".CRX"))) { 139 | 140 | strcpy(uncfile,tmpfile); 141 | uncfile[p-tmpfile+3]=*(p+3)=='D'?'O':'o'; 142 | sprintf(cmd,"crx2rnx < \"%s\" > \"%s\"",tmpfile,uncfile); 143 | 144 | if (execcmd(cmd)) { 145 | remove(uncfile); 146 | if (stat) remove(tmpfile); 147 | return -1; 148 | } 149 | if (stat) remove(tmpfile); 150 | stat=1; 151 | } 152 | trace(3,"rtk_uncompress: stat=%d\n",stat); 153 | return stat; 154 | } -------------------------------------------------------------------------------- /src/user/user.h: -------------------------------------------------------------------------------- 1 | #ifndef _USER_H 2 | #define _USER_H 3 | 4 | #include "corr/corr.h" 5 | #include "io/io.h" 6 | #include "qc/qc.h" 7 | #include "sat/sat.h" 8 | 9 | typedef struct { /* solution type */ 10 | gtime_t time; /* time (GPST) */ 11 | double rr[6]; /* position/velocity (m|m/s) */ 12 | /* {x,y,z,vx,vy,vz} or {e,n,u,ve,vn,vu} */ 13 | float qr[6]; /* position variance/covariance (m^2) */ 14 | /* {c_xx,c_yy,c_zz,c_xy,c_yz,c_zx} or */ 15 | /* {c_ee,c_nn,c_uu,c_en,c_nu,c_ue} */ 16 | float qv[6]; /* velocity variance/covariance (m^2/s^2) */ 17 | double dtr[6]; /* receiver clock bias to time systems (s) */ 18 | unsigned char type; /* type (0:xyz-ecef,1:enu-baseline) */ 19 | unsigned char stat; /* solution status (SOLQ_???) */ 20 | unsigned char ns; /* number of valid satellites */ 21 | float age; /* age of differential (s) */ 22 | float ratio; /* AR ratio factor for valiation */ 23 | float rate; /* AR success rate */ 24 | float thres; /* AR ratio threshold for valiation */ 25 | } sol_t; 26 | 27 | typedef struct { /* ambiguity control type */ 28 | gtime_t epoch[4]; /* last epoch */ 29 | int n[4]; /* number of epochs */ 30 | double LC [4]; /* linear combination average */ 31 | double LCv[4]; /* linear combination variance */ 32 | int fixcnt; /* fix count */ 33 | char flags[MAXSAT]; /* fix flags */ 34 | } ambc_t; 35 | 36 | typedef struct { 37 | double floamb[NFREQ]; /* float ambiguity, sd for if {wide,narr} */ 38 | double flostd[NFREQ]; 39 | int fixamb[NFREQ]; /* fixed ambiguity, sd for if {wide,narr} */ 40 | int fixflag; 41 | }ambr_t; 42 | 43 | typedef struct { /* RTK control/result type */ 44 | sol_t sol; /* RTK solution */ 45 | double rb[6]; /* base position/velocity (ecef) (m|m/s) */ 46 | int nx,na,nw; /* number of float states/fixed states */ 47 | double tt; /* time difference between current and previous (s) */ 48 | double *x,*P; /* float states and their covariance */ 49 | double *xa,*Pa; /* fixed states and their covariance */ 50 | double *xw,*Pw; /* wide-lane ambiguity estimation */ 51 | int nfix; /* number of continuous fixes of ambiguity */ 52 | ambc_t ambc[MAXSAT];/* ambibuity control */ 53 | ssat_t ssat[MAXSAT];/* satellite status */ 54 | int neb; /* bytes in error message buffer */ 55 | char errbuf[MAXERRMSG]; /* error message buffer */ 56 | prcopt_t opt; /* processing options */ 57 | int jumpc; /* clock jump values --by ls */ 58 | int datum[MAXSAT+1];/* decoupled model datum of ambiguities */ 59 | /* last index means datum has been set */ 60 | ambt_t amb[MAXSAT]; /* ar tracking */ 61 | ambr_t ambr[MAXSAT];/* record ambiguity */ 62 | char cTime[32]; /* time string of current epoch */ 63 | } rtk_t; 64 | 65 | /* pntpos.c ------------------------------------------------------------------*/ 66 | extern int ionocorr(gtime_t time, const nav_t *nav, int sat, const double *pos, 67 | const double *azel, int ionoopt, double *ion, double *var); 68 | extern int tropcorr(gtime_t time, const nav_t *nav, const double *pos, 69 | const double *azel, int tropopt, double *trp, double *var); 70 | extern int pntpos(const obsd_t *obs, int n, const nav_t *nav, 71 | const prcopt_t *opt, sol_t *sol, double *azel, ssat_t *ssat, 72 | char *msg); 73 | 74 | /* interBias.c ---------------------------------------------------------------*/ 75 | extern int interpol_phasebias(const prcopt_t *opt, gtime_t time, int sat, 76 | const nav_t *nav, double *bias, double *varBias); 77 | extern int interpol_codebias(const prcopt_t *opt, gtime_t time, int sat, 78 | const nav_t *nav, double *ucd, double *varUcd); 79 | 80 | /* solution.c ----------------------------------------------------------------*/ 81 | extern int outprcopts(unsigned char *buff, const prcopt_t *opt); 82 | extern int outsolheads(unsigned char *buff, const solopt_t *opt); 83 | extern int outsols(unsigned char *buff, const sol_t *sol, const double *rb, 84 | const solopt_t *opt); 85 | extern void outprcopt(FILE *fp, const prcopt_t *opt); 86 | extern void outsolhead(FILE *fp, const solopt_t *opt); 87 | extern void outsol(FILE *fp, const sol_t *sol, const double *rb, 88 | const solopt_t *opt); 89 | 90 | /* userSession.c -------------------------------------------------------------*/ 91 | extern int userOpenSession(const prcopt_t *popt, const filopt_t *fopt, 92 | nav_t *nav, pcvs_t *pcv); 93 | extern void userCloseSession(nav_t *nav,pcvs_t *pcv); 94 | 95 | /* userCmn.c -----------------------------------------------------------------*/ 96 | extern pcvs_t *userGetPcv(); 97 | extern obs_t *userGetObs(); 98 | extern nav_t *userGetNav(); 99 | extern sta_t *userGetSta(); 100 | extern int userGet_revs(); 101 | extern int userGet_aborts(); 102 | extern int userJudge_sol(); 103 | extern void userSet_revs(int i); 104 | extern void userSet_iobs(int i); 105 | extern void userSet_isol(int i); 106 | extern void userResetPar(); 107 | extern void userFree_sol_rb(); 108 | extern void userMallocSol(); 109 | extern int userCombForw(rtk_t *rtk); 110 | extern int userCombBack(rtk_t *rtk); 111 | extern void userSortObs(); 112 | extern int userCheckbrk(const char *format,...); 113 | extern int userInputObs(obsd_t *obs, int solq, const prcopt_t *popt); 114 | extern void userCombres(FILE *fp,const prcopt_t *popt,const solopt_t *sopt); 115 | extern void userFreeObs(); 116 | extern int UserOutHead(const char *outfile, const prcopt_t *popt, 117 | const solopt_t *sopt); 118 | extern void userRTKInit(rtk_t *rtk, const prcopt_t *opt, int nx); 119 | extern void userRTKFree(rtk_t *rtk); 120 | 121 | /* userCmnPPP.c --------------------------------------------------------------*/ 122 | extern void userSetAmbDatum(const rtk_t *rtk, const obsd_t *obs, int n, 123 | const int *exc, const double *azel, int *datum); 124 | extern void CalCorrAntObs(rtk_t *rtk, const obsd_t *obs, const nav_t *nav, 125 | const double *rs, const double *rr, const double *azel, double *L, 126 | double *P, double *Lc, double *Pc); 127 | extern void userUdSolution(rtk_t *rtk, const obsd_t *obs, int n, int stat); 128 | extern void userInitX_dp(rtk_t *rtk, double xi, double var, int i); 129 | 130 | #endif /* _USER_H */ 131 | -------------------------------------------------------------------------------- /src/io/readpcv.c: -------------------------------------------------------------------------------- 1 | 2 | #include "io.h" 3 | 4 | /* decode antenna parameter field --------------------------------------------*/ 5 | static int decodef(char* p, int n, double* v) 6 | { 7 | int i; 8 | 9 | for (i=0; inmax<=pcvs->n) { 21 | pcvs->nmax+=256; 22 | if (!(pcvs_pcv=(pcv_t*)realloc(pcvs->pcv, sizeof(pcv_t)*pcvs->nmax))) { 23 | trace(1, "addpcv: memory allocation error\n"); 24 | free(pcvs->pcv); pcvs->pcv=NULL; pcvs->n=pcvs->nmax=0; 25 | return; 26 | } 27 | pcvs->pcv=pcvs_pcv; 28 | } 29 | pcvs->pcv[pcvs->n++]=*pcv; 30 | } 31 | /* read ngs antenna parameter file -------------------------------------------*/ 32 | static int readngspcv(const char* file, pcvs_t* pcvs) 33 | { 34 | FILE* fp; 35 | static const pcv_t pcv0={ 0 }; 36 | pcv_t pcv; 37 | double neu[3]; 38 | int n=0; 39 | char buff[256]; 40 | 41 | if (!(fp=fopen(file, "r"))) { 42 | trace(2, "ngs pcv file open error: %s\n", file); 43 | return 0; 44 | } 45 | while (fgets(buff, sizeof(buff), fp)) { 46 | 47 | if (strlen(buff)>=62&&buff[61]=='|') continue; 48 | 49 | if (buff[0] != ' ') n=0; /* start line */ 50 | if (++n==1) { 51 | pcv=pcv0; 52 | strncpy(pcv.type, buff, 61); pcv.type[61]='\0'; 53 | } 54 | else if (n==2) { 55 | if (decodef(buff, 3, neu)<3) continue; 56 | pcv.off[0][0]=neu[1]; 57 | pcv.off[0][1]=neu[0]; 58 | pcv.off[0][2]=neu[2]; 59 | } 60 | else if (n==3) decodef(buff, 10, pcv.var[0]); 61 | else if (n==4) decodef(buff, 9, pcv.var[0]+10); 62 | else if (n==5) { 63 | if (decodef(buff, 3, neu)<3) continue;; 64 | pcv.off[1][0]=neu[1]; 65 | pcv.off[1][1]=neu[0]; 66 | pcv.off[1][2]=neu[2]; 67 | } 68 | else if (n==6) decodef(buff, 10, pcv.var[1]); 69 | else if (n==7) { 70 | decodef(buff, 9, pcv.var[1]+10); 71 | addpcv(&pcv, pcvs); 72 | } 73 | } 74 | fclose(fp); 75 | 76 | return 1; 77 | } 78 | /* read antex file ----------------------------------------------------------*/ 79 | static int readantex(const char* file, pcvs_t* pcvs) 80 | { 81 | FILE* fp; 82 | static const pcv_t pcv0={ 0 }; 83 | pcv_t pcv; 84 | double neu[3]; 85 | int i, f, freq=0, state=0, freqs[]={ 1,2,5,6,7,8,0 }; 86 | char buff[256]; 87 | 88 | trace(3, "readantex: file=%s\n", file); 89 | 90 | if (!(fp=fopen(file, "r"))) { 91 | trace(2, "antex pcv file open error: %s\n", file); 92 | return 0; 93 | } 94 | while (fgets(buff, sizeof(buff), fp)) { 95 | 96 | if (strlen(buff)<60||strstr(buff+60, "COMMENT")) continue; 97 | 98 | if (strstr(buff+60, "START OF ANTENNA")) { 99 | pcv=pcv0; 100 | state=1; 101 | } 102 | if (strstr(buff+60, "END OF ANTENNA")) { 103 | addpcv(&pcv, pcvs); 104 | state=0; 105 | } 106 | if (!state) continue; 107 | 108 | if (strstr(buff+60, "TYPE / SERIAL NO")) { 109 | strncpy(pcv.type, buff, 20); pcv.type[20]='\0'; 110 | strncpy(pcv.code, buff+20, 20); pcv.code[20]='\0'; 111 | if (!strncmp(pcv.code+3, " ", 8)) { 112 | pcv.sat=satid2no(pcv.code); 113 | } 114 | } 115 | else if (strstr(buff+60, "VALID FROM")) { 116 | if (!str2time(buff, 0, 43, &pcv.ts)) continue; 117 | } 118 | else if (strstr(buff+60, "VALID UNTIL")) { 119 | if (!str2time(buff, 0, 43, &pcv.te)) continue; 120 | } 121 | else if (strstr(buff+60, "START OF FREQUENCY")) { 122 | if (sscanf(buff+4, "%d", &f)<1) continue; 123 | for (i=0; in; i++) { 173 | pcv=pcvs->pcv+i; 174 | trace(4, "sat=%2d type=%20s code=%s off=%8.4f %8.4f %8.4f %8.4f %8.4f %8.4f\n", 175 | pcv->sat, pcv->type, pcv->code, pcv->off[0][0], pcv->off[0][1], 176 | pcv->off[0][2], pcv->off[1][0], pcv->off[1][1], pcv->off[1][2]); 177 | } 178 | return stat; 179 | } -------------------------------------------------------------------------------- /src/net/uck/udStates_u.c: -------------------------------------------------------------------------------- 1 | 2 | #include "uck.h" 3 | 4 | #define SQR(x) (x*x) 5 | #define VAR_GRA SQR(0.01) /* init variance gradient (m^2) */ 6 | #define GAP_RESTROP 120 /* default gap to reset trops parameters (ep) */ 7 | #define GAP_RESION 120 /* default gap to reset ionos parameters (ep) */ 8 | 9 | 10 | 11 | // 12 | ///* temporal update of tropospheric delay -------------------------------------*/ 13 | //static updateClk(net_t *uck, rcv_t *rcv, int n, const nav_t *nav) 14 | //{ 15 | // sol_t sol,sol0={{0}}; 16 | // ssat_t ssats[MAXSAT]; 17 | // double dts; 18 | // char msg[128]=""; 19 | // int i,k; 20 | // 21 | // for (i=0;iopt); 23 | // if (uck->x[k]!=0.0) continue; 24 | // if (!ephclk(uck->sol.time,uck->sol.time,i+1,nav,&dts)) { 25 | // trace(2,"updateClk error\n"); 26 | // continue; 27 | // } 28 | // uck->x[k]=dts; 29 | // } 30 | // for (i=0;iopt)); 32 | // if (uck->x[k]!=0.0) continue; 33 | // sol=sol0; 34 | // if (!pntpos(rcv[i].obs,rcv[i].nobs,nav,&uck->opt,&sol,NULL,ssats,msg)) { 35 | // trace(2,"%s spp err rcv(%s) msg(%s)\n",uck->time,rcv[i].sta.name,msg); 36 | // rcv[i].nobs=0; 37 | // continue; 38 | // } 39 | // uck->x[k]=sol.dtr[0]; 40 | // } 41 | //} 42 | /* temporal update of tropospheric delay -------------------------------------*/ 43 | static void updateTrop(net_t *uck, const rcv_t *rcv, int n) 44 | { 45 | const prcopt_t *opt=&uck->opt; 46 | double pos[3],azel[]={0.0,PI/2.0},ztd,var; 47 | int i,j,k,nx=uck->nx; 48 | 49 | for (i=0;iopt); 52 | if (uck->x[k]==0.0||(int)rcv[i].outc>GAP_RESTROP) { 53 | ecef2pos(rcv[i].sta.pos,pos); 54 | ztd=tropMops(rcv[i].time,pos,azel,&var); /* zenith total delay */ 55 | initxNet(uck,ztd,var,k); 56 | 57 | if (opt->tropopt==TROPOPT_ESTG) { 58 | for (j=k+1;jP[k*(nx+1)]+=opt->prn[1]*fabs(rcv[i].tt); 63 | if (opt->tropopt==TROPOPT_ESTG) { 64 | for (j=k+1;jP[j*(nx+1)]+=SQR(0.1)*opt->prn[1]*fabs(rcv[i].tt); 66 | } 67 | } 68 | } 69 | } 70 | } 71 | /* temporal update of ionospheric delay --------------------------------------*/ 72 | static void updateIono(net_t *uck, const rcv_t *rcv, int n) 73 | { 74 | const prcopt_t *opt=&uck->opt; 75 | int i,j,k,sat; 76 | 77 | for (i=0;ix[k]!=0.0&&(int)rcv[i].ssat[sat-1].outc[0]>GAP_RESION) { 81 | initxNet(uck,0.0,0.0,k); 82 | } 83 | else if (uck->x[k]!=0.0) { 84 | uck->P[k+k*uck->nx]+=opt->prn[2]*fabs(rcv[i].tt); 85 | } 86 | } 87 | } 88 | /* update states of ambiguities ----------------------------------------------*/ 89 | static void updateAmb(net_t *uck, rcv_t *rcv, int n) 90 | { 91 | const prcopt_t *opt=&uck->opt; 92 | int i,j,k,f,sat,slip; 93 | 94 | /* reset ambiguity of outlock receiver in previous epoch */ 95 | for (i=0;i=MAXRCVOUT) { 96 | for (j=0;joutc[j]>=MAXSATOUT) { 104 | for (i=0;i=MAXSATOUT) { 114 | initxNet(uck,0.0,0.0,UIAMB(i+1,j+1,f+1,opt)); 115 | rcv[i].amb[j].count[f]=0; 116 | } 117 | } 118 | } 119 | 120 | /* reset ambiguity if cycle slip in current epoch */ 121 | for (i=0;ix[k]!=0.0&&!slip) { 128 | uck->P[k+k*uck->nx]+=opt->prn[3]*fabs(rcv[i].tt); 129 | } 130 | else { 131 | initxNet(uck,0.0,0.0,k); 132 | rcv[i].amb[sat-1].count[f]=0; 133 | } 134 | } 135 | } 136 | } 137 | /* temporal update of satellite and receiver delay ---------------------------*/ 138 | static void updateDelay(net_t *uck, const rcv_t *rcv, int n) 139 | { 140 | const prcopt_t *opt=&uck->opt; 141 | int i,f,k; 142 | 143 | /* reset delay if receiver outage */ 144 | for (i=0;ix[k]!=0.0&&(int)rcv[i].outc>=MAXRCVOUT) initxNet(uck,0.0,0.0,k); 147 | else uck->P[k+k*uck->nx]+=opt->prn[4]*fabs(rcv[i].tt); 148 | } 149 | 150 | /* reset delay if satellite outage */ 151 | for (i=0;ix[k]!=0.0&&uck->outc[i]>=MAXSATOUT) initxNet(uck,0.0,0.0,k); 154 | else uck->P[k+k*uck->nx]+=opt->prn[5]*fabs(rcv[0].tt); 155 | } 156 | } 157 | /* temporal update of satellite and receiver code bias -----------------------*/ 158 | static void updateCob(net_t *uck, const rcv_t *rcv, int n) 159 | { 160 | const prcopt_t *opt=&uck->opt; 161 | int i,f,k; 162 | 163 | /* reset delay if receiver outage */ 164 | if (opt->rcb) 165 | for (i=0;ix[k]!=0.0&&(int)rcv[i].outc>=MAXRCVOUT) initxNet(uck,0.0,0.0,k); 168 | else uck->P[k+k*uck->nx]+=opt->prn[6]*fabs(rcv[i].tt); 169 | } 170 | 171 | /* reset delay if satellite outage */ 172 | if (opt->scb) 173 | for (i=0;ix[k]!=0.0&&uck->outc[i]>=MAXSATOUT) initxNet(uck,0.0,0.0,k); 176 | else uck->P[k+k*uck->nx]+=opt->prn[7]*fabs(rcv[0].tt); 177 | } 178 | } 179 | /* update decoupled model states ---------------------------------------------*/ 180 | extern void udStates_u(net_t *uck, rcv_t *rcv, int n, const nav_t *nav) 181 | { 182 | trace(3,"udStates_u\n"); 183 | 184 | //updateClk(uck,rcv,n,nav); 185 | updateTrop (uck,rcv,n); 186 | updateAmb (uck,rcv,n); 187 | if (uck->opt.ionoopt==IONOOPT_EST) { 188 | updateIono (uck,rcv,n); 189 | updateDelay(uck,rcv,n); 190 | } 191 | updateCob(uck,rcv,n); 192 | } -------------------------------------------------------------------------------- /src/io/readdck.c: -------------------------------------------------------------------------------- 1 | 2 | #include "io.h" 3 | 4 | #define MAXRNXLEN (16*MAXOBSTYPE+4) /* max rinex record length */ 5 | #define MAXPOSHEAD 1024 /* max head line position */ 6 | 7 | /* compare precise clock -----------------------------------------------------*/ 8 | static int cmppclk(const void *p1, const void *p2) 9 | { 10 | pclk_t *q1=(pclk_t*)p1,*q2=(pclk_t*)p2; 11 | double tt=timediff(q1->time,q2->time); 12 | return tt<-1E-9?-1:(tt>1E-9?1:q1->index-q2->index); 13 | } 14 | /* combine precise clock -----------------------------------------------------*/ 15 | static void combpclk(nav_t *nav) 16 | { 17 | pclk_t *nav_pclk; 18 | int i,j,k,m; 19 | 20 | trace(3,"combpclk: nc=%d\n",nav->nc); 21 | 22 | if (nav->nc<=0) return; 23 | qsort(nav->pclk,nav->nc,sizeof(pclk_t),cmppclk); 24 | 25 | for (i=0,j=1;jnc;j++) { 26 | /* if i and j at the same epoch */ 27 | if (fabs(timediff(nav->pclk[i].time,nav->pclk[j].time))<1E-9) { 28 | for (k=0;kpclk[j].clk[k][0]==0.0) continue; 30 | for (m=0;m<3;m++) { 31 | nav->pclk[i].clk[k][m]=nav->pclk[j].clk[k][m]; 32 | nav->pclk[i].std[k][m]=nav->pclk[j].std[k][m]; 33 | } 34 | } 35 | } 36 | else if (++ipclk[i]=nav->pclk[j]; 37 | } 38 | nav->nc=i+1; 39 | 40 | if (!(nav_pclk=(pclk_t*)realloc(nav->pclk,sizeof(pclk_t)*nav->nc))) { 41 | free(nav->pclk);nav->pclk=NULL;nav->nc=nav->ncmax=0; 42 | trace(1,"combpclk malloc error nc=%d\n",nav->nc); 43 | return; 44 | } 45 | nav->pclk=nav_pclk; 46 | nav->ncmax=nav->nc; 47 | 48 | trace(3,"combpclk: nc=%d\n",nav->nc); 49 | } 50 | /* read rinex clock ----------------------------------------------------------*/ 51 | static int readdckb(FILE *fp, const int mask, int index, nav_t *nav) 52 | { 53 | pclk_t *nav_pclk; 54 | gtime_t time; 55 | double data[6]={0}; 56 | int i,j,sat; 57 | char buff[MAXRNXLEN],satid[8]=""; 58 | 59 | trace(3,"readdckb: index=%d\n",index); 60 | 61 | if (!nav) return 0; 62 | 63 | while (fgets(buff,sizeof(buff),fp)) { 64 | 65 | if (str2time(buff,8,26,&time)) { 66 | trace(2,"dcoupled clk invalid epoch (%34.34s)\n",buff); 67 | continue; 68 | } 69 | strncpy(satid,buff+3,4); 70 | 71 | /* only read AS (satellite clock) record */ 72 | if (strncmp(buff,"AS",2)||!(sat=satid2no(satid))) continue; 73 | if (!(satsys(sat,NULL)&mask)) continue; 74 | 75 | for (i=0,j=40;i<6;i++,j+=20) data[i]=str2num(buff,j,19); 76 | 77 | if (nav->nc>=nav->ncmax) { 78 | nav->ncmax+=1024; 79 | if (!(nav_pclk=(pclk_t*)realloc(nav->pclk,sizeof(pclk_t)*(nav->ncmax)))) { 80 | trace(1,"readdckb malloc error: nmax=%d\n",nav->ncmax); 81 | free(nav->pclk);nav->pclk=NULL;nav->nc=nav->ncmax=0; 82 | return 0; 83 | } 84 | nav->pclk=nav_pclk; 85 | } 86 | 87 | if (nav->nc<=0||fabs(timediff(time,nav->pclk[nav->nc-1].time))>1E-9) { 88 | nav->nc++; 89 | nav->pclk[nav->nc-1].time=time; 90 | nav->pclk[nav->nc-1].index=index; 91 | for (i=0;ipclk[nav->nc-1].clk[i][j]=0.0; 93 | nav->pclk[nav->nc-1].std[i][j]=0.0f; 94 | } 95 | } 96 | /* nenoseconds to seconds */ 97 | for (i=0;i<3;i++) { 98 | nav->pclk[nav->nc-1].clk[sat-1][i]=data[i]; 99 | nav->pclk[nav->nc-1].std[sat-1][i]=(float)(data[i+3]); 100 | } 101 | } 102 | 103 | return nav->nc>0; 104 | } 105 | /* read clock file header ----------------------------------------------------*/ 106 | static int readdckh(FILE *fp, nav_t *nav) 107 | { 108 | 109 | trace(3,"readdckh:\n"); 110 | 111 | char buff[MAXRNXLEN],*label=buff+60; 112 | 113 | while (fgets(buff,MAXRNXLEN,fp)) { 114 | 115 | //if (strlen(buff)<=60) continue; 116 | 117 | //else if (strstr(label,"RINEX VERSION / TYPE")) { 118 | // if ((type=*(buff+20)) != 'C') { 119 | // trace(2,"unsupported clock type type=%c\n",type); 120 | // return 0; 121 | // } 122 | // continue; 123 | //} 124 | //else if (strstr(label,"PGM / RUN BY / DATE")) continue; 125 | //else if (strstr(label,"COMMENT")) continue; 126 | if (strstr(label,"END OF HEADER")) return 1; 127 | } 128 | return 0; 129 | } 130 | /* read decoupled clock file ---------------------------------------------------*/ 131 | static int readdckf(const char *file, const int mask, int index, nav_t *nav) 132 | { 133 | trace(3,"readdckf: file=%s index=%d\n",file,index); 134 | 135 | FILE* fp; 136 | int stat; 137 | 138 | if (!(fp=fopen(file,"r"))) { 139 | trace(2,"decoupled clock file open error (%s)\n",file); 140 | return 0; 141 | } 142 | /* read clock file header */ 143 | if (!readdckh(fp,nav)) return 0; 144 | 145 | /* read clock file body */ 146 | stat=readdckb(fp,mask,index,nav); 147 | 148 | fclose(fp); 149 | return stat; 150 | } 151 | /* read decoupled clock files -------------------------------------------------- 152 | * read decoupled clock file 153 | * args : char *file I file (wild-card * expanded) 154 | * int mask I system mask (SYS_GPS for gps) 155 | * nav_t *nav IO navigation data (NULL: no input) 156 | * return : 0:error, 1:ok 157 | *-----------------------------------------------------------------------------*/ 158 | extern int readdck(const char *file, const int mask, nav_t *nav) 159 | { 160 | int i,n,index=0,stat=1; 161 | char *files[MAXEXFILE]={ 0 }; 162 | 163 | trace(3,"readrnxc: file=%s mask=%d\n",file,mask); 164 | 165 | for (i=0;i=0;i--) free(files[i]); 168 | return -1; 169 | } 170 | } 171 | /* expand wild-card */ 172 | n=expath(file,files,MAXEXFILE); 173 | 174 | /* read dcoupled clock files */ 175 | for (i=0;i