Changeset 9258 in ntrip


Ignore:
Timestamp:
Nov 17, 2020, 3:50:34 PM (3 years ago)
Author:
stuerze
Message:

combination adapted to work system by system

Location:
trunk/BNC/src/combination
Files:
2 edited

Legend:

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

    r9025 r9258  
    4848  eph    = 0;
    4949
    50   if      (type == offACgps) {
    51     epoSpec = true;
    52     sig0    = sig0_offAC;
    53     sigP    = sig0;
    54   }
    55   else if (type == offACglo) {
     50  if      (type == offACgnss) {
    5651    epoSpec = true;
    5752    sig0    = sig0_offAC;
     
    7772// Partial
    7873////////////////////////////////////////////////////////////////////////////
    79 double bncComb::cmbParam::partial(const QString& AC_, const QString& prn_) {
    80 
    81   if      (type == offACgps) {
    82     if (AC == AC_ && prn_[0] == 'G') {
    83       return 1.0;
    84     }
    85   }
    86   else if (type == offACglo) {
    87     if (AC == AC_ && prn_[0] == 'R') {
     74double bncComb::cmbParam::partial(char sys, const QString& AC_, const QString& prn_) {
     75
     76  if      (type == offACgnss) {
     77    if (AC == AC_ && prn_[0].toLatin1() == sys) {
    8878      return 1.0;
    8979    }
     
    10595//
    10696////////////////////////////////////////////////////////////////////////////
    107 QString bncComb::cmbParam::toString() const {
     97QString bncComb::cmbParam::toString(char sys) const {
    10898
    10999  QString outStr;
    110100
    111   if      (type == offACgps) {
    112     outStr = "AC offset GPS " + AC;
    113   }
    114   else if (type == offACglo) {
    115     outStr = "AC offset GLO " + AC;
     101  if      (type == offACgnss) {
     102    outStr = "AC  Offset " + AC + " " + sys ;
    116103  }
    117104  else if (type == offACSat) {
     
    145132  }
    146133
    147   _masterMissingEpochs = 0;
     134  _cmbSysPrn['G'] = t_prn::MAXPRN_GPS;     _masterMissingEpochs['G'] = 0;
     135  _cmbSysPrn['R'] = t_prn::MAXPRN_GLONASS; _masterMissingEpochs['R'] = 0;
     136  _cmbSysPrn['E'] = t_prn::MAXPRN_GALILEO; _masterMissingEpochs['E'] = 0;
     137  _cmbSysPrn['C'] = t_prn::MAXPRN_BDS;     _masterMissingEpochs['C'] = 0;/*
     138  _cmbSysPrn['J'] = t_prn::MAXPRN_QZSS;    _masterMissingEpochs['J'] = 0;
     139  _cmbSysPrn['S'] = t_prn::MAXPRN_SBAS;    _masterMissingEpochs['S'] = 0;
     140  */
    148141
    149142  if (cmbStreams.size() >= 1 && !cmbStreams[0].isEmpty()) {
     
    155148      newAC->name       = hlp[1];
    156149      newAC->weight     = hlp[2].toDouble();
    157       if (_masterOrbitAC.isEmpty()) {
    158         _masterOrbitAC = newAC->name;
     150      QMapIterator<char, unsigned> itSys(_cmbSysPrn);
     151      // init
     152      while (itSys.hasNext()) {
     153        itSys.next();
     154        char sys = itSys.key();
     155        if (_masterOrbitAC.isEmpty()) {
     156          _masterOrbitAC[sys] = newAC->name;
     157        }
    159158      }
    160159      _ACs.append(newAC);
     
    163162
    164163  QString ssrFormat;
     164  _ssrCorr = 0;
    165165  QListIterator<QString> it(settings.value("uploadMountpointsOut").toStringList());
    166166  while (it.hasNext()) {
     
    170170    }
    171171  }
    172   _ssrCorr = 0;
    173172  if      (ssrFormat == "IGS-SSR") {
    174173    _ssrCorr = new SsrCorrIgs();
     
    177176    _ssrCorr = new SsrCorrRtcm();
    178177  }
    179 
     178  else { // default
     179    _ssrCorr = new SsrCorrIgs();
     180  }
    180181
    181182  _rtnetDecoder = 0;
     
    192193  connect(BNC_CORE, SIGNAL(newClkCorrections(QList<t_clkCorr>)),
    193194          this,     SLOT(slotNewClkCorrections(QList<t_clkCorr>)));
     195
     196
    194197
    195198  // Combination Method
     
    202205  }
    203206
    204   // Use Glonass
    205   // -----------
    206   if ( Qt::CheckState(settings.value("cmbUseGlonass").toInt()) == Qt::Checked) {
    207     _useGlonass = true;
    208   }
    209   else {
    210     _useGlonass = false;
    211   }
    212 
    213207  // Initialize Parameters (model: Clk_Corr = AC_Offset + Sat_Offset + Clk)
    214208  // ----------------------------------------------------------------------
    215209  if (_method == filter) {
    216     int nextPar = 0;
    217     QListIterator<cmbAC*> it(_ACs);
    218     while (it.hasNext()) {
    219       cmbAC* AC = it.next();
    220       _params.push_back(new cmbParam(cmbParam::offACgps, ++nextPar, AC->name, ""));
    221       for (unsigned iGps = 1; iGps <= t_prn::MAXPRN_GPS; iGps++) {
    222         QString prn = QString("G%1_0").arg(iGps, 2, 10, QChar('0'));
    223         _params.push_back(new cmbParam(cmbParam::offACSat, ++nextPar,
    224                                        AC->name, prn));
    225       }
    226       if (_useGlonass) {
    227         _params.push_back(new cmbParam(cmbParam::offACglo, ++nextPar, AC->name, ""));
    228         for (unsigned iGlo = 1; iGlo <= t_prn::MAXPRN_GLONASS; iGlo++) {
    229           QString prn = QString("R%1_0").arg(iGlo, 2, 10, QChar('0'));
    230           _params.push_back(new cmbParam(cmbParam::offACSat, ++nextPar,
    231                                          AC->name, prn));
     210    // SYSTEM
     211    QMapIterator<char, unsigned> itSys(_cmbSysPrn);
     212    while (itSys.hasNext()) {
     213      itSys.next();
     214      int nextPar = 0;
     215      char sys = itSys.key();
     216      unsigned maxPrn = itSys.value();
     217      unsigned flag = 0;
     218      if (sys == 'E') {
     219        flag = 1;
     220      }
     221      // AC
     222      QListIterator<cmbAC*> itAc(_ACs);
     223      while (itAc.hasNext()) {
     224        cmbAC* AC = itAc.next();
     225        _params[sys].push_back(new cmbParam(cmbParam::offACgnss, ++nextPar, AC->name, ""));
     226        for (unsigned iGnss = 1; iGnss <= maxPrn; iGnss++) {
     227          QString prn = QString("%1%2_%3").arg(sys).arg(iGnss, 2, 10, QChar('0')).arg(flag);
     228          _params[sys].push_back(new cmbParam(cmbParam::offACSat, ++nextPar, AC->name, prn));
    232229        }
    233230      }
    234     }
    235     for (unsigned iGps = 1; iGps <= t_prn::MAXPRN_GPS; iGps++) {
    236       QString prn = QString("G%1_0").arg(iGps, 2, 10, QChar('0'));
    237       _params.push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
    238     }
    239     if (_useGlonass) {
    240       for (unsigned iGlo = 1; iGlo <= t_prn::MAXPRN_GLONASS; iGlo++) {
    241         QString prn = QString("R%1_0").arg(iGlo, 2, 10, QChar('0'));
    242         _params.push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
    243       }
    244     }
    245 
    246     // Initialize Variance-Covariance Matrix
    247     // -------------------------------------
    248     _QQ.ReSize(_params.size());
    249     _QQ = 0.0;
    250     for (int iPar = 1; iPar <= _params.size(); iPar++) {
    251       cmbParam* pp = _params[iPar-1];
    252       _QQ(iPar,iPar) = pp->sig0 * pp->sig0;
     231      for (unsigned iGnss = 1; iGnss <= maxPrn; iGnss++) {
     232        QString prn = QString("%1%2_%3").arg(sys).arg(iGnss, 2, 10, QChar('0')).arg(flag);
     233        _params[sys].push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
     234      }
     235      // Initialize Variance-Covariance Matrix
     236      // -------------------------------------
     237      _QQ[sys].ReSize(_params[sys].size());
     238      _QQ[sys] = 0.0;
     239      for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
     240        cmbParam* pp = _params[sys][iPar-1];
     241        _QQ[sys](iPar,iPar) = pp->sig0 * pp->sig0;
     242      }
    253243    }
    254244  }
     
    287277  }
    288278  delete _antex;
    289   for (int iPar = 1; iPar <= _params.size(); iPar++) {
    290     delete _params[iPar-1];
    291   }
    292   QListIterator<bncTime> itTime(_buffer.keys());
    293   while (itTime.hasNext()) {
    294     bncTime epoTime = itTime.next();
    295     _buffer.remove(epoTime);
    296   }
     279  QMapIterator<char, unsigned> itSys(_cmbSysPrn);
     280  while (itSys.hasNext()) {
     281    itSys.next();
     282    char sys = itSys.key();
     283    for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
     284      delete _params[sys][iPar-1];
     285    }
     286    QListIterator<bncTime> itTime(_buffer[sys].keys());
     287    while (itTime.hasNext()) {
     288      bncTime epoTime = itTime.next();
     289      _buffer[sys].remove(epoTime);
     290    }
     291  }
     292
    297293}
    298294
     
    340336    QString    staID(clkCorr._staID.c_str());
    341337    QString    prn(clkCorr._prn.toInternalString().c_str());
     338    char       sys = clkCorr._prn.system();
    342339
    343340    // Set the last time
     
    362359    }
    363360
    364     // Check GLONASS
    365     // -------------
    366     if (!_useGlonass && clkCorr._prn.system() == 'R') {
    367       continue;
    368     }
    369 
    370     if (
    371         clkCorr._prn.system() == 'E' ||
    372         clkCorr._prn.system() == 'C' ||
    373         clkCorr._prn.system() == 'J' ||
    374         clkCorr._prn.system() == 'I' ||
    375         clkCorr._prn.system() == 'S' )   {
    376       continue;
    377     }
    378 
    379361    // Check Modulo Time
    380362    // -----------------
     
    408390    else {
    409391      QMap<t_prn, t_orbCorr>& storage = _orbCorrections[acName];
    410       if (!storage.contains(clkCorr._prn)  || storage[clkCorr._prn]._iod != newCorr->_iod) {
     392      if (!storage.contains(clkCorr._prn)  ||
     393           storage[clkCorr._prn]._iod != newCorr->_iod) {
    411394        delete newCorr;
    412395        continue;
     
    422405    t_eph* ephPrev = _ephUser.ephPrev(prn);
    423406    if (ephLast == 0) {
    424       emit newMessage("bncComb: eph not found for "  + prn.mid(0,3).toLatin1(), true);
     407      //emit newMessage("bncComb: eph not found for "  + prn.mid(0,3).toLatin1(), true);
    425408      delete newCorr;
    426409      continue;
     
    435418      }
    436419      else {
    437         emit newMessage("bncComb: eph not found for "  + prn.mid(0,3).toLatin1() +
    438                         QString(" with IOD %1").arg(newCorr->_iod).toLatin1(), true);
     420        //emit newMessage("bncComb: eph not found for "  + prn.mid(0,3).toLatin1() +
     421                        //QString(" with IOD %1").arg(newCorr->_iod).toLatin1(), true);
    439422        delete newCorr;
    440423        continue;
     
    444427    // Store correction into the buffer
    445428    // --------------------------------
    446     QVector<cmbCorr*>& corrs = _buffer[newCorr->_time].corrs;
     429    QVector<cmbCorr*>& corrs = _buffer[sys][newCorr->_time].corrs;
    447430    corrs.push_back(newCorr);
     431
     432
    448433  }
    449434
     
    451436  // -------------------------
    452437  const double outWait = 1.0 * _cmbSampl;
    453   QListIterator<bncTime> itTime(_buffer.keys());
    454   while (itTime.hasNext()) {
    455     bncTime epoTime = itTime.next();
    456     if (epoTime < lastTime - outWait) {
    457       _resTime = epoTime;
    458       processEpoch();
     438  QMapIterator<char, unsigned> itSys(_cmbSysPrn);
     439  while (itSys.hasNext()) {
     440    itSys.next();
     441    char sys = itSys.key();
     442    QListIterator<bncTime> itTime(_buffer[sys].keys());
     443    while (itTime.hasNext()) {
     444      bncTime epoTime = itTime.next();
     445      if (epoTime < lastTime - outWait) {
     446        _resTime = epoTime;
     447        processEpoch(sys);
     448      }
    459449    }
    460450  }
     
    502492// Process Epoch
    503493////////////////////////////////////////////////////////////////////////////
    504 void bncComb::processEpoch() {
     494void bncComb::processEpoch(char sys) {
    505495
    506496  _log.clear();
     
    508498  QTextStream out(&_log, QIODevice::WriteOnly);
    509499
    510   out << endl <<           "Combination:" << endl
    511       << "------------------------------" << endl;
     500  out << endl <<           "Combination: " << sys << endl
     501      << "--------------------------------" << endl;
    512502
    513503  // Observation Statistics
     
    517507  while (icAC.hasNext()) {
    518508    cmbAC* AC = icAC.next();
    519     AC->numObs = 0;
    520     QVectorIterator<cmbCorr*> itCorr(corrs());
     509    AC->numObs[sys] = 0;
     510    QVectorIterator<cmbCorr*> itCorr(corrs(sys));
    521511    while (itCorr.hasNext()) {
    522512      cmbCorr* corr = itCorr.next();
    523513      if (corr->_acName == AC->name) {
    524         AC->numObs += 1;
    525         if (AC->name == _masterOrbitAC) {
     514        AC->numObs[sys] += 1;
     515        if (AC->name == _masterOrbitAC[sys]) {
    526516          masterPresent = true;
    527517        }
    528518      }
    529519    }
    530     out << AC->name.toLatin1().data() << ": " << AC->numObs << endl;
     520    out << AC->name.toLatin1().data() << ": " << AC->numObs[sys] << endl;
    531521  }
    532522
     
    535525  const unsigned switchMasterAfterGap = 1;
    536526  if (masterPresent) {
    537     _masterMissingEpochs = 0;
     527    _masterMissingEpochs[sys] = 0;
    538528  }
    539529  else {
    540     ++_masterMissingEpochs;
    541     if (_masterMissingEpochs < switchMasterAfterGap) {
     530    ++_masterMissingEpochs[sys];
     531    if (_masterMissingEpochs[sys] < switchMasterAfterGap) {
    542532      out << "Missing Master, Epoch skipped" << endl;
    543       _buffer.remove(_resTime);
     533      _buffer[sys].remove(_resTime);
    544534      emit newMessage(_log, false);
    545535      return;
    546536    }
    547537    else {
    548       _masterMissingEpochs = 0;
     538      _masterMissingEpochs[sys] = 0;
    549539      QListIterator<cmbAC*> icAC(_ACs);
    550540      while (icAC.hasNext()) {
    551541        cmbAC* AC = icAC.next();
    552         if (AC->numObs > 0) {
     542        if (AC->numObs[sys] > 0) {
    553543          out << "Switching Master AC "
    554               << _masterOrbitAC.toLatin1().data() << " --> "
     544              << _masterOrbitAC[sys].toLatin1().data() << " --> "
    555545              << AC->name.toLatin1().data()   << " "
    556546              << _resTime.datestr().c_str()    << " "
    557547              << _resTime.timestr().c_str()    << endl;
    558           _masterOrbitAC = AC->name;
     548          _masterOrbitAC[sys] = AC->name;
    559549          break;
    560550        }
     
    570560  ColumnVector dx;
    571561  if (_method == filter) {
    572     irc = processEpoch_filter(out, resCorr, dx);
     562    irc = processEpoch_filter(sys, out, resCorr, dx);
    573563  }
    574564  else {
    575     irc = processEpoch_singleEpoch(out, resCorr, dx);
     565    irc = processEpoch_singleEpoch(sys, out, resCorr, dx);
    576566  }
    577567
     
    579569  // --------------------------------------
    580570  if (irc == success) {
    581     for (int iPar = 1; iPar <= _params.size(); iPar++) {
    582       cmbParam* pp = _params[iPar-1];
     571    for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
     572      cmbParam* pp = _params[sys][iPar-1];
    583573      pp->xx += dx(iPar);
    584574      if (pp->type == cmbParam::clkSat) {
     
    592582      out.setFieldWidth(8);
    593583      out.setRealNumberPrecision(4);
    594       out << pp->toString() << " "
    595           << pp->xx << " +- " << sqrt(_QQ(pp->index,pp->index)) << endl;
     584      out << pp->toString(sys) << " "
     585          << pp->xx << " +- " << sqrt(_QQ[sys](pp->index,pp->index)) << endl;
    596586      out.setFieldWidth(0);
    597587    }
     
    602592  // Delete Data, emit Message
    603593  // -------------------------
    604   _buffer.remove(_resTime);
     594  _buffer[sys].remove(_resTime);
    605595  emit newMessage(_log, false);
    606596}
     
    608598// Process Epoch - Filter Method
    609599////////////////////////////////////////////////////////////////////////////
    610 t_irc bncComb::processEpoch_filter(QTextStream& out,
     600t_irc bncComb::processEpoch_filter(char sys, QTextStream& out,
    611601                                   QMap<QString, cmbCorr*>& resCorr,
    612602                                   ColumnVector& dx) {
     
    614604  // Prediction Step
    615605  // ---------------
    616   int nPar = _params.size();
     606  int nPar = _params[sys].size();
    617607  ColumnVector x0(nPar);
    618   for (int iPar = 1; iPar <= _params.size(); iPar++) {
    619     cmbParam* pp  = _params[iPar-1];
     608  for (int iPar = 1; iPar <= nPar; iPar++) {
     609    cmbParam* pp  = _params[sys][iPar-1];
    620610    if (pp->epoSpec) {
    621611      pp->xx = 0.0;
    622       _QQ.Row(iPar)    = 0.0;
    623       _QQ.Column(iPar) = 0.0;
    624       _QQ(iPar,iPar) = pp->sig0 * pp->sig0;
     612      _QQ[sys].Row(iPar)    = 0.0;
     613      _QQ[sys].Column(iPar) = 0.0;
     614      _QQ[sys](iPar,iPar) = pp->sig0 * pp->sig0;
    625615    }
    626616    else {
    627       _QQ(iPar,iPar) += pp->sigP * pp->sigP;
     617      _QQ[sys](iPar,iPar) += pp->sigP * pp->sigP;
    628618    }
    629619    x0(iPar) = pp->xx;
     
    632622  // Check Satellite Positions for Outliers
    633623  // --------------------------------------
    634   if (checkOrbits(out) != success) {
     624  if (checkOrbits(sys, out) != success) {
    635625    return failure;
    636626  }
     
    638628  // Update and outlier detection loop
    639629  // ---------------------------------
    640   SymmetricMatrix QQ_sav = _QQ;
     630  SymmetricMatrix QQ_sav = _QQ[sys];
    641631  while (true) {
    642632
     
    645635    DiagonalMatrix PP;
    646636
    647     if (createAmat(AA, ll, PP, x0, resCorr) != success) {
     637    if (createAmat(sys, AA, ll, PP, x0, resCorr) != success) {
    648638      return failure;
    649639    }
    650640
    651641    dx.ReSize(nPar); dx = 0.0;
    652     kalman(AA, ll, PP, _QQ, dx);
     642    kalman(AA, ll, PP, _QQ[sys], dx);
    653643
    654644    ColumnVector vv = ll - AA * dx;
     
    660650    out << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
    661651        << " Maximum Residuum " << maxRes << ' '
    662         << corrs()[maxResIndex-1]->_acName << ' ' << corrs()[maxResIndex-1]->_prn.mid(0,3);
     652        << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
    663653    if (maxRes > _MAXRES) {
    664       for (int iPar = 1; iPar <= _params.size(); iPar++) {
    665         cmbParam* pp = _params[iPar-1];
     654      for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
     655        cmbParam* pp = _params[sys][iPar-1];
    666656        if (pp->type == cmbParam::offACSat            &&
    667             pp->AC   == corrs()[maxResIndex-1]->_acName &&
    668             pp->prn  == corrs()[maxResIndex-1]->_prn.mid(0,3)) {
     657            pp->AC   == corrs(sys)[maxResIndex-1]->_acName &&
     658            pp->prn  == corrs(sys)[maxResIndex-1]->_prn.mid(0,3)) {
    669659          QQ_sav.Row(iPar)    = 0.0;
    670660          QQ_sav.Column(iPar) = 0.0;
     
    674664
    675665      out << "  Outlier" << endl;
    676       _QQ = QQ_sav;
    677       corrs().remove(maxResIndex-1);
     666      _QQ[sys] = QQ_sav;
     667      corrs(sys).remove(maxResIndex-1);
    678668    }
    679669    else {
     
    681671      out.setRealNumberNotation(QTextStream::FixedNotation);
    682672      out.setRealNumberPrecision(4);
    683       for (int ii = 0; ii < corrs().size(); ii++) {
    684       const cmbCorr* corr = corrs()[ii];
     673      for (int ii = 0; ii < corrs(sys).size(); ii++) {
     674      const cmbCorr* corr = corrs(sys)[ii];
    685675        out << _resTime.datestr().c_str() << ' '
    686676            << _resTime.timestr().c_str() << " "
     
    734724
    735725  QString     outLines;
    736   //QStringList corrLines;
    737726
    738727  unsigned year, month, day, hour, minute;
     
    809798                 corr->_orbCorr._dotXr[2],
    810799                 0.0);
    811     //corrLines << line;
    812800
    813801    delete corr;
     
    833821// Create First Design Matrix and Vector of Measurements
    834822////////////////////////////////////////////////////////////////////////////
    835 t_irc bncComb::createAmat(Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
    836                           const ColumnVector& x0,
    837                           QMap<QString, cmbCorr*>& resCorr) {
    838 
    839   unsigned nPar = _params.size();
    840   unsigned nObs = corrs().size();
     823t_irc bncComb::createAmat(char sys, Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
     824                          const ColumnVector& x0, QMap<QString, cmbCorr*>& resCorr) {
     825
     826  unsigned nPar = _params[sys].size();
     827  unsigned nObs = corrs(sys).size();
    841828
    842829  if (nObs == 0) {
     
    844831  }
    845832
    846   int maxSat = t_prn::MAXPRN_GPS;
    847 //  if (_useGlonass) {
    848 //    maxSat = t_prn::MAXPRN_GPS + t_prn::MAXPRN_GLONASS;
    849 //  }
    850 
    851   const int nCon = (_method == filter) ? 1 + maxSat : 0;
     833  int maxSat = _cmbSysPrn[sys];
     834
     835  const int nCon = (_method == filter) ? 1 + maxSat : 0; //(maybe not for GLONASS)
    852836
    853837  AA.ReSize(nObs+nCon, nPar);  AA = 0.0;
     
    856840
    857841  int iObs = 0;
    858   QVectorIterator<cmbCorr*> itCorr(corrs());
     842  QVectorIterator<cmbCorr*> itCorr(corrs(sys));
    859843  while (itCorr.hasNext()) {
    860844    cmbCorr* corr = itCorr.next();
     
    863847    ++iObs;
    864848
    865     if (corr->_acName == _masterOrbitAC && resCorr.find(prn) == resCorr.end()) {
     849    if (corr->_acName == _masterOrbitAC[sys] && resCorr.find(prn) == resCorr.end()) {
    866850      resCorr[prn] = new cmbCorr(*corr);
    867851    }
    868852
    869     for (int iPar = 1; iPar <= _params.size(); iPar++) {
    870       cmbParam* pp = _params[iPar-1];
    871       AA(iObs, iPar) = pp->partial(corr->_acName, prn);
     853    for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
     854      cmbParam* pp = _params[sys][iPar-1];
     855      AA(iObs, iPar) = pp->partial(sys, corr->_acName, prn);
    872856    }
    873857
     
    880864    const double Ph = 1.e6;
    881865    PP(nObs+1) = Ph;
    882     for (int iPar = 1; iPar <= _params.size(); iPar++) {
    883       cmbParam* pp = _params[iPar-1];
     866    for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
     867      cmbParam* pp = _params[sys][iPar-1];
    884868      if ( AA.Column(iPar).maximum_absolute_value() > 0.0 &&
    885869           pp->type == cmbParam::clkSat ) {
     
    888872    }
    889873    int iCond = 1;
    890     for (unsigned iGps = 1; iGps <= t_prn::MAXPRN_GPS; iGps++) {
    891       QString prn = QString("G%1_0").arg(iGps, 2, 10, QChar('0'));
     874    unsigned flag = 0;
     875    if (sys == 'E') {
     876      flag = 1;
     877    }
     878    // GNSS (maybe not for GLONASS)
     879    for (unsigned iGnss = 1; iGnss <= _cmbSysPrn[sys]; iGnss++) {
     880      QString prn = QString("%1%2_%3").arg(sys).arg(iGnss, 2, 10, QChar('0')).arg(flag);
    892881      ++iCond;
    893882      PP(nObs+iCond) = Ph;
    894       for (int iPar = 1; iPar <= _params.size(); iPar++) {
    895         cmbParam* pp = _params[iPar-1];
     883      for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
     884        cmbParam* pp = _params[sys][iPar-1];
    896885        if ( pp &&
    897886             AA.Column(iPar).maximum_absolute_value() > 0.0 &&
     
    902891      }
    903892    }
    904 //    if (_useGlonass) {// liefert schlechtere Höhenkomponente im PPP
    905 //      for (unsigned iGlo = 1; iGlo <= t_prn::MAXPRN_GLONASS; iGlo++) {
    906 //        QString prn = QString("R%1_0").arg(iGlo, 2, 10, QChar('0'));
    907 //        ++iCond;
    908 //        PP(nObs+iCond) = Ph;
    909 //        for (int iPar = 1; iPar <= _params.size(); iPar++) {
    910 //          cmbParam* pp = _params[iPar-1];
    911 //          if ( pp &&
    912 //               AA.Column(iPar).maximum_absolute_value() > 0.0 &&
    913 //               pp->type == cmbParam::offACSat                 &&
    914 //               pp->prn == prn) {
    915 //            AA(nObs+iCond, iPar) = 1.0;
    916 //          }
    917 //        }
    918 //      }
    919 //    }
    920893  }
    921894
     
    925898// Process Epoch - Single-Epoch Method
    926899////////////////////////////////////////////////////////////////////////////
    927 t_irc bncComb::processEpoch_singleEpoch(QTextStream& out,
     900t_irc bncComb::processEpoch_singleEpoch(char sys, QTextStream& out,
    928901                                        QMap<QString, cmbCorr*>& resCorr,
    929902                                        ColumnVector& dx) {
     
    931904  // Check Satellite Positions for Outliers
    932905  // --------------------------------------
    933   if (checkOrbits(out) != success) {
     906  if (checkOrbits(sys, out) != success) {
    934907    return failure;
    935908  }
     
    941914    // Remove Satellites that are not in Master
    942915    // ----------------------------------------
    943     QMutableVectorIterator<cmbCorr*> it(corrs());
     916    QMutableVectorIterator<cmbCorr*> it(corrs(sys));
    944917    while (it.hasNext()) {
    945918      cmbCorr* corr = it.next();
    946919      QString  prn  = corr->_prn;
    947920      bool foundMaster = false;
    948       QVectorIterator<cmbCorr*> itHlp(corrs());
     921      QVectorIterator<cmbCorr*> itHlp(corrs(sys));
    949922      while (itHlp.hasNext()) {
    950923        cmbCorr* corrHlp = itHlp.next();
    951924        QString  prnHlp  = corrHlp->_prn;
    952925        QString  ACHlp   = corrHlp->_acName;
    953         if (ACHlp == _masterOrbitAC && prn == prnHlp) {
     926        if (ACHlp == _masterOrbitAC[sys] && prn == prnHlp) {
    954927          foundMaster = true;
    955928          break;
     
    966939    QMap<QString, int> numObsPrn;
    967940    QMap<QString, int> numObsAC;
    968     QVectorIterator<cmbCorr*> itCorr(corrs());
     941    QVectorIterator<cmbCorr*> itCorr(corrs(sys));
    969942    while (itCorr.hasNext()) {
    970943      cmbCorr* corr = itCorr.next();
     
    985958    }
    986959
    987     // Clean-Up the Paramters
    988     // ----------------------
    989     for (int iPar = 1; iPar <= _params.size(); iPar++) {
    990       delete _params[iPar-1];
    991     }
    992     _params.clear();
     960    // Clean-Up the Parameters
     961    // -----------------------
     962    for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
     963      delete _params[sys][iPar-1];
     964    }
     965    _params[sys].clear();
    993966
    994967    // Set new Parameters
     
    1001974      const QString& AC     = itAC.key();
    1002975      int            numObs = itAC.value();
    1003       if (AC != _masterOrbitAC && numObs > 0) {
    1004         _params.push_back(new cmbParam(cmbParam::offACgps, ++nextPar, AC, ""));
    1005         if (_useGlonass) {
    1006           _params.push_back(new cmbParam(cmbParam::offACglo, ++nextPar, AC, ""));
    1007         }
     976      if (AC != _masterOrbitAC[sys] && numObs > 0) {
     977        _params[sys].push_back(new cmbParam(cmbParam::offACgnss, ++nextPar, AC, ""));
    1008978      }
    1009979    }
     
    1015985      int            numObs = itPrn.value();
    1016986      if (numObs > 0) {
    1017         _params.push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
    1018       }
    1019     }
    1020 
    1021     int nPar = _params.size();
     987        _params[sys].push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
     988      }
     989    }
     990
     991    int nPar = _params[sys].size();
    1022992    ColumnVector x0(nPar);
    1023993    x0 = 0.0;
     
    1028998    ColumnVector   ll;
    1029999    DiagonalMatrix PP;
    1030     if (createAmat(AA, ll, PP, x0, resCorr) != success) {
     1000    if (createAmat(sys, AA, ll, PP, x0, resCorr) != success) {
    10311001      return failure;
    10321002    }
     
    10371007      SymmetricMatrix NN; NN << ATP * AA;
    10381008      ColumnVector    bb = ATP * ll;
    1039       _QQ = NN.i();
    1040       dx  = _QQ * bb;
     1009      _QQ[sys] = NN.i();
     1010      dx  = _QQ[sys] * bb;
    10411011      vv  = ll - AA * dx;
    10421012    }
     
    10521022    out << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
    10531023        << " Maximum Residuum " << maxRes << ' '
    1054         << corrs()[maxResIndex-1]->_acName << ' ' << corrs()[maxResIndex-1]->_prn.mid(0,3);
     1024        << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
    10551025
    10561026    if (maxRes > _MAXRES) {
    10571027      out << "  Outlier" << endl;
    1058       delete corrs()[maxResIndex-1];
    1059       corrs().remove(maxResIndex-1);
     1028      delete corrs(sys)[maxResIndex-1];
     1029      corrs(sys).remove(maxResIndex-1);
    10601030    }
    10611031    else {
     
    10641034      out.setRealNumberPrecision(3);
    10651035      for (int ii = 0; ii < vv.Nrows(); ii++) {
    1066         const cmbCorr* corr = corrs()[ii];
     1036        const cmbCorr* corr = corrs(sys)[ii];
    10671037        out << _resTime.datestr().c_str() << ' '
    10681038            << _resTime.timestr().c_str() << " "
     
    10821052// Check Satellite Positions for Outliers
    10831053////////////////////////////////////////////////////////////////////////////
    1084 t_irc bncComb::checkOrbits(QTextStream& out) {
     1054t_irc bncComb::checkOrbits(char sys, QTextStream& out) {
    10851055
    10861056  const double MAX_DISPLACEMENT = 0.20;
     
    10881058  // Switch to last ephemeris (if possible)
    10891059  // --------------------------------------
    1090   QMutableVectorIterator<cmbCorr*> im(corrs());
     1060  QMutableVectorIterator<cmbCorr*> im(corrs(sys));
    10911061  while (im.hasNext()) {
    10921062    cmbCorr* corr = im.next();
     
    11241094    QMap<QString, int>          numCorr;
    11251095    QMap<QString, ColumnVector> meanRao;
    1126     QVectorIterator<cmbCorr*> it(corrs());
     1096    QVectorIterator<cmbCorr*> it(corrs(sys));
    11271097    while (it.hasNext()) {
    11281098      cmbCorr* corr = it.next();
     
    11451115    }
    11461116
    1147     // Compute Differences wrt Mean, find Maximum
    1148     // ------------------------------------------
     1117    // Compute Differences wrt. Mean, find Maximum
     1118    // -------------------------------------------
    11491119    QMap<QString, cmbCorr*> maxDiff;
    11501120    it.toFront();
     
    11761146    // ---------------
    11771147    bool removed = false;
    1178     QMutableVectorIterator<cmbCorr*> im(corrs());
     1148    QMutableVectorIterator<cmbCorr*> im(corrs(sys));
    11791149    while (im.hasNext()) {
    11801150      cmbCorr* corr = im.next();
     
    12331203    return;
    12341204  }
    1235 
    1236   // Remove all corrections of the corresponding AC
    1237   // ----------------------------------------------
    1238   QListIterator<bncTime> itTime(_buffer.keys());
    1239   while (itTime.hasNext()) {
    1240     bncTime epoTime = itTime.next();
    1241     QVector<cmbCorr*>& corrVec = _buffer[epoTime].corrs;
    1242     QMutableVectorIterator<cmbCorr*> it(corrVec);
    1243     while (it.hasNext()) {
    1244       cmbCorr* corr = it.next();
    1245       if (acName == corr->_acName) {
    1246         delete corr;
    1247         it.remove();
    1248       }
    1249     }
    1250   }
    1251 
    1252   // Reset Satellite Offsets
    1253   // -----------------------
    1254   if (_method == filter) {
    1255     for (int iPar = 1; iPar <= _params.size(); iPar++) {
    1256       cmbParam* pp = _params[iPar-1];
    1257       if (pp->AC == acName && pp->type == cmbParam::offACSat) {
    1258         pp->xx = 0.0;
    1259         _QQ.Row(iPar)    = 0.0;
    1260         _QQ.Column(iPar) = 0.0;
    1261         _QQ(iPar,iPar) = pp->sig0 * pp->sig0;
    1262       }
    1263     }
    1264   }
    1265 }
     1205  QMapIterator<char, unsigned> itSys(_cmbSysPrn);
     1206  while (itSys.hasNext()) {
     1207    itSys.next();
     1208    char sys = itSys.key();
     1209    // Remove all corrections of the corresponding AC
     1210    // ----------------------------------------------
     1211    QListIterator<bncTime> itTime(_buffer[sys].keys());
     1212    while (itTime.hasNext()) {
     1213      bncTime epoTime = itTime.next();
     1214      QVector<cmbCorr*>& corrVec = _buffer[sys][epoTime].corrs;
     1215      QMutableVectorIterator<cmbCorr*> it(corrVec);
     1216      while (it.hasNext()) {
     1217        cmbCorr* corr = it.next();
     1218        if (acName == corr->_acName) {
     1219          delete corr;
     1220          it.remove();
     1221        }
     1222      }
     1223    }
     1224
     1225    // Reset Satellite Offsets
     1226    // -----------------------
     1227    if (_method == filter) {
     1228      for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
     1229        cmbParam* pp = _params[sys][iPar-1];
     1230        if (pp->AC == acName && pp->type == cmbParam::offACSat) {
     1231          pp->xx = 0.0;
     1232          _QQ[sys].Row(iPar)    = 0.0;
     1233          _QQ[sys].Column(iPar) = 0.0;
     1234          _QQ[sys](iPar,iPar) = pp->sig0 * pp->sig0;
     1235        }
     1236      }
     1237    }
     1238  }
     1239}
  • trunk/BNC/src/combination/bnccomb.h

    r9025 r9258  
    3737  class cmbParam {
    3838   public:
    39     enum parType {offACgps, offACglo, offACSat, clkSat};
     39    enum parType {offACgnss, offACSat, clkSat};
    4040    cmbParam(parType type_, int index_, const QString& ac_, const QString& prn_);
    4141    ~cmbParam();
    42     double partial(const QString& AC_, const QString& prn_);
    43     QString toString() const;
     42    double partial(char sys, const QString& AC_, const QString& prn_);
     43    QString toString(char sys) const;
    4444    parType type;
    4545    int     index;
     
    5757    cmbAC() {
    5858      weight = 0.0;
    59       numObs = 0;
     59      numObs['G'] = 0;
     60      numObs['R'] = 0;
     61      numObs['E'] = 0;
     62      numObs['C'] = 0;
     63      numObs['J'] = 0;
     64      numObs['S'] = 0;
    6065    }
    6166    ~cmbAC() {}
     
    6368    QString  name;
    6469    double   weight;
    65     unsigned numObs;
     70    QMap<char, unsigned> numObs;
    6671  };
    6772
     
    98103  };
    99104
    100   void  processEpoch();
    101   t_irc processEpoch_filter(QTextStream& out, QMap<QString, cmbCorr*>& resCorr,
     105  void  processEpoch(char sys);
     106  t_irc processEpoch_filter(char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr,
    102107                            ColumnVector& dx);
    103   t_irc processEpoch_singleEpoch(QTextStream& out, QMap<QString, cmbCorr*>& resCorr,
     108  t_irc processEpoch_singleEpoch(char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr,
    104109                                 ColumnVector& dx);
    105   t_irc createAmat(Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
     110  t_irc createAmat(char sys, Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
    106111                   const ColumnVector& x0, QMap<QString, cmbCorr*>& resCorr);
    107112  void  dumpResults(const QMap<QString, cmbCorr*>& resCorr);
    108113  void  printResults(QTextStream& out, const QMap<QString, cmbCorr*>& resCorr);
    109114  void  switchToLastEph(t_eph* lastEph, cmbCorr* corr);
    110   t_irc checkOrbits(QTextStream& out);
    111   QVector<cmbCorr*>& corrs() {return _buffer[_resTime].corrs;}
     115  t_irc checkOrbits(char sys, QTextStream& out);
     116  QVector<cmbCorr*>& corrs(char sys) {return _buffer[sys][_resTime].corrs;}
    112117
    113118  QMutex                                 _mutex;
    114119  QList<cmbAC*>                          _ACs;
    115120  bncTime                                _resTime;
    116   QVector<cmbParam*>                     _params;
    117   QMap<bncTime, cmbEpoch>                _buffer;
     121  QMap<char, QVector<cmbParam*>>         _params;
     122  QMap<char, QMap<bncTime, cmbEpoch>>    _buffer;
    118123  bncRtnetDecoder*                       _rtnetDecoder;
    119   SymmetricMatrix                        _QQ;
     124  QMap<char, SymmetricMatrix>            _QQ;
    120125  QByteArray                             _log;
    121126  bncAntex*                              _antex;
    122127  double                                 _MAXRES;
    123   QString                                _masterOrbitAC;
    124   unsigned                               _masterMissingEpochs;
     128  QMap<char, QString>                    _masterOrbitAC;
     129  QMap<char, unsigned>                   _masterMissingEpochs;
    125130  e_method                               _method;
    126   bool                                   _useGlonass;
    127131  int                                    _cmbSampl;
    128132  QMap<QString, QMap<t_prn, t_orbCorr> > _orbCorrections;
    129133  bncEphUser                             _ephUser;
    130134  SsrCorr*                               _ssrCorr;
     135  QMap<char, unsigned>                   _cmbSysPrn;
    131136};
    132137
Note: See TracChangeset for help on using the changeset viewer.