-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCycleSlip.cpp
271 lines (225 loc) · 9.04 KB
/
CycleSlip.cpp
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
/*-------------------------------------------------------------------
Purpose: Class to detect cycle slip
-------------------------------------------------------------------
Input:
Output:
-------------------------------------------------------------------
Authors: Haroldo Antonio Marques
Programa de Pos-Graduacao em Ciencias Cartograficas
FCT/UNESP - Presidente Prudente - SP
FAPESP PROCESS: 05/03522-1
Date: July of 2010
-------------------------------------------------------------------
Observation:
-------------------------------------------------------------------*/
#include "CycleSlip.h"
namespace CSLIP{
//---------------------------------------------------------------------------
Class_Cycle_Slip::Class_Cycle_Slip()
{
Start_CycleSlip();
ICslip = 0;
old_ph1 = 0.0;
old_ph2 = 0.0;
old_p1 = 0.0;
old_p2 = 0.0;
}
//---------------------------------------------------------------------------
void Class_Cycle_Slip::Start_CycleSlip()
{
wlbias = 0.0;
diff_wl = 0.0;
diff_nl = 0.0;
sig_wlbias = 0.0;
flag_wl = false;
flag_nl = false;
count = 0;
ICslip = 0;
}
//---------------------------------------------------------------------------
void Class_Cycle_Slip::Wide_Cycle_Slip(double ph1,double ph2,double ca,double p2,bool initial_epoch)
{/*-------------------------------------------------------------------
Purpose: To compute cycle slip based on wide-lane combination
-------------------------------------------------------------------
Input: CycleSlip - struct of WLCycleSlip type
ph1 - L1 phasse in cycles
ph2 - L2 phase in cycles
ca - CA in meters
p2 - P2 in meters
initial_epoch - to indicate initial epoch of the data arc
Output: bias and sigma wide-lane inside CycleSlip struct
-------------------------------------------------------------------
Authors: Haroldo Antonio Marques
Programa de Pos-Graduacao em Ciencias Cartograficas
FCT/UNESP - Presidente Prudente - SP
FAPESP PROCESS: 05/03522-1
Date: July of 2010
-------------------------------------------------------------------
Observation: We are following Turbo Edit algorithm:
Blewitt, G. (1990), An Automatic Editing Algorithm for GPS data, Geophys. Res. Lett., 17(3),
199–202, doi:10.1029/GL017i003p00199
-------------------------------------------------------------------*/
double Lw=0.0,Pw=0.0;
double bwi=0.0,wlbias_before=0.0,sig_before=0.0;
Lw = wl1p*ph1 + wl2p*ph2; // Wide lane phase (meters)
Pw = wl1r*ca + wl2r*p2; // 'NL' range (meters)
bwi = (1.0/wlwl)*(Lw - Pw); //time-average phase widelane - code widelane
if (initial_epoch || count == 0.0) //first epoch or starting new computation
{
wlbias = bwi;
sig_wlbias = pow(0.5*wlwl,2); //set intial sigma as 0.5 wide-lane cycles
count=1;
}//if
else
{
count++; //current number of points in the data arc
}//else
if(flag_wl == true) //if there is cycle slip in the epoch k-1
{ sig_wlbias = pow(0.5*wlwl,2); //set intial sigma as 0.5 wide-lane cycles
count = 1;
flag_wl = false;
}//if
if(!initial_epoch && count > 1 )
{
wlbias_before = wlbias; //bias from epoch k-1
diff_wl = bwi - wlbias_before;
wlbias = wlbias_before + (diff_wl/count); //filter for wide-lane
sig_before = sig_wlbias; //variance from epoch k-1
//computation of recursive mean
if(diff_wl !=0 )
sig_wlbias = sig_before+(1.0/(count))*( pow(diff_wl,2) - sig_before);
//Subsequent epoch estimates bw(i+1) are required to lie within 4sig(i)
//if diff_wl greather than 4.0*sig from epoch k-1
if( fabs(diff_wl) > (4.0*sqrt(sig_before)) )
{
flag_wl = true; //to indicate a cycle slip
//cout<<"prn: "<<prn<<" sig_wlbias: "<<sig_wlbias<<endl;
}//if
}//if
//WN_Cycle_Slip(ph1,ph2,ca,p2,initial_epoch);
return;
}
//---------------------------------------------------------------------------
void Class_Cycle_Slip::WN_Cycle_Slip(double ph1,double ph2,double p1,double p2,bool initial_epoch)
{ /*-------------------------------------------------------------------
Purpose: To compute cycle slip based on wide-lane and narrow-lane combination
-------------------------------------------------------------------
Input: CycleSlip - struct of WLCycleSlip type
ph1 - L1 phasse in cycles
ph2 - L2 phase in cycles
ca - CA in meters
p2 - P2 in meters
initial_epoch - to indicate initial epoch of the data arc
Output:
-------------------------------------------------------------------
Authors: Haroldo Antonio Marques
Programa de Pos-Graduacao em Ciencias Cartograficas
FCT/UNESP - Presidente Prudente - SP
FAPESP PROCESS: 05/03522-1
Date: July of 2010
-------------------------------------------------------------------
Observation: Unlike the subroutine Wide_Cycle_Slip where wide-lane is computed
based on a filter, this subroutine computes wide and narrow lane
only looking up against the previous epoch
-------------------------------------------------------------------*/
double Curnl=0.0, Oldnl=0.0,Difnl=0.0, Difwl=0.0;
//Empirical values
double DMAXWL = 2.0, //2 m
DMAXNL = 0.2; //0.2 m
if(flag_nl == true) //if there is cycle slip in the epoch k-1
{
flag_nl = false;
}//if
if(!initial_epoch && count >= 1
&& old_ph1 && old_ph2 && old_p1 && old_p2)
{
Curnl = ( ph2*wlf2 - ph1*wlf1);
Oldnl = ( old_ph2*wlf2 - old_ph1*wlf1);
if(Oldnl!=0)
Difnl = Curnl - Oldnl;
// Difwl = ( ph1 - ph2 )*wlwl - ( old_ph1 - old_ph2 )*wlwl
// - ( p1 + p2 )/2.0 + ( old_p1 + old_p2 )/2.0;
// if TOLERANCE FAILURE
if( fabs(Difnl) > DMAXNL )
{ flag_nl=true;
diff_nl = Difnl;
}
/* if(fabs(Difwl) > DMAXWL)
{ flag_wl=true;
diff_wl=Difwl;
}
*/
}//if
old_ph1 = ph1;
old_ph2 = ph2;
old_p1 = p1;
old_p2 = p2;
return;
}
//---------------------------------------------------------------------------
double Class_Cycle_Slip::Get_wlbias() //wide lane bias
{
return (wlbias);
}
//---------------------------------------------------------------------------
double Class_Cycle_Slip::Get_sig_wlbias() //RMS wide lane bias
{
return (sig_wlbias);
}
//---------------------------------------------------------------------------
double Class_Cycle_Slip::Get_diff_wl() //diff betwen phase wide-lane and code wide-lane
{
return (diff_wl);
}
//---------------------------------------------------------------------------
double Class_Cycle_Slip::Get_diff_nl() //diff betwen phase narrow-lane and code narrow-lane
{ //Added by Marques (may of 2013)
return (diff_nl);
}
//---------------------------------------------------------------------------
bool Class_Cycle_Slip::Get_flag_wl() //flag to indicate a potential cycle slip
{
return (flag_wl);
}
//---------------------------------------------------------------------------
bool Class_Cycle_Slip::Get_flag_nl()
{
return (flag_nl);
}
//---------------------------------------------------------------------------
int Class_Cycle_Slip::Get_count() //current point in the data arc
{
return (count);
}
//---------------------------------------------------------------------------
void Class_Cycle_Slip::Set_wlbias(double value) //wide lane bias
{
wlbias = value;
}
//---------------------------------------------------------------------------
void Class_Cycle_Slip::Set_sig_wlbias(double value) //RMS wide lane bias
{
sig_wlbias = value;
}
//---------------------------------------------------------------------------
void Class_Cycle_Slip::Set_diff_wl(double value) //diff betwen phase wide-lane and code wide-lane
{
diff_wl = value;
}
//---------------------------------------------------------------------------
void Class_Cycle_Slip::Set_flag_wl(bool value) //flag to indicate a potential cycle slip
{
flag_wl = value;
}
//---------------------------------------------------------------------------
void Class_Cycle_Slip::Set_flag_nl(bool value) //flag to indicate a potential cycle slip
{
flag_nl = value;
}
//---------------------------------------------------------------------------
void Class_Cycle_Slip::Set_count(double value) //current point in the data arc
{
count = value;
}
//---------------------------------------------------------------------------
}//namespace CSlip