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

Last change on this file since 11024 was 10942, checked in by stuerze, 3 months ago

handling of ionospheric constraints descrived/updated

  • Property svn:keywords set to Author Date Id Rev URL;svn:eol-style=native
  • Property svn:mime-type set to text/plain
File size: 23.8 KB
RevLine 
[7237]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 *
[7288]13 * Changes:
[7237]14 *
15 * -----------------------------------------------------------------------*/
16
17
18#include <iostream>
[9473]19#include <iomanip>
[7237]20#include <cmath>
[10791]21#include <algorithm>
22#include <set>
[7237]23#include <newmatio.h>
24
25#include "pppSatObs.h"
26#include "bncconst.h"
27#include "pppEphPool.h"
28#include "pppStation.h"
29#include "bncutils.h"
30#include "bncantex.h"
31#include "pppObsPool.h"
32#include "pppClient.h"
33
34using namespace BNC_PPP;
[9590]35using namespace std;
[7237]36
[9821]37
[7237]38// Constructor
39////////////////////////////////////////////////////////////////////////////
40t_pppSatObs::t_pppSatObs(const t_satObs& pppSatObs) {
[8905]41 _prn = pppSatObs._prn;
42 _time = pppSatObs._time;
43 _outlier = false;
44 _valid = true;
45 _reference = false;
46 _stecSat = 0.0;
[10938]47 _stecRefSat = 0.0;
[7237]48 for (unsigned ii = 0; ii < t_frequency::max; ii++) {
49 _obs[ii] = 0;
50 }
51 prepareObs(pppSatObs);
52}
53
54// Destructor
55////////////////////////////////////////////////////////////////////////////
56t_pppSatObs::~t_pppSatObs() {
57 for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
58 delete _obs[iFreq];
59 }
60}
61
[7288]62//
[7237]63////////////////////////////////////////////////////////////////////////////
[10791]64bool t_pppSatObs::isBetter(const t_frqObs* aa, t_frqObs* bb, const string& trkModes) const {
[7237]65
[10791]66 if (!trkModes.empty()) {
67 size_t posA = trkModes.find(aa->trkChar());
68 size_t posB = trkModes.find(bb->trkChar());
69 if (posA != posB) {
70 if (posA == string::npos) {
71 return false;
72 }
73 else if (posB == string::npos) {
74 return true;
75 }
76 else {
77 return posA < posB;
78 }
79 }
80 }
81
82 unsigned numValA = 0;
83 if (aa->_codeValid) numValA += 1;
84 if (aa->_phaseValid) numValA += 1;
[7237]85
[10791]86 unsigned numValB = 0;
87 if (bb->_codeValid) numValB += 1;
88 if (bb->_phaseValid) numValB += 1;
89
90 if (numValA != numValB) {
91 return numValA > numValB;
[10251]92 }
93
[10791]94 return false;
95}
96
97//
98////////////////////////////////////////////////////////////////////////////
99void t_pppSatObs::prepareObs(const t_satObs& satObs) {
100
101 _model.reset();
102
103 const t_pppOptions::SysTrkModes* sysTrkModes = OPT->sysTrkModes(_prn.system());
104 using FrqTrkModes = t_pppOptions::SysTrkModes::FrqTrkModes;
105
106 for (const t_frqObs* obs : satObs._obs) {
107 if ( (obs->_codeValid || obs->_phaseValid)) {
108 t_frequency::type frq = t_frequency::toFreq(_prn.system(), obs->frqChar());
109 if (frq == t_frequency::dummy) {
110 continue;
[9598]111 }
[10791]112 string trkModes;
113 if (sysTrkModes) {
114 const vector<FrqTrkModes>& frqTrkModes = sysTrkModes->_frqTrkModes;
115 auto it = find_if(frqTrkModes.begin(), frqTrkModes.end(),
116 [frq](const FrqTrkModes& mm){return mm._frq == frq;});
117 if (it != frqTrkModes.end()) {
118 trkModes = it->_trkModes;
[7237]119 }
120 }
[10791]121 if (_obs[frq] == 0 || isBetter(obs, _obs[frq], trkModes)) {
122 delete _obs[frq];
123 _obs[frq] = new t_frqObs(*obs);
124 }
[7237]125 }
126 }
[10791]127
[7237]128 // Check whether all required frequencies available
129 // ------------------------------------------------
[10791]130 const std::vector<t_lc>& LCs = OPT->LCs(_prn.system());
131 for (unsigned ii = 0; ii < LCs.size(); ii++) {
132 t_lc LC = LCs[ii];
133 if (LC._type == t_lc::GIM) {
134 continue;
135 }
136 if (LC._frq1 != t_frequency::G5 && !isValid(LC)) {
[7237]137 _valid = false;
138 return;
139 }
140 }
141
[9560]142 // Find GLONASS Channel Number
[7237]143 // ---------------------------
144 if (_prn.system() == 'R') {
145 _channel = PPP_CLIENT->ephPool()->getChannel(_prn);
146 }
147 else {
148 _channel = 0;
149 }
150
151 // Compute Satellite Coordinates at Time of Transmission
152 // -----------------------------------------------------
[8619]153 _xcSat.ReSize(6); _xcSat = 0.0;
[8495]154 _vvSat.ReSize(3); _vvSat = 0.0;
[7237]155 bool totOK = false;
[8619]156 ColumnVector satPosOld(6); satPosOld = 0.0;
[10791]157
158 _valid = false;
159 t_frequency::type frq1 = t_frequency::dummy;
160 t_frequency::type frq2 = t_frequency::dummy;
161 OPT->defaultFrqs(_prn.system(), frq1, frq2);
162 if (frq1 != t_frequency::dummy) {
163 t_lc lc1(t_lc::code, frq1);
164 if (isValid(lc1)) {
165 _valid = true;
166 _rangeLC = lc1;
167 }
168 if (frq2 != t_frequency::dummy) {
169 t_lc lcIF(t_lc::codeIF, frq1, frq2);
170 if (isValid(lcIF)) {
171 _valid = true;
172 _rangeLC = lcIF;
173 }
174 }
[9600]175 }
[10791]176 if (!_valid) {
[9600]177 return;
178 }
[10791]179
180 double prange = obsValue(_rangeLC);
[7237]181 for (int ii = 1; ii <= 10; ii++) {
182 bncTime ToT = _time - prange / t_CST::c - _xcSat[3];
183 if (PPP_CLIENT->ephPool()->getCrd(_prn, ToT, _xcSat, _vvSat) != success) {
184 _valid = false;
185 return;
186 }
187 ColumnVector dx = _xcSat - satPosOld;
188 dx[3] *= t_CST::c;
[8905]189 if (dx.NormFrobenius() < 1.e-4) {
[7237]190 totOK = true;
191 break;
192 }
[7288]193 satPosOld = _xcSat;
[7237]194 }
195 if (totOK) {
[7250]196 _signalPropagationTime = prange / t_CST::c - _xcSat[3];
[7288]197 _model._satClkM = _xcSat[3] * t_CST::c;
[7237]198 }
199 else {
200 _valid = false;
201 }
202}
203
[7288]204//
[7237]205////////////////////////////////////////////////////////////////////////////
[10791]206void t_pppSatObs::lcCoeff(t_lc LC,
[7237]207 map<t_frequency::type, double>& codeCoeff,
[8905]208 map<t_frequency::type, double>& phaseCoeff,
209 map<t_frequency::type, double>& ionoCoeff) const {
[7237]210
211 codeCoeff.clear();
212 phaseCoeff.clear();
[8905]213 ionoCoeff.clear();
[7237]214
[10791]215 double f1 = t_CST::freq(LC._frq1, _channel);
216 double f2 = t_CST::freq(LC._frq2, _channel);
[8905]217 double f1GPS = t_CST::freq(t_frequency::G1, 0);
[7237]218
[10791]219 switch (LC._type) {
220 case t_lc::phase:
221 phaseCoeff[LC._frq1] = 1.0;
222 ionoCoeff [LC._frq1] = -1.0 * pow(f1GPS, 2) / pow(f1, 2);
[7237]223 return;
[10791]224 case t_lc::code:
225 codeCoeff[LC._frq1] = 1.0;
226 ionoCoeff[LC._frq1] = pow(f1GPS, 2) / pow(f1, 2);
[7237]227 return;
[10791]228 case t_lc::phaseIF:
229 phaseCoeff[LC._frq1] = f1 * f1 / (f1 * f1 - f2 * f2);
230 phaseCoeff[LC._frq2] = -f2 * f2 / (f1 * f1 - f2 * f2);
[7237]231 return;
[10791]232 case t_lc::codeIF:
233 codeCoeff[LC._frq1] = f1 * f1 / (f1 * f1 - f2 * f2);
234 codeCoeff[LC._frq2] = -f2 * f2 / (f1 * f1 - f2 * f2);
235 return;
[7288]236 case t_lc::MW:
[10791]237 phaseCoeff[LC._frq1] = f1 / (f1 - f2);
238 phaseCoeff[LC._frq2] = -f2 / (f1 - f2);
239 codeCoeff [LC._frq1] = -f1 / (f1 + f2);
240 codeCoeff [LC._frq2] = -f2 / (f1 + f2);
[7237]241 return;
[7288]242 case t_lc::CL:
[10791]243 phaseCoeff[LC._frq1] = 0.5;
244 codeCoeff [LC._frq1] = 0.5;
[7237]245 return;
[8905]246 case t_lc::GIM:
[7288]247 case t_lc::dummy:
248 case t_lc::maxLc:
[7237]249 return;
250 }
251}
252
[7288]253//
[7237]254////////////////////////////////////////////////////////////////////////////
[10791]255bool t_pppSatObs::isValid(t_lc LC) const {
[7237]256 bool valid = true;
[10791]257 obsValue(LC, &valid);
[9497]258
[7237]259 return valid;
260}
[7288]261//
[7237]262////////////////////////////////////////////////////////////////////////////
[10791]263double t_pppSatObs::obsValue(t_lc LC, bool* valid) const {
[7237]264
[8905]265 double retVal = 0.0;
266 if (valid) *valid = true;
267
[10938]268 // Pseudo observations (single-differenced: reference minus satellite)
[10791]269 if (LC._type == t_lc::GIM) {
[10938]270 if (_stecSat == 0.0 || _stecRefSat == 0.0) {
[8905]271 if (valid) *valid = false;
272 return 0.0;
273 }
274 else {
[10938]275 return _stecRefSat - _stecSat;
[8905]276 }
277 }
278
[7237]279 map<t_frequency::type, double> codeCoeff;
280 map<t_frequency::type, double> phaseCoeff;
[8905]281 map<t_frequency::type, double> ionoCoeff;
[10791]282 lcCoeff(LC, codeCoeff, phaseCoeff, ionoCoeff);
[7237]283
[8905]284 map<t_frequency::type, double>::const_iterator it;
[7237]285
[8905]286 // Code observations
[7237]287 for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
288 t_frequency::type tFreq = it->first;
289 if (_obs[tFreq] == 0) {
290 if (valid) *valid = false;
291 return 0.0;
292 }
293 else {
294 retVal += it->second * _obs[tFreq]->_code;
295 }
296 }
[8905]297 // Phase observations
[7237]298 for (it = phaseCoeff.begin(); it != phaseCoeff.end(); it++) {
299 t_frequency::type tFreq = it->first;
300 if (_obs[tFreq] == 0) {
301 if (valid) *valid = false;
302 return 0.0;
303 }
304 else {
305 retVal += it->second * _obs[tFreq]->_phase * t_CST::lambda(tFreq, _channel);
306 }
307 }
308 return retVal;
309}
310
[7288]311//
[7237]312////////////////////////////////////////////////////////////////////////////
[10791]313double t_pppSatObs::lambda(t_lc LC) const {
[7237]314
[10791]315 double f1 = t_CST::freq(LC._frq1, _channel);
316 double f2 = t_CST::freq(LC._frq2, _channel);
[7237]317
[10791]318 if (LC._type == t_lc::phase) {
[7237]319 return t_CST::c / f1;
320 }
[10791]321 else if (LC._type == t_lc::phaseIF) {
[7237]322 return t_CST::c / (f1 + f2);
323 }
[10791]324 else if (LC._type == t_lc::MW) {
[7237]325 return t_CST::c / (f1 - f2);
326 }
[10791]327 else if (LC._type == t_lc::CL) {
[7237]328 return t_CST::c / f1 / 2.0;
329 }
330
331 return 0.0;
332}
333
[7288]334//
[7237]335////////////////////////////////////////////////////////////////////////////
[10791]336double t_pppSatObs::sigma(t_lc LC) const {
[7237]337
[8905]338 double retVal = 0.0;
[7237]339 map<t_frequency::type, double> codeCoeff;
340 map<t_frequency::type, double> phaseCoeff;
[8905]341 map<t_frequency::type, double> ionoCoeff;
[10791]342 lcCoeff(LC, codeCoeff, phaseCoeff, ionoCoeff);
[7237]343
[10791]344 if (LC._type == t_lc::GIM) {
[10034]345 retVal = OPT->_sigmaGIM * OPT->_sigmaGIM;
[8905]346 }
[7237]347
348 map<t_frequency::type, double>::const_iterator it;
[9473]349 for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
[7237]350 retVal += it->second * it->second * OPT->_sigmaC1 * OPT->_sigmaC1;
351 }
[8905]352
[9473]353 for (it = phaseCoeff.begin(); it != phaseCoeff.end(); it++) {
[7237]354 retVal += it->second * it->second * OPT->_sigmaL1 * OPT->_sigmaL1;
355 }
356
[7288]357 retVal = sqrt(retVal);
[9551]358
[10573]359 // De-Weight R
[10411]360 // -----------
[10791]361 if (_prn.system() == 'R'&& LC.includesCode()) {
[10411]362 retVal *= 5.0;
[9821]363 }
364
[7237]365 // Elevation-Dependent Weighting
366 // -----------------------------
367 double cEle = 1.0;
[10791]368 if ( (OPT->_eleWgtCode && LC.includesCode()) ||
369 (OPT->_eleWgtPhase && LC.includesPhase()) ) {
[7237]370 double eleD = eleSat()*180.0/M_PI;
371 double hlp = fabs(90.0 - eleD);
372 cEle = (1.0 + hlp*hlp*hlp*0.000004);
373 }
374
375 return cEle * retVal;
376}
377
[7288]378//
[7237]379////////////////////////////////////////////////////////////////////////////
[10791]380double t_pppSatObs::maxRes(t_lc LC) const {
[8905]381 double retVal = 0.0;
[7237]382
383 map<t_frequency::type, double> codeCoeff;
384 map<t_frequency::type, double> phaseCoeff;
[8905]385 map<t_frequency::type, double> ionoCoeff;
[10791]386 lcCoeff(LC, codeCoeff, phaseCoeff, ionoCoeff);
[7237]387
388 map<t_frequency::type, double>::const_iterator it;
[9473]389 for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
[7237]390 retVal += it->second * it->second * OPT->_maxResC1 * OPT->_maxResC1;
391 }
[9473]392 for (it = phaseCoeff.begin(); it != phaseCoeff.end(); it++) {
[7237]393 retVal += it->second * it->second * OPT->_maxResL1 * OPT->_maxResL1;
394 }
[9386]395
396 retVal = sqrt(retVal);
[9537]397
[9561]398 return retVal;
[7237]399}
400
401
[7288]402//
[7237]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);
[8905]413 ColumnVector rRec = station->xyzApr();
414 ColumnVector rhoV = rSat - rRec;
415 _model._rho = rhoV.NormFrobenius();
[7237]416
[8619]417 ColumnVector vSat = _vvSat;
418
[7237]419 ColumnVector neu(3);
420 xyz2neu(station->ellApr().data(), rhoV.data(), neu.data());
421
[8905]422 _model._eleSat = acos(sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / _model._rho);
[10219]423 if (neu[2] < 0.0) {
[7237]424 _model._eleSat *= -1.0;
425 }
426 _model._azSat = atan2(neu[1], neu[0]);
427
[9485]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
[7237]455 // Satellite Clocks
456 // ----------------
[10618]457 _model._satClkM = _xcSat[3] * t_CST::c; // satellite system specific
[7237]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;
[8905]469 _model._sagnac = DotProduct(Omega, crossproduct(rSat, rRec));
[7237]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);
[9598]480 string frqStr = t_frequency::toString(frqType);
481 if (frqStr[0] != _prn.system()) {continue;}
[7237]482 bool found;
[9485]483 QString prn(_prn.toString().c_str());
484 _model._antPCO[ii] = PPP_CLIENT->antex()->rcvCorr(station->antName(), frqType, _model._eleSat, _model._azSat, found);
[9593]485 _model._antPCO[ii] += PPP_CLIENT->antex()->satCorr(prn, frqType, _model._elTx, _model._azTx, found);
[9560]486 if (OPT->_isAPC && found) {
[9485]487 // the PCOs as given in the satellite antenna correction for all frequencies
[9807]488 // have to be reduced by the PCO of the respective reference frequency
[9485]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 }
[7237]502 }
503 }
504
505 // Tropospheric Delay
506 // ------------------
[8961]507 _model._tropo = t_tropo::delay_saast(rRec, _model._eleSat);
[7237]508
509 // Code Biases
510 // -----------
511 const t_satCodeBias* satCodeBias = PPP_CLIENT->obsPool()->satCodeBias(_prn);
[7288]512 if (satCodeBias) {
[7237]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++) {
[9598]516 string frqStr = t_frequency::toString(t_frequency::type(iFreq));
517 if (frqStr[0] != _prn.system()) {
518 continue;
519 }
[7237]520 const t_frqObs* obs = _obs[iFreq];
[10791]521 if (obs && obs->_rnxType2ch == bias._rnxType2ch) {
522 _model._codeBias[iFreq] = (bias._value != 0.0 ? bias._value : ZEROVALUE);
[7237]523 }
524 }
525 }
526 }
527
[7288]528 // Phase Biases
529 // -----------
[10791]530 double yaw = 0.0;
531 bool useYaw = false;
532 if (OPT->arSystem(_prn.system())) {
533 const t_satPhaseBias* satPhaseBias = PPP_CLIENT->obsPool()->satPhaseBias(_prn);
534 if (satPhaseBias) {
535 if (OPT->_ar._useYaw) {
536 double dt = station->epochTime() - satPhaseBias->_time;
537 if (satPhaseBias->_updateInt) {
538 dt -= (0.5 * ssrUpdateInt[satPhaseBias->_updateInt]);
[9598]539 }
[10791]540 yaw = satPhaseBias->_yaw + satPhaseBias->_yawRate * dt;
541 useYaw = true;
542 }
543 for (unsigned ii = 0; ii < satPhaseBias->_bias.size(); ii++) {
544 const t_frqPhaseBias& bias = satPhaseBias->_bias[ii];
545 if (bias._fixIndicator) { // if AR, biases without fixIndicator not used
546 for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
547 string frqStr = t_frequency::toString(t_frequency::type(iFreq));
548 if (frqStr[0] != _prn.system()) {
549 continue;
550 }
551 t_frqObs* obs = _obs[iFreq];
552 if (obs && obs->_rnxType2ch[0] == bias._rnxType2ch[0]) { // allow different tracking mode
553 _model._phaseBias[iFreq] = (bias._value != 0.0 ? bias._value : ZEROVALUE);
554 obs->_biasJumpCounter = bias._jumpCounter;
555 }
556 }
[7288]557 }
558 }
559 }
560 }
561
[8619]562 // Phase Wind-Up
563 // -------------
[10791]564 _model._windUp = station->windUp(_time, _prn, rSat, useYaw, yaw, vSat) ;
[8619]565
[8905]566 // Relativistic effect due to earth gravity
567 // ----------------------------------------
568 double a = rSat.NormFrobenius() + rRec.NormFrobenius();
569 double b = (rSat - rRec).NormFrobenius();
570 double gm = 3.986004418e14; // m3/s2
571 _model._rel = 2 * gm / t_CST::c / t_CST::c * log((a + b) / (a - b));
[8619]572
[7237]573 // Tidal Correction
574 // ----------------
[8905]575 _model._tideEarth = -DotProduct(station->tideDsplEarth(), rhoV) / _model._rho;
576 _model._tideOcean = -DotProduct(station->tideDsplOcean(), rhoV) / _model._rho;
[7237]577
578 // Ionospheric Delay
579 // -----------------
[7250]580 const t_vTec* vTec = PPP_CLIENT->obsPool()->vTec();
[7253]581 bool vTecUsage = true;
582 for (unsigned ii = 0; ii < OPT->LCs(_prn.system()).size(); ii++) {
[10791]583 t_lc LC = OPT->LCs(_prn.system())[ii];
584 if (LC._type == t_lc::codeIF || LC._type == t_lc::phaseIF) {
[7253]585 vTecUsage = false;
[7237]586 }
587 }
[8905]588
[7258]589 if (vTecUsage && vTec) {
[8905]590 double stec = station->stec(vTec, _signalPropagationTime, rSat);
591 double f1GPS = t_CST::freq(t_frequency::G1, 0);
[7258]592 for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
[10034]593 if (OPT->_pseudoObsIono) {
[8905]594 // For scaling the slant ionospheric delays the trick is to be consistent with units!
595 // The conversion of TECU into meters requires the frequency of the signal.
596 // Hence, GPS L1 frequency is used for all systems. The same is true for mu_i in lcCoeff().
597 _model._ionoCodeDelay[iFreq] = 40.3E16 / pow(f1GPS, 2) * stec;
598 }
599 else { // PPP-RTK
600 t_frequency::type frqType = static_cast<t_frequency::type>(iFreq);
601 _model._ionoCodeDelay[iFreq] = 40.3E16 / pow(t_CST::freq(frqType, _channel), 2) * stec;
602 }
[7253]603 }
604 }
[7237]605
606 // Set Model Set Flag
607 // ------------------
608 _model._set = true;
609
[10791]610 if (OPT->_logMode == t_pppOptions::all) {
611 printModel();
612 }
[7252]613
[7237]614 return success;
615}
616
[7288]617//
[7237]618////////////////////////////////////////////////////////////////////////////
619void t_pppSatObs::printModel() const {
[8956]620
621 LOG.setf(ios::fixed);
622 LOG << "\nMODEL for Satellite " << _prn.toString() << (isReference() ? " (Reference Satellite)" : "")
623
[9598]624 << "\n======================= " << endl
[10251]625 << "PPP "
[9588]626 << ((OPT->_pseudoObsIono) ? " with pseudo-observations for STEC" : "") << endl
[8905]627 << "RHO : " << setw(12) << setprecision(3) << _model._rho << endl
628 << "ELE : " << setw(12) << setprecision(3) << _model._eleSat * RHO_DEG << endl
629 << "AZI : " << setw(12) << setprecision(3) << _model._azSat * RHO_DEG << endl
630 << "SATCLK : " << setw(12) << setprecision(3) << _model._satClkM << endl
631 << "RECCLK : " << setw(12) << setprecision(3) << _model._recClkM << endl
632 << "SAGNAC : " << setw(12) << setprecision(3) << _model._sagnac << endl
633 << "ANTECC : " << setw(12) << setprecision(3) << _model._antEcc << endl
634 << "TROPO : " << setw(12) << setprecision(3) << _model._tropo << endl
635 << "WINDUP : " << setw(12) << setprecision(3) << _model._windUp << endl
636 << "REL : " << setw(12) << setprecision(3) << _model._rel << endl
637 << "EARTH TIDES : " << setw(12) << setprecision(3) << _model._tideEarth << endl
638 << "OCEAN TIDES : " << setw(12) << setprecision(3) << _model._tideOcean << endl
639 << endl
640 << "FREQUENCY DEPENDENT CORRECTIONS:" << endl
641 << "-------------------------------" << endl;
[7237]642 for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
643 if (_obs[iFreq]) {
[7288]644 string frqStr = t_frequency::toString(t_frequency::type(iFreq));
645 if (_prn.system() == frqStr[0]) {
[8956]646 LOG << "PCO : " << frqStr << setw(12) << setprecision(3) << _model._antPCO[iFreq] << endl
[10791]647 << "BIAS CODE : " << frqStr << setw(12) << setprecision(3) << _model._codeBias[iFreq] << "\t(" << _obs[iFreq]->trkChar() << ") " << endl
648 << "BIAS PHASE : " << frqStr << setw(12) << setprecision(3) << _model._phaseBias[iFreq] << "\t(" << _obs[iFreq]->trkChar() << ") " << endl
[9588]649 << "IONO CODEDELAY: " << frqStr << setw(12) << setprecision(3) << _model._ionoCodeDelay[iFreq]<< endl;
[7288]650 }
[7237]651 }
652 }
[8905]653}
654
655//
656////////////////////////////////////////////////////////////////////////////
657void t_pppSatObs::printObsMinusComputed() const {
[9618]658 LOG.setf(ios::fixed);
659 LOG << "\nOBS-COMP for Satellite " << _prn.toString() << (isReference() ? " (Reference Satellite)" : "") << endl
[8905]660 << "========================== " << endl;
[10256]661 char sys = _prn.system();
662 for (unsigned ii = 0; ii < OPT->LCs(sys).size(); ii++) {
[10791]663 t_lc LC = OPT->LCs(sys)[ii];
664 LOG << "OBS-CMP " << setw(4) << LC.toString() << ": " << _prn.toString() << " "
665 << setw(12) << setprecision(3) << obsValue(LC) << " "
666 << setw(12) << setprecision(3) << cmpValue(LC) << " "
667 << setw(12) << setprecision(3) << obsValue(LC) - cmpValue(LC) << endl;
[7253]668 }
[7237]669}
670
[7288]671//
[7237]672////////////////////////////////////////////////////////////////////////////
[10791]673double t_pppSatObs::cmpValueForBanc(t_lc LC) const {
674 return cmpValue(LC) - _model._rho - _model._sagnac - _model._recClkM;
[7237]675}
676
[7288]677//
[7237]678////////////////////////////////////////////////////////////////////////////
[10791]679double t_pppSatObs::cmpValue(t_lc LC) const {
[8905]680 double cmpValue;
[7237]681
[10791]682 if (!isValid(LC)) {
[8905]683 cmpValue = 0.0;
[7237]684 }
[10791]685 else if (LC._type == t_lc::GIM) {
[10938]686 cmpValue = 0.0;
[8905]687 }
688 else {
689 // Non-Dispersive Part
690 // -------------------
691 double nonDisp = _model._rho
692 + _model._recClkM - _model._satClkM
693 + _model._sagnac + _model._antEcc + _model._tropo
694 + _model._tideEarth + _model._tideOcean + _model._rel;
[7237]695
[8905]696 // Add Dispersive Part
697 // -------------------
698 double dispPart = 0.0;
699 map<t_frequency::type, double> codeCoeff;
700 map<t_frequency::type, double> phaseCoeff;
701 map<t_frequency::type, double> ionoCoeff;
[10791]702 lcCoeff(LC, codeCoeff, phaseCoeff, ionoCoeff);
[8905]703 map<t_frequency::type, double>::const_iterator it;
704 for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
705 t_frequency::type tFreq = it->first;
706 dispPart += it->second * (_model._antPCO[tFreq] - _model._codeBias[tFreq]);
707 }
708 for (it = phaseCoeff.begin(); it != phaseCoeff.end(); it++) {
709 t_frequency::type tFreq = it->first;
710 dispPart += it->second * (_model._antPCO[tFreq] - _model._phaseBias[tFreq] +
711 _model._windUp * t_CST::lambda(tFreq, _channel));
712 }
713 cmpValue = nonDisp + dispPart;
[7237]714 }
715
[8905]716 return cmpValue;
[7237]717}
718
[7288]719//
[7237]720////////////////////////////////////////////////////////////////////////////
[10791]721void t_pppSatObs::setRes(t_lc LC, double res) {
722 _res[LC] = res;
[7237]723}
724
[7288]725//
[7237]726////////////////////////////////////////////////////////////////////////////
[10791]727double t_pppSatObs::getRes(t_lc LC) const {
728 map<t_lc, double>::const_iterator it = _res.find(LC);
[7237]729 if (it != _res.end()) {
730 return it->second;
731 }
732 else {
733 return 0.0;
734 }
735}
[8905]736
737//
738////////////////////////////////////////////////////////////////////////////
[10938]739bool t_pppSatObs::setPseudoObsIono(t_frequency::type freq, double stecRefSat) {
[8905]740 _stecSat = _model._ionoCodeDelay[freq];
[10938]741 _stecRefSat = stecRefSat;
742 return (_stecSat != 0.0 && _stecRefSat != 0.0);
[8905]743}
[10791]744
745//
746////////////////////////////////////////////////////////////////////////////
747bool t_pppSatObs::hasBiases() const {
748 bool ar = OPT->arSystem(_prn.system());
749 set<t_frequency::type> frqs;
750 for (const auto& lc : OPT->LCs(_prn.system())) {
751 if (lc._frq1 != t_frequency::dummy) frqs.insert(lc._frq1);
752 if (lc._frq2 != t_frequency::dummy) frqs.insert(lc._frq2);
753 }
754 for (int iFreq : frqs) {
755 if (_obs[iFreq] != 0) {
756 if (_model._codeBias[iFreq] == 0 || (ar && _model._phaseBias[iFreq] == 0)) {
757 return false;
758 }
759 }
760 }
761 return true;
762}
Note: See TracBrowser for help on using the repository browser.