[7237] | 1 | /* -------------------------------------------------------------------------
|
---|
| 2 | * BKG NTRIP Client
|
---|
| 3 | * -------------------------------------------------------------------------
|
---|
| 4 | *
|
---|
| 5 | * Class: t_pppFilter
|
---|
| 6 | *
|
---|
| 7 | * Purpose: Filter Adjustment
|
---|
| 8 | *
|
---|
| 9 | * Author: L. Mervart
|
---|
| 10 | *
|
---|
| 11 | * Created: 29-Jul-2014
|
---|
| 12 | *
|
---|
[7267] | 13 | * Changes:
|
---|
[7237] | 14 | *
|
---|
| 15 | * -----------------------------------------------------------------------*/
|
---|
| 16 |
|
---|
| 17 | #include <iostream>
|
---|
| 18 | #include <iomanip>
|
---|
| 19 | #include <cmath>
|
---|
| 20 | #include <newmat.h>
|
---|
| 21 | #include <newmatio.h>
|
---|
| 22 | #include <newmatap.h>
|
---|
| 23 |
|
---|
| 24 | #include "pppFilter.h"
|
---|
| 25 | #include "bncutils.h"
|
---|
| 26 | #include "pppParlist.h"
|
---|
| 27 | #include "pppObsPool.h"
|
---|
| 28 | #include "pppStation.h"
|
---|
[10034] | 29 | #include "pppClient.h"
|
---|
[7237] | 30 |
|
---|
| 31 | using namespace BNC_PPP;
|
---|
| 32 | using namespace std;
|
---|
| 33 |
|
---|
| 34 | // Constructor
|
---|
| 35 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10034] | 36 | t_pppFilter::t_pppFilter() {
|
---|
| 37 | _parlist = 0;
|
---|
[7237] | 38 | }
|
---|
| 39 |
|
---|
| 40 | // Destructor
|
---|
| 41 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 42 | t_pppFilter::~t_pppFilter() {
|
---|
[10034] | 43 | delete _parlist;
|
---|
[7237] | 44 | }
|
---|
| 45 |
|
---|
| 46 | // Process Single Epoch
|
---|
| 47 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10034] | 48 | t_irc t_pppFilter::processEpoch(t_pppObsPool* obsPool) {
|
---|
| 49 |
|
---|
[9642] | 50 | _numSat = 0;
|
---|
[7302] | 51 | const double maxSolGap = 60.0;
|
---|
[10028] | 52 | bool setNeuNoiseToZero = false;
|
---|
[7237] | 53 |
|
---|
[10034] | 54 | if (!_parlist) {
|
---|
| 55 | _parlist = new t_pppParlist();
|
---|
[10028] | 56 | }
|
---|
| 57 |
|
---|
[7237] | 58 | // Vector of all Observations
|
---|
| 59 | // --------------------------
|
---|
[10034] | 60 | t_pppObsPool::t_epoch *epoch = obsPool->lastEpoch();
|
---|
[7237] | 61 | if (!epoch) {
|
---|
| 62 | return failure;
|
---|
| 63 | }
|
---|
[9642] | 64 | vector<t_pppSatObs*> &allObs = epoch->obsVector();
|
---|
[7237] | 65 |
|
---|
| 66 | // Time of the Epoch
|
---|
| 67 | // -----------------
|
---|
| 68 | _epoTime = epoch->epoTime();
|
---|
| 69 |
|
---|
[10015] | 70 | if (!_firstEpoTime.valid() ||
|
---|
| 71 | !_lastEpoTimeOK.valid()||
|
---|
| 72 | (maxSolGap > 0.0 && _epoTime - _lastEpoTimeOK > maxSolGap)) {
|
---|
[7237] | 73 | _firstEpoTime = _epoTime;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
[7267] | 76 | string epoTimeStr = string(_epoTime);
|
---|
| 77 |
|
---|
[10034] | 78 | const QList<char> &usedSystems = _parlist->usedSystems();
|
---|
[10015] | 79 |
|
---|
[7237] | 80 | // Set Parameters
|
---|
[10034] | 81 | // --------------
|
---|
| 82 | if (_parlist->set(_epoTime, allObs) != success) {
|
---|
[9419] | 83 | return failure;
|
---|
| 84 | }
|
---|
[10028] | 85 |
|
---|
[7237] | 86 | // Status Vector, Variance-Covariance Matrix
|
---|
| 87 | // -----------------------------------------
|
---|
[10031] | 88 | ColumnVector xFltOld = _xFlt;
|
---|
[7237] | 89 | SymmetricMatrix QFltOld = _QFlt;
|
---|
[10010] | 90 | setStateVectorAndVarCovMatrix(xFltOld, QFltOld, setNeuNoiseToZero);
|
---|
[8956] | 91 |
|
---|
[7237] | 92 | // Process Satellite Systems separately
|
---|
| 93 | // ------------------------------------
|
---|
[9431] | 94 | for (int iSys = 0; iSys < usedSystems.size(); iSys++) {
|
---|
| 95 | char sys = usedSystems[iSys];
|
---|
[7267] | 96 | unsigned int num = 0;
|
---|
[7237] | 97 | vector<t_pppSatObs*> obsVector;
|
---|
| 98 | for (unsigned jj = 0; jj < allObs.size(); jj++) {
|
---|
[9419] | 99 | if (allObs[jj]->prn().system() == sys) {
|
---|
[7237] | 100 | obsVector.push_back(allObs[jj]);
|
---|
[10034] | 101 | num++;
|
---|
[7237] | 102 | }
|
---|
| 103 | }
|
---|
[10034] | 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;
|
---|
[7237] | 107 | return failure;
|
---|
| 108 | }
|
---|
| 109 | }
|
---|
[8912] | 110 |
|
---|
| 111 | // close epoch processing
|
---|
| 112 | // ----------------------
|
---|
[10034] | 113 | cmpDOP(allObs);
|
---|
| 114 | _parlist->printResult(_epoTime, _QFlt, _xFlt);
|
---|
[9642] | 115 | _lastEpoTimeOK = _epoTime; // remember time of last successful epoch processing
|
---|
[7237] | 116 | return success;
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | // Process Selected LCs
|
---|
| 120 | ////////////////////////////////////////////////////////////////////////////
|
---|
[9642] | 121 | t_irc t_pppFilter::processSystem(const vector<t_lc::type> &LCs,
|
---|
[10034] | 122 | const vector<t_pppSatObs*> &obsVector,
|
---|
| 123 | bool pseudoObsIonoAvailable) {
|
---|
[7237] | 124 | LOG.setf(ios::fixed);
|
---|
| 125 |
|
---|
| 126 | // Detect Cycle Slips
|
---|
| 127 | // ------------------
|
---|
[10034] | 128 | if (detectCycleSlips(LCs, obsVector) != success) {
|
---|
[7237] | 129 | return failure;
|
---|
| 130 | }
|
---|
| 131 |
|
---|
[10034] | 132 | ColumnVector xSav = _xFlt;
|
---|
[9642] | 133 | SymmetricMatrix QSav = _QFlt;
|
---|
[10034] | 134 | string epoTimeStr = string(_epoTime);
|
---|
| 135 | const vector<t_pppParam*> ¶ms = _parlist->params();
|
---|
| 136 | unsigned nPar = _parlist->nPar();
|
---|
[8965] | 137 |
|
---|
[9642] | 138 | unsigned usedLCs = LCs.size();
|
---|
[8965] | 139 | if (OPT->_pseudoObsIono && !pseudoObsIonoAvailable) {
|
---|
[9642] | 140 | usedLCs -= 1; // GIM not used
|
---|
[8961] | 141 | }
|
---|
| 142 | // max Obs
|
---|
[9538] | 143 | unsigned maxObs = obsVector.size() * usedLCs;
|
---|
| 144 |
|
---|
[7237] | 145 | // Outlier Detection Loop
|
---|
| 146 | // ----------------------
|
---|
| 147 | for (unsigned iOutlier = 0; iOutlier < maxObs; iOutlier++) {
|
---|
| 148 |
|
---|
| 149 | if (iOutlier > 0) {
|
---|
| 150 | _xFlt = xSav;
|
---|
| 151 | _QFlt = QSav;
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | // First-Design Matrix, Terms Observed-Computed, Weight Matrix
|
---|
| 155 | // -----------------------------------------------------------
|
---|
[9642] | 156 | Matrix AA(maxObs, nPar);
|
---|
[10034] | 157 | ColumnVector ll(maxObs); ll = 0.0;
|
---|
| 158 | DiagonalMatrix PP(maxObs); PP = 0.0;
|
---|
[8912] | 159 |
|
---|
[7237] | 160 | int iObs = -1;
|
---|
| 161 | vector<t_pppSatObs*> usedObs;
|
---|
[9642] | 162 | vector<t_lc::type> usedTypes;
|
---|
[9386] | 163 |
|
---|
| 164 | // Real Observations
|
---|
| 165 | // =================
|
---|
[9583] | 166 | double nSat = 0;
|
---|
[7237] | 167 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
[9642] | 168 | t_pppSatObs *obs = obsVector[ii];
|
---|
[10034] | 169 | if (iOutlier == 0) {
|
---|
[9419] | 170 | obs->resetOutlier();
|
---|
| 171 | }
|
---|
[7237] | 172 | if (!obs->outlier()) {
|
---|
[9583] | 173 | nSat++;
|
---|
[8905] | 174 | for (unsigned jj = 0; jj < usedLCs; jj++) {
|
---|
[7237] | 175 | const t_lc::type tLC = LCs[jj];
|
---|
[9642] | 176 | if (tLC == t_lc::GIM) {
|
---|
| 177 | continue;
|
---|
| 178 | }
|
---|
[7237] | 179 | ++iObs;
|
---|
| 180 | usedObs.push_back(obs);
|
---|
| 181 | usedTypes.push_back(tLC);
|
---|
[9524] | 182 | for (unsigned iPar = 0; iPar < nPar; iPar++) {
|
---|
[9642] | 183 | const t_pppParam *par = params[iPar];
|
---|
[10034] | 184 | AA[iObs][iPar] = par->partial(_epoTime, obs, tLC);
|
---|
[7237] | 185 | }
|
---|
[10034] | 186 | ll[iObs] = obs->obsValue(tLC) - obs->cmpValue(tLC) - DotProduct(_x0, AA.Row(iObs + 1));
|
---|
[7237] | 187 | PP[iObs] = 1.0 / (obs->sigma(tLC) * obs->sigma(tLC));
|
---|
| 188 | }
|
---|
| 189 | }
|
---|
| 190 | }
|
---|
| 191 |
|
---|
[9556] | 192 | // Check number of observations
|
---|
| 193 | // ----------------------------
|
---|
[10159] | 194 | if (nSat < 2) {
|
---|
[10156] | 195 | LOG << "t_pppFilter::processSystem not enough observations " << nSat << "\n";
|
---|
[9701] | 196 | return failure;
|
---|
[9699] | 197 | }
|
---|
[9625] | 198 |
|
---|
[9386] | 199 | // Pseudo Obs Iono
|
---|
| 200 | // ================
|
---|
| 201 | if (OPT->_pseudoObsIono && pseudoObsIonoAvailable) {
|
---|
| 202 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
[9642] | 203 | t_pppSatObs *obs = obsVector[ii];
|
---|
[9386] | 204 | if (!obs->outlier()) {
|
---|
| 205 | for (unsigned jj = 0; jj < usedLCs; jj++) {
|
---|
| 206 | const t_lc::type tLC = LCs[jj];
|
---|
[10034] | 207 | if (tLC == t_lc::GIM) {
|
---|
[9386] | 208 | ++iObs;
|
---|
[9642] | 209 | } else {
|
---|
| 210 | continue;
|
---|
| 211 | }
|
---|
[9386] | 212 | usedObs.push_back(obs);
|
---|
| 213 | usedTypes.push_back(tLC);
|
---|
[9524] | 214 | for (unsigned iPar = 0; iPar < nPar; iPar++) {
|
---|
[9642] | 215 | const t_pppParam *par = params[iPar];
|
---|
[10034] | 216 | AA[iObs][iPar] = par->partial(_epoTime, obs, tLC);
|
---|
[9386] | 217 | }
|
---|
[10034] | 218 | ll[iObs] = obs->obsValue(tLC) - obs->cmpValue(tLC) - DotProduct(_x0, AA.Row(iObs + 1));
|
---|
[9386] | 219 | PP[iObs] = 1.0 / (obs->sigma(tLC) * obs->sigma(tLC));
|
---|
| 220 | }
|
---|
| 221 | }
|
---|
[8956] | 222 | }
|
---|
[8915] | 223 | }
|
---|
| 224 |
|
---|
[9556] | 225 | // Truncate matrices
|
---|
| 226 | // -----------------
|
---|
[9642] | 227 | AA = AA.Rows(1, iObs + 1);
|
---|
| 228 | ll = ll.Rows(1, iObs + 1);
|
---|
| 229 | PP = PP.SymSubMatrix(1, iObs + 1);
|
---|
[7237] | 230 |
|
---|
| 231 | // Kalman update step
|
---|
| 232 | // ------------------
|
---|
| 233 | kalman(AA, ll, PP, _QFlt, _xFlt);
|
---|
| 234 |
|
---|
| 235 | // Check Residuals
|
---|
| 236 | // ---------------
|
---|
| 237 | ColumnVector vv = AA * _xFlt - ll;
|
---|
[9642] | 238 | double maxOutlier = 0.0;
|
---|
| 239 | int maxOutlierIndex = -1;
|
---|
| 240 | t_lc::type maxOutlierLC = t_lc::dummy;
|
---|
[7237] | 241 | for (unsigned ii = 0; ii < usedObs.size(); ii++) {
|
---|
| 242 | const t_lc::type tLC = usedTypes[ii];
|
---|
| 243 | double res = fabs(vv[ii]);
|
---|
| 244 | if (res > usedObs[ii]->maxRes(tLC)) {
|
---|
| 245 | if (res > fabs(maxOutlier)) {
|
---|
[9642] | 246 | maxOutlier = vv[ii];
|
---|
[7237] | 247 | maxOutlierIndex = ii;
|
---|
[9642] | 248 | maxOutlierLC = tLC;
|
---|
[7237] | 249 | }
|
---|
| 250 | }
|
---|
| 251 | }
|
---|
| 252 |
|
---|
| 253 | // Mark outlier or break outlier detection loop
|
---|
| 254 | // --------------------------------------------
|
---|
| 255 | if (maxOutlierIndex > -1) {
|
---|
[9642] | 256 | t_pppSatObs *obs = usedObs[maxOutlierIndex];
|
---|
| 257 | t_pppParam *par = 0;
|
---|
[10034] | 258 | LOG << epoTimeStr << " Outlier " << t_lc::toString(maxOutlierLC) << ' '
|
---|
| 259 | << obs->prn().toString() << ' ' << setw(8) << setprecision(4)
|
---|
| 260 | << maxOutlier << endl;
|
---|
[9524] | 261 | for (unsigned iPar = 0; iPar < nPar; iPar++) {
|
---|
[9642] | 262 | t_pppParam *hlp = params[iPar];
|
---|
[10008] | 263 | if (hlp->type() == t_pppParam::amb &&
|
---|
[10034] | 264 | hlp->prn() == obs->prn() &&
|
---|
| 265 | hlp->tLC() == usedTypes[maxOutlierIndex]) {
|
---|
[7237] | 266 | par = hlp;
|
---|
| 267 | }
|
---|
| 268 | }
|
---|
[10034] | 269 | if (par) {
|
---|
| 270 | if (par->ambResetCandidate()) {
|
---|
| 271 | resetAmb(par->prn(), obsVector, maxOutlierLC, &QSav, &xSav);
|
---|
[10018] | 272 | }
|
---|
| 273 | else {
|
---|
[10034] | 274 | par->setAmbResetCandidate();
|
---|
[10009] | 275 | obs->setOutlier();
|
---|
| 276 | }
|
---|
[10021] | 277 | }
|
---|
[10034] | 278 | else {
|
---|
| 279 | obs->setOutlier();
|
---|
[7237] | 280 | }
|
---|
| 281 | }
|
---|
| 282 | // Print Residuals
|
---|
| 283 | // ---------------
|
---|
| 284 | else {
|
---|
[8905] | 285 | for (unsigned jj = 0; jj < LCs.size(); jj++) {
|
---|
| 286 | for (unsigned ii = 0; ii < usedObs.size(); ii++) {
|
---|
| 287 | const t_lc::type tLC = usedTypes[ii];
|
---|
[9642] | 288 | t_pppSatObs *obs = usedObs[ii];
|
---|
[8905] | 289 | if (tLC == LCs[jj]) {
|
---|
| 290 | obs->setRes(tLC, vv[ii]);
|
---|
[9642] | 291 | LOG << epoTimeStr << " RES " << left << setw(3)
|
---|
[9699] | 292 | << t_lc::toString(tLC) << right << ' '
|
---|
[10034] | 293 | << obs->prn().toString() << ' '
|
---|
| 294 | << setw(8) << setprecision(4) << vv[ii] << endl;
|
---|
[7237] | 295 | }
|
---|
| 296 | }
|
---|
| 297 | }
|
---|
| 298 | break;
|
---|
| 299 | }
|
---|
| 300 | }
|
---|
| 301 | return success;
|
---|
| 302 | }
|
---|
| 303 |
|
---|
| 304 | // Cycle-Slip Detection
|
---|
| 305 | ////////////////////////////////////////////////////////////////////////////
|
---|
[9642] | 306 | t_irc t_pppFilter::detectCycleSlips(const vector<t_lc::type> &LCs,
|
---|
[10034] | 307 | const vector<t_pppSatObs*> &obsVector) {
|
---|
| 308 |
|
---|
[10037] | 309 | const double SLIP = 300.0;
|
---|
[9386] | 310 | string epoTimeStr = string(_epoTime);
|
---|
[10034] | 311 | const vector<t_pppParam*> ¶ms = _parlist->params();
|
---|
[7237] | 312 |
|
---|
| 313 | for (unsigned ii = 0; ii < LCs.size(); ii++) {
|
---|
[9642] | 314 | const t_lc::type &tLC = LCs[ii];
|
---|
[7237] | 315 | if (t_lc::includesPhase(tLC)) {
|
---|
| 316 | for (unsigned iObs = 0; iObs < obsVector.size(); iObs++) {
|
---|
[9642] | 317 | const t_pppSatObs *obs = obsVector[iObs];
|
---|
[7237] | 318 |
|
---|
[7267] | 319 | // Check set Slips and Jump Counters
|
---|
[7237] | 320 | // ---------------------------------
|
---|
| 321 | bool slip = false;
|
---|
[9386] | 322 |
|
---|
[7237] | 323 | if (obs->slip()) {
|
---|
[10034] | 324 | LOG << epoTimeStr << "cycle slip set (obs) " << obs->prn().toString() << endl;
|
---|
[7237] | 325 | slip = true;
|
---|
| 326 | }
|
---|
| 327 |
|
---|
[10034] | 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;
|
---|
[7237] | 331 | slip = true;
|
---|
| 332 | }
|
---|
[10034] | 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;
|
---|
[7237] | 338 | slip = true;
|
---|
| 339 | }
|
---|
[10034] | 340 | _slips[obs->prn()]._biasJumpCounter = obs->biasJumpCounter();
|
---|
| 341 |
|
---|
[7237] | 342 | // Slip Set
|
---|
[7267] | 343 | // --------
|
---|
[7237] | 344 | if (slip) {
|
---|
[10034] | 345 | resetAmb(obs->prn(), obsVector, tLC);
|
---|
[7237] | 346 | }
|
---|
[10034] | 347 |
|
---|
[10002] | 348 | // Check Pre-Fit Residuals
|
---|
[10034] | 349 | // -----------------------
|
---|
[7237] | 350 | else {
|
---|
[10034] | 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);
|
---|
[7237] | 355 | }
|
---|
[10034] | 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;
|
---|
| 363 | resetAmb(obs->prn(), obsVector, tLC);
|
---|
| 364 | }
|
---|
| 365 | }
|
---|
[7237] | 366 | }
|
---|
| 367 | }
|
---|
| 368 | }
|
---|
[10034] | 369 |
|
---|
[7237] | 370 | return success;
|
---|
| 371 | }
|
---|
| 372 |
|
---|
| 373 | // Reset Ambiguity Parameter (cycle slip)
|
---|
| 374 | ////////////////////////////////////////////////////////////////////////////
|
---|
[9642] | 375 | t_irc t_pppFilter::resetAmb(t_prn prn, const vector<t_pppSatObs*> &obsVector,
|
---|
[10008] | 376 | t_lc::type lc, SymmetricMatrix *QSav, ColumnVector *xSav) {
|
---|
[8965] | 377 |
|
---|
[7237] | 378 | t_irc irc = failure;
|
---|
[10034] | 379 | vector<t_pppParam*>& params = _parlist->params();
|
---|
[7237] | 380 | for (unsigned iPar = 0; iPar < params.size(); iPar++) {
|
---|
[9642] | 381 | t_pppParam *par = params[iPar];
|
---|
[7237] | 382 | if (par->type() == t_pppParam::amb && par->prn() == prn) {
|
---|
| 383 | int ind = par->indexNew();
|
---|
[10156] | 384 | bncTime firstObsTime;
|
---|
| 385 | bncTime lastObsTime = par->lastObsTime();
|
---|
| 386 | if (par->firstObsTime().undef()) {
|
---|
| 387 | firstObsTime = lastObsTime;
|
---|
| 388 | }
|
---|
| 389 | else {
|
---|
| 390 | firstObsTime = par->firstObsTime();
|
---|
| 391 | }
|
---|
[7237] | 392 | t_lc::type tLC = par->tLC();
|
---|
[10166] | 393 | // if (tLC != lc) {continue;}
|
---|
[7237] | 394 | LOG << string(_epoTime) << " RESET " << par->toString() << endl;
|
---|
[10034] | 395 | delete par; par = new t_pppParam(t_pppParam::amb, prn, tLC, &obsVector);
|
---|
[7237] | 396 | par->setIndex(ind);
|
---|
[10156] | 397 | par->setFirstObsTime(firstObsTime);
|
---|
| 398 | par->setLastObsTime(lastObsTime);
|
---|
[7237] | 399 | params[iPar] = par;
|
---|
| 400 | for (unsigned ii = 1; ii <= params.size(); ii++) {
|
---|
[9642] | 401 | _QFlt(ii, ind + 1) = 0.0;
|
---|
[7237] | 402 | if (QSav) {
|
---|
[9642] | 403 | (*QSav)(ii, ind + 1) = 0.0;
|
---|
[7237] | 404 | }
|
---|
| 405 | }
|
---|
[9642] | 406 | _QFlt(ind + 1, ind + 1) = par->sigma0() * par->sigma0();
|
---|
[7237] | 407 | if (QSav) {
|
---|
[9642] | 408 | (*QSav)(ind + 1, ind + 1) = _QFlt(ind + 1, ind + 1);
|
---|
[7237] | 409 | }
|
---|
| 410 | _xFlt[ind] = 0.0;
|
---|
| 411 | if (xSav) {
|
---|
| 412 | (*xSav)[ind] = _xFlt[ind];
|
---|
| 413 | }
|
---|
| 414 | _x0[ind] = par->x0();
|
---|
| 415 | irc = success;
|
---|
| 416 | }
|
---|
| 417 | }
|
---|
| 418 |
|
---|
| 419 | return irc;
|
---|
| 420 | }
|
---|
| 421 |
|
---|
| 422 | // Compute various DOP Values
|
---|
| 423 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10034] | 424 | void t_pppFilter::cmpDOP(const vector<t_pppSatObs*> &obsVector) {
|
---|
[7237] | 425 |
|
---|
| 426 | _dop.reset();
|
---|
| 427 |
|
---|
| 428 | try {
|
---|
| 429 | const unsigned numPar = 4;
|
---|
| 430 | Matrix AA(obsVector.size(), numPar);
|
---|
| 431 | _numSat = 0;
|
---|
| 432 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
[9642] | 433 | t_pppSatObs *obs = obsVector[ii];
|
---|
[7237] | 434 | if (obs->isValid() && !obs->outlier()) {
|
---|
| 435 | ++_numSat;
|
---|
| 436 | for (unsigned iPar = 0; iPar < numPar; iPar++) {
|
---|
[10034] | 437 | const t_pppParam* par = _parlist->params()[iPar];
|
---|
| 438 | AA[_numSat - 1][iPar] = par->partial(_epoTime, obs, t_lc::c1);
|
---|
[7237] | 439 | }
|
---|
| 440 | }
|
---|
| 441 | }
|
---|
| 442 | if (_numSat < 4) {
|
---|
| 443 | return;
|
---|
| 444 | }
|
---|
| 445 | AA = AA.Rows(1, _numSat);
|
---|
[10034] | 446 | SymmetricMatrix NN; NN << AA.t() * AA;
|
---|
[7237] | 447 | SymmetricMatrix QQ = NN.i();
|
---|
[7267] | 448 |
|
---|
[9642] | 449 | _dop.H = sqrt(QQ(1, 1) + QQ(2, 2));
|
---|
| 450 | _dop.V = sqrt(QQ(3, 3));
|
---|
| 451 | _dop.P = sqrt(QQ(1, 1) + QQ(2, 2) + QQ(3, 3));
|
---|
| 452 | _dop.T = sqrt(QQ(4, 4));
|
---|
| 453 | _dop.G = sqrt(QQ(1, 1) + QQ(2, 2) + QQ(3, 3) + QQ(4, 4));
|
---|
[7237] | 454 | }
|
---|
[10034] | 455 | catch (...) {
|
---|
| 456 | }
|
---|
[7237] | 457 | }
|
---|
| 458 |
|
---|
[9526] | 459 | //
|
---|
[7237] | 460 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10010] | 461 | void t_pppFilter::predictCovCrdPart(const SymmetricMatrix &QFltOld, bool setNeuNoiseToZero) {
|
---|
[7237] | 462 |
|
---|
[10034] | 463 | const vector<t_pppParam*>& params = _parlist->params();
|
---|
| 464 |
|
---|
[7237] | 465 | if (params.size() < 3) {
|
---|
| 466 | return;
|
---|
| 467 | }
|
---|
| 468 |
|
---|
| 469 | bool first = (params[0]->indexOld() < 0);
|
---|
| 470 |
|
---|
[10034] | 471 | SymmetricMatrix Qneu(3); Qneu = 0.0;
|
---|
[7237] | 472 | for (unsigned ii = 0; ii < 3; ii++) {
|
---|
[9642] | 473 | const t_pppParam *par = params[ii];
|
---|
[7237] | 474 | if (first) {
|
---|
| 475 | Qneu[ii][ii] = par->sigma0() * par->sigma0();
|
---|
[10034] | 476 | }
|
---|
| 477 | else {
|
---|
[7237] | 478 | Qneu[ii][ii] = par->noise() * par->noise();
|
---|
| 479 | }
|
---|
| 480 | }
|
---|
| 481 |
|
---|
[9642] | 482 | const t_pppStation *sta = PPP_CLIENT->staRover();
|
---|
[7237] | 483 | SymmetricMatrix Qxyz(3);
|
---|
| 484 | covariNEU_XYZ(Qneu, sta->ellApr().data(), Qxyz);
|
---|
| 485 |
|
---|
| 486 | if (first) {
|
---|
[9642] | 487 | _QFlt.SymSubMatrix(1, 3) = Qxyz;
|
---|
[10034] | 488 | }
|
---|
| 489 | else {
|
---|
[7237] | 490 | double dt = _epoTime - _firstEpoTime;
|
---|
[10010] | 491 | if (dt < OPT->_seedingTime || setNeuNoiseToZero) {
|
---|
[9642] | 492 | _QFlt.SymSubMatrix(1, 3) = QFltOld.SymSubMatrix(1, 3);
|
---|
[10034] | 493 | }
|
---|
| 494 | else {
|
---|
[9642] | 495 | _QFlt.SymSubMatrix(1, 3) = QFltOld.SymSubMatrix(1, 3) + Qxyz;
|
---|
[7237] | 496 | }
|
---|
| 497 | }
|
---|
| 498 | }
|
---|
[8912] | 499 |
|
---|
[9526] | 500 | //
|
---|
| 501 | ////////////////////////////////////////////////////////////////////////////
|
---|
[9642] | 502 | void t_pppFilter::setStateVectorAndVarCovMatrix(const ColumnVector &xFltOld,
|
---|
[10010] | 503 | const SymmetricMatrix &QFltOld, bool setNeuNoiseToZero) {
|
---|
[9526] | 504 |
|
---|
[10034] | 505 | const vector<t_pppParam*>& params = _parlist->params();
|
---|
[9526] | 506 | unsigned nPar = params.size();
|
---|
| 507 |
|
---|
[10034] | 508 | _QFlt.ReSize(nPar); _QFlt = 0.0;
|
---|
| 509 | _xFlt.ReSize(nPar); _xFlt = 0.0;
|
---|
| 510 | _x0.ReSize(nPar); _x0 = 0.0;
|
---|
[9526] | 511 |
|
---|
| 512 | for (unsigned ii = 0; ii < nPar; ii++) {
|
---|
[9642] | 513 | t_pppParam *par1 = params[ii];
|
---|
[9526] | 514 | if (QFltOld.size() == 0) {
|
---|
| 515 | par1->resetIndex();
|
---|
| 516 | }
|
---|
| 517 | _x0[ii] = par1->x0();
|
---|
| 518 | int iOld = par1->indexOld();
|
---|
| 519 | if (iOld < 0) {
|
---|
| 520 | _QFlt[ii][ii] = par1->sigma0() * par1->sigma0(); // new parameter
|
---|
[9642] | 521 | } else {
|
---|
[9526] | 522 | _QFlt[ii][ii] = QFltOld[iOld][iOld] + par1->noise() * par1->noise();
|
---|
[9642] | 523 | _xFlt[ii] = xFltOld[iOld];
|
---|
[9526] | 524 | for (unsigned jj = 0; jj < ii; jj++) {
|
---|
[9642] | 525 | t_pppParam *par2 = params[jj];
|
---|
| 526 | int jOld = par2->indexOld();
|
---|
[9526] | 527 | if (jOld >= 0) {
|
---|
[9642] | 528 | _QFlt[ii][jj] = QFltOld(iOld + 1, jOld + 1);
|
---|
[9526] | 529 | }
|
---|
| 530 | }
|
---|
| 531 | }
|
---|
| 532 | }
|
---|
[10010] | 533 | predictCovCrdPart(QFltOld, setNeuNoiseToZero);
|
---|
[9526] | 534 | }
|
---|
| 535 |
|
---|