Changeset 3448 in ntrip for trunk


Ignore:
Timestamp:
Sep 22, 2011, 4:58:48 PM (13 years ago)
Author:
mervart
Message:
 
Location:
trunk/BNC/combination
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/combination/bnccomb.cpp

    r3447 r3448  
    3535const double sig0_offACSat =  100.0;
    3636const double sigP_offACSat =    0.0;
    37 const double sig0_clkSat   =   10.0;
    38 const double sigP_clkSat   =    0.1;
    39 
    40 const double sigObs        =   0.05;
     37const double sig0_clkSat   =  100.0;
     38const double sigP_clkSat   =  100.0;
    4139
    4240const int MAXPRN_GPS = 32;
     
    5452  prn    = prn_;
    5553  xx     = 0.0;
    56   eph    = 0;
    5754
    5855  if      (type == offAC) {
     
    186183  }
    187184
     185  // Not yet regularized
     186  // -------------------
     187  _firstReg = false;
     188
    188189  // Maximal Residuum
    189190  // ----------------
     
    337338  XYZ_to_RSW(newXC.Rows(1,3), newVV, dV, dDotRAO);
    338339
    339   QString msg = "switch corr " + corr->prn
     340  QString msg = "switch " + corr->prn
    340341    + QString(" %1 -> %2 %3").arg(corr->iod,3)
    341342    .arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
     
    355356
    356357  int nPar = _params.size();
     358  int nObs = corrs().size();
     359
     360  if (nObs == 0) {
     361    return;
     362  }
    357363
    358364  _log.clear();
     
    383389  ColumnVector x0(nPar);
    384390  for (int iPar = 1; iPar <= _params.size(); iPar++) {
    385     cmbParam* pp  = _params[iPar-1];
    386     QString   prn = pp->prn;
    387     if (!prn.isEmpty() && _eph.find(prn) != _eph.end()) {
    388       switchToLastEph(_eph[prn]->last, pp);
    389     }
     391    cmbParam* pp = _params[iPar-1];
    390392    if (pp->epoSpec) {
    391393      pp->xx = 0.0;
     
    400402  }
    401403
     404  // Create First Design Matrix and Vector of Measurements
     405  // -----------------------------------------------------
     406  const double Pl = 1.0 / (0.05 * 0.05);
     407
     408  const int nCon = (_firstReg == false) ? 1 + MAXPRN_GPS : 1;
     409  Matrix         AA(nObs+nCon, nPar);  AA = 0.0;
     410  ColumnVector   ll(nObs+nCon);        ll = 0.0;
     411  DiagonalMatrix PP(nObs+nCon);        PP = Pl;
     412
     413  int iObs = 0;
     414
     415  QMap<QString, t_corr*> resCorr;
     416
     417  QVectorIterator<cmbCorr*> itCorr(corrs());
     418  while (itCorr.hasNext()) {
     419    cmbCorr* corr = itCorr.next();
     420    QString  prn  = corr->prn;
     421    switchToLastEph(_eph[prn]->last, corr);
     422    ++iObs;
     423
     424    if (resCorr.find(prn) == resCorr.end()) {
     425      resCorr[prn] = new t_corr(*corr);
     426    }
     427
     428    for (int iPar = 1; iPar <= _params.size(); iPar++) {
     429      cmbParam* pp = _params[iPar-1];
     430      AA(iObs, iPar) = pp->partial(corr->acName, prn);
     431    }
     432
     433    ll(iObs) = corr->dClk * t_CST::c - DotProduct(AA.Row(iObs), x0);
     434  }
     435
     436  // Regularization
     437  // --------------
     438  const double Ph = 1.e6;
     439  int iCond = 1;
     440  PP(nObs+iCond)          = Ph;
     441  for (int iPar = 1; iPar <= _params.size(); iPar++) {
     442    cmbParam* pp = _params[iPar-1];
     443    if (pp->type == cmbParam::clkSat &&
     444        AA.Column(iPar).maximum_absolute_value() > 0.0) {
     445      AA(nObs+iCond, iPar) = 1.0;
     446    }
     447  }
     448
     449  if (!_firstReg) {
     450    _firstReg = true;
     451    for (int iGps = 1; iGps <= MAXPRN_GPS; iGps++) {
     452      ++iCond;
     453      QString prn = QString("G%1").arg(iGps, 2, 10, QChar('0'));
     454      PP(nObs+1+iGps)       = Ph;
     455      for (int iPar = 1; iPar <= _params.size(); iPar++) {
     456        cmbParam* pp = _params[iPar-1];
     457        if (pp->type == cmbParam::offACSat && pp->prn == prn) {
     458          AA(nObs+iCond, iPar) = 1.0;
     459        }
     460      }
     461    }
     462  }
     463
     464  ColumnVector dx;
    402465  SymmetricMatrix QQ_sav = _QQ;
    403466
    404   ColumnVector dx;
    405   QMap<QString, t_corr*> resCorr;
    406    
    407467  // Update and outlier detection loop
    408468  // ---------------------------------
    409   while (true) {
    410 
    411     Matrix         AA;
    412     ColumnVector   ll;
    413     DiagonalMatrix PP;
    414 
    415     if (createAmat(AA, ll, PP, x0, resCorr) != success) {
    416       return;
    417     }
    418 
     469  for (int ii = 1; ii < 10; ii++) {
    419470    bncModel::kalman(AA, ll, PP, _QQ, dx);
    420471    ColumnVector vv = ll - AA * dx;
     
    442493      out << "  Outlier" << endl;
    443494      _QQ = QQ_sav;
    444       corrs().remove(maxResIndex-1);
     495      AA.Row(maxResIndex) = 0.0;
     496      ll.Row(maxResIndex) = 0.0;
    445497    }
    446498    else {
     
    637689  }
    638690}
    639 
    640 // Create First Design Matrix and Vector of Measurements
    641 ////////////////////////////////////////////////////////////////////////////
    642 t_irc bncComb::createAmat(Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
    643                           const ColumnVector& x0,
    644                           QMap<QString, t_corr*>& resCorr) {
    645 
    646   unsigned nPar = _params.size();
    647   unsigned nObs = corrs().size();
    648 
    649   if (nObs == 0) {
    650     return failure;
    651   }
    652 
    653   const int nCon = 2;
    654 
    655   AA.ReSize(nObs+nCon, nPar);  AA = 0.0;
    656   ll.ReSize(nObs+nCon);        ll = 0.0;
    657   PP.ReSize(nObs+nCon);        PP = 1.0 / (sigObs * sigObs);
    658 
    659   int iObs = 0;
    660 
    661   QVectorIterator<cmbCorr*> itCorr(corrs());
    662   while (itCorr.hasNext()) {
    663     cmbCorr* corr = itCorr.next();
    664     QString  prn  = corr->prn;
    665     switchToLastEph(_eph[prn]->last, corr);
    666     ++iObs;
    667 
    668     if (resCorr.find(prn) == resCorr.end()) {
    669       resCorr[prn] = new t_corr(*corr);
    670     }
    671 
    672     for (int iPar = 1; iPar <= _params.size(); iPar++) {
    673       cmbParam* pp = _params[iPar-1];
    674       AA(iObs, iPar) = pp->partial(corr->acName, prn);
    675     }
    676 
    677     ll(iObs) = corr->dClk * t_CST::c - DotProduct(AA.Row(iObs), x0);
    678   }
    679 
    680   // Regularization
    681   // --------------
    682   const double Ph = 1.e6;
    683   PP(nObs+1) = Ph;
    684   PP(nObs+2) = Ph;
    685   for (int iPar = 1; iPar <= _params.size(); iPar++) {
    686     cmbParam* pp = _params[iPar-1];
    687     if      (pp->type == cmbParam::clkSat) {
    688       AA(nObs+1, iPar) = 1.0;
    689     }
    690     else if (pp->type == cmbParam::offAC) {
    691       AA(nObs+2, iPar) = 1.0;
    692     }
    693   }
    694 
    695   return success;
    696 }
    697 
    698 // Change the parameter so that it refers to last received ephemeris
    699 ////////////////////////////////////////////////////////////////////////////
    700 void bncComb::switchToLastEph(const t_eph* lastEph, cmbParam* pp) {
    701 
    702   if (pp->type != cmbParam::clkSat) {
    703     return;
    704   }
    705 
    706   if (pp->eph == 0) {
    707     pp->eph = lastEph;
    708     return;
    709   }
    710 
    711   if (pp->eph == lastEph) {
    712     return;
    713   }
    714 
    715   ColumnVector oldXC(4);
    716   ColumnVector oldVV(3);
    717   pp->eph->position(_resTime.gpsw(), _resTime.gpssec(),
    718                       oldXC.data(), oldVV.data());
    719 
    720   ColumnVector newXC(4);
    721   ColumnVector newVV(3);
    722   lastEph->position(_resTime.gpsw(), _resTime.gpssec(),
    723                     newXC.data(), newVV.data());
    724 
    725   double dC = newXC(4) - oldXC(4);
    726 
    727   QString msg = "switch param " + pp->prn
    728     + QString(" %1 -> %2 %3").arg(pp->eph->IOD(),3)
    729     .arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
    730 
    731   emit newMessage(msg.toAscii(), false);
    732 
    733   pp->eph = lastEph;
    734   pp->xx  -= dC * t_CST::c;
    735 }
    736 
  • trunk/BNC/combination/bnccomb.h

    r3442 r3448  
    2626  double  sigP;
    2727  bool    epoSpec;
    28   const t_eph* eph;
    2928};
    3029
     
    7473
    7574  void processEpoch();
    76   t_irc createAmat(Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
    77                    const ColumnVector& x0, QMap<QString, t_corr*>& resCorr);
    7875  void dumpResults(const QMap<QString, t_corr*>& resCorr);
    7976  void printResults(QTextStream& out, const QMap<QString, t_corr*>& resCorr);
    8077  void switchToLastEph(const t_eph* lastEph, t_corr* corr);
    81   void switchToLastEph(const t_eph* lastEph, cmbParam* pp);
    8278
    8379  QVector<cmbCorr*>& corrs() {return _buffer[_resTime].corrs;}
     
    8985  bncRtnetDecoder*        _rtnetDecoder;
    9086  SymmetricMatrix         _QQ;
     87  bool                    _firstReg;
    9188  QByteArray              _log;
    9289  bncAntex*               _antex;
Note: See TracChangeset for help on using the changeset viewer.