1 | /* -------------------------------------------------------------------------
|
---|
2 | * BKG NTRIP Client
|
---|
3 | * -------------------------------------------------------------------------
|
---|
4 | *
|
---|
5 | * Class: t_pppSatObs
|
---|
6 | *
|
---|
7 | * Purpose: Satellite observations
|
---|
8 | *
|
---|
9 | * Author: L. Mervart
|
---|
10 | *
|
---|
11 | * Created: 29-Jul-2014
|
---|
12 | *
|
---|
13 | * Changes:
|
---|
14 | *
|
---|
15 | * -----------------------------------------------------------------------*/
|
---|
16 |
|
---|
17 |
|
---|
18 | #include <iostream>
|
---|
19 | #include <cmath>
|
---|
20 | #include <newmatio.h>
|
---|
21 |
|
---|
22 | #include "pppSatObs.h"
|
---|
23 | #include "bncconst.h"
|
---|
24 | #include "pppEphPool.h"
|
---|
25 | #include "pppStation.h"
|
---|
26 | #include "bncutils.h"
|
---|
27 | #include "bncantex.h"
|
---|
28 | #include "pppObsPool.h"
|
---|
29 | #include "pppClient.h"
|
---|
30 |
|
---|
31 | using namespace BNC_PPP;
|
---|
32 | using namespace std;
|
---|
33 |
|
---|
34 | // Constructor
|
---|
35 | ////////////////////////////////////////////////////////////////////////////
|
---|
36 | t_pppSatObs::t_pppSatObs(const t_satObs& pppSatObs) {
|
---|
37 | _prn = pppSatObs._prn;
|
---|
38 | _time = pppSatObs._time;
|
---|
39 | _outlier = false;
|
---|
40 | _valid = true;
|
---|
41 | _reference = false;
|
---|
42 | _stecRefSat = 0.0;
|
---|
43 | _stecSat = 0.0;
|
---|
44 | for (unsigned ii = 0; ii < t_frequency::max; ii++) {
|
---|
45 | _obs[ii] = 0;
|
---|
46 | }
|
---|
47 | prepareObs(pppSatObs);
|
---|
48 | }
|
---|
49 |
|
---|
50 | // Destructor
|
---|
51 | ////////////////////////////////////////////////////////////////////////////
|
---|
52 | t_pppSatObs::~t_pppSatObs() {
|
---|
53 | for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
|
---|
54 | delete _obs[iFreq];
|
---|
55 | }
|
---|
56 | }
|
---|
57 |
|
---|
58 | //
|
---|
59 | ////////////////////////////////////////////////////////////////////////////
|
---|
60 | void t_pppSatObs::prepareObs(const t_satObs& pppSatObs) {
|
---|
61 |
|
---|
62 | _model.reset();
|
---|
63 |
|
---|
64 | // Select pseudoranges and phase observations
|
---|
65 | // ------------------------------------------
|
---|
66 | const string preferredAttrib = "G:12&PWCSLXYN G:5&IQX R:12&PC R:3&IQX E:16&BCX E:578&IQX J:1&SLXCZ J:26&SLX J:5&IQX C:IQX I:ABCX S:1&C S:5&IQX";
|
---|
67 |
|
---|
68 | for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
|
---|
69 | string frqNum = t_frequency::toString(t_frequency::type(iFreq)).substr(1);
|
---|
70 | for (unsigned iPref = 0; iPref < preferredAttrib.length(); iPref++) {
|
---|
71 | string obsType = (preferredAttrib[iPref] == '_') ? frqNum : frqNum + preferredAttrib[iPref];
|
---|
72 | if (_obs[iFreq] == 0) {
|
---|
73 | for (unsigned ii = 0; ii < pppSatObs._obs.size(); ii++) {
|
---|
74 | const t_frqObs* obs = pppSatObs._obs[ii];
|
---|
75 | if (obs->_rnxType2ch == obsType &&
|
---|
76 | obs->_codeValid && obs->_code &&
|
---|
77 | obs->_phaseValid && obs->_phase) {
|
---|
78 | _obs[iFreq] = new t_frqObs(*obs);
|
---|
79 | }
|
---|
80 | }
|
---|
81 | }
|
---|
82 | }
|
---|
83 | }
|
---|
84 |
|
---|
85 | // Used frequency types
|
---|
86 | // --------------------
|
---|
87 | _fType1 = t_lc::toFreq(_prn.system(),t_lc::l1);
|
---|
88 | _fType2 = t_lc::toFreq(_prn.system(),t_lc::l2);
|
---|
89 |
|
---|
90 | // Check whether all required frequencies available
|
---|
91 | // ------------------------------------------------
|
---|
92 | for (unsigned ii = 0; ii < OPT->LCs(_prn.system()).size(); ii++) {
|
---|
93 | t_lc::type tLC = OPT->LCs(_prn.system())[ii];
|
---|
94 | if (tLC == t_lc::GIM) {continue;}
|
---|
95 | if (!isValid(tLC)) {
|
---|
96 | _valid = false;
|
---|
97 | return;
|
---|
98 | }
|
---|
99 | }
|
---|
100 |
|
---|
101 | // Find Glonass Channel Number
|
---|
102 | // ---------------------------
|
---|
103 | if (_prn.system() == 'R') {
|
---|
104 | _channel = PPP_CLIENT->ephPool()->getChannel(_prn);
|
---|
105 | }
|
---|
106 | else {
|
---|
107 | _channel = 0;
|
---|
108 | }
|
---|
109 |
|
---|
110 | // Compute Satellite Coordinates at Time of Transmission
|
---|
111 | // -----------------------------------------------------
|
---|
112 | _xcSat.ReSize(6); _xcSat = 0.0;
|
---|
113 | _vvSat.ReSize(3); _vvSat = 0.0;
|
---|
114 | bool totOK = false;
|
---|
115 | ColumnVector satPosOld(6); satPosOld = 0.0;
|
---|
116 | t_lc::type tLC = isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
|
---|
117 | double prange = obsValue(tLC);
|
---|
118 | for (int ii = 1; ii <= 10; ii++) {
|
---|
119 | bncTime ToT = _time - prange / t_CST::c - _xcSat[3];
|
---|
120 | if (PPP_CLIENT->ephPool()->getCrd(_prn, ToT, _xcSat, _vvSat) != success) {
|
---|
121 | _valid = false;
|
---|
122 | return;
|
---|
123 | }
|
---|
124 | ColumnVector dx = _xcSat - satPosOld;
|
---|
125 | dx[3] *= t_CST::c;
|
---|
126 | if (dx.NormFrobenius() < 1.e-4) {
|
---|
127 | totOK = true;
|
---|
128 | break;
|
---|
129 | }
|
---|
130 | satPosOld = _xcSat;
|
---|
131 | }
|
---|
132 | if (totOK) {
|
---|
133 | _signalPropagationTime = prange / t_CST::c - _xcSat[3];
|
---|
134 | _model._satClkM = _xcSat[3] * t_CST::c;
|
---|
135 | }
|
---|
136 | else {
|
---|
137 | _valid = false;
|
---|
138 | }
|
---|
139 | }
|
---|
140 |
|
---|
141 | //
|
---|
142 | ////////////////////////////////////////////////////////////////////////////
|
---|
143 | void t_pppSatObs::lcCoeff(t_lc::type tLC,
|
---|
144 | map<t_frequency::type, double>& codeCoeff,
|
---|
145 | map<t_frequency::type, double>& phaseCoeff,
|
---|
146 | map<t_frequency::type, double>& ionoCoeff) const {
|
---|
147 |
|
---|
148 | codeCoeff.clear();
|
---|
149 | phaseCoeff.clear();
|
---|
150 | ionoCoeff.clear();
|
---|
151 |
|
---|
152 | double f1 = t_CST::freq(_fType1, _channel);
|
---|
153 | double f2 = t_CST::freq(_fType2, _channel);
|
---|
154 | double f1GPS = t_CST::freq(t_frequency::G1, 0);
|
---|
155 |
|
---|
156 | switch (tLC) {
|
---|
157 | case t_lc::l1:
|
---|
158 | phaseCoeff[_fType1] = 1.0;
|
---|
159 | ionoCoeff [_fType1] = -1.0 * pow(f1GPS, 2) / pow(f1, 2);
|
---|
160 | return;
|
---|
161 | case t_lc::l2:
|
---|
162 | phaseCoeff[_fType2] = 1.0;
|
---|
163 | ionoCoeff [_fType2] = -1.0 * pow(f1GPS, 2) / pow(f2, 2);
|
---|
164 | return;
|
---|
165 | case t_lc::lIF:
|
---|
166 | phaseCoeff[_fType1] = f1 * f1 / (f1 * f1 - f2 * f2);
|
---|
167 | phaseCoeff[_fType2] = -f2 * f2 / (f1 * f1 - f2 * f2);
|
---|
168 | return;
|
---|
169 | case t_lc::MW:
|
---|
170 | phaseCoeff[_fType1] = f1 / (f1 - f2);
|
---|
171 | phaseCoeff[_fType2] = -f2 / (f1 - f2);
|
---|
172 | codeCoeff[_fType1] = -f1 / (f1 + f2);
|
---|
173 | codeCoeff[_fType2] = -f2 / (f1 + f2);
|
---|
174 | return;
|
---|
175 | case t_lc::CL:
|
---|
176 | phaseCoeff[_fType1] = 0.5;
|
---|
177 | codeCoeff [_fType1] = 0.5;
|
---|
178 | return;
|
---|
179 | case t_lc::c1:
|
---|
180 | codeCoeff[_fType1] = 1.0;
|
---|
181 | ionoCoeff[_fType1] = pow(f1GPS, 2) / pow(f1, 2);
|
---|
182 | return;
|
---|
183 | case t_lc::c2:
|
---|
184 | codeCoeff[_fType2] = 1.0;
|
---|
185 | ionoCoeff[_fType2] = pow(f1GPS, 2) / pow(f2, 2);
|
---|
186 | return;
|
---|
187 | case t_lc::cIF:
|
---|
188 | codeCoeff[_fType1] = f1 * f1 / (f1 * f1 - f2 * f2);
|
---|
189 | codeCoeff[_fType2] = -f2 * f2 / (f1 * f1 - f2 * f2);
|
---|
190 | return;
|
---|
191 | case t_lc::GIM:
|
---|
192 | case t_lc::dummy:
|
---|
193 | case t_lc::maxLc:
|
---|
194 | return;
|
---|
195 | }
|
---|
196 | }
|
---|
197 |
|
---|
198 | //
|
---|
199 | ////////////////////////////////////////////////////////////////////////////
|
---|
200 | bool t_pppSatObs::isValid(t_lc::type tLC) const {
|
---|
201 | bool valid = true;
|
---|
202 | obsValue(tLC, &valid);
|
---|
203 | //qDebug() << "tLC: " << tLC << " valid: " << valid;
|
---|
204 | return valid;
|
---|
205 | }
|
---|
206 | //
|
---|
207 | ////////////////////////////////////////////////////////////////////////////
|
---|
208 | double t_pppSatObs::obsValue(t_lc::type tLC, bool* valid) const {
|
---|
209 |
|
---|
210 | double retVal = 0.0;
|
---|
211 | if (valid) *valid = true;
|
---|
212 |
|
---|
213 | // Pseudo observations
|
---|
214 | if (tLC == t_lc::GIM) {
|
---|
215 | if (_stecRefSat == 0.0 || _stecSat == 0.0) {
|
---|
216 | if (valid) *valid = false;
|
---|
217 | return 0.0;
|
---|
218 | }
|
---|
219 | else {
|
---|
220 | return _stecRefSat - _stecSat;
|
---|
221 | }
|
---|
222 | }
|
---|
223 |
|
---|
224 | map<t_frequency::type, double> codeCoeff;
|
---|
225 | map<t_frequency::type, double> phaseCoeff;
|
---|
226 | map<t_frequency::type, double> ionoCoeff;
|
---|
227 | lcCoeff(tLC, codeCoeff, phaseCoeff, ionoCoeff);
|
---|
228 |
|
---|
229 | map<t_frequency::type, double>::const_iterator it;
|
---|
230 |
|
---|
231 | // Code observations
|
---|
232 | for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
|
---|
233 | t_frequency::type tFreq = it->first;
|
---|
234 | if (_obs[tFreq] == 0) {
|
---|
235 | if (valid) *valid = false;
|
---|
236 | return 0.0;
|
---|
237 | }
|
---|
238 | else {
|
---|
239 | retVal += it->second * _obs[tFreq]->_code;
|
---|
240 | }
|
---|
241 | }
|
---|
242 | // Phase observations
|
---|
243 | for (it = phaseCoeff.begin(); it != phaseCoeff.end(); it++) {
|
---|
244 | t_frequency::type tFreq = it->first;
|
---|
245 | if (_obs[tFreq] == 0) {
|
---|
246 | if (valid) *valid = false;
|
---|
247 | return 0.0;
|
---|
248 | }
|
---|
249 | else {
|
---|
250 | retVal += it->second * _obs[tFreq]->_phase * t_CST::lambda(tFreq, _channel);
|
---|
251 | }
|
---|
252 | }
|
---|
253 | return retVal;
|
---|
254 | }
|
---|
255 |
|
---|
256 | //
|
---|
257 | ////////////////////////////////////////////////////////////////////////////
|
---|
258 | double t_pppSatObs::lambda(t_lc::type tLC) const {
|
---|
259 |
|
---|
260 | double f1 = t_CST::freq(_fType1, _channel);
|
---|
261 | double f2 = t_CST::freq(_fType2, _channel);
|
---|
262 |
|
---|
263 | if (tLC == t_lc::l1) {
|
---|
264 | return t_CST::c / f1;
|
---|
265 | }
|
---|
266 | else if (tLC == t_lc::l2) {
|
---|
267 | return t_CST::c / f2;
|
---|
268 | }
|
---|
269 | else if (tLC == t_lc::lIF) {
|
---|
270 | return t_CST::c / (f1 + f2);
|
---|
271 | }
|
---|
272 | else if (tLC == t_lc::MW) {
|
---|
273 | return t_CST::c / (f1 - f2);
|
---|
274 | }
|
---|
275 | else if (tLC == t_lc::CL) {
|
---|
276 | return t_CST::c / f1 / 2.0;
|
---|
277 | }
|
---|
278 |
|
---|
279 | return 0.0;
|
---|
280 | }
|
---|
281 |
|
---|
282 | //
|
---|
283 | ////////////////////////////////////////////////////////////////////////////
|
---|
284 | double t_pppSatObs::sigma(t_lc::type tLC) const {
|
---|
285 |
|
---|
286 | double retVal = 0.0;
|
---|
287 | map<t_frequency::type, double> codeCoeff;
|
---|
288 | map<t_frequency::type, double> phaseCoeff;
|
---|
289 | map<t_frequency::type, double> ionoCoeff;
|
---|
290 | lcCoeff(tLC, codeCoeff, phaseCoeff, ionoCoeff);
|
---|
291 |
|
---|
292 | if (tLC == t_lc::GIM) {
|
---|
293 | retVal = OPT->_sigmaGIMdiff * OPT->_sigmaGIMdiff;
|
---|
294 | }
|
---|
295 |
|
---|
296 | map<t_frequency::type, double>::const_iterator it;
|
---|
297 | for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {//qDebug() << "codeCoeff : " << t_frequency::toString(it->first).c_str() << ": " << it->second;
|
---|
298 | retVal += it->second * it->second * OPT->_sigmaC1 * OPT->_sigmaC1;
|
---|
299 | }
|
---|
300 |
|
---|
301 | for (it = phaseCoeff.begin(); it != phaseCoeff.end(); it++) {//qDebug() << "phaseCoeff: " << t_frequency::toString(it->first).c_str() << ": " << it->second;
|
---|
302 | retVal += it->second * it->second * OPT->_sigmaL1 * OPT->_sigmaL1;
|
---|
303 | }
|
---|
304 |
|
---|
305 | retVal = sqrt(retVal);
|
---|
306 |
|
---|
307 | // De-Weight GLONASS
|
---|
308 | // -----------------
|
---|
309 | if (_prn.system() == 'R') {
|
---|
310 | retVal *= 5.0;
|
---|
311 | }
|
---|
312 |
|
---|
313 | // Elevation-Dependent Weighting
|
---|
314 | // -----------------------------
|
---|
315 | double cEle = 1.0;
|
---|
316 | if ( (OPT->_eleWgtCode && t_lc::includesCode(tLC)) ||
|
---|
317 | (OPT->_eleWgtPhase && t_lc::includesPhase(tLC)) ) {
|
---|
318 | double eleD = eleSat()*180.0/M_PI;
|
---|
319 | double hlp = fabs(90.0 - eleD);
|
---|
320 | cEle = (1.0 + hlp*hlp*hlp*0.000004);
|
---|
321 | }
|
---|
322 |
|
---|
323 | return cEle * retVal;
|
---|
324 | }
|
---|
325 |
|
---|
326 | //
|
---|
327 | ////////////////////////////////////////////////////////////////////////////
|
---|
328 | double t_pppSatObs::maxRes(t_lc::type tLC) const {//qDebug() << "t_pppSatObs::maxRes(t_lc::type tLC)";
|
---|
329 | double retVal = 0.0;
|
---|
330 |
|
---|
331 | map<t_frequency::type, double> codeCoeff;
|
---|
332 | map<t_frequency::type, double> phaseCoeff;
|
---|
333 | map<t_frequency::type, double> ionoCoeff;
|
---|
334 | lcCoeff(tLC, codeCoeff, phaseCoeff, ionoCoeff);
|
---|
335 |
|
---|
336 | map<t_frequency::type, double>::const_iterator it;
|
---|
337 | for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {//qDebug() << "codeCoeff: " << it->first << ": " << it->second;
|
---|
338 | retVal += it->second * it->second * OPT->_maxResC1 * OPT->_maxResC1;
|
---|
339 | }
|
---|
340 | for (it = phaseCoeff.begin(); it != phaseCoeff.end(); it++) {//qDebug() << "phaseCoeff: " << it->first << ": " << it->second;
|
---|
341 | retVal += it->second * it->second * OPT->_maxResL1 * OPT->_maxResL1;
|
---|
342 | }
|
---|
343 | if (tLC == t_lc::GIM) {
|
---|
344 | retVal = 3 * (OPT->_sigmaGIMdiff * OPT->_sigmaGIMdiff);
|
---|
345 | }
|
---|
346 | return sqrt(retVal);
|
---|
347 | }
|
---|
348 |
|
---|
349 |
|
---|
350 | //
|
---|
351 | ////////////////////////////////////////////////////////////////////////////
|
---|
352 | t_irc t_pppSatObs::cmpModel(const t_pppStation* station) {
|
---|
353 |
|
---|
354 | // Reset all model values
|
---|
355 | // ----------------------
|
---|
356 | _model.reset();
|
---|
357 |
|
---|
358 | // Topocentric Satellite Position
|
---|
359 | // ------------------------------
|
---|
360 | ColumnVector rSat = _xcSat.Rows(1,3);
|
---|
361 | ColumnVector rRec = station->xyzApr();
|
---|
362 | ColumnVector rhoV = rSat - rRec;
|
---|
363 | _model._rho = rhoV.NormFrobenius();
|
---|
364 |
|
---|
365 | ColumnVector vSat = _vvSat;
|
---|
366 |
|
---|
367 | ColumnVector neu(3);
|
---|
368 | xyz2neu(station->ellApr().data(), rhoV.data(), neu.data());
|
---|
369 |
|
---|
370 | _model._eleSat = acos(sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / _model._rho);
|
---|
371 | if (neu[2] < 0) {
|
---|
372 | _model._eleSat *= -1.0;
|
---|
373 | }
|
---|
374 | _model._azSat = atan2(neu[1], neu[0]);
|
---|
375 |
|
---|
376 | // Satellite Clocks
|
---|
377 | // ----------------
|
---|
378 | _model._satClkM = _xcSat[3] * t_CST::c;
|
---|
379 |
|
---|
380 | // Receiver Clocks
|
---|
381 | // ---------------
|
---|
382 | _model._recClkM = station->dClk() * t_CST::c;
|
---|
383 |
|
---|
384 | // Sagnac Effect (correction due to Earth rotation)
|
---|
385 | // ------------------------------------------------
|
---|
386 | ColumnVector Omega(3);
|
---|
387 | Omega[0] = 0.0;
|
---|
388 | Omega[1] = 0.0;
|
---|
389 | Omega[2] = t_CST::omega / t_CST::c;
|
---|
390 | _model._sagnac = DotProduct(Omega, crossproduct(rSat, rRec));
|
---|
391 |
|
---|
392 | // Antenna Eccentricity
|
---|
393 | // --------------------
|
---|
394 | _model._antEcc = -DotProduct(station->xyzEcc(), rhoV) / _model._rho;
|
---|
395 |
|
---|
396 | // Antenna Phase Center Offsets and Variations
|
---|
397 | // -------------------------------------------
|
---|
398 | if (PPP_CLIENT->antex()) {
|
---|
399 | for (unsigned ii = 0; ii < t_frequency::max; ii++) {
|
---|
400 | t_frequency::type frqType = static_cast<t_frequency::type>(ii);
|
---|
401 | bool found;
|
---|
402 | _model._antPCO[ii] = PPP_CLIENT->antex()->rcvCorr(station->antName(), frqType,
|
---|
403 | _model._eleSat, _model._azSat, found);
|
---|
404 | }
|
---|
405 | }
|
---|
406 |
|
---|
407 | // Tropospheric Delay
|
---|
408 | // ------------------
|
---|
409 | _model._tropo = t_tropo::delay_saast(rRec, _model._eleSat);
|
---|
410 |
|
---|
411 | // Code Biases
|
---|
412 | // -----------
|
---|
413 | const t_satCodeBias* satCodeBias = PPP_CLIENT->obsPool()->satCodeBias(_prn);
|
---|
414 | if (satCodeBias) {
|
---|
415 | for (unsigned ii = 0; ii < satCodeBias->_bias.size(); ii++) {
|
---|
416 | const t_frqCodeBias& bias = satCodeBias->_bias[ii];
|
---|
417 | for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
|
---|
418 | const t_frqObs* obs = _obs[iFreq];
|
---|
419 | if (obs && obs->_rnxType2ch == bias._rnxType2ch) {
|
---|
420 | _model._codeBias[iFreq] = bias._value;
|
---|
421 | }
|
---|
422 | }
|
---|
423 | }
|
---|
424 | }
|
---|
425 |
|
---|
426 | // Phase Biases
|
---|
427 | // -----------
|
---|
428 | const t_satPhaseBias* satPhaseBias = PPP_CLIENT->obsPool()->satPhaseBias(_prn);
|
---|
429 | double yaw = 0.0;
|
---|
430 | bool ssr = false;
|
---|
431 | if (satPhaseBias) {
|
---|
432 | double dt = station->epochTime() - satPhaseBias->_time;
|
---|
433 | if (satPhaseBias->_updateInt) {
|
---|
434 | dt -= (0.5 * ssrUpdateInt[satPhaseBias->_updateInt]);
|
---|
435 | }
|
---|
436 | yaw = satPhaseBias->_yaw + satPhaseBias->_yawRate * dt;
|
---|
437 | ssr = true;
|
---|
438 | for (unsigned ii = 0; ii < satPhaseBias->_bias.size(); ii++) {
|
---|
439 | const t_frqPhaseBias& bias = satPhaseBias->_bias[ii];
|
---|
440 | for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
|
---|
441 | const t_frqObs* obs = _obs[iFreq];
|
---|
442 | if (obs && obs->_rnxType2ch == bias._rnxType2ch) {
|
---|
443 | _model._phaseBias[iFreq] = bias._value;
|
---|
444 | }
|
---|
445 | }
|
---|
446 | }
|
---|
447 | }
|
---|
448 |
|
---|
449 | // Phase Wind-Up
|
---|
450 | // -------------
|
---|
451 | _model._windUp = station->windUp(_time, _prn, rSat, ssr, yaw, vSat) ;
|
---|
452 |
|
---|
453 | // Relativistic effect due to earth gravity
|
---|
454 | // ----------------------------------------
|
---|
455 | double a = rSat.NormFrobenius() + rRec.NormFrobenius();
|
---|
456 | double b = (rSat - rRec).NormFrobenius();
|
---|
457 | double gm = 3.986004418e14; // m3/s2
|
---|
458 | _model._rel = 2 * gm / t_CST::c / t_CST::c * log((a + b) / (a - b));
|
---|
459 |
|
---|
460 | // Tidal Correction
|
---|
461 | // ----------------
|
---|
462 | _model._tideEarth = -DotProduct(station->tideDsplEarth(), rhoV) / _model._rho;
|
---|
463 | _model._tideOcean = -DotProduct(station->tideDsplOcean(), rhoV) / _model._rho;
|
---|
464 |
|
---|
465 | // Ionospheric Delay
|
---|
466 | // -----------------
|
---|
467 | const t_vTec* vTec = PPP_CLIENT->obsPool()->vTec();
|
---|
468 | bool vTecUsage = true;
|
---|
469 | for (unsigned ii = 0; ii < OPT->LCs(_prn.system()).size(); ii++) {
|
---|
470 | t_lc::type tLC = OPT->LCs(_prn.system())[ii];
|
---|
471 | if (tLC == t_lc::cIF || tLC == t_lc::lIF) {
|
---|
472 | vTecUsage = false;
|
---|
473 | }
|
---|
474 | }
|
---|
475 |
|
---|
476 | if (vTecUsage && vTec) {
|
---|
477 | double stec = station->stec(vTec, _signalPropagationTime, rSat);
|
---|
478 | double f1GPS = t_CST::freq(t_frequency::G1, 0);
|
---|
479 | for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
|
---|
480 | if (OPT->_pseudoObsIono) { // DCMcodeBias, DCMphaseBias
|
---|
481 | // For scaling the slant ionospheric delays the trick is to be consistent with units!
|
---|
482 | // The conversion of TECU into meters requires the frequency of the signal.
|
---|
483 | // Hence, GPS L1 frequency is used for all systems. The same is true for mu_i in lcCoeff().
|
---|
484 | _model._ionoCodeDelay[iFreq] = 40.3E16 / pow(f1GPS, 2) * stec;
|
---|
485 | }
|
---|
486 | else { // PPP-RTK
|
---|
487 | t_frequency::type frqType = static_cast<t_frequency::type>(iFreq);
|
---|
488 | _model._ionoCodeDelay[iFreq] = 40.3E16 / pow(t_CST::freq(frqType, _channel), 2) * stec;
|
---|
489 | }
|
---|
490 | }
|
---|
491 | }
|
---|
492 |
|
---|
493 | // Set Model Set Flag
|
---|
494 | // ------------------
|
---|
495 | _model._set = true;
|
---|
496 |
|
---|
497 | printModel();
|
---|
498 |
|
---|
499 | return success;
|
---|
500 | }
|
---|
501 |
|
---|
502 | //
|
---|
503 | ////////////////////////////////////////////////////////////////////////////
|
---|
504 | void t_pppSatObs::printModel() const {
|
---|
505 | // TODO: cout should be LOG
|
---|
506 | cout.setf(ios::fixed);
|
---|
507 | cout << "\nMODEL for Satellite " << _prn.toString() << (isReference() ? " (Reference Satellite)" : "") << endl
|
---|
508 | << "======================= " << endl
|
---|
509 | << "PPP STRATEGY : " << OPT->_obsmodelTypeStr.at((int)OPT->_obsModelType).toLocal8Bit().constData()
|
---|
510 | << ((OPT->_pseudoObsIono) ? " with pseudo-observations for STEC" : "") << endl
|
---|
511 | << "RHO : " << setw(12) << setprecision(3) << _model._rho << endl
|
---|
512 | << "ELE : " << setw(12) << setprecision(3) << _model._eleSat * RHO_DEG << endl
|
---|
513 | << "AZI : " << setw(12) << setprecision(3) << _model._azSat * RHO_DEG << endl
|
---|
514 | << "SATCLK : " << setw(12) << setprecision(3) << _model._satClkM << endl
|
---|
515 | << "RECCLK : " << setw(12) << setprecision(3) << _model._recClkM << endl
|
---|
516 | << "SAGNAC : " << setw(12) << setprecision(3) << _model._sagnac << endl
|
---|
517 | << "ANTECC : " << setw(12) << setprecision(3) << _model._antEcc << endl
|
---|
518 | << "TROPO : " << setw(12) << setprecision(3) << _model._tropo << endl
|
---|
519 | << "WINDUP : " << setw(12) << setprecision(3) << _model._windUp << endl
|
---|
520 | << "REL : " << setw(12) << setprecision(3) << _model._rel << endl
|
---|
521 | << "EARTH TIDES : " << setw(12) << setprecision(3) << _model._tideEarth << endl
|
---|
522 | << "OCEAN TIDES : " << setw(12) << setprecision(3) << _model._tideOcean << endl
|
---|
523 | << endl
|
---|
524 | << "FREQUENCY DEPENDENT CORRECTIONS:" << endl
|
---|
525 | << "-------------------------------" << endl;
|
---|
526 | for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
|
---|
527 | if (_obs[iFreq]) {
|
---|
528 | string frqStr = t_frequency::toString(t_frequency::type(iFreq));
|
---|
529 | if (_prn.system() == frqStr[0]) {
|
---|
530 | cout << "PCO : " << frqStr << setw(12) << setprecision(3) << _model._antPCO[iFreq] << endl
|
---|
531 | << "BIAS CODE : " << frqStr << setw(12) << setprecision(3) << _model._codeBias[iFreq] << endl
|
---|
532 | << "BIAS PHASE : " << frqStr << setw(12) << setprecision(3) << _model._phaseBias[iFreq] << endl
|
---|
533 | << "IONO CODEDELAY: " << frqStr << setw(12) << setprecision(3) << _model._ionoCodeDelay[iFreq]<< endl;
|
---|
534 | }
|
---|
535 | }
|
---|
536 | }
|
---|
537 | }
|
---|
538 |
|
---|
539 | //
|
---|
540 | ////////////////////////////////////////////////////////////////////////////
|
---|
541 | void t_pppSatObs::printObsMinusComputed() const {
|
---|
542 | // TODO: cout should be LOG
|
---|
543 | cout.setf(ios::fixed);
|
---|
544 | cout << "\nOBS-COMP for Satellite " << _prn.toString() << (isReference() ? " (Reference Satellite)" : "") << endl
|
---|
545 | << "========================== " << endl;
|
---|
546 | for (unsigned ii = 0; ii < OPT->LCs(_prn.system()).size(); ii++) {
|
---|
547 | t_lc::type tLC = OPT->LCs(_prn.system())[ii];
|
---|
548 | cout << "OBS-CMP " << setw(4) << t_lc::toString(tLC) << ": " << _prn.toString() << " "
|
---|
549 | << setw(12) << setprecision(3) << obsValue(tLC) << " "
|
---|
550 | << setw(12) << setprecision(3) << cmpValue(tLC) << " "
|
---|
551 | << setw(12) << setprecision(3) << obsValue(tLC) - cmpValue(tLC) << endl;
|
---|
552 | }
|
---|
553 | }
|
---|
554 |
|
---|
555 |
|
---|
556 | //
|
---|
557 | ////////////////////////////////////////////////////////////////////////////
|
---|
558 | double t_pppSatObs::cmpValueForBanc(t_lc::type tLC) const {
|
---|
559 | return cmpValue(tLC) - _model._rho - _model._sagnac - _model._recClkM;
|
---|
560 | }
|
---|
561 |
|
---|
562 | //
|
---|
563 | ////////////////////////////////////////////////////////////////////////////
|
---|
564 | double t_pppSatObs::cmpValue(t_lc::type tLC) const {
|
---|
565 | double cmpValue;
|
---|
566 |
|
---|
567 | if (!isValid(tLC)) {
|
---|
568 | cmpValue = 0.0;
|
---|
569 | }
|
---|
570 | else if (tLC == t_lc::GIM) {
|
---|
571 | cmpValue = 0.0;
|
---|
572 | }
|
---|
573 | else {
|
---|
574 | // Non-Dispersive Part
|
---|
575 | // -------------------
|
---|
576 | double nonDisp = _model._rho
|
---|
577 | + _model._recClkM - _model._satClkM
|
---|
578 | + _model._sagnac + _model._antEcc + _model._tropo
|
---|
579 | + _model._tideEarth + _model._tideOcean + _model._rel;
|
---|
580 |
|
---|
581 | // Add Dispersive Part
|
---|
582 | // -------------------
|
---|
583 | double dispPart = 0.0;
|
---|
584 | map<t_frequency::type, double> codeCoeff;
|
---|
585 | map<t_frequency::type, double> phaseCoeff;
|
---|
586 | map<t_frequency::type, double> ionoCoeff;
|
---|
587 | lcCoeff(tLC, codeCoeff, phaseCoeff, ionoCoeff);
|
---|
588 | map<t_frequency::type, double>::const_iterator it;
|
---|
589 | for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
|
---|
590 | t_frequency::type tFreq = it->first;
|
---|
591 | dispPart += it->second * (_model._antPCO[tFreq] - _model._codeBias[tFreq]);
|
---|
592 | if (OPT->PPPRTK) {
|
---|
593 | dispPart += it->second * (_model._ionoCodeDelay[tFreq]);
|
---|
594 | }
|
---|
595 | }
|
---|
596 | for (it = phaseCoeff.begin(); it != phaseCoeff.end(); it++) {
|
---|
597 | t_frequency::type tFreq = it->first;
|
---|
598 | dispPart += it->second * (_model._antPCO[tFreq] - _model._phaseBias[tFreq] +
|
---|
599 | _model._windUp * t_CST::lambda(tFreq, _channel));
|
---|
600 | if (OPT->PPPRTK) {
|
---|
601 | dispPart += it->second * (- _model._ionoCodeDelay[tFreq]);
|
---|
602 | }
|
---|
603 | }
|
---|
604 | cmpValue = nonDisp + dispPart;
|
---|
605 | }
|
---|
606 |
|
---|
607 | return cmpValue;
|
---|
608 | }
|
---|
609 |
|
---|
610 | //
|
---|
611 | ////////////////////////////////////////////////////////////////////////////
|
---|
612 | void t_pppSatObs::setRes(t_lc::type tLC, double res) {
|
---|
613 | _res[tLC] = res;
|
---|
614 | }
|
---|
615 |
|
---|
616 | //
|
---|
617 | ////////////////////////////////////////////////////////////////////////////
|
---|
618 | double t_pppSatObs::getRes(t_lc::type tLC) const {
|
---|
619 | map<t_lc::type, double>::const_iterator it = _res.find(tLC);
|
---|
620 | if (it != _res.end()) {
|
---|
621 | return it->second;
|
---|
622 | }
|
---|
623 | else {
|
---|
624 | return 0.0;
|
---|
625 | }
|
---|
626 | }
|
---|
627 |
|
---|
628 | //
|
---|
629 | ////////////////////////////////////////////////////////////////////////////
|
---|
630 | void t_pppSatObs::setPseudoObsIono(t_frequency::type freq, double stecRefSat) {
|
---|
631 | _stecSat = _model._ionoCodeDelay[freq];
|
---|
632 | _stecRefSat = stecRefSat;
|
---|
633 | }
|
---|