source: ntrip/trunk/BNC/src/PPP/pppSatObs.cpp@ 9604

Last change on this file since 9604 was 9604, checked in by stuerze, 7 months ago

minor changes

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