Changeset 3474 in ntrip


Ignore:
Timestamp:
Oct 14, 2011, 8:04:47 PM (13 years ago)
Author:
mervart
Message:
 
File:
1 edited

Legend:

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

    r3473 r3474  
    4242
    4343using namespace std;
     44
     45// Auxiliary Class for Single-Differences
     46////////////////////////////////////////////////////////////////////////////
     47class t_sDiff {
     48 public:
     49  QMap<QString, double> diff;
     50};
    4451
    4552// Constructor
     
    715722  }
    716723
    717   const int nCon = 1 + MAXPRN_GPS;
     724  const int nCon = (_method == filter) ? 1 + MAXPRN_GPS : 0;
    718725
    719726  AA.ReSize(nObs+nCon, nPar);  AA = 0.0;
     
    730737    ++iObs;
    731738
    732     if (corr->acName == _masterOrbitAC && resCorr.find(prn) == resCorr.end()) {
    733       resCorr[prn] = new t_corr(*corr);
     739    if (_method == filter) {
     740      if (corr->acName == _masterOrbitAC && resCorr.find(prn) == resCorr.end()) {
     741        resCorr[prn] = new t_corr(*corr);
     742      }
    734743    }
    735744
     
    744753  // Regularization
    745754  // --------------
    746   const double Ph = 1.e6;
    747   PP(nObs+1) = Ph;
    748   for (int iPar = 1; iPar <= _params.size(); iPar++) {
    749     cmbParam* pp = _params[iPar-1];
    750     if ( AA.Column(iPar).maximum_absolute_value() > 0.0 &&
    751          pp->type == cmbParam::clkSat ) {
    752       AA(nObs+1, iPar) = 1.0;
    753     }
    754   }
    755   int iCond = 1;
    756   for (int iGps = 1; iGps <= MAXPRN_GPS; iGps++) {
    757     QString prn = QString("G%1").arg(iGps, 2, 10, QChar('0'));
    758     ++iCond;
    759     PP(nObs+iCond) = Ph;
     755  if (_method == filter) {
     756    const double Ph = 1.e6;
     757    PP(nObs+1) = Ph;
    760758    for (int iPar = 1; iPar <= _params.size(); iPar++) {
    761759      cmbParam* pp = _params[iPar-1];
    762760      if ( AA.Column(iPar).maximum_absolute_value() > 0.0 &&
    763            pp->type == cmbParam::offACSat                 &&
    764            pp->prn == prn) {
    765         AA(nObs+iCond, iPar) = 1.0;
     761           pp->type == cmbParam::clkSat ) {
     762        AA(nObs+1, iPar) = 1.0;
     763      }
     764    }
     765    int iCond = 1;
     766    for (int iGps = 1; iGps <= MAXPRN_GPS; iGps++) {
     767      QString prn = QString("G%1").arg(iGps, 2, 10, QChar('0'));
     768      ++iCond;
     769      PP(nObs+iCond) = Ph;
     770      for (int iPar = 1; iPar <= _params.size(); iPar++) {
     771        cmbParam* pp = _params[iPar-1];
     772        if ( AA.Column(iPar).maximum_absolute_value() > 0.0 &&
     773             pp->type == cmbParam::offACSat                 &&
     774             pp->prn == prn) {
     775          AA(nObs+iCond, iPar) = 1.0;
     776        }
    766777      }
    767778    }
     
    776787                                        QMap<QString, t_corr*>& resCorr) {
    777788
    778   int iObs = 0;
     789  // Initialize resCorr
     790  // ------------------
    779791  QVectorIterator<cmbCorr*> itCorr(corrs());
    780792  while (itCorr.hasNext()) {
     
    782794    QString  prn  = corr->prn;
    783795    switchToLastEph(_eph[prn]->last, corr);
    784     ++iObs;
    785 
    786796    if (corr->acName == _masterOrbitAC && resCorr.find(prn) == resCorr.end()) {
    787797      resCorr[prn] = new t_corr(*corr);
     
    789799  }
    790800
    791   if (iObs == 0) {
     801  // Count Number of Observations per Satellite and per AC
     802  // -----------------------------------------------------
     803  QMap<QString, int> numObsPrn;
     804  QMap<QString, int> numObsAC;
     805  QMapIterator<QString, t_corr*> itRes(resCorr);
     806  while (itRes.hasNext()) {
     807    itRes.next();
     808    const QString& prnRes = itRes.key();
     809    QVectorIterator<cmbCorr*> itCorr(corrs());
     810    while (itCorr.hasNext()) {
     811      cmbCorr* corr = itCorr.next();
     812      QString  prn  = corr->prn;
     813      QString  AC   = corr->acName;
     814      if (prn == prnRes) {
     815        if (numObsPrn.find(prn) == numObsPrn.end()) {
     816          numObsPrn[prn]  = 1;
     817        }
     818        else {
     819          numObsPrn[prn] += 1;
     820        }
     821        if (numObsAC.find(prn) == numObsAC.end()) {
     822          numObsAC[AC]  = 1;
     823        }
     824        else {
     825          numObsAC[AC] += 1;
     826        }
     827      }
     828    }
     829  }
     830
     831  // Clean-Up the Paramters
     832  // ----------------------
     833  for (int iPar = 1; iPar <= _params.size(); iPar++) {
     834    delete _params[iPar-1];
     835  }
     836  _params.clear();
     837
     838  // Set new Parameters
     839  // ------------------
     840  int nextPar = 0;
     841
     842  QMapIterator<QString, int> itAC(numObsAC);
     843  while (itAC.hasNext()) {
     844    itAC.next();
     845    const QString& AC     = itAC.key();
     846    int            numObs = itAC.value();
     847    if (numObs > 0) {
     848      _params.push_back(new cmbParam(cmbParam::offAC, ++nextPar, AC, ""));
     849    }
     850  }
     851
     852  QMapIterator<QString, int> itPrn(numObsPrn);
     853  while (itPrn.hasNext()) {
     854    itPrn.next();
     855    const QString& prn    = itPrn.key();
     856    int            numObs = itPrn.value();
     857    if (numObs > 0) {
     858      _params.push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
     859    }
     860  } 
     861
     862  int nPar = _params.size();
     863  ColumnVector x0(nPar);
     864  x0 = 0.0;
     865
     866  // Create First-Design Matrix
     867  // --------------------------
     868  Matrix         AA;
     869  ColumnVector   ll;
     870  DiagonalMatrix PP;
     871  if (createAmat(AA, ll, PP, x0, resCorr) != success) {
    792872    return failure;
    793873  }
    794   else {
    795     return success;
    796   }
    797 }
     874
     875  SymmetricMatrix NN; NN << AA.t() * PP * AA;
     876  ColumnVector    bb = AA.t() * PP * ll;
     877  SymmetricMatrix QQ = NN.i();
     878
     879  ColumnVector    xx = QQ * bb;
     880
     881  cout << xx.t() << endl;
     882
     883  return success;
     884}
Note: See TracChangeset for help on using the changeset viewer.