Skip to content

Commit 6249a77

Browse files
committed
Add SNR RINEX header, and option to output standardized SNR (1-9) [DEVINFRA-561]
Take #2
1 parent d035b36 commit 6249a77

File tree

4 files changed

+42
-11
lines changed

4 files changed

+42
-11
lines changed

app/consapp/convbin/convbin.c

+4
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ static const char *help[]={
9898
" -oi include iono correction in rinex nav header [off]",
9999
" -ot include time correction in rinex nav header [off]",
100100
" -ol include leap seconds in rinex nav header [off]",
101+
" -os include standardized signal strength (1-9) in rinex obs [off]",
101102
" -halfc half-cycle ambiguity correction [off]",
102103
" -mask [sig[,...]] signal mask(s) (sig={G|R|E|J|S|C|I}L{1C|1P|1W|...})",
103104
" -nomask [sig[,...]] signal no mask (same as above)",
@@ -437,6 +438,9 @@ static int cmdopts(int argc, char **argv, rnxopt_t *opt, char **ifile,
437438
else if (!strcmp(argv[i],"-ol")) {
438439
opt->outleaps=1;
439440
}
441+
else if (!strcmp(argv[i],"-os")) {
442+
opt->outsnr=1;
443+
}
440444
else if (!strcmp(argv[i],"-scan")) {
441445
/* obsolute */ ;
442446
}

src/rinex.c

+36-11
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,7 @@ extern int outrnxobsh(FILE *fp, const rnxopt_t *opt, const nav_t *nav)
20312031
{
20322032
double ep[6],pos[3]={0},del[3]={0};
20332033
char date[32],*sys,*tsys="GPS";
2034-
int i;
2034+
int i,m,j,snr;
20352035

20362036
trace(3,"outrnxobsh:\n");
20372037

@@ -2085,6 +2085,15 @@ extern int outrnxobsh(FILE *fp, const rnxopt_t *opt, const nav_t *nav)
20852085
if (opt->tint>0.0) {
20862086
fprintf(fp,"%10.3f%50s%-20s\n",opt->tint,"","INTERVAL");
20872087
}
2088+
if (opt->rnxver>=300) { /* ver.3 */
2089+
snr=0;
2090+
for (m=0;m<7;m++) {
2091+
for (j=0;j<opt->nobs[m];j++) {
2092+
if (opt->tobs[m][j][0]=='S') snr=1;
2093+
}
2094+
}
2095+
if (snr) fprintf(fp,"%4s%-56s%-20s\n","DBHZ","","SIGNAL STRENGTH UNIT");
2096+
}
20882097
time2epoch(opt->tstart,ep);
20892098
fprintf(fp," %04.0f %02.0f %02.0f %02.0f %02.0f %010.7f %-12s%-20s\n",
20902099
ep[0],ep[1],ep[2],ep[3],ep[4],ep[5],tsys,"TIME OF FIRST OBS");
@@ -2105,7 +2114,7 @@ extern int outrnxobsh(FILE *fp, const rnxopt_t *opt, const nav_t *nav)
21052114
return fprintf(fp,"%-60.60s%-20s\n","","END OF HEADER")!=EOF;
21062115
}
21072116
/* output observation data field ---------------------------------------------*/
2108-
static void outrnxobsf(FILE *fp, double obs, int lli)
2117+
static void outrnxobsf(FILE *fp, double obs, int lli, int snr)
21092118
{
21102119
if (obs==0.0||obs<=-1E9||obs>=1E9) {
21112120
fprintf(fp," ");
@@ -2114,10 +2123,16 @@ static void outrnxobsf(FILE *fp, double obs, int lli)
21142123
fprintf(fp,"%14.3f",obs);
21152124
}
21162125
if (lli<0||!(lli&(LLI_SLIP|LLI_HALFC|LLI_BOCTRK))) {
2117-
fprintf(fp," ");
2126+
fprintf(fp," ");
21182127
}
21192128
else {
2120-
fprintf(fp,"%1.1d ",lli&(LLI_SLIP|LLI_HALFC|LLI_BOCTRK));
2129+
fprintf(fp,"%1.1d",lli&(LLI_SLIP|LLI_HALFC|LLI_BOCTRK));
2130+
}
2131+
if (snr<0) {
2132+
fprintf(fp," ");
2133+
}
2134+
else {
2135+
fprintf(fp,"%1.1d",snr);
21212136
}
21222137
}
21232138
/* search obsservattion data index -------------------------------------------*/
@@ -2195,9 +2210,9 @@ extern int outrnxobsb(FILE *fp, const rnxopt_t *opt, const obsd_t *obs, int n,
21952210
int flag, double _dClockBias)
21962211
{
21972212
const char *mask;
2198-
double ep[6],dL;
2213+
double ep[6],dL,snrRaw;
21992214
char sats[MAXOBS][4]={""};
2200-
int i,j,k,m,ns,sys,ind[MAXOBS],s[MAXOBS]={0};
2215+
int i,j,k,m,ns,sys,ind[MAXOBS],s[MAXOBS]={0},snrRnx;
22012216

22022217
trace(3,"outrnxobsb: n=%d\n",n);
22032218

@@ -2253,19 +2268,29 @@ extern int outrnxobsb(FILE *fp, const rnxopt_t *opt, const obsd_t *obs, int n,
22532268
/* search obs data index */
22542269
if ((k=obsindex(opt->rnxver,sys,obs[ind[i]].code,opt->tobs[m][j],
22552270
mask))<0) {
2256-
outrnxobsf(fp,0.0,-1);
2271+
outrnxobsf(fp,0.0,-1,-1);
22572272
continue;
22582273
}
22592274
/* phase shift (cyc) */
22602275
dL=(obs[ind[i]].L[k]!=0.0)?opt->shift[m][j]:0.0;
22612276

2277+
/* stardized signal strength */
2278+
snrRaw=obs[ind[i]].SNR[k]*SNR_UNIT;
2279+
if (opt->outsnr&&snrRaw>0.0) {
2280+
snrRnx=snrRaw/6;
2281+
snrRnx=snrRnx<1?1:snrRnx;
2282+
snrRnx=snrRnx>9?9:snrRnx;
2283+
} else {
2284+
snrRnx=-1;
2285+
}
2286+
22622287
/* output field */
22632288
switch (opt->tobs[m][j][0]) {
22642289
case 'C':
2265-
case 'P': outrnxobsf(fp,obs[ind[i]].P[k],-1); break;
2266-
case 'L': outrnxobsf(fp,obs[ind[i]].L[k]+dL,obs[ind[i]].LLI[k]); break;
2267-
case 'D': outrnxobsf(fp,obs[ind[i]].D[k],-1); break;
2268-
case 'S': outrnxobsf(fp,obs[ind[i]].SNR[k]*SNR_UNIT,-1); break;
2290+
case 'P': outrnxobsf(fp,obs[ind[i]].P[k],-1,snrRnx); break;
2291+
case 'L': outrnxobsf(fp,obs[ind[i]].L[k]+dL,obs[ind[i]].LLI[k],-1); break;
2292+
case 'D': outrnxobsf(fp,obs[ind[i]].D[k],-1,-1); break;
2293+
case 'S': outrnxobsf(fp,snrRaw,-1,-1); break;
22692294
}
22702295
}
22712296
if (opt->rnxver>=300&&fprintf(fp,"\n")==EOF) return 0;

src/rtklib.h

+1
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,7 @@ typedef struct { /* RINEX options type */
10991099
char tobs[7][MAXOBSTYPE][4]; /* obs types {GPS,GLO,GAL,QZS,SBS,CMP,IRN} */
11001100
double shift[7][MAXOBSTYPE]; /* phase shift (cyc) {GPS,GLO,GAL,QZS,SBS,CMP,IRN} */
11011101
int nobs[7]; /* number of obs types {GPS,GLO,GAL,QZS,SBS,CMP,IRN} */
1102+
int outsnr; /* output standardized signal strength */
11021103
} rnxopt_t;
11031104

11041105
typedef struct { /* satellite status type */

test/data/rcvraw/2018-06-15-json-ref.obs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ G 8 C1C L1C D1C S1C C2S L2S D2S S2S SYS / # / OBS TYPES
1010
R 8 C1C L1C D1C S1C C2C L2C D2C S2C SYS / # / OBS TYPES
1111
E 8 C1B L1B D1B S1B C7I L7I D7I S7I SYS / # / OBS TYPES
1212
C 8 C2I L2I D2I S2I C7I L7I D7I S7I SYS / # / OBS TYPES
13+
DBHZ SIGNAL STRENGTH UNIT
1314
2018 06 15 06 48 20.0000000 GPS TIME OF FIRST OBS
1415
2018 06 15 07 18 19.0000000 GPS TIME OF LAST OBS
1516
G L1C SYS / PHASE SHIFT

0 commit comments

Comments
 (0)