Changeset 8956 in ntrip for trunk/BNC/src/PPP/pppFilter.cpp


Ignore:
Timestamp:
Jun 23, 2020, 11:58:46 AM (4 years ago)
Author:
stuerze
Message:

update regarding PPP

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/PPP/pppFilter.cpp

    r8915 r8956  
    8383  // Set Parameters
    8484  // --------------
    85   _parlist->set(_epoTime, allObs);
     85  _parlist->set(_epoTime, allObs, _obsPool->getRefSatMap());
    8686  const vector<t_pppParam*>& params = _parlist->params();
    8787
     
    9090  ColumnVector    xFltOld = _xFlt;
    9191  SymmetricMatrix QFltOld = _QFlt;
     92
    9293  _QFlt.ReSize(_parlist->nPar()); _QFlt = 0.0;
    9394  _xFlt.ReSize(_parlist->nPar()); _xFlt = 0.0;
     
    114115  predictCovCrdPart(QFltOld);
    115116
     117  // Init Datum Trafo
     118  // ----------------------------------------
     119  if ((OPT->_obsModelType == OPT->DCMcodeBias ||
     120       OPT->_obsModelType == OPT->DCMphaseBias) &&
     121      (_numEpoProcessing == 1)) {
     122    _numAllUsedLCs = 0;
     123    for (unsigned iSys = 0; iSys < OPT->systems().size(); iSys++) {
     124      char system = OPT->systems()[iSys];
     125      _numAllUsedLCs += OPT->LCs(system).size();
     126      if (OPT->_pseudoObsIono && !epoch->pseudoObsIono()) {
     127        _numAllUsedLCs -= 1;  // GIM not used
     128      }
     129    }
     130    int maxObs = allObs.size() * _numAllUsedLCs;
     131    _datumTrafo->initAA(maxObs, _parlist->nPar());
     132  }
    116133
    117134  // Pre-Process Satellite Systems separately
     
    121138      OPT->_obsModelType == OPT->DCMphaseBias) {
    122139    preProcessing = true;
    123     _numAllUsedLCs = 0;
    124140    for (unsigned iSys = 0; iSys < OPT->systems().size(); iSys++) {
     141      (iSys) ? _datumTrafo->setFirstSystem(false) : _datumTrafo->setFirstSystem(true);
    125142      char system = OPT->systems()[iSys];
    126       _numAllUsedLCs += OPT->LCs(system).size();
    127       if (OPT->_pseudoObsIono && !epoch->pseudoObsIono()) {
    128         _numAllUsedLCs -= 1;  // GIM not used
    129       }
    130143      if (OPT->_refSatRequired) {
    131144        _refPrn = (_obsPool->getRefSatMapElement(system))->prn();
     145        if (_obsPool->hasHistoricalRefSat(_refPrn)) {
     146          return failure;
     147        }
    132148      }
    133149      vector<t_pppSatObs*> obsVector;
     
    142158      }
    143159    }
    144   }
    145 
    146   if (_numEpoProcessing == 1) {
    147     int maxObs = allObs.size() * _numAllUsedLCs;
    148     _datumTrafo->initAA(maxObs, _parlist->nPar());
     160    // refSat change required?
     161    // -----------------------
     162    if (_obsPool->refSatChangeRequired()) {
     163      _xFlt = xFltOld;
     164      _QFlt = QFltOld;
     165      return success;
     166    }
     167    else if (!_obsPool->refSatChangeRequired() &&
     168             _numEpoProcessing > 1) {
     169      datumTransformation(xFltOld, QFltOld);
     170    }
    149171  }
    150172
     
    154176  for (unsigned iSys = 0; iSys < OPT->systems().size(); iSys++) {
    155177    char system = OPT->systems()[iSys];
    156     (iSys) ? _datumTrafo->setFirstSystem(false) :
    157                  _datumTrafo->setFirstSystem(true);
    158178    if (OPT->_refSatRequired) {
    159179      _refPrn = (_obsPool->getRefSatMapElement(system))->prn();
     
    174194  }
    175195
    176   // refSat change required?
    177   // -----------------------
    178   if (_obsPool->refSatChangeRequired()) {
    179     _xFlt = xFltOld;
    180     _QFlt = QFltOld;
    181   }
    182196  // close epoch processing
    183197  // ----------------------
    184   else {
    185     cmpDOP(allObs);
    186     _parlist->printResult(_epoTime, _QFlt, _xFlt);
    187     _lastEpoTimeOK = _epoTime;  // remember time of last successful epoch processing
    188   }
     198  cmpDOP(allObs);
     199  _parlist->printResult(_epoTime, _QFlt, _xFlt);
     200  _lastEpoTimeOK = _epoTime;  // remember time of last successful epoch processing
    189201
    190202  return success;
     
    198210                                 bool pseudoObsIonoAvailable,
    199211                                 bool preProcessing) {
    200   qDebug() << "======t_pppFilter::processSystem=======";
    201212  LOG.setf(ios::fixed);
    202213
    203214  // Detect Cycle Slips
    204215  // ------------------
     216
    205217  if (detectCycleSlips(LCs, obsVector, refPrn, preProcessing) != success) {
    206218    return failure;
     
    221233    maxObs -= 1;
    222234  }
    223   qDebug() << "par.size()      : " << _parlist->nPar() << " LCs.size(): " << usedLCs;
    224   qDebug() << "obsVector.size(): " << obsVector.size() << " maxObs    : " << maxObs;
    225235
    226236  // Outlier Detection Loop
    227237  // ----------------------
    228238  for (unsigned iOutlier = 0; iOutlier < maxObs; iOutlier++) {
    229     qDebug() << "iOutlier: " << iOutlier;
    230239
    231240    if (iOutlier > 0) {
     
    236245    // First-Design Matrix, Terms Observed-Computed, Weight Matrix
    237246    // -----------------------------------------------------------
    238     qDebug() << "A(" << maxObs << "," << _parlist->nPar() << ")";
    239247    Matrix                AA(maxObs, _parlist->nPar());
    240248    ColumnVector          ll(maxObs);
    241249    DiagonalMatrix        PP(maxObs); PP = 0.0;
    242 
    243     // TETSPLOT
    244     for (unsigned iPar = 0; iPar < params.size(); iPar++) {
    245       const t_pppParam* par = params[iPar];
    246       cout << "  " << par->toString() <<endl;
    247     }
    248     cout << endl;
    249     //END TETSPLOT
    250250
    251251    int iObs = -1;
     
    253253    vector<t_lc::type>   usedTypes;
    254254    for (unsigned ii = 0; ii < obsVector.size(); ii++) {
    255       t_pppSatObs* obs = obsVector[ii]; qDebug() << "SATELLITE: " << obs->prn().toString().c_str() << "isRef: " << obs->isReference();
     255      t_pppSatObs* obs = obsVector[ii];
    256256      if (!obs->outlier()) {
    257257        for (unsigned jj = 0; jj < usedLCs; jj++) {
     
    263263          for (unsigned iPar = 0; iPar < params.size(); iPar++) {
    264264            const t_pppParam* par = params[iPar];
    265             AA[iObs][iPar] = par->partial(_epoTime, obs, tLC);
    266             cout << setw(10) << par->partial(_epoTime, obs, tLC);
    267           }
    268           cout << endl;
     265            AA[iObs][iPar] = par->partial(_epoTime, obs, tLC, refPrn);
     266          }
    269267          ll[iObs] = obs->obsValue(tLC) - obs->cmpValue(tLC) - DotProduct(_x0, AA.Row(iObs+1));
    270268          PP[iObs] = 1.0 / (obs->sigma(tLC) * obs->sigma(tLC));
    271           //qDebug() << "ll[iObs]: " << ll[iObs];
    272           //qDebug() << "PP[iObs]: " << PP[iObs];
    273         }
    274       }
    275     }
    276 
    277     if ((!preProcessing) &&
    278        (OPT->_obsModelType == OPT->DCMcodeBias ||
    279         OPT->_obsModelType == OPT->DCMphaseBias)) {
     269        }
     270      }
     271    }
     272
     273    if ((preProcessing && ! iOutlier) &&
     274        (OPT->_obsModelType == OPT->DCMcodeBias || OPT->_obsModelType == OPT->DCMphaseBias)) {
    280275          _datumTrafo->updateIndices(maxObs);
    281276      _datumTrafo->prepareAA(AA, _numEpoProcessing, _parlist->nPar());
     277      if (_obsPool->refSatChangeRequired()) { // from detectCycleSlips()
     278        return success;
     279      }
    282280    }
    283281
     
    331329        }
    332330      }
    333       if      (par && preProcessing) {
    334         if (par->prn() == refPrn) {
     331      if (preProcessing) {
     332        if (par && obs->prn() == refPrn) {
    335333          _obsPool->setRefSatChangeRequired(true);
    336         }
    337       }
    338       else if (par && !preProcessing) {
    339         if (par->ambResetCandidate()) {
    340           resetAmb(par->prn(), obsVector, &QSav, &xSav);
     334          break;
     335        }
     336      }
     337      else {
     338        if (par) {
     339          if (par->ambResetCandidate() || _obsPool->hasHistoricalRefSat(par->prn())) {
     340            resetAmb(par->prn(), obsVector, &QSav, &xSav);
     341          }
     342          else {
     343            par->setAmbResetCandidate();
     344            obs->setOutlier();
     345          }
    341346        }
    342347        else {
    343           par->setAmbResetCandidate();
    344348          obs->setOutlier();
    345349        }
    346350      }
    347       else if (!par && !preProcessing){
    348         obs->setOutlier();
    349       }
    350     }
    351 
     351    }
    352352    // Print Residuals
    353353    // ---------------
     
    381381                                    const t_prn& refPrn,
    382382                                    bool preProcessing) {
    383 
    384   const double            SLIP       = 20.0;  // slip threshold
     383  if (_obsPool->hasHistoricalRefSat(refPrn)) {
     384    return success;
     385  }
     386
     387  double                  SLIP       = 20.0;  // slip threshold
    385388  string                  epoTimeStr = string(_epoTime);
    386389  const vector<t_pppParam*>& params  = _parlist->params();
     390
     391  if (preProcessing) {
     392    SLIP += 10.0;
     393  }
    387394
    388395  for (unsigned ii = 0; ii < LCs.size(); ii++) {
     
    391398      for (unsigned iObs = 0; iObs < obsVector.size(); iObs++) {
    392399        const t_pppSatObs* obs = obsVector[iObs];
     400
     401        if (preProcessing && obs->prn() != refPrn) {continue;}
    393402
    394403        // Check set Slips and Jump Counters
     
    405414          slip = true;
    406415        }
    407         _slips[obs->prn()]._obsSlipCounter = obs->slipCounter();
     416        if (!preProcessing) {
     417          _slips[obs->prn()]._obsSlipCounter = obs->slipCounter();
     418        }
    408419
    409420        if (_slips[obs->prn()]._biasJumpCounter != -1 &&
     
    412423          slip = true;
    413424        }
    414 
     425        if (!preProcessing) {
     426          _slips[obs->prn()]._biasJumpCounter = obs->biasJumpCounter();
     427        }
    415428        // Slip Set
    416429        // --------
    417430        if (slip) {
    418431          if (preProcessing) {
    419             if (obs->prn() == refPrn) {
    420               _obsPool->setRefSatChangeRequired(true);
    421             }
     432            _obsPool->setRefSatChangeRequired(true);
    422433          }
    423434          else {
     
    431442          for (unsigned iPar = 0; iPar < params.size(); iPar++) {
    432443            const t_pppParam* par = params[iPar];
    433             AA[iPar] = par->partial(_epoTime, obs, tLC);
    434           }
     444            AA[iPar] = par->partial(_epoTime, obs, tLC, refPrn);
     445          }
     446
    435447          double ll = obs->obsValue(tLC) - obs->cmpValue(tLC) - DotProduct(_x0, AA);
    436448          double vv = DotProduct(AA, _xFlt) - ll;
    437449          if (fabs(vv) > SLIP) {
    438450            if (preProcessing) {
    439               if (obs->prn() == refPrn) {
    440                 _obsPool->setRefSatChangeRequired(true);
    441               }
     451              _obsPool->setRefSatChangeRequired(true);
    442452            }
    443453            else {
     
    451461    }
    452462  }
    453 
    454463  return success;
    455464}
     
    459468t_irc t_pppFilter::resetAmb(t_prn prn, const vector<t_pppSatObs*>& obsVector,
    460469                            SymmetricMatrix* QSav, ColumnVector* xSav) {
     470
    461471  t_irc irc = failure;
    462472  vector<t_pppParam*>& params = _parlist->params();
     
    504514    for (unsigned ii = 0; ii < obsVector.size(); ii++) {
    505515      t_pppSatObs* obs = obsVector[ii];
     516      char system = obs->prn().system();
     517      t_prn refPrn = t_prn();
     518      if (OPT->_refSatRequired) {
     519        refPrn = _obsPool->getRefSatMapElement(system)->prn();
     520      }
    506521      if (obs->isValid() && !obs->outlier()) {
    507522        ++_numSat;
    508523        for (unsigned iPar = 0; iPar < numPar; iPar++) {
    509524          const t_pppParam* par = _parlist->params()[iPar];
    510           AA[_numSat-1][iPar] = par->partial(_epoTime, obs, t_lc::c1);
     525          AA[_numSat-1][iPar] = par->partial(_epoTime, obs, t_lc::c1, refPrn);
    511526        }
    512527      }
     
    571586// Compute datum transformation
    572587////////////////////////////////////////////////////////////////////////////
    573 void t_pppFilter::datumTransformation(void) {
    574   _QFlt = _datumTrafo->varCov(Q());
    575 }
    576 
     588void t_pppFilter::datumTransformation(const ColumnVector& xFltOld, const SymmetricMatrix& QFltOld) {
     589
     590  Matrix D21 = _datumTrafo->computeTrafoMatrix();
     591  _QFlt << D21 * QFltOld * D21.t();
     592  _xFlt = D21 * xFltOld;
     593}
     594
     595
     596// Reset Ambiguity Parameter (cycle slip)
     597////////////////////////////////////////////////////////////////////////////
     598t_irc t_pppFilter::addInfiniteNoise(t_pppParam::e_type para) {
     599  t_irc irc = failure;
     600  vector<t_pppParam*>& params = _parlist->params();
     601  for (unsigned iPar = 0; iPar < params.size(); iPar++) {
     602    t_pppParam* par = params[iPar];
     603    if (par->type() == para) {
     604      int ind = par->indexNew();
     605      if (ind < 0) {
     606        return irc;
     607      }
     608      _QFlt(ind+1,ind+1) += par->sigma0() * par->sigma0();
     609      irc = success;
     610    }
     611  }
     612  return irc;
     613}
Note: See TracChangeset for help on using the changeset viewer.