Changeset 2108 in ntrip for trunk/BNC/bncmodel.cpp
- Timestamp:
- Dec 13, 2009, 4:56:01 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncmodel.cpp
r2084 r2108 143 143 144 144 _QQ.ReSize(nPar); 145 _xx.ReSize(nPar);146 145 _QQ = 0.0; 147 _xx = 0.0;148 146 149 147 _QQ(1,1) = sig_crd_0 * sig_crd_0; … … 285 283 // ----------------------------------------------- 286 284 SymmetricMatrix QQ_old = _QQ; 287 ColumnVector xx_old = _xx;288 285 289 286 for (int iPar = 1; iPar <= _params.size(); iPar++) { … … 333 330 334 331 int nPar = _params.size(); 335 _xx.ReSize(nPar); _xx = 0.0;336 332 _QQ.ReSize(nPar); _QQ = 0.0; 337 333 for (int i1 = 1; i1 <= nPar; i1++) { 338 334 bncParam* p1 = _params[i1-1]; 339 335 if (p1->index_old != 0) { 340 _xx(p1->index) = xx_old(p1->index_old);341 336 _QQ(p1->index, p1->index) = QQ_old(p1->index_old, p1->index_old); 342 337 for (int i2 = 1; i2 <= nPar; i2++) { … … 410 405 _params[iPar-1]->xx = 0.0; 411 406 } 412 _xx = 0.0;413 407 } 414 408 … … 417 411 t_irc bncModel::update(t_epoData* epoData) { 418 412 419 if (epoData->size() < MINOBS) { 420 return failure; 421 } 422 423 predict(epoData); 424 425 unsigned nPar = _params.size(); 426 unsigned nObs = _usePhase ? 2 * epoData->size() : epoData->size(); 427 428 // Create First-Design Matrix 429 // -------------------------- 430 Matrix AA(nObs, nPar); // first design matrix 431 ColumnVector ll(nObs); // tems observed-computed 432 SymmetricMatrix PP(nObs); PP = 0.0; 433 434 unsigned iObs = 0; 435 QMapIterator<QString, t_satData*> itObs(epoData->satData); 436 while (itObs.hasNext()) { 437 ++iObs; 438 itObs.next(); 439 QString prn = itObs.key(); 440 t_satData* satData = itObs.value(); 441 442 double rhoCmp = cmpValue(satData); 443 444 ll(iObs) = satData->P3 - rhoCmp; 445 PP(iObs,iObs) = 1.0 / (sig_P3 * sig_P3); 446 for (int iPar = 1; iPar <= _params.size(); iPar++) { 447 AA(iObs, iPar) = _params[iPar-1]->partial(satData, ""); 448 } 449 450 if (_usePhase) { 413 const static double MAXRES_CODE = 10.0; 414 const static double MAXRES_PHASE = 0.10; 415 416 ColumnVector xx; 417 418 bool outlier = false; 419 420 do { 421 422 outlier = false; 423 424 if (epoData->size() < MINOBS) { 425 return failure; 426 } 427 428 // Bancroft Solution 429 // ----------------- 430 if (cmpBancroft(epoData) != success) { 431 return failure; 432 } 433 434 // Status Prediction 435 // ----------------- 436 predict(epoData); 437 438 SymmetricMatrix QQsav = _QQ; 439 440 unsigned nPar = _params.size(); 441 unsigned nObs = _usePhase ? 2 * epoData->size() : epoData->size(); 442 443 // Set Solution Vector 444 // ------------------- 445 xx.ReSize(nPar); 446 QVectorIterator<bncParam*> itPar(_params); 447 while (itPar.hasNext()) { 448 bncParam* par = itPar.next(); 449 xx(par->index) = par->xx; 450 } 451 452 // Create First-Design Matrix 453 // -------------------------- 454 Matrix AA(nObs, nPar); // first design matrix 455 ColumnVector ll(nObs); // tems observed-computed 456 SymmetricMatrix PP(nObs); PP = 0.0; 457 458 unsigned iObs = 0; 459 QMapIterator<QString, t_satData*> itObs(epoData->satData); 460 while (itObs.hasNext()) { 451 461 ++iObs; 452 ll(iObs) = satData->L3 - rhoCmp; 453 PP(iObs,iObs) = 1.0 / (sig_L3 * sig_L3); 462 itObs.next(); 463 QString prn = itObs.key(); 464 t_satData* satData = itObs.value(); 465 466 double rhoCmp = cmpValue(satData); 467 468 ll(iObs) = satData->P3 - rhoCmp; 469 PP(iObs,iObs) = 1.0 / (sig_P3 * sig_P3); 454 470 for (int iPar = 1; iPar <= _params.size(); iPar++) { 455 if (_params[iPar-1]->type == bncParam::AMB_L3 && 456 _params[iPar-1]->prn == prn) { 457 ll(iObs) -= _params[iPar-1]->x0; 458 } 459 AA(iObs, iPar) = _params[iPar-1]->partial(satData, prn); 460 } 461 } 462 } 463 464 // Compute Kalman Update 465 // --------------------- 466 if (false) { 467 SymmetricMatrix HH; HH << PP + AA * _QQ * AA.t(); 468 SymmetricMatrix Hi = HH.i(); 469 Matrix KK = _QQ * AA.t() * Hi; 470 ColumnVector v1 = ll - AA * _xx; 471 _xx = _xx + KK * v1; 472 IdentityMatrix Id(nPar); 473 _QQ << (Id - KK * AA) * _QQ; 474 } 475 else { 476 Matrix ATP = AA.t() * PP; 477 SymmetricMatrix NN = _QQ.i(); 478 ColumnVector bb = NN * _xx + ATP * ll; 479 NN << NN + ATP * AA; 480 _QQ = NN.i(); 481 _xx = _QQ * bb; 482 } 483 484 // Set Solution Vector 485 // ------------------- 471 AA(iObs, iPar) = _params[iPar-1]->partial(satData, ""); 472 } 473 474 if (_usePhase) { 475 ++iObs; 476 ll(iObs) = satData->L3 - rhoCmp; 477 PP(iObs,iObs) = 1.0 / (sig_L3 * sig_L3); 478 for (int iPar = 1; iPar <= _params.size(); iPar++) { 479 if (_params[iPar-1]->type == bncParam::AMB_L3 && 480 _params[iPar-1]->prn == prn) { 481 ll(iObs) -= _params[iPar-1]->x0; 482 } 483 AA(iObs, iPar) = _params[iPar-1]->partial(satData, prn); 484 } 485 } 486 } 487 488 // Compute Kalman Update 489 // --------------------- 490 if (false) { 491 SymmetricMatrix HH; HH << PP + AA * _QQ * AA.t(); 492 SymmetricMatrix Hi = HH.i(); 493 Matrix KK = _QQ * AA.t() * Hi; 494 ColumnVector v1 = ll - AA * xx; 495 xx = xx + KK * v1; 496 IdentityMatrix Id(nPar); 497 _QQ << (Id - KK * AA) * _QQ; 498 } 499 else { 500 Matrix ATP = AA.t() * PP; 501 SymmetricMatrix NN = _QQ.i(); 502 ColumnVector bb = NN * xx + ATP * ll; 503 NN << NN + ATP * AA; 504 _QQ = NN.i(); 505 xx = _QQ * bb; 506 } 507 508 // Outlier Detection 509 // ----------------- 510 ColumnVector vv = ll - AA * xx; 511 512 iObs = 0; 513 QMutableMapIterator<QString, t_satData*> it2Obs(epoData->satData); 514 while (it2Obs.hasNext()) { 515 ++iObs; 516 it2Obs.next(); 517 QString prn = it2Obs.key(); 518 t_satData* satData = it2Obs.value(); 519 if (fabs(vv(iObs)) > MAXRES_CODE) { 520 delete satData; 521 it2Obs.remove(); 522 _QQ = QQsav; 523 outlier = true; 524 cout << "Code " << prn.toAscii().data() << " " << vv(iObs) << endl; 525 break; 526 } 527 if (_usePhase) { 528 ++iObs; 529 if (fabs(vv(iObs)) > MAXRES_PHASE) { 530 delete satData; 531 it2Obs.remove(); 532 _QQ = QQsav; 533 outlier = true; 534 cout << "Phase " << prn.toAscii().data() << " " << vv(iObs) << endl; 535 break; 536 } 537 } 538 } 539 540 } while (outlier); 541 542 // Set Solution Vector back 543 // ------------------------ 486 544 QVectorIterator<bncParam*> itPar(_params); 487 545 while (itPar.hasNext()) { 488 546 bncParam* par = itPar.next(); 489 par->xx = _xx(par->index);547 par->xx = xx(par->index); 490 548 } 491 549
Note:
See TracChangeset
for help on using the changeset viewer.