Changeset 10034 in ntrip for trunk/BNC/src/PPP/pppFilter.cpp
- Timestamp:
- Apr 21, 2023, 11:48:24 AM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/PPP/pppFilter.cpp
r10033 r10034 27 27 #include "pppObsPool.h" 28 28 #include "pppStation.h" 29 #include "pppClient.h" 29 30 30 31 using namespace BNC_PPP; … … 33 34 // Constructor 34 35 //////////////////////////////////////////////////////////////////////////// 35 t_pppFilter::t_pppFilter(t_pppObsPool *obsPool) { 36 _numSat = 0; 37 _obsPool = obsPool; 38 _refPrn = t_prn(); 39 _datumTrafo = new t_datumTrafo(); 36 t_pppFilter::t_pppFilter() { 37 _parlist = 0; 40 38 } 41 39 … … 43 41 //////////////////////////////////////////////////////////////////////////// 44 42 t_pppFilter::~t_pppFilter() { 45 delete _ datumTrafo;43 delete _parlist; 46 44 } 47 45 48 46 // Process Single Epoch 49 47 //////////////////////////////////////////////////////////////////////////// 50 t_irc t_pppFilter::processEpoch(int num) { 48 t_irc t_pppFilter::processEpoch(t_pppObsPool* obsPool) { 49 51 50 _numSat = 0; 52 51 const double maxSolGap = 60.0; 53 52 bool setNeuNoiseToZero = false; 54 53 55 if ( num > 1) {56 setNeuNoiseToZero = true;54 if (!_parlist) { 55 _parlist = new t_pppParlist(); 57 56 } 58 57 59 58 // Vector of all Observations 60 59 // -------------------------- 61 t_pppObsPool::t_epoch *epoch = _obsPool->lastEpoch();60 t_pppObsPool::t_epoch *epoch = obsPool->lastEpoch(); 62 61 if (!epoch) { 63 62 return failure; … … 77 76 string epoTimeStr = string(_epoTime); 78 77 79 const QMap<char, t_pppRefSat*> &refSatMap = epoch->refSatMap(); 80 81 const QList<char> &usedSystems = _parlist.usedSystems(); 82 //-- 78 const QList<char> &usedSystems = _parlist->usedSystems(); 79 83 80 // Set Parameters 84 if (_parlist.set(_epoTime, allObs, refSatMap) != success) { 81 // -------------- 82 if (_parlist->set(_epoTime, allObs) != success) { 85 83 return failure; 86 84 } 87 88 #ifdef BNC_DEBUG_PPP89 if (OPT->_obsModelType == OPT->DCMcodeBias ||90 OPT->_obsModelType == OPT->DCMphaseBias) {91 // _parlist.printParams(_epoTime);92 }93 #endif94 85 95 86 // Status Vector, Variance-Covariance Matrix … … 99 90 setStateVectorAndVarCovMatrix(xFltOld, QFltOld, setNeuNoiseToZero); 100 91 101 // Pre-Process Satellite Systems separately102 // ----------------------------------------103 bool preProcessing = false;104 if (OPT->_obsModelType == OPT->DCMcodeBias ||105 OPT->_obsModelType == OPT->DCMphaseBias) {106 preProcessing = true;107 for (int iSys = 0; iSys < usedSystems.size(); iSys++) {108 char sys = usedSystems[iSys];109 _refPrn.set(sys, 0);110 if (OPT->_refSatRequired) {111 _refPrn = refSatMap[sys]->prn();112 }113 vector<t_pppSatObs*> obsVector;114 for (unsigned jj = 0; jj < allObs.size(); jj++) {115 if (allObs[jj]->prn().system() == sys) {116 obsVector.push_back(allObs[jj]);117 }118 }119 if (iSys == 0) {120 _datumTrafo->setFirstSystem(sys);121 }122 if (processSystem(OPT->LCs(sys), obsVector, _refPrn,123 epoch->pseudoObsIono(), preProcessing) != success) {124 LOG << sys << ": processSystem != success (pre-processing)" << endl;125 _xFlt = xFltOld;126 _QFlt = QFltOld;127 restoreState(1);128 return failure;129 }130 }131 // refSat change required?132 // -----------------------133 if (_obsPool->refSatChangeRequired()) {134 _xFlt = xFltOld;135 _QFlt = QFltOld;136 return success;137 } else if (!_obsPool->refSatChangeRequired()) {138 initDatumTransformation(allObs, epoch->pseudoObsIono());139 }140 }141 142 92 // Process Satellite Systems separately 143 93 // ------------------------------------ 144 preProcessing = false;145 94 for (int iSys = 0; iSys < usedSystems.size(); iSys++) { 146 95 char sys = usedSystems[iSys]; 147 _refPrn.set(sys, 0);148 if (OPT->_refSatRequired) {149 _refPrn = refSatMap[sys]->prn();150 }151 96 unsigned int num = 0; 152 97 vector<t_pppSatObs*> obsVector; … … 154 99 if (allObs[jj]->prn().system() == sys) { 155 100 obsVector.push_back(allObs[jj]); 156 ++num; 157 } 158 } 159 if (iSys == 0 && OPT->_obsModelType == OPT->UncombPPP) { 160 _datumTrafo->setFirstSystem(sys); 161 } 162 LOG << epoTimeStr << " SATNUM " << sys << ' ' << right << setw(2) << num 163 << endl; 164 if (processSystem(OPT->LCs(sys), obsVector, _refPrn, 165 epoch->pseudoObsIono(), preProcessing) != success) { 166 LOG << "processSystem != success (fin-processing)" << endl; 167 if (OPT->_obsModelType == OPT->DCMcodeBias || 168 OPT->_obsModelType == OPT->DCMphaseBias) { 169 _xFlt = xFltOld; 170 _QFlt = QFltOld; 171 restoreState(2); 172 } 101 num++; 102 } 103 } 104 LOG << epoTimeStr << " SATNUM " << sys << ' ' << right << setw(2) << num << endl; 105 if (processSystem(OPT->LCs(sys), obsVector, epoch->pseudoObsIono()) != success) { 106 LOG << "processSystem != success: " << sys << endl; 173 107 return failure; 174 108 } … … 177 111 // close epoch processing 178 112 // ---------------------- 179 cmpDOP(allObs , refSatMap);180 _parlist .printResult(_epoTime, _QFlt, _xFlt);113 cmpDOP(allObs); 114 _parlist->printResult(_epoTime, _QFlt, _xFlt); 181 115 _lastEpoTimeOK = _epoTime; // remember time of last successful epoch processing 182 116 return success; … … 186 120 //////////////////////////////////////////////////////////////////////////// 187 121 t_irc t_pppFilter::processSystem(const vector<t_lc::type> &LCs, 188 const vector<t_pppSatObs*> &obsVector, const t_prn &refPrn,189 bool pseudoObsIonoAvailable, bool preProcessing) {122 const vector<t_pppSatObs*> &obsVector, 123 bool pseudoObsIonoAvailable) { 190 124 LOG.setf(ios::fixed); 191 char sys = refPrn.system();192 125 193 126 // Detect Cycle Slips 194 127 // ------------------ 195 if (detectCycleSlips(LCs, obsVector , refPrn, preProcessing) != success) {128 if (detectCycleSlips(LCs, obsVector) != success) { 196 129 return failure; 197 130 } 198 if (preProcessing && _obsPool->refSatChangeRequired(sys)) { 199 return success; 200 } 201 202 ColumnVector xSav = _xFlt; 131 132 ColumnVector xSav = _xFlt; 203 133 SymmetricMatrix QSav = _QFlt; 204 string epoTimeStr = string(_epoTime);205 const vector<t_pppParam*> ¶ms = _parlist .params();206 unsigned nPar = _parlist.nPar();134 string epoTimeStr = string(_epoTime); 135 const vector<t_pppParam*> ¶ms = _parlist->params(); 136 unsigned nPar = _parlist->nPar(); 207 137 208 138 unsigned usedLCs = LCs.size(); … … 213 143 unsigned maxObs = obsVector.size() * usedLCs; 214 144 215 if (OPT->_pseudoObsIono && pseudoObsIonoAvailable) {216 maxObs -= 1; // pseudo obs iono with respect to refSat217 }218 219 145 // Outlier Detection Loop 220 146 // ---------------------- … … 229 155 // ----------------------------------------------------------- 230 156 Matrix AA(maxObs, nPar); 231 ColumnVector ll(maxObs); 232 DiagonalMatrix PP(maxObs); 233 PP = 0.0; 157 ColumnVector ll(maxObs); ll = 0.0; 158 DiagonalMatrix PP(maxObs); PP = 0.0; 234 159 235 160 int iObs = -1; … … 242 167 for (unsigned ii = 0; ii < obsVector.size(); ii++) { 243 168 t_pppSatObs *obs = obsVector[ii]; 244 if (iOutlier == 0 && !preProcessing) {169 if (iOutlier == 0) { 245 170 obs->resetOutlier(); 246 171 } … … 257 182 for (unsigned iPar = 0; iPar < nPar; iPar++) { 258 183 const t_pppParam *par = params[iPar]; 259 AA[iObs][iPar] = par->partial(_epoTime, obs, tLC , refPrn);184 AA[iObs][iPar] = par->partial(_epoTime, obs, tLC); 260 185 } 261 ll[iObs] = obs->obsValue(tLC) - obs->cmpValue(tLC) 262 - DotProduct(_x0, AA.Row(iObs + 1)); 186 ll[iObs] = obs->obsValue(tLC) - obs->cmpValue(tLC) - DotProduct(_x0, AA.Row(iObs + 1)); 263 187 PP[iObs] = 1.0 / (obs->sigma(tLC) * obs->sigma(tLC)); 264 188 } … … 269 193 // ---------------------------- 270 194 if ((iObs +1) < OPT->_minObs) { 271 LOG << "t_pppFilter::processSystem not enough observations " << sys << ": " <<iObs + 1 << "\n";195 LOG << "t_pppFilter::processSystem not enough observations " << iObs + 1 << "\n"; 272 196 return failure; 273 }274 275 if ((!iOutlier) &&276 (OPT->_obsModelType == OPT->DCMcodeBias ||277 OPT->_obsModelType == OPT->DCMphaseBias) && (!preProcessing)) {278 _datumTrafo->updateIndices(sys, iObs + 1);279 _datumTrafo->prepareAA(AA.SubMatrix(1, iObs + 1, 1, _parlist.nPar()), 1);280 197 } 281 198 … … 288 205 for (unsigned jj = 0; jj < usedLCs; jj++) { 289 206 const t_lc::type tLC = LCs[jj]; 290 if (tLC == t_lc::GIM && !obs->isReference()) {207 if (tLC == t_lc::GIM) { 291 208 ++iObs; 292 209 } else { … … 297 214 for (unsigned iPar = 0; iPar < nPar; iPar++) { 298 215 const t_pppParam *par = params[iPar]; 299 AA[iObs][iPar] = par->partial(_epoTime, obs, tLC , refPrn);216 AA[iObs][iPar] = par->partial(_epoTime, obs, tLC); 300 217 } 301 ll[iObs] = obs->obsValue(tLC) - obs->cmpValue(tLC) 302 - DotProduct(_x0, AA.Row(iObs + 1)); 218 ll[iObs] = obs->obsValue(tLC) - obs->cmpValue(tLC) - DotProduct(_x0, AA.Row(iObs + 1)); 303 219 PP[iObs] = 1.0 / (obs->sigma(tLC) * obs->sigma(tLC)); 304 220 } … … 340 256 t_pppSatObs *obs = usedObs[maxOutlierIndex]; 341 257 t_pppParam *par = 0; 258 LOG << epoTimeStr << " Outlier " << t_lc::toString(maxOutlierLC) << ' ' 259 << obs->prn().toString() << ' ' << setw(8) << setprecision(4) 260 << maxOutlier << endl; 342 261 for (unsigned iPar = 0; iPar < nPar; iPar++) { 343 262 t_pppParam *hlp = params[iPar]; 344 263 if (hlp->type() == t_pppParam::amb && 345 hlp->prn() == obs->prn() &&346 hlp->tLC() == usedTypes[maxOutlierIndex]) {264 hlp->prn() == obs->prn() && 265 hlp->tLC() == usedTypes[maxOutlierIndex]) { 347 266 par = hlp; 348 267 } 349 268 } 350 if (preProcessing) { 351 if (obs->prn() == refPrn) { 352 LOG << epoTimeStr << " Outlier (" 353 << ((preProcessing) ? "pre-processing) " : "fin-processing) ") 354 << t_lc::toString(maxOutlierLC) << ' ' << obs->prn().toString() 355 << ' ' << setw(8) << setprecision(4) << maxOutlier << endl; 356 _obsPool->setRefSatChangeRequired(sys, true); 357 break; 269 if (par) { 270 if (par->ambResetCandidate()) { 271 resetAmb(par->prn(), obsVector, maxOutlierLC, &QSav, &xSav); 358 272 } 359 273 else { 274 par->setAmbResetCandidate(); 360 275 obs->setOutlier(); 361 276 } 362 277 } 363 else { // fin-processing 364 LOG << epoTimeStr << " Outlier " << t_lc::toString(maxOutlierLC) << ' ' 365 << obs->prn().toString() << ' ' << setw(8) << setprecision(4) 366 << maxOutlier << endl; 367 if (par) { 368 if (par->ambResetCandidate() || 369 OPT->_obsModelType == OPT->DCMcodeBias || 370 OPT->_obsModelType == OPT->DCMphaseBias) { 371 resetAmb(par->prn(), obsVector, maxOutlierLC, &QSav, &xSav); 372 } 373 else { 374 par->setAmbResetCandidate(); 375 obs->setOutlier(); 376 } 377 } 378 else { 379 obs->setOutlier(); 380 } 278 else { 279 obs->setOutlier(); 381 280 } 382 281 } … … 384 283 // --------------- 385 284 else { 386 if (!preProcessing) {387 285 for (unsigned jj = 0; jj < LCs.size(); jj++) { 388 286 for (unsigned ii = 0; ii < usedObs.size(); ii++) { … … 393 291 LOG << epoTimeStr << " RES " << left << setw(3) 394 292 << t_lc::toString(tLC) << right << ' ' 395 << obs->prn().toString(); 396 LOG << setw(9) << setprecision(4) << vv[ii] << endl; 397 } 293 << obs->prn().toString() << ' ' 294 << setw(8) << setprecision(4) << vv[ii] << endl; 398 295 } 399 296 } … … 408 305 //////////////////////////////////////////////////////////////////////////// 409 306 t_irc t_pppFilter::detectCycleSlips(const vector<t_lc::type> &LCs, 410 const vector<t_pppSatObs*> &obsVector, const t_prn &refPrn, 411 bool preProcessing) { 412 const double SLIP = 50.0; 413 char sys = refPrn.system(); 307 const vector<t_pppSatObs*> &obsVector) { 308 309 const double SLIP = 20.0; 414 310 string epoTimeStr = string(_epoTime); 415 const vector<t_pppParam*> ¶ms = _parlist.params(); 416 unsigned nPar = _parlist.nPar(); 311 const vector<t_pppParam*> ¶ms = _parlist->params(); 417 312 418 313 for (unsigned ii = 0; ii < LCs.size(); ii++) { … … 426 321 bool slip = false; 427 322 428 // in pre-processing only the reference satellite has to be checked429 if (preProcessing && obs->prn() != refPrn) {430 continue;431 }432 433 323 if (obs->slip()) { 434 LOG << epoTimeStr << "cycle slip set (obs) " << obs->prn().toString() 435 << endl; 324 LOG << epoTimeStr << "cycle slip set (obs) " << obs->prn().toString() << endl; 436 325 slip = true; 437 326 } 438 327 439 if (_slips[obs->prn()]._obsSlipCounter != -1 440 && _slips[obs->prn()]._obsSlipCounter != obs->slipCounter()) { 441 LOG << epoTimeStr << "cycle slip set (obsSlipCounter) " 442 << obs->prn().toString() << endl; 328 if (_slips[obs->prn()]._obsSlipCounter != -1 && 329 _slips[obs->prn()]._obsSlipCounter != obs->slipCounter()) { 330 LOG << epoTimeStr << "cycle slip set (obsSlipCounter) " << obs->prn().toString() << endl; 443 331 slip = true; 444 332 } 445 if (!preProcessing) { 446 _slips[obs->prn()]._obsSlipCounter = obs->slipCounter(); 447 } 448 if (_slips[obs->prn()]._biasJumpCounter != -1 449 && _slips[obs->prn()]._biasJumpCounter != obs->biasJumpCounter()) { 450 LOG << epoTimeStr << "cycle slip set (biasJumpCounter) " 451 << obs->prn().toString() << endl; 333 _slips[obs->prn()]._obsSlipCounter = obs->slipCounter(); 334 335 if (_slips[obs->prn()]._biasJumpCounter != -1 && 336 _slips[obs->prn()]._biasJumpCounter != obs->biasJumpCounter()) { 337 LOG << epoTimeStr << "cycle slip set (biasJumpCounter) " << obs->prn().toString() << endl; 452 338 slip = true; 453 339 } 454 if (!preProcessing) { 455 _slips[obs->prn()]._biasJumpCounter = obs->biasJumpCounter(); 456 } 340 _slips[obs->prn()]._biasJumpCounter = obs->biasJumpCounter(); 341 457 342 // Slip Set 458 343 // -------- 459 344 if (slip) { 460 if (preProcessing) { 461 _obsPool->setRefSatChangeRequired(sys, true); 462 } else { 345 resetAmb(obs->prn(), obsVector, tLC); 346 } 347 348 // Check Pre-Fit Residuals 349 // ----------------------- 350 else { 351 ColumnVector AA(params.size()); 352 for (unsigned iPar = 0; iPar < params.size(); iPar++) { 353 const t_pppParam* par = params[iPar]; 354 AA[iPar] = par->partial(_epoTime, obs, tLC); 355 } 356 357 double ll = obs->obsValue(tLC) - obs->cmpValue(tLC) - DotProduct(_x0, AA); 358 double vv = DotProduct(AA, _xFlt) - ll; 359 360 if (fabs(vv) > SLIP) { 361 LOG << epoTimeStr << " cycle slip detected " << t_lc::toString(tLC) << ' ' 362 << obs->prn().toString() << ' ' << setw(8) << setprecision(4) << vv << endl; 463 363 resetAmb(obs->prn(), obsVector, tLC); 464 364 } 465 365 } 466 // Check Pre-Fit Residuals 467 /* ----------------------- 468 else { 469 if (!preProcessing) { 470 ColumnVector AA(nPar); 471 for (unsigned iPar = 0; iPar < nPar; iPar++) { 472 const t_pppParam *par = params[iPar]; 473 AA[iPar] = par->partial(_epoTime, obs, tLC, refPrn); 474 } 475 double ll = obs->obsValue(tLC) - obs->cmpValue(tLC) 476 - DotProduct(_x0, AA); 477 double vv = DotProduct(AA, _xFlt) - ll; 478 if (fabs(vv) > SLIP) { 479 LOG << epoTimeStr << " cycle slip detected " << t_lc::toString(tLC) 480 << ' ' << obs->prn().toString() << ' ' << setw(8) 481 << setprecision(4) << vv << endl; 482 resetAmb(obs->prn(), obsVector, tLC); 483 } 484 } 485 }*/ 486 } 487 } 488 } 366 } 367 } 368 } 369 489 370 return success; 490 371 } … … 496 377 497 378 t_irc irc = failure; 498 vector<t_pppParam*> ¶ms = _parlist.params();379 vector<t_pppParam*>& params = _parlist->params(); 499 380 for (unsigned iPar = 0; iPar < params.size(); iPar++) { 500 381 t_pppParam *par = params[iPar]; … … 506 387 } 507 388 LOG << string(_epoTime) << " RESET " << par->toString() << endl; 508 delete par; 509 par = new t_pppParam(t_pppParam::amb, prn, tLC, &obsVector); 389 delete par; par = new t_pppParam(t_pppParam::amb, prn, tLC, &obsVector); 510 390 par->setIndex(ind); 511 391 params[iPar] = par; … … 532 412 } 533 413 534 // Add infinite noise to iono535 ////////////////////////////////////////////////////////////////////////////536 t_irc t_pppFilter::addNoiseToPar(t_pppParam::e_type parType, char sys) {537 t_irc irc = failure;538 vector<t_pppParam*> ¶ms = _parlist.params();539 for (unsigned iPar = 0; iPar < params.size(); iPar++) {540 t_pppParam *par = params[iPar];541 if (par->type() == parType && par->prn().system() == sys) {542 int ind = par->indexNew();543 LOG << string(_epoTime) << " ADD NOISE TO " << par->toString() << endl;544 par->setIndex(ind);545 _QFlt(ind + 1, ind + 1) = par->sigma0() * par->sigma0();546 irc = success;547 }548 }549 550 return irc;551 }552 553 414 // Compute various DOP Values 554 415 //////////////////////////////////////////////////////////////////////////// 555 void t_pppFilter::cmpDOP(const vector<t_pppSatObs*> &obsVector, 556 const QMap<char, t_pppRefSat*> &refSatMap) { 416 void t_pppFilter::cmpDOP(const vector<t_pppSatObs*> &obsVector) { 557 417 558 418 _dop.reset(); … … 564 424 for (unsigned ii = 0; ii < obsVector.size(); ii++) { 565 425 t_pppSatObs *obs = obsVector[ii]; 566 char sys = obs->prn().system();567 t_prn refPrn = t_prn();568 if (OPT->_refSatRequired) {569 refPrn = refSatMap[sys]->prn();570 }571 426 if (obs->isValid() && !obs->outlier()) { 572 427 ++_numSat; 573 428 for (unsigned iPar = 0; iPar < numPar; iPar++) { 574 const t_pppParam *par = _parlist.params()[iPar];575 AA[_numSat - 1][iPar] = par->partial(_epoTime, obs, t_lc::c1 , refPrn);429 const t_pppParam* par = _parlist->params()[iPar]; 430 AA[_numSat - 1][iPar] = par->partial(_epoTime, obs, t_lc::c1); 576 431 } 577 432 } … … 581 436 } 582 437 AA = AA.Rows(1, _numSat); 583 SymmetricMatrix NN; 584 NN << AA.t() * AA; 438 SymmetricMatrix NN; NN << AA.t() * AA; 585 439 SymmetricMatrix QQ = NN.i(); 586 440 … … 590 444 _dop.T = sqrt(QQ(4, 4)); 591 445 _dop.G = sqrt(QQ(1, 1) + QQ(2, 2) + QQ(3, 3) + QQ(4, 4)); 592 } catch (...) { 446 } 447 catch (...) { 593 448 } 594 449 } … … 598 453 void t_pppFilter::predictCovCrdPart(const SymmetricMatrix &QFltOld, bool setNeuNoiseToZero) { 599 454 600 const vector<t_pppParam*> ¶ms = _parlist.params(); 455 const vector<t_pppParam*>& params = _parlist->params(); 456 601 457 if (params.size() < 3) { 602 458 return; … … 605 461 bool first = (params[0]->indexOld() < 0); 606 462 607 SymmetricMatrix Qneu(3); 608 Qneu = 0.0; 463 SymmetricMatrix Qneu(3); Qneu = 0.0; 609 464 for (unsigned ii = 0; ii < 3; ii++) { 610 465 const t_pppParam *par = params[ii]; 611 466 if (first) { 612 467 Qneu[ii][ii] = par->sigma0() * par->sigma0(); 613 } else { 468 } 469 else { 614 470 Qneu[ii][ii] = par->noise() * par->noise(); 615 471 } … … 622 478 if (first) { 623 479 _QFlt.SymSubMatrix(1, 3) = Qxyz; 624 } else { 480 } 481 else { 625 482 double dt = _epoTime - _firstEpoTime; 626 483 if (dt < OPT->_seedingTime || setNeuNoiseToZero) { 627 484 _QFlt.SymSubMatrix(1, 3) = QFltOld.SymSubMatrix(1, 3); 628 } else { 485 } 486 else { 629 487 _QFlt.SymSubMatrix(1, 3) = QFltOld.SymSubMatrix(1, 3) + Qxyz; 630 488 } … … 637 495 const SymmetricMatrix &QFltOld, bool setNeuNoiseToZero) { 638 496 639 const vector<t_pppParam*> ¶ms = _parlist.params();497 const vector<t_pppParam*>& params = _parlist->params(); 640 498 unsigned nPar = params.size(); 641 499 642 _QFlt.ReSize(nPar); 643 _QFlt = 0.0; 644 _xFlt.ReSize(nPar); 645 _xFlt = 0.0; 646 _x0.ReSize(nPar); 647 _x0 = 0.0; 500 _QFlt.ReSize(nPar); _QFlt = 0.0; 501 _xFlt.ReSize(nPar); _xFlt = 0.0; 502 _x0.ReSize(nPar); _x0 = 0.0; 648 503 649 504 for (unsigned ii = 0; ii < nPar; ii++) { … … 671 526 } 672 527 673 // Compute datum transformation674 ////////////////////////////////////////////////////////////////////////////675 t_irc t_pppFilter::datumTransformation(676 const QMap<char, t_pppRefSat*> &refSatMap) {677 678 // get last epoch679 t_pppObsPool::t_epoch *epoch = _obsPool->lastEpoch();680 #ifdef BNC_DEBUG_PPP681 LOG << "GET LAST EPOCH" << endl;682 #endif683 if (!epoch) {684 LOG << "t_pppFilter::datumTransformation: !lastEpoch" << endl;685 return failure;686 }687 _epoTime = epoch->epoTime();688 689 LOG.setf(ios::fixed);690 LOG << "DATUM TRANSFORMATION in Epoch "<< string(_epoTime) << endl;691 692 vector<t_pppSatObs*> &allObs = epoch->obsVector();693 694 const QMap<char, t_pppRefSat*> &refSatMapLastEpoch = epoch->refSatMap();695 696 bool pseudoObsIono = epoch->pseudoObsIono();697 698 // reset old and set new refSats in last epoch (ambiguities/GIM)699 // =============================================================700 if (resetRefSatellitesLastEpoch(allObs, refSatMap, refSatMapLastEpoch) != true) {701 LOG << "datumTransformation: resetRefSatellitesLastEpoch != success" << endl;702 return failure;703 }704 705 if (OPT->_obsModelType == OPT->UncombPPP) {706 _obsPool->putEpoch(_epoTime, allObs, pseudoObsIono, refSatMap);707 return success;708 }709 710 // set AA2711 // =======712 if (_parlist.set(_epoTime, allObs, refSatMap) != success) {713 return failure;714 }715 #ifdef BNC_DEBUG_PPP716 //_parlist.printParams(_epoTime);717 #endif718 719 const QList<char> &usedSystems = _parlist.usedSystems();720 for (int iSys = 0; iSys < usedSystems.size(); iSys++) {721 char sys = usedSystems[iSys];722 t_prn refPrn = refSatMap[sys]->prn();723 vector<t_pppSatObs*> obsVector;724 for (unsigned jj = 0; jj < allObs.size(); jj++) {725 if (allObs[jj]->prn().system() == sys) {726 allObs[jj]->resetOutlier();727 obsVector.push_back(allObs[jj]);728 }729 }730 if (iSys == 0) {731 _datumTrafo->setFirstSystem(sys);732 }733 vector<t_lc::type> LCs = OPT->LCs(sys);734 unsigned usedLCs = LCs.size();735 if (OPT->_pseudoObsIono && !pseudoObsIono) {736 usedLCs -= 1; // GIM not used737 }738 // max Obs739 unsigned maxObs = obsVector.size() * usedLCs;740 741 if (OPT->_pseudoObsIono && pseudoObsIono) {742 maxObs -= 1; // pseudo obs iono with respect to refSat743 }744 745 const vector<t_pppParam*> ¶ms = _parlist.params();746 unsigned nPar = _parlist.nPar();747 748 Matrix AA(maxObs, nPar); AA = 0.0;749 750 // Real Observations751 // -----------------752 int iObs = -1;753 for (unsigned ii = 0; ii < obsVector.size(); ii++) {754 t_pppSatObs *obs = obsVector[ii];755 for (unsigned jj = 0; jj < usedLCs; jj++) {756 const t_lc::type tLC = LCs[jj];757 if (tLC == t_lc::GIM) {758 continue;759 }760 ++iObs;761 for (unsigned iPar = 0; iPar < nPar; iPar++) {762 const t_pppParam *par = params[iPar];763 AA[iObs][iPar] = par->partial(_epoTime, obs, tLC, refPrn);764 }765 }766 }767 768 if (!(iObs+1)) {769 continue;770 }771 _datumTrafo->updateIndices(sys, iObs + 1);772 773 if (_datumTrafo->prepareAA(AA.SubMatrix(1, iObs + 1, 1, nPar), 2) != success) {774 return failure;775 }776 }777 _datumTrafo->updateNumObs();778 779 // Datum Transformation780 // ====================781 if (_datumTrafo->computeTrafoMatrix() != success) {782 return failure;783 }784 785 ColumnVector xFltOld = _xFlt;786 SymmetricMatrix QFltOld = _QFlt;787 788 _QFlt << _datumTrafo->D21() * QFltOld * _datumTrafo->D21().t();789 _xFlt = _datumTrafo->D21() * xFltOld;790 791 #ifdef BNC_DEBUG_PPP792 // LOG << "xFltOld:\n" << xFltOld << endl;793 // LOG << "xFlt :\n" << _xFlt << endl;794 #endif795 796 // Reset Ambiguities after Datum Transformation797 // ============================================798 for (int iSys = 0; iSys < usedSystems.size(); iSys++) {799 char sys = usedSystems[iSys];800 vector<t_lc::type> LCs = OPT->LCs(sys);801 unsigned usedLCs = LCs.size();802 if (OPT->_pseudoObsIono && !pseudoObsIono) {803 usedLCs -= 1; // GIM not used804 }805 t_prn refPrnOld = refSatMapLastEpoch[sys]->prn();806 t_prn refPrnNew = refSatMap[sys]->prn();807 if (refPrnNew != refPrnOld) {808 for (unsigned jj = 0; jj < usedLCs; jj++) {809 const t_lc::type tLC = LCs[jj];810 if (tLC == t_lc::GIM) {811 continue;812 }813 resetAmb(refPrnOld, allObs, tLC);814 }815 }816 }817 818 // switch AA2 to AA1819 // =================820 _datumTrafo->switchAA();821 822 _obsPool->putEpoch(_epoTime, allObs, pseudoObsIono, refSatMap);823 #ifdef BNC_DEBUG_PPP824 LOG << "PUT EPOCH t_pppFilter::datumTransformation " << _epoTime.timestr().c_str() << endl;825 #endif826 827 return success;828 }829 830 // Init datum transformation831 ////////////////////////////////////////////////////////////////////////////832 void t_pppFilter::initDatumTransformation(833 const std::vector<t_pppSatObs*> &allObs, bool pseudoObsIono) {834 unsigned trafoObs = 0;835 const QList<char> &usedSystems = _parlist.usedSystems();836 for (int iSys = 0; iSys < usedSystems.size(); iSys++) {837 char sys = usedSystems[iSys];838 int satNum = 0;839 for (unsigned jj = 0; jj < allObs.size(); jj++) {840 if (allObs[jj]->prn().system() == sys) {841 satNum++;842 }843 }844 // all LCs845 unsigned realUsedLCs = OPT->LCs(sys).size();846 // exclude pseudo obs GIM847 if (OPT->_pseudoObsIono && !pseudoObsIono) {848 realUsedLCs -= 1;849 }850 851 trafoObs += satNum * realUsedLCs;852 853 if (OPT->_pseudoObsIono && pseudoObsIono) {854 trafoObs -= 1; // pseudo obs iono with respect to refSat855 }856 }857 _datumTrafo->setNumObs(trafoObs);858 _datumTrafo->setNumPar(_parlist.nPar());859 _datumTrafo->initAA();860 }861 862 //863 //////////////////////////////////////////////////////////////////////////////864 bool t_pppFilter::resetRefSatellitesLastEpoch(865 std::vector<t_pppSatObs*> &obsVector,866 const QMap<char, t_pppRefSat*> &refSatMap,867 const QMap<char, t_pppRefSat*> &refSatMapLastEpoch) {868 bool resetRefSat;869 // reference satellite definition per system870 const QList<char> &usedSystems = _parlist.usedSystems();871 for (int iSys = 0; iSys < usedSystems.size(); iSys++) {872 resetRefSat = false;873 char sys = usedSystems[iSys];874 t_prn newPrn = refSatMap[sys]->prn();875 t_prn oldPrn = refSatMapLastEpoch[sys]->prn();876 #ifdef BNC_DEBUG_PPP877 if (oldPrn != newPrn) {878 LOG << "oldRef: " << oldPrn.toString() << " => newRef " << newPrn.toString() << endl;879 }880 #endif881 vector<t_pppSatObs*>::iterator it = obsVector.begin();882 while (it != obsVector.end()) {883 t_pppSatObs *satObs = *it;884 if (satObs->prn() == newPrn) {885 resetRefSat = true;886 satObs->setAsReference();887 } else if (satObs->prn() == oldPrn) {888 satObs->resetReference();889 }890 it++;891 }892 if (!resetRefSat) {893 _obsPool->setRefSatChangeRequired(sys, true);894 return resetRefSat;895 }896 }897 return resetRefSat;898 }
Note:
See TracChangeset
for help on using the changeset viewer.