File: t_preceph.c

package info (click to toggle)
rtklib 2.4.3%2Bdfsg1-2.1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 41,796 kB
  • sloc: cpp: 51,592; ansic: 50,584; fortran: 987; makefile: 861; sh: 45
file content (209 lines) | stat: -rw-r--r-- 5,725 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*------------------------------------------------------------------------------
* rtklib unit test driver : precise ephemeris function
*-----------------------------------------------------------------------------*/
#include <stdio.h>
#include <assert.h>
#include "../../src/rtklib.h"

static void dumpeph(peph_t *peph, int n)
{
    char s[64];
    int i,j;
    for (i=0;i<n;i++) {
        time2str(peph[i].time,s,3);
        printf("time=%s\n",s);
        for (j=0;j<MAXSAT;j++) {
            printf("%03d: %14.3f %14.3f %14.3f : %5.3f %5.3f %5.3f\n",
                   j+1,peph[i].pos[j][0],peph[i].pos[j][1],peph[i].pos[j][2],
                   peph[i].std[j][0],peph[i].std[j][1],peph[i].std[j][2]);
        }
    }
}
static void dumpclk(pclk_t *pclk, int n)
{
    char s[64];
    int i,j;
    for (i=0;i<n;i++) {
        time2str(pclk[i].time,s,3);
        printf("time=%s\n",s);
        for (j=0;j<MAXSAT;j++) {
            printf("%03d: %14.3f : %5.3f\n",
                   j+1,pclk[i].clk[j][0]*1E9,pclk[i].std[j][0]*1E9);
        }
    }
}
/* readsp3() */
void utest1(void)
{
    char *file1="../data/sp3/igs15904.sp4";
    char *file2="../data/sp3/igs15904.sp3";
    char *file3="../data/sp3/igs1590*.sp3";
    nav_t nav={0};
    
    printf("file=%s\n",file1);
    readsp3(file1,&nav,0);
        assert(nav.ne==0);
    
    printf("file=%s\n",file2);
    readsp3(file2,&nav,0);
        assert(nav.ne==96);
    dumpeph(nav.peph,nav.ne);
    
    printf("file=%s\n",file3);
    readsp3(file3,&nav,0);
        assert(nav.ne==192);
    dumpeph(nav.peph,nav.ne);
    
    printf("%s utest1 : OK\n",__FILE__);
}
/* readsap() */
void utest2(void)
{
    double ep1[]={2008,3,1,0,0,0};
    double ep2[]={2006,11,4,23,59,59};
    char *file1="../data/sp3/igs06.atx";
    char *file2="../../data/igs05.atx";
    pcvs_t pcvs={0};
    pcv_t *pcv;
    gtime_t time;
    int i,stat;
    
    printf("file=%s\n",file1);
    stat=readpcv(file1,&pcvs);
        assert(!stat);
    stat=readpcv(file2,&pcvs);
        assert(stat);
    
    time=epoch2time(ep1);
    for (i=0;i<MAXSAT;i++) {
        if (!(pcv=searchpcv(i+1,"",time,&pcvs))) continue;
        printf("PRN%02d : %7.4f %7.4f %7.4f\n",i+1,pcv->off[0][0],pcv->off[0][1],pcv->off[0][2]);
    }
    time=epoch2time(ep2);
    for (i=0;i<MAXSAT;i++) {
        if (!(pcv=searchpcv(i+1,"",time,&pcvs))) continue;
        printf("PRN%02d : %7.4f %7.4f %7.4f\n",i+1,pcv->off[0][0],pcv->off[0][1],pcv->off[0][2]);
    }
    
    printf("%s utest2 : OK\n",__FILE__);
}
/* readrnxc() */
void utest3(void)
{
    char *file1="../data/sp3/igs15904.cls";
    char *file2="../data/sp3/igs15904.clk";
    char *file3="../data/sp3/igs1590*.clk";
    nav_t nav={0};
    
    printf("file=%s\n",file1);
    readrnxc(file1,&nav);
        assert(nav.nc==0);
    
    printf("file=%s\n",file2);
    readrnxc(file2,&nav);
        assert(nav.nc>0);
    dumpclk(nav.pclk,nav.nc);
    free(nav.pclk); nav.pclk=NULL; nav.nc=nav.ncmax=0;
    
    printf("file=%s\n",file3);
    readrnxc(file3,&nav);
        assert(nav.nc>0);
    dumpclk(nav.pclk,nav.nc);
    free(nav.pclk); nav.pclk=NULL; nav.nc=nav.ncmax=0;
    
    printf("%s utest3 : OK\n",__FILE__);
}
/* peph2pos() */
void utest4(void)
{
    FILE *fp;
    char *file1="../data/sp3/igs1590*.sp3"; /* 2010/7/1 */
    char *file2="../data/sp3/igs1590*.clk"; /* 2010/7/1 */
    nav_t nav={0};
    int i,j,stat,sat;
    double ep[]={2010,7,1,0,0,0};
    double rs[6]={0},dts[2]={0};
    double var;
    gtime_t t,time;
    
    time=epoch2time(ep);
    
    readsp3(file1,&nav,0);
        assert(nav.ne>0);
    readrnxc(file2,&nav);
        assert(nav.nc>0);
    stat=peph2pos(time,0,&nav,0,rs,dts,&var);
        assert(!stat);
    stat=peph2pos(time,160,&nav,0,rs,dts,&var);
        assert(!stat);
    
    fp=fopen("testpeph1.out","w");
    
    sat=4;
    
    for (i=0;i<86400*2;i+=30) {
        t=timeadd(time,(double)i);
        for (j=0;j<6;j++) rs [j]=0.0;
        for (j=0;j<2;j++) dts[j]=0.0;
        peph2pos(t,sat,&nav,0,rs,dts,&var);
        fprintf(fp,"%02d %6d %14.3f %14.3f %14.3f %14.3f %10.3f %10.3f %10.3f %10.3f\n",
                sat,i,rs[0],rs[1],rs[2],dts[0]*1E9,rs[3],rs[4],rs[5],dts[1]*1E9);
    }
    fclose(fp);
    printf("%s utest4 : OK\n",__FILE__);
}
/* satpos() */
void utest5(void)
{
    FILE *fp;
    char *file1="../data/sp3/igs1590*.sp3"; /* 2010/7/1 */
    char *file2="../data/sp3/igs1590*.clk"; /* 2010/7/1 */
    char *file3="../../data/igs05.atx";
    char *file4="../data/rinex/brdc*.10n";
    pcvs_t pcvs={0};
    pcv_t *pcv;
    nav_t nav={0};
    int i,stat,sat,svh;
    double ep[]={2010,7,1,0,0,0};
    double rs1[6]={0},dts1[2]={0},rs2[6]={0},dts2[2]={0};
    double var;
    gtime_t t,time;
    
    time=epoch2time(ep);
    
    readsp3(file1,&nav,0);
        assert(nav.ne>0);
    readrnxc(file2,&nav);
        assert(nav.nc>0);
    stat=readpcv(file3,&pcvs);
        assert(stat);
    readrnx(file4,1,"",NULL,&nav,NULL);
        assert(nav.n>0);
    for (i=0;i<MAXSAT;i++) {
        if (!(pcv=searchpcv(i+1,"",time,&pcvs))) continue;
        nav.pcvs[i]=*pcv;
    }
    fp=fopen("testpeph2.out","w");
    
    sat=3;
    
    for (i=0;i<86400*2;i+=30) {
        t=timeadd(time,(double)i);
        satpos(t,t,sat,EPHOPT_BRDC,&nav,rs1,dts1,&var,&svh);
        satpos(t,t,sat,EPHOPT_PREC,&nav,rs2,dts2,&var,&svh);
        fprintf(fp,"%02d %6d %14.3f %14.3f %14.3f %14.3f %14.3f %14.3f %14.3f %14.3f\n",
                sat,i,
                rs1[0],rs1[1],rs1[2],dts1[0]*1E9,rs2[0],rs2[1],rs2[2],dts2[0]*1E9);
    }
    fclose(fp);
    printf("%s utest4 : OK\n",__FILE__);
}
int main(int argc, char **argv)
{
    utest1();
    utest2();
    utest3();
    utest4();
    utest5();
    return 0;
}