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


Ignore:
Timestamp:
Mar 18, 2020, 11:13:50 AM (4 years ago)
Author:
stuerze
Message:

some developments regarding PPP, not completed!

File:
1 edited

Legend:

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

    r8329 r8905  
    3434// Constructor
    3535////////////////////////////////////////////////////////////////////////////
    36 t_pppFilter::t_pppFilter() {
     36t_pppFilter::t_pppFilter(t_pppObsPool* obsPool) {
    3737  _parlist = 0;
     38  _numSat = 0;
     39  _obsPool = obsPool;
    3840}
    3941
     
    4648// Process Single Epoch
    4749////////////////////////////////////////////////////////////////////////////
    48 t_irc t_pppFilter::processEpoch(t_pppObsPool* obsPool) {
    49 
     50t_irc t_pppFilter::processEpoch(int num) {
    5051  _numSat     = 0;
    5152  const double maxSolGap = 60.0;
     
    5758  // Vector of all Observations
    5859  // --------------------------
    59   t_pppObsPool::t_epoch* epoch = obsPool->lastEpoch();
     60  t_pppObsPool::t_epoch* epoch = _obsPool->lastEpoch();
    6061  if (!epoch) {
    6162    return failure;
     
    7576  string epoTimeStr = string(_epoTime);
    7677
     78  //--
    7779  // Set Parameters
    7880  // --------------
     
    9193  for (unsigned ii = 0; ii < params.size(); ii++) {
    9294    const t_pppParam* par1 = params[ii];
    93 
    9495    _x0[ii] = par1->x0();
    95 
    9696    int iOld = par1->indexOld();
    9797    if (iOld < 0) {
     
    113113  predictCovCrdPart(QFltOld);
    114114
     115
     116  // Pre-Process Satellite Systems separately
     117  // ----------------------------------------
     118  bool preProcessing = false;
     119  if (OPT->_obsModelType == OPT->DCMcodeBias ||
     120      OPT->_obsModelType == OPT->DCMphaseBias) {
     121    preProcessing = true;
     122    for (unsigned iSys = 0; iSys < OPT->systems().size(); iSys++) {
     123      char system = OPT->systems()[iSys];
     124      t_prn refPrn = (_obsPool->getRefSatMapElement(system))->prn();
     125      vector<t_pppSatObs*> obsVector;
     126      for (unsigned jj = 0; jj < allObs.size(); jj++) {
     127        if (allObs[jj]->prn().system() == system) {
     128          obsVector.push_back(allObs[jj]);
     129        }
     130      }
     131      if (processSystem(OPT->LCs(system), obsVector, refPrn,
     132                        epoch->pseudoObsIono(), preProcessing) != success) {
     133        return failure;
     134      }
     135    }
     136  }
     137
    115138  // Process Satellite Systems separately
    116139  // ------------------------------------
    117140  for (unsigned iSys = 0; iSys < OPT->systems().size(); iSys++) {
    118141    char system = OPT->systems()[iSys];
     142    t_prn refPrn = (_obsPool->getRefSatMapElement(system))->prn();
    119143    unsigned int num = 0;
    120144    vector<t_pppSatObs*> obsVector;
     
    126150    }
    127151    LOG << epoTimeStr << " SATNUM " << system << ' ' << right << setw(2) << num << endl;
    128     if ( processSystem(OPT->LCs(system), obsVector) != success ) {
     152    if (processSystem(OPT->LCs(system), obsVector, refPrn,
     153                      epoch->pseudoObsIono(), preProcessing) != success) {
    129154      return failure;
    130155    }
    131156  }
    132 
    133   cmpDOP(allObs);
    134 
    135   _parlist->printResult(_epoTime, _QFlt, _xFlt);
    136   _lastEpoTimeOK = _epoTime;  // remember time of last successful epoch processing
     157  if (_obsPool->epoReProcessing()) {
     158    // set A1 und A2 abhängig von num
     159    // if num == 1 => A1
     160    // if num >  1 => A2
     161  }
     162  else {
     163    cmpDOP(allObs);
     164    _parlist->printResult(_epoTime, _QFlt, _xFlt);
     165    _lastEpoTimeOK = _epoTime;  // remember time of last successful epoch processing
     166  }
     167
    137168  return success;
    138169}
     
    141172////////////////////////////////////////////////////////////////////////////
    142173t_irc t_pppFilter::processSystem(const vector<t_lc::type>& LCs,
    143                                  const vector<t_pppSatObs*>& obsVector) {
    144 
     174                                 const vector<t_pppSatObs*>& obsVector,
     175                                 const t_prn& refPrn,
     176                                 bool pseudoObsIonoAvailable,
     177                                 bool preProcessing) {
     178  qDebug() << "======t_pppFilter::processSystem=======";
    145179  LOG.setf(ios::fixed);
    146180
    147181  // Detect Cycle Slips
    148182  // ------------------
    149   if (detectCycleSlips(LCs, obsVector) != success) {
     183  if (detectCycleSlips(LCs, obsVector, refPrn, preProcessing) != success) {
    150184    return failure;
    151185  }
    152186
    153   ColumnVector            xSav       = _xFlt;
    154   SymmetricMatrix         QSav       = _QFlt;
    155   string                  epoTimeStr = string(_epoTime);
     187  unsigned usedLCs = LCs.size(); //qDebug() << "usedLCs: " << usedLCs;
     188  if (OPT->_pseudoObsIono && !pseudoObsIonoAvailable) {
     189    usedLCs -= 1;  // GIM not used
     190  }
     191  ColumnVector               xSav       = _xFlt;
     192  SymmetricMatrix            QSav       = _QFlt;
     193  string                     epoTimeStr = string(_epoTime);
    156194  const vector<t_pppParam*>& params     = _parlist->params();
    157   unsigned                maxObs     = obsVector.size() * LCs.size();
     195  unsigned                   maxObs     = obsVector.size() * usedLCs;
     196  //unsigned                   maxObs     = 2 * usedLCs;
     197
     198  if (OPT->_pseudoObsIono && pseudoObsIonoAvailable) { // stecDiff w.r.t refSat
     199    maxObs -= 1;
     200  }
     201  qDebug() << "par.size()      : " << _parlist->nPar() << " LCs.size(): " << usedLCs;
     202  qDebug() << "obsVector.size(): " << obsVector.size() << " maxObs    : " << maxObs;
    158203
    159204  // Outlier Detection Loop
    160205  // ----------------------
    161206  for (unsigned iOutlier = 0; iOutlier < maxObs; iOutlier++) {
     207    qDebug() << "iOutlier: " << iOutlier;
    162208
    163209    if (iOutlier > 0) {
     
    168214    // First-Design Matrix, Terms Observed-Computed, Weight Matrix
    169215    // -----------------------------------------------------------
     216    qDebug() << "A(" << maxObs << "," << _parlist->nPar() << ")";
    170217    Matrix                AA(maxObs, _parlist->nPar());
    171218    ColumnVector          ll(maxObs);
    172219    DiagonalMatrix        PP(maxObs); PP = 0.0;
     220    //TETSPLOT
     221    for (unsigned iPar = 0; iPar < params.size(); iPar++) {
     222      const t_pppParam* par = params[iPar];
     223      cout << "  " << par->toString() <<endl;
     224    }
     225    cout << endl;
    173226
    174227    int iObs = -1;
     
    176229    vector<t_lc::type>   usedTypes;
    177230    for (unsigned ii = 0; ii < obsVector.size(); ii++) {
    178       t_pppSatObs* obs = obsVector[ii];
     231      t_pppSatObs* obs = obsVector[ii]; qDebug() << "SATELLITE: " << obs->prn().toString().c_str() << "isRef: " << obs->isReference();
    179232      if (!obs->outlier()) {
    180         for (unsigned jj = 0; jj < LCs.size(); jj++) {
     233        for (unsigned jj = 0; jj < usedLCs; jj++) {
    181234          const t_lc::type tLC = LCs[jj];
     235          if (tLC == t_lc::GIM &&  obs->isReference()) {continue;}
    182236          ++iObs;
    183237          usedObs.push_back(obs);
     
    186240            const t_pppParam* par = params[iPar];
    187241            AA[iObs][iPar] = par->partial(_epoTime, obs, tLC);
     242            cout << setw(10) << par->partial(_epoTime, obs, tLC);
    188243          }
     244          cout << endl;
    189245          ll[iObs] = obs->obsValue(tLC) - obs->cmpValue(tLC) - DotProduct(_x0, AA.Row(iObs+1));
    190246          PP[iObs] = 1.0 / (obs->sigma(tLC) * obs->sigma(tLC));
     247          //qDebug() << "ll[iObs]: " << ll[iObs];
     248          //qDebug() << "PP[iObs]: " << PP[iObs];
    191249        }
    192250      }
     
    229287      t_pppSatObs* obs = usedObs[maxOutlierIndex];
    230288      t_pppParam* par = 0;
    231       LOG << epoTimeStr << " Outlier " << t_lc::toString(maxOutlierLC) << ' '
    232           << obs->prn().toString()                        << ' '
    233           << setw(8) << setprecision(4) << maxOutlier << endl;
     289      if (!preProcessing) {
     290        LOG << epoTimeStr << " Outlier " << t_lc::toString(maxOutlierLC) << ' '
     291            << obs->prn().toString()                        << ' '
     292            << setw(8) << setprecision(4) << maxOutlier << endl;
     293      }
    234294      for (unsigned iPar = 0; iPar < params.size(); iPar++) {
    235295        t_pppParam* hlp = params[iPar];
    236         if (hlp->type() == t_pppParam::amb && hlp->prn()  == obs->prn() &&
     296        if (hlp->type() == t_pppParam::amb &&
     297            hlp->prn()  == obs->prn() &&
    237298            hlp->tLC()  == usedTypes[maxOutlierIndex]) {
    238299          par = hlp;
    239300        }
    240301      }
    241       if (par) {
     302      if      (par && preProcessing) {
     303        if (par->prn() == refPrn) {
     304          _obsPool->setEpoReProcessing(true);
     305        }
     306      }
     307      else if (par && !preProcessing) {
    242308        if (par->ambResetCandidate()) {
    243309          resetAmb(par->prn(), obsVector, &QSav, &xSav);
     
    248314        }
    249315      }
    250       else {
     316      else if (!par && !preProcessing){
    251317        obs->setOutlier();
    252318      }
     
    256322    // ---------------
    257323    else {
    258       for (unsigned jj = 0; jj < LCs.size(); jj++) {
    259         for (unsigned ii = 0; ii < usedObs.size(); ii++) {
    260           const t_lc::type tLC = usedTypes[ii];
    261           t_pppSatObs*        obs = usedObs[ii];
    262           if (tLC == LCs[jj]) {
    263             obs->setRes(tLC, vv[ii]);
    264             LOG << epoTimeStr << " RES "
    265                 << left << setw(3) << t_lc::toString(tLC) << right << ' '
    266                 << obs->prn().toString().substr(0,3) << ' '
    267                 << setw(8) << setprecision(4) << vv[ii] << endl;
     324      if (!preProcessing) {
     325        for (unsigned jj = 0; jj < LCs.size(); jj++) {
     326          for (unsigned ii = 0; ii < usedObs.size(); ii++) {
     327            const t_lc::type tLC = usedTypes[ii];
     328            t_pppSatObs*        obs = usedObs[ii];
     329            if (tLC == LCs[jj]) {
     330              obs->setRes(tLC, vv[ii]);
     331              LOG << epoTimeStr << " RES "
     332                  << left << setw(3) << t_lc::toString(tLC) << right << ' '
     333                  << obs->prn().toString().substr(0,3) << ' '
     334                  << setw(8) << setprecision(4) << vv[ii] << endl;
     335            }
    268336          }
    269337        }
     
    279347////////////////////////////////////////////////////////////////////////////
    280348t_irc t_pppFilter::detectCycleSlips(const vector<t_lc::type>& LCs,
    281                                     const vector<t_pppSatObs*>& obsVector) {
     349                                    const vector<t_pppSatObs*>& obsVector,
     350                                    const t_prn& refPrn,
     351                                    bool preProcessing) {
    282352
    283353  const double            SLIP       = 20.0;  // slip threshold
    284354  string                  epoTimeStr = string(_epoTime);
    285   const vector<t_pppParam*>& params     = _parlist->params();
     355  const vector<t_pppParam*>& params  = _parlist->params();
    286356
    287357  for (unsigned ii = 0; ii < LCs.size(); ii++) {
     
    294364        // ---------------------------------
    295365        bool slip = false;
    296 
    297366        if (obs->slip()) {
    298367          LOG << epoTimeStr  << "cycle slip set (obs) " << obs->prn().toString()  << endl;
     
    312381          slip = true;
    313382        }
    314         _slips[obs->prn()]._biasJumpCounter = obs->biasJumpCounter();
    315383
    316384        // Slip Set
    317385        // --------
    318386        if (slip) {
    319           resetAmb(obs->prn(), obsVector);
    320         }
    321 
     387          if (preProcessing) {
     388            if (obs->prn() == refPrn) {
     389              _obsPool->setEpoReProcessing(true);
     390            }
     391          }
     392          else {
     393            resetAmb(obs->prn(), obsVector);
     394          }
     395        }
    322396        // Check Pre-Fit Residuals
    323397        // -----------------------
     
    328402            AA[iPar] = par->partial(_epoTime, obs, tLC);
    329403          }
    330 
    331404          double ll = obs->obsValue(tLC) - obs->cmpValue(tLC) - DotProduct(_x0, AA);
    332405          double vv = DotProduct(AA, _xFlt) - ll;
    333 
    334406          if (fabs(vv) > SLIP) {
    335             LOG << epoTimeStr << " cycle slip detected " << t_lc::toString(tLC) << ' '
    336                 << obs->prn().toString() << ' ' << setw(8) << setprecision(4) << vv << endl;
    337             resetAmb(obs->prn(), obsVector);
     407            if (preProcessing) {
     408              if (obs->prn() == refPrn) {
     409                _obsPool->setEpoReProcessing(true);
     410              }
     411            }
     412            else {
     413              LOG << epoTimeStr << " cycle slip detected " << t_lc::toString(tLC) << ' '
     414                  << obs->prn().toString() << ' ' << setw(8) << setprecision(4) << vv << endl;
     415              resetAmb(obs->prn(), obsVector);
     416            }
    338417          }
    339418        }
Note: See TracChangeset for help on using the changeset viewer.