[2898] | 1 | /* -------------------------------------------------------------------------
|
---|
| 2 | * BKG NTRIP Client
|
---|
| 3 | * -------------------------------------------------------------------------
|
---|
| 4 | *
|
---|
| 5 | * Class: bncComb
|
---|
| 6 | *
|
---|
| 7 | * Purpose: Combinations of Orbit/Clock Corrections
|
---|
| 8 | *
|
---|
| 9 | * Author: L. Mervart
|
---|
| 10 | *
|
---|
| 11 | * Created: 22-Jan-2011
|
---|
| 12 | *
|
---|
[7297] | 13 | * Changes:
|
---|
[2898] | 14 | *
|
---|
| 15 | * -----------------------------------------------------------------------*/
|
---|
| 16 |
|
---|
[2933] | 17 | #include <newmatio.h>
|
---|
[2921] | 18 | #include <iomanip>
|
---|
[3214] | 19 | #include <sstream>
|
---|
[9635] | 20 | #include <map>
|
---|
[2898] | 21 |
|
---|
| 22 | #include "bnccomb.h"
|
---|
[9676] | 23 | #include <combination/bncbiassnx.h>
|
---|
[5070] | 24 | #include "bnccore.h"
|
---|
[3201] | 25 | #include "upload/bncrtnetdecoder.h"
|
---|
[2910] | 26 | #include "bncsettings.h"
|
---|
[2988] | 27 | #include "bncutils.h"
|
---|
[3181] | 28 | #include "bncsp3.h"
|
---|
[3052] | 29 | #include "bncantex.h"
|
---|
[5742] | 30 | #include "t_prn.h"
|
---|
[2898] | 31 |
|
---|
[3455] | 32 | const double sig0_offAC = 1000.0;
|
---|
| 33 | const double sig0_offACSat = 100.0;
|
---|
[3468] | 34 | const double sigP_offACSat = 0.01;
|
---|
[3455] | 35 | const double sig0_clkSat = 100.0;
|
---|
| 36 |
|
---|
| 37 | const double sigObs = 0.05;
|
---|
| 38 |
|
---|
| 39 | using namespace std;
|
---|
| 40 |
|
---|
[2898] | 41 | // Constructor
|
---|
| 42 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6155] | 43 | bncComb::cmbParam::cmbParam(parType type_, int index_, const QString& ac_, const QString& prn_) {
|
---|
[3032] | 44 |
|
---|
[3433] | 45 | type = type_;
|
---|
| 46 | index = index_;
|
---|
| 47 | AC = ac_;
|
---|
| 48 | prn = prn_;
|
---|
| 49 | xx = 0.0;
|
---|
[3455] | 50 | eph = 0;
|
---|
[3429] | 51 |
|
---|
[9258] | 52 | if (type == offACgnss) {
|
---|
[3455] | 53 | epoSpec = true;
|
---|
| 54 | sig0 = sig0_offAC;
|
---|
| 55 | sigP = sig0;
|
---|
[3429] | 56 | }
|
---|
| 57 | else if (type == offACSat) {
|
---|
[3455] | 58 | epoSpec = false;
|
---|
| 59 | sig0 = sig0_offACSat;
|
---|
| 60 | sigP = sigP_offACSat;
|
---|
[3429] | 61 | }
|
---|
| 62 | else if (type == clkSat) {
|
---|
[3455] | 63 | epoSpec = true;
|
---|
| 64 | sig0 = sig0_clkSat;
|
---|
| 65 | sigP = sig0;
|
---|
[3429] | 66 | }
|
---|
[2933] | 67 | }
|
---|
| 68 |
|
---|
| 69 | // Destructor
|
---|
| 70 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6155] | 71 | bncComb::cmbParam::~cmbParam() {
|
---|
[2933] | 72 | }
|
---|
| 73 |
|
---|
| 74 | // Partial
|
---|
| 75 | ////////////////////////////////////////////////////////////////////////////
|
---|
[9258] | 76 | double bncComb::cmbParam::partial(char sys, const QString& AC_, const QString& prn_) {
|
---|
[7297] | 77 |
|
---|
[9258] | 78 | if (type == offACgnss) {
|
---|
| 79 | if (AC == AC_ && prn_[0].toLatin1() == sys) {
|
---|
[2934] | 80 | return 1.0;
|
---|
| 81 | }
|
---|
| 82 | }
|
---|
[3429] | 83 | else if (type == offACSat) {
|
---|
| 84 | if (AC == AC_ && prn == prn_) {
|
---|
[2933] | 85 | return 1.0;
|
---|
| 86 | }
|
---|
| 87 | }
|
---|
[3429] | 88 | else if (type == clkSat) {
|
---|
| 89 | if (prn == prn_) {
|
---|
[2933] | 90 | return 1.0;
|
---|
| 91 | }
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | return 0.0;
|
---|
| 95 | }
|
---|
| 96 |
|
---|
[7297] | 97 | //
|
---|
[2990] | 98 | ////////////////////////////////////////////////////////////////////////////
|
---|
[9258] | 99 | QString bncComb::cmbParam::toString(char sys) const {
|
---|
[2933] | 100 |
|
---|
[2990] | 101 | QString outStr;
|
---|
[7297] | 102 |
|
---|
[9258] | 103 | if (type == offACgnss) {
|
---|
[9262] | 104 | outStr = "AC Offset " + AC + " " + sys + " ";
|
---|
[2990] | 105 | }
|
---|
[3429] | 106 | else if (type == offACSat) {
|
---|
[7008] | 107 | outStr = "Sat Offset " + AC + " " + prn.mid(0,3);
|
---|
[2990] | 108 | }
|
---|
[3429] | 109 | else if (type == clkSat) {
|
---|
[7008] | 110 | outStr = "Clk Corr " + prn.mid(0,3);
|
---|
[2990] | 111 | }
|
---|
[2933] | 112 |
|
---|
[2990] | 113 | return outStr;
|
---|
| 114 | }
|
---|
| 115 |
|
---|
[10040] | 116 | // Singleton: definition class variable
|
---|
[7299] | 117 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10042] | 118 | bncComb* bncComb::instance = nullptr;
|
---|
[7299] | 119 |
|
---|
[10040] | 120 |
|
---|
[2933] | 121 | // Constructor
|
---|
| 122 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10040] | 123 | bncComb::bncComb() : _ephUser(true) {
|
---|
[2910] | 124 |
|
---|
| 125 | bncSettings settings;
|
---|
| 126 |
|
---|
[7297] | 127 | QStringList cmbStreams = settings.value("cmbStreams").toStringList();
|
---|
[2918] | 128 |
|
---|
[4183] | 129 | _cmbSampl = settings.value("cmbSampl").toInt();
|
---|
| 130 | if (_cmbSampl <= 0) {
|
---|
[9676] | 131 | _cmbSampl = 5;
|
---|
[4183] | 132 | }
|
---|
[9292] | 133 | _useGps = (Qt::CheckState(settings.value("cmbGps").toInt()) == Qt::Checked) ? true : false;
|
---|
| 134 | if (_useGps) {
|
---|
| 135 | _cmbSysPrn['G'] = t_prn::MAXPRN_GPS;
|
---|
| 136 | _masterMissingEpochs['G'] = 0;
|
---|
| 137 | }
|
---|
| 138 | _useGlo = (Qt::CheckState(settings.value("cmbGlo").toInt()) == Qt::Checked) ? true : false;
|
---|
| 139 | if (_useGlo) {
|
---|
| 140 | _cmbSysPrn['R'] = t_prn::MAXPRN_GLONASS;
|
---|
| 141 | _masterMissingEpochs['R'] = 0;
|
---|
| 142 | }
|
---|
| 143 | _useGal = (Qt::CheckState(settings.value("cmbGal").toInt()) == Qt::Checked) ? true : false;
|
---|
| 144 | if (_useGal) {
|
---|
| 145 | _cmbSysPrn['E'] = t_prn::MAXPRN_GALILEO;
|
---|
| 146 | _masterMissingEpochs['E'] = 0;
|
---|
| 147 | }
|
---|
| 148 | _useBds = (Qt::CheckState(settings.value("cmbBds").toInt()) == Qt::Checked) ? true : false;
|
---|
| 149 | if (_useBds) {
|
---|
| 150 | _cmbSysPrn['C'] = t_prn::MAXPRN_BDS;
|
---|
| 151 | _masterMissingEpochs['C'] = 0;
|
---|
| 152 | }
|
---|
| 153 | _useQzss = (Qt::CheckState(settings.value("cmbQzss").toInt()) == Qt::Checked) ? true : false;
|
---|
| 154 | if (_useQzss) {
|
---|
| 155 | _cmbSysPrn['J'] = t_prn::MAXPRN_QZSS;
|
---|
| 156 | _masterMissingEpochs['J'] = 0;
|
---|
| 157 | }
|
---|
| 158 | _useSbas = (Qt::CheckState(settings.value("cmbSbas").toInt()) == Qt::Checked) ? true : false;
|
---|
| 159 | if (_useSbas) {
|
---|
| 160 | _cmbSysPrn['S'] = t_prn::MAXPRN_SBAS;
|
---|
| 161 | _masterMissingEpochs['S'] = 0;
|
---|
| 162 | }
|
---|
| 163 | _useIrnss = (Qt::CheckState(settings.value("cmbIrnss").toInt()) == Qt::Checked) ? true : false;
|
---|
| 164 | if (_useIrnss) {
|
---|
| 165 | _cmbSysPrn['I'] = t_prn::MAXPRN_IRNSS;
|
---|
| 166 | _masterMissingEpochs['I'] = 0;
|
---|
| 167 | }
|
---|
[4183] | 168 |
|
---|
[7297] | 169 | if (cmbStreams.size() >= 1 && !cmbStreams[0].isEmpty()) {
|
---|
| 170 | QListIterator<QString> it(cmbStreams);
|
---|
[2910] | 171 | while (it.hasNext()) {
|
---|
| 172 | QStringList hlp = it.next().split(" ");
|
---|
[2918] | 173 | cmbAC* newAC = new cmbAC();
|
---|
[9821] | 174 | newAC->mountPoint = hlp[0];
|
---|
| 175 | newAC->name = hlp[1];
|
---|
| 176 | newAC->weightFactor = hlp[2].toDouble();
|
---|
[9258] | 177 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
---|
| 178 | // init
|
---|
| 179 | while (itSys.hasNext()) {
|
---|
| 180 | itSys.next();
|
---|
| 181 | char sys = itSys.key();
|
---|
| 182 | if (_masterOrbitAC.isEmpty()) {
|
---|
| 183 | _masterOrbitAC[sys] = newAC->name;
|
---|
| 184 | }
|
---|
[3453] | 185 | }
|
---|
[3429] | 186 | _ACs.append(newAC);
|
---|
[2910] | 187 | }
|
---|
| 188 | }
|
---|
[2927] | 189 |
|
---|
[9025] | 190 | QString ssrFormat;
|
---|
[9258] | 191 | _ssrCorr = 0;
|
---|
[9025] | 192 | QListIterator<QString> it(settings.value("uploadMountpointsOut").toStringList());
|
---|
| 193 | while (it.hasNext()) {
|
---|
| 194 | QStringList hlp = it.next().split(",");
|
---|
| 195 | if (hlp.size() > 7) {
|
---|
| 196 | ssrFormat = hlp[7];
|
---|
| 197 | }
|
---|
| 198 | }
|
---|
| 199 | if (ssrFormat == "IGS-SSR") {
|
---|
| 200 | _ssrCorr = new SsrCorrIgs();
|
---|
| 201 | }
|
---|
| 202 | else if (ssrFormat == "RTCM-SSR") {
|
---|
| 203 | _ssrCorr = new SsrCorrRtcm();
|
---|
| 204 | }
|
---|
[9258] | 205 | else { // default
|
---|
| 206 | _ssrCorr = new SsrCorrIgs();
|
---|
| 207 | }
|
---|
[9025] | 208 |
|
---|
[3211] | 209 | _rtnetDecoder = 0;
|
---|
[3201] | 210 |
|
---|
[9819] | 211 | connect(this, SIGNAL(newMessage(QByteArray,bool)), BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
---|
| 212 | connect(BNC_CORE, SIGNAL(providerIDChanged(QString)), this, SLOT(slotProviderIDChanged(QString)));
|
---|
| 213 | connect(BNC_CORE, SIGNAL(newOrbCorrections(QList<t_orbCorr>)), this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)));
|
---|
| 214 | connect(BNC_CORE, SIGNAL(newClkCorrections(QList<t_clkCorr>)), this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)));
|
---|
| 215 | connect(BNC_CORE, SIGNAL(newCodeBiases(QList<t_satCodeBias>)), this, SLOT(slotNewCodeBiases(QList<t_satCodeBias>)));
|
---|
[2933] | 216 |
|
---|
[3470] | 217 | // Combination Method
|
---|
| 218 | // ------------------
|
---|
[3481] | 219 | if (settings.value("cmbMethod").toString() == "Single-Epoch") {
|
---|
| 220 | _method = singleEpoch;
|
---|
[3470] | 221 | }
|
---|
| 222 | else {
|
---|
[3481] | 223 | _method = filter;
|
---|
[3470] | 224 | }
|
---|
[3032] | 225 |
|
---|
| 226 | // Initialize Parameters (model: Clk_Corr = AC_Offset + Sat_Offset + Clk)
|
---|
| 227 | // ----------------------------------------------------------------------
|
---|
[3470] | 228 | if (_method == filter) {
|
---|
[9258] | 229 | // SYSTEM
|
---|
| 230 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
---|
| 231 | while (itSys.hasNext()) {
|
---|
| 232 | itSys.next();
|
---|
| 233 | int nextPar = 0;
|
---|
| 234 | char sys = itSys.key();
|
---|
| 235 | unsigned maxPrn = itSys.value();
|
---|
| 236 | unsigned flag = 0;
|
---|
| 237 | if (sys == 'E') {
|
---|
| 238 | flag = 1;
|
---|
[3470] | 239 | }
|
---|
[9258] | 240 | // AC
|
---|
| 241 | QListIterator<cmbAC*> itAc(_ACs);
|
---|
| 242 | while (itAc.hasNext()) {
|
---|
| 243 | cmbAC* AC = itAc.next();
|
---|
| 244 | _params[sys].push_back(new cmbParam(cmbParam::offACgnss, ++nextPar, AC->name, ""));
|
---|
| 245 | for (unsigned iGnss = 1; iGnss <= maxPrn; iGnss++) {
|
---|
| 246 | QString prn = QString("%1%2_%3").arg(sys).arg(iGnss, 2, 10, QChar('0')).arg(flag);
|
---|
| 247 | _params[sys].push_back(new cmbParam(cmbParam::offACSat, ++nextPar, AC->name, prn));
|
---|
[3483] | 248 | }
|
---|
| 249 | }
|
---|
[9258] | 250 | for (unsigned iGnss = 1; iGnss <= maxPrn; iGnss++) {
|
---|
| 251 | QString prn = QString("%1%2_%3").arg(sys).arg(iGnss, 2, 10, QChar('0')).arg(flag);
|
---|
| 252 | _params[sys].push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
|
---|
[3483] | 253 | }
|
---|
[9258] | 254 | // Initialize Variance-Covariance Matrix
|
---|
| 255 | // -------------------------------------
|
---|
| 256 | _QQ[sys].ReSize(_params[sys].size());
|
---|
| 257 | _QQ[sys] = 0.0;
|
---|
| 258 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 259 | cmbParam* pp = _params[sys][iPar-1];
|
---|
| 260 | _QQ[sys](iPar,iPar) = pp->sig0 * pp->sig0;
|
---|
| 261 | }
|
---|
[3483] | 262 | }
|
---|
[2991] | 263 | }
|
---|
[2933] | 264 |
|
---|
[3052] | 265 | // ANTEX File
|
---|
| 266 | // ----------
|
---|
| 267 | _antex = 0;
|
---|
[6667] | 268 | QString antexFileName = settings.value("uploadAntexFile").toString();
|
---|
[3052] | 269 | if (!antexFileName.isEmpty()) {
|
---|
| 270 | _antex = new bncAntex();
|
---|
| 271 | if (_antex->readFile(antexFileName) != success) {
|
---|
[9695] | 272 | emit newMessage("bncCmb: wrong ANTEX file", true);
|
---|
[3052] | 273 | delete _antex;
|
---|
| 274 | _antex = 0;
|
---|
| 275 | }
|
---|
| 276 | }
|
---|
[3138] | 277 |
|
---|
[9676] | 278 |
|
---|
| 279 | // Bias SINEX File
|
---|
| 280 | // ---------------
|
---|
| 281 | _bsx = 0;
|
---|
| 282 | QString bsxFileName = settings.value("cmbBsxFile").toString();
|
---|
| 283 | if (!bsxFileName.isEmpty()) {
|
---|
| 284 | _bsx = new bncBiasSnx();
|
---|
| 285 | if (_bsx->readFile(bsxFileName) != success) {
|
---|
[9695] | 286 | emit newMessage("bncComb: wrong Bias SINEX file", true);
|
---|
[9676] | 287 | delete _bsx;
|
---|
| 288 | _bsx = 0;
|
---|
| 289 | }
|
---|
| 290 | }
|
---|
| 291 | if (_bsx) {
|
---|
[9695] | 292 | _ms = 6.0 * 3600 * 1000.0;
|
---|
| 293 | QTimer::singleShot(_ms, this, SLOT(slotReadBiasSnxFile()));
|
---|
[9676] | 294 | }
|
---|
| 295 |
|
---|
| 296 |
|
---|
[3329] | 297 | // Maximal Residuum
|
---|
| 298 | // ----------------
|
---|
| 299 | _MAXRES = settings.value("cmbMaxres").toDouble();
|
---|
| 300 | if (_MAXRES <= 0.0) {
|
---|
| 301 | _MAXRES = 999.0;
|
---|
| 302 | }
|
---|
[2898] | 303 | }
|
---|
| 304 |
|
---|
| 305 | // Destructor
|
---|
| 306 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 307 | bncComb::~bncComb() {
|
---|
[3429] | 308 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 309 | while (icAC.hasNext()) {
|
---|
| 310 | delete icAC.next();
|
---|
[2918] | 311 | }
|
---|
[3201] | 312 | delete _rtnetDecoder;
|
---|
[9025] | 313 | if (_ssrCorr) {
|
---|
| 314 | delete _ssrCorr;
|
---|
| 315 | }
|
---|
[3052] | 316 | delete _antex;
|
---|
[9676] | 317 | delete _bsx;
|
---|
[10038] | 318 |
|
---|
[9258] | 319 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
---|
| 320 | while (itSys.hasNext()) {
|
---|
| 321 | itSys.next();
|
---|
| 322 | char sys = itSys.key();
|
---|
| 323 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 324 | delete _params[sys][iPar-1];
|
---|
| 325 | }
|
---|
[10038] | 326 | _buffer.remove(sys);
|
---|
[3296] | 327 | }
|
---|
[10038] | 328 | while (!_epoClkData.empty()) {
|
---|
| 329 | delete _epoClkData.front();
|
---|
| 330 | _epoClkData.pop_front();
|
---|
| 331 | }
|
---|
[2898] | 332 | }
|
---|
| 333 |
|
---|
[9676] | 334 | void bncComb::slotReadBiasSnxFile() {
|
---|
| 335 | bncSettings settings;
|
---|
| 336 | QString bsxFileName = settings.value("cmbBsxFile").toString();
|
---|
[9695] | 337 |
|
---|
| 338 | if (bsxFileName.isEmpty()) {
|
---|
| 339 | emit newMessage("bncComb: no Bias SINEX file specified", true);
|
---|
| 340 | return;
|
---|
| 341 | }
|
---|
| 342 | if (!_bsx) {
|
---|
[9676] | 343 | _bsx = new bncBiasSnx();
|
---|
| 344 | }
|
---|
| 345 | if (_bsx->readFile(bsxFileName) != success) {
|
---|
[9695] | 346 | emit newMessage("bncComb: wrong Bias SINEX file", true);
|
---|
[9676] | 347 | delete _bsx;
|
---|
| 348 | _bsx = 0;
|
---|
| 349 | }
|
---|
| 350 | else {
|
---|
[9695] | 351 | emit newMessage("bncComb: successfully read Bias SINEX file", true);
|
---|
[9676] | 352 | }
|
---|
[9710] | 353 |
|
---|
[9695] | 354 | QTimer::singleShot(_ms, this, SLOT(slotReadBiasSnxFile()));
|
---|
[9676] | 355 | }
|
---|
| 356 |
|
---|
| 357 |
|
---|
[6155] | 358 | // Remember orbit corrections
|
---|
[2898] | 359 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6155] | 360 | void bncComb::slotNewOrbCorrections(QList<t_orbCorr> orbCorrections) {
|
---|
[2906] | 361 | QMutexLocker locker(&_mutex);
|
---|
[2913] | 362 |
|
---|
[6155] | 363 | for (int ii = 0; ii < orbCorrections.size(); ii++) {
|
---|
| 364 | t_orbCorr& orbCorr = orbCorrections[ii];
|
---|
| 365 | QString staID(orbCorr._staID.c_str());
|
---|
[9296] | 366 | char sys = orbCorr._prn.system();
|
---|
[6155] | 367 |
|
---|
[9296] | 368 | if (!_cmbSysPrn.contains(sys)){
|
---|
| 369 | continue;
|
---|
| 370 | }
|
---|
| 371 |
|
---|
[6155] | 372 | // Find/Check the AC Name
|
---|
| 373 | // ----------------------
|
---|
| 374 | QString acName;
|
---|
| 375 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 376 | while (icAC.hasNext()) {
|
---|
| 377 | cmbAC* AC = icAC.next();
|
---|
| 378 | if (AC->mountPoint == staID) {
|
---|
| 379 | acName = AC->name;
|
---|
| 380 | break;
|
---|
| 381 | }
|
---|
[3431] | 382 | }
|
---|
[6155] | 383 | if (acName.isEmpty()) {
|
---|
| 384 | continue;
|
---|
| 385 | }
|
---|
[3431] | 386 |
|
---|
[6155] | 387 | // Store the correction
|
---|
| 388 | // --------------------
|
---|
[10038] | 389 | QMap<t_prn, t_orbCorr*>& storage = _orbCorrections[acName];
|
---|
| 390 | if (storage[orbCorr._prn]) {
|
---|
| 391 | delete storage[orbCorr._prn];
|
---|
| 392 | }
|
---|
| 393 | storage[orbCorr._prn] = new t_orbCorr(orbCorr);
|
---|
[2913] | 394 | }
|
---|
[6155] | 395 | }
|
---|
[2913] | 396 |
|
---|
[9676] | 397 | // Remember Satellite Code Biases
|
---|
[9529] | 398 | ////////////////////////////////////////////////////////////////////////////
|
---|
[9530] | 399 | void bncComb::slotNewCodeBiases(QList<t_satCodeBias> satCodeBiases) {
|
---|
[9529] | 400 | QMutexLocker locker(&_mutex);
|
---|
| 401 |
|
---|
[9530] | 402 | for (int ii = 0; ii < satCodeBiases.size(); ii++) {
|
---|
| 403 | t_satCodeBias& satCodeBias = satCodeBiases[ii];
|
---|
| 404 | QString staID(satCodeBias._staID.c_str());
|
---|
| 405 | char sys = satCodeBias._prn.system();
|
---|
[9529] | 406 |
|
---|
| 407 | if (!_cmbSysPrn.contains(sys)){
|
---|
| 408 | continue;
|
---|
| 409 | }
|
---|
| 410 |
|
---|
| 411 | // Find/Check the AC Name
|
---|
| 412 | // ----------------------
|
---|
| 413 | QString acName;
|
---|
| 414 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 415 | while (icAC.hasNext()) {
|
---|
| 416 | cmbAC* AC = icAC.next();
|
---|
| 417 | if (AC->mountPoint == staID) {
|
---|
| 418 | acName = AC->name;
|
---|
| 419 | break;
|
---|
| 420 | }
|
---|
| 421 | }
|
---|
| 422 | if (acName.isEmpty()) {
|
---|
| 423 | continue;
|
---|
| 424 | }
|
---|
| 425 |
|
---|
| 426 | // Store the correction
|
---|
| 427 | // --------------------
|
---|
[10038] | 428 | QMap<t_prn, t_satCodeBias*>& storage = _satCodeBiases[acName];
|
---|
| 429 | if (storage[satCodeBias._prn]) {
|
---|
| 430 | delete storage[satCodeBias._prn];
|
---|
| 431 | }
|
---|
| 432 | storage[satCodeBias._prn] = new t_satCodeBias(satCodeBias);
|
---|
[9529] | 433 | }
|
---|
| 434 | }
|
---|
| 435 |
|
---|
[6155] | 436 | // Process clock corrections
|
---|
| 437 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 438 | void bncComb::slotNewClkCorrections(QList<t_clkCorr> clkCorrections) {
|
---|
| 439 | QMutexLocker locker(&_mutex);
|
---|
[10038] | 440 | const double outWait = 1.0 * _cmbSampl;
|
---|
[10081] | 441 | int currentWeek = 0;
|
---|
| 442 | double currentSec = 0.0;
|
---|
| 443 | currentGPSWeeks(currentWeek, currentSec);
|
---|
| 444 | bncTime currentTime(currentWeek, currentSec);
|
---|
[6155] | 445 |
|
---|
[10038] | 446 | // Loop over all observations (possible different epochs)
|
---|
| 447 | // -----------------------------------------------------
|
---|
[6155] | 448 | for (int ii = 0; ii < clkCorrections.size(); ii++) {
|
---|
[10038] | 449 | t_clkCorr* newClk = new t_clkCorr(clkCorrections[ii]);
|
---|
[6155] | 450 |
|
---|
[10038] | 451 | char sys = newClk->_prn.system();
|
---|
[9296] | 452 | if (!_cmbSysPrn.contains(sys)){
|
---|
[10038] | 453 | delete newClk;
|
---|
[9296] | 454 | continue;
|
---|
| 455 | }
|
---|
| 456 |
|
---|
[10078] | 457 | // Check regarding current time
|
---|
| 458 | // ----------------------------
|
---|
[10081] | 459 | if ((newClk->_time >= currentTime) || // future time stamp
|
---|
| 460 | (currentTime - newClk->_time) > 60.0) { // very old data sets
|
---|
[10078] | 461 | delete newClk;
|
---|
| 462 | continue;
|
---|
| 463 | }
|
---|
| 464 |
|
---|
[10038] | 465 | // Check Modulo Time
|
---|
[6155] | 466 | // -----------------
|
---|
[10038] | 467 | int sec = int(nint(newClk->_time.gpssec()*10));
|
---|
| 468 | if (sec % (_cmbSampl*10) != 0.0) {
|
---|
| 469 | delete newClk;
|
---|
| 470 | continue;
|
---|
[3483] | 471 | }
|
---|
| 472 |
|
---|
[6155] | 473 | // Find/Check the AC Name
|
---|
| 474 | // ----------------------
|
---|
| 475 | QString acName;
|
---|
[10038] | 476 | QString staID(newClk->_staID.c_str());
|
---|
[6155] | 477 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 478 | while (icAC.hasNext()) {
|
---|
| 479 | cmbAC* AC = icAC.next();
|
---|
| 480 | if (AC->mountPoint == staID) {
|
---|
| 481 | acName = AC->name;
|
---|
| 482 | break;
|
---|
| 483 | }
|
---|
[3588] | 484 | }
|
---|
[6155] | 485 | if (acName.isEmpty()) {
|
---|
[10038] | 486 | delete newClk;
|
---|
[6155] | 487 | continue;
|
---|
| 488 | }
|
---|
[3588] | 489 |
|
---|
[10038] | 490 | // Set the last time
|
---|
[6155] | 491 | // -----------------
|
---|
[10038] | 492 | if (_lastClkCorrTime.undef() || newClk->_time > _lastClkCorrTime) {
|
---|
| 493 | _lastClkCorrTime = newClk->_time;
|
---|
[6155] | 494 | }
|
---|
[3274] | 495 |
|
---|
[6155] | 496 | // Check Correction Age
|
---|
| 497 | // --------------------
|
---|
[10042] | 498 | if (_resTime.valid() && newClk->_time <= _resTime) {
|
---|
[10077] | 499 | #ifdef BNC_DEBUG_CMB
|
---|
[10038] | 500 | emit newMessage("bncComb: old correction: " + acName.toLatin1() + " " + newClk->_prn.toString().c_str() +
|
---|
[10042] | 501 | QString(" %1 ").arg(newClk->_time.timestr().c_str()).toLatin1() + "vs. last processing Epoch" +
|
---|
| 502 | QString(" %1 ").arg(_resTime.timestr().c_str()).toLatin1(), true);
|
---|
[10077] | 503 | #endif
|
---|
[10038] | 504 | delete newClk;
|
---|
[6155] | 505 | continue;
|
---|
| 506 | }
|
---|
[7297] | 507 |
|
---|
[10038] | 508 | // Find the corresponding data epoch or create a new one
|
---|
| 509 | // -----------------------------------------------------
|
---|
| 510 | epoClkData* epoch = 0;
|
---|
| 511 | deque<epoClkData*>::const_iterator it;
|
---|
| 512 | for (it = _epoClkData.begin(); it != _epoClkData.end(); it++) {
|
---|
| 513 | if (newClk->_time == (*it)->_time) {
|
---|
| 514 | epoch = *it;
|
---|
| 515 | break;
|
---|
| 516 | }
|
---|
| 517 | }
|
---|
| 518 | if (epoch == 0) {
|
---|
| 519 | if (_epoClkData.empty() || newClk->_time > _epoClkData.back()->_time) {
|
---|
| 520 | epoch = new epoClkData;
|
---|
| 521 | epoch->_time = newClk->_time;
|
---|
| 522 | _epoClkData.push_back(epoch);
|
---|
| 523 | }
|
---|
| 524 | }
|
---|
| 525 |
|
---|
| 526 | // Put data into the epoch
|
---|
| 527 | // -----------------------
|
---|
| 528 | if (epoch != 0) {
|
---|
| 529 | epoch->_clkCorr.push_back(newClk);
|
---|
| 530 | }
|
---|
| 531 | else {
|
---|
| 532 | delete newClk;
|
---|
| 533 | }
|
---|
| 534 | }
|
---|
| 535 |
|
---|
| 536 | // Make sure the buffer does not grow beyond any limit
|
---|
| 537 | // ---------------------------------------------------
|
---|
[10081] | 538 | const unsigned MAX_EPODATA_SIZE = 10;
|
---|
[10038] | 539 | if (_epoClkData.size() > MAX_EPODATA_SIZE) {
|
---|
| 540 | delete _epoClkData.front();
|
---|
| 541 | _epoClkData.pop_front();
|
---|
| 542 | }
|
---|
| 543 |
|
---|
| 544 | // Process the oldest epochs
|
---|
| 545 | // ------------------------
|
---|
| 546 | while (_epoClkData.size()) {
|
---|
| 547 |
|
---|
[10042] | 548 | if (!_lastClkCorrTime.valid()) {
|
---|
[10038] | 549 | return;
|
---|
| 550 | }
|
---|
| 551 |
|
---|
| 552 | const vector<t_clkCorr*>& clkCorrVec = _epoClkData.front()->_clkCorr;
|
---|
| 553 |
|
---|
| 554 | bncTime epoTime = _epoClkData.front()->_time;
|
---|
| 555 |
|
---|
[10081] | 556 | if ((currentTime - epoTime) > 60.0) {
|
---|
[10043] | 557 | delete _epoClkData.front();
|
---|
| 558 | _epoClkData.pop_front();
|
---|
| 559 | continue;
|
---|
| 560 | }
|
---|
| 561 |
|
---|
[10038] | 562 | // Process the front epoch
|
---|
| 563 | // -----------------------
|
---|
| 564 | if (epoTime < (_lastClkCorrTime - outWait)) {
|
---|
[10042] | 565 | _resTime = epoTime;
|
---|
| 566 | processEpoch(_resTime, clkCorrVec);
|
---|
[10038] | 567 | delete _epoClkData.front();
|
---|
| 568 | _epoClkData.pop_front();
|
---|
| 569 | }
|
---|
| 570 | else {
|
---|
| 571 | return;
|
---|
| 572 | }
|
---|
| 573 | }
|
---|
| 574 | }
|
---|
| 575 |
|
---|
| 576 | // Change the correction so that it refers to last received ephemeris
|
---|
| 577 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 578 | void bncComb::switchToLastEph(t_eph* lastEph, cmbCorr* corr) {
|
---|
| 579 |
|
---|
| 580 | if (corr->_eph == lastEph) {
|
---|
| 581 | return;
|
---|
| 582 | }
|
---|
| 583 |
|
---|
| 584 | ColumnVector oldXC(6);
|
---|
| 585 | ColumnVector oldVV(3);
|
---|
| 586 | if (corr->_eph->getCrd(corr->_time, oldXC, oldVV, false) != success) {
|
---|
| 587 | return;
|
---|
| 588 | }
|
---|
| 589 |
|
---|
| 590 | ColumnVector newXC(6);
|
---|
| 591 | ColumnVector newVV(3);
|
---|
| 592 | if (lastEph->getCrd(corr->_time, newXC, newVV, false) != success) {
|
---|
| 593 | return;
|
---|
| 594 | }
|
---|
| 595 |
|
---|
| 596 | ColumnVector dX = newXC.Rows(1,3) - oldXC.Rows(1,3);
|
---|
| 597 | ColumnVector dV = newVV - oldVV;
|
---|
| 598 | double dC = newXC(4) - oldXC(4);
|
---|
| 599 |
|
---|
| 600 | ColumnVector dRAO(3);
|
---|
| 601 | XYZ_to_RSW(newXC.Rows(1,3), newVV, dX, dRAO);
|
---|
| 602 |
|
---|
| 603 | ColumnVector dDotRAO(3);
|
---|
| 604 | XYZ_to_RSW(newXC.Rows(1,3), newVV, dV, dDotRAO);
|
---|
| 605 |
|
---|
| 606 | QString msg = "switch corr " + corr->_prn.mid(0,3)
|
---|
| 607 | + QString(" %1 -> %2 %3").arg(corr->_iod,3).arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
|
---|
| 608 |
|
---|
| 609 | emit newMessage(msg.toLatin1(), false);
|
---|
| 610 |
|
---|
| 611 | corr->_iod = lastEph->IOD();
|
---|
| 612 | corr->_eph = lastEph;
|
---|
| 613 |
|
---|
| 614 | corr->_orbCorr->_xr += dRAO;
|
---|
| 615 | corr->_orbCorr->_dotXr += dDotRAO;
|
---|
| 616 | corr->_clkCorr->_dClk -= dC;
|
---|
| 617 | }
|
---|
| 618 |
|
---|
| 619 | // Process Epoch
|
---|
| 620 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 621 | void bncComb::processEpoch(bncTime epoTime, const vector<t_clkCorr*>& clkCorrVec) {
|
---|
| 622 |
|
---|
| 623 | for (unsigned ii = 0; ii < clkCorrVec.size(); ii++) {
|
---|
| 624 | const t_clkCorr* clkCorr = clkCorrVec.at(ii);
|
---|
| 625 | QString staID(clkCorr->_staID.c_str());
|
---|
| 626 | QString prn(clkCorr->_prn.toInternalString().c_str());
|
---|
| 627 | char sys = clkCorr->_prn.system();
|
---|
| 628 |
|
---|
| 629 | // Find/Check the AC Name
|
---|
| 630 | // ----------------------
|
---|
| 631 | QString acName;
|
---|
| 632 | double weigthFactor;
|
---|
| 633 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 634 | while (icAC.hasNext()) {
|
---|
| 635 | cmbAC* AC = icAC.next();
|
---|
| 636 | if (AC->mountPoint == staID) {
|
---|
| 637 | acName = AC->name;
|
---|
| 638 | weigthFactor = AC->weightFactor;
|
---|
| 639 | break;
|
---|
| 640 | }
|
---|
| 641 | }
|
---|
| 642 |
|
---|
[6155] | 643 | // Create new correction
|
---|
| 644 | // ---------------------
|
---|
[10038] | 645 | cmbCorr* newCorr = new cmbCorr();
|
---|
| 646 | newCorr->_prn = prn;
|
---|
| 647 | newCorr->_time = clkCorr->_time;
|
---|
| 648 | newCorr->_iod = clkCorr->_iod;
|
---|
| 649 | newCorr->_acName = acName;
|
---|
[9821] | 650 | newCorr->_weightFactor = weigthFactor;
|
---|
[10038] | 651 | newCorr->_clkCorr = new t_clkCorr(*clkCorrVec[ii]);
|
---|
[6155] | 652 |
|
---|
[6156] | 653 | // Check orbit correction
|
---|
| 654 | // ----------------------
|
---|
| 655 | if (!_orbCorrections.contains(acName)) {
|
---|
| 656 | delete newCorr;
|
---|
| 657 | continue;
|
---|
| 658 | }
|
---|
| 659 | else {
|
---|
[10038] | 660 | QMap<t_prn, t_orbCorr*>& storage = _orbCorrections[acName];
|
---|
| 661 | if (!storage.contains(clkCorr->_prn) ||
|
---|
| 662 | storage[clkCorr->_prn]->_iod != newCorr->_iod) {
|
---|
[6156] | 663 | delete newCorr;
|
---|
| 664 | continue;
|
---|
| 665 | }
|
---|
| 666 | else {
|
---|
[10038] | 667 | newCorr->_orbCorr = storage[clkCorr->_prn];
|
---|
[6156] | 668 | }
|
---|
| 669 | }
|
---|
| 670 |
|
---|
[6155] | 671 | // Check the Ephemeris
|
---|
| 672 | //--------------------
|
---|
[7012] | 673 | t_eph* ephLast = _ephUser.ephLast(prn);
|
---|
| 674 | t_eph* ephPrev = _ephUser.ephPrev(prn);
|
---|
[6443] | 675 | if (ephLast == 0) {
|
---|
[9676] | 676 | #ifdef BNC_DEBUG_CMB
|
---|
[9265] | 677 | emit newMessage("bncComb: eph not found for " + prn.mid(0,3).toLatin1(), true);
|
---|
[9676] | 678 | #endif
|
---|
[6155] | 679 | delete newCorr;
|
---|
| 680 | continue;
|
---|
[2986] | 681 | }
|
---|
[9268] | 682 | else if (ephLast->checkState() == t_eph::bad ||
|
---|
| 683 | ephLast->checkState() == t_eph::outdated ||
|
---|
| 684 | ephLast->checkState() == t_eph::unhealthy) {
|
---|
[9676] | 685 | #ifdef BNC_DEBUG_CMB
|
---|
| 686 | emit newMessage("bncComb: ephLast not ok (checkState: " + ephLast->checkStateToString().toLatin1() + ") for " + prn.mid(0,3).toLatin1(), true);
|
---|
| 687 | #endif
|
---|
[9266] | 688 | delete newCorr;
|
---|
| 689 | continue;
|
---|
| 690 | }
|
---|
[3029] | 691 | else {
|
---|
[6443] | 692 | if (ephLast->IOD() == newCorr->_iod) {
|
---|
| 693 | newCorr->_eph = ephLast;
|
---|
[6155] | 694 | }
|
---|
[9268] | 695 | else if (ephPrev && ephPrev->checkState() == t_eph::ok &&
|
---|
| 696 | ephPrev->IOD() == newCorr->_iod) {
|
---|
[6443] | 697 | newCorr->_eph = ephPrev;
|
---|
| 698 | switchToLastEph(ephLast, newCorr);
|
---|
[6155] | 699 | }
|
---|
| 700 | else {
|
---|
[9676] | 701 | #ifdef BNC_DEBUG_CMB
|
---|
[9265] | 702 | emit newMessage("bncComb: eph not found for " + prn.mid(0,3).toLatin1() +
|
---|
| 703 | QString(" with IOD %1").arg(newCorr->_iod).toLatin1(), true);
|
---|
[9676] | 704 | #endif
|
---|
[6155] | 705 | delete newCorr;
|
---|
| 706 | continue;
|
---|
| 707 | }
|
---|
[2986] | 708 | }
|
---|
[6155] | 709 |
|
---|
[9635] | 710 | // Check satellite code biases
|
---|
| 711 | // ----------------------------
|
---|
[9819] | 712 | if (_satCodeBiases.contains(acName)) {
|
---|
[10038] | 713 | QMap<t_prn, t_satCodeBias*>& storage = _satCodeBiases[acName];
|
---|
| 714 | if (storage.contains(clkCorr->_prn)) {
|
---|
| 715 | newCorr->_satCodeBias = storage[clkCorr->_prn];
|
---|
[9676] | 716 | QMap<t_frequency::type, double> codeBiasesRefSig;
|
---|
| 717 | for (unsigned ii = 1; ii < cmbRefSig::cIF; ii++) {
|
---|
[10038] | 718 | t_frequency::type frqType = cmbRefSig::toFreq(sys, static_cast<cmbRefSig::type>(ii));
|
---|
[9635] | 719 | char frqNum = t_frequency::toString(frqType)[1];
|
---|
[10038] | 720 | char attrib = cmbRefSig::toAttrib(sys, static_cast<cmbRefSig::type>(ii));
|
---|
[9676] | 721 | QString rnxType2ch = QString("%1%2").arg(frqNum).arg(attrib);
|
---|
[10038] | 722 | for (unsigned ii = 0; ii < newCorr->_satCodeBias->_bias.size(); ii++) {
|
---|
| 723 | const t_frqCodeBias& bias = newCorr->_satCodeBias->_bias[ii];
|
---|
[9676] | 724 | if (rnxType2ch.toStdString() == bias._rnxType2ch) {
|
---|
| 725 | codeBiasesRefSig[frqType] = bias._value;
|
---|
[9635] | 726 | }
|
---|
| 727 | }
|
---|
| 728 | }
|
---|
[9819] | 729 | if (codeBiasesRefSig.size() == 2) {
|
---|
| 730 | map<t_frequency::type, double> codeCoeff;
|
---|
| 731 | double channel = double(newCorr->_eph->slotNum());
|
---|
| 732 | cmbRefSig::coeff(sys, cmbRefSig::cIF, channel, codeCoeff);
|
---|
| 733 | map<t_frequency::type, double>::const_iterator it;
|
---|
| 734 | for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
|
---|
| 735 | t_frequency::type frqType = it->first;
|
---|
| 736 | newCorr->_satCodeBiasIF += it->second * codeBiasesRefSig[frqType];
|
---|
| 737 | }
|
---|
[9676] | 738 | }
|
---|
[10038] | 739 | newCorr->_satCodeBias->_bias.clear();
|
---|
[9635] | 740 | }
|
---|
| 741 | }
|
---|
| 742 |
|
---|
[6155] | 743 | // Store correction into the buffer
|
---|
| 744 | // --------------------------------
|
---|
[10038] | 745 | QVector<cmbCorr*>& corrs = _buffer[sys].corrs;
|
---|
| 746 |
|
---|
| 747 | QVectorIterator<cmbCorr*> itCorr(corrs);
|
---|
| 748 | bool available = false;
|
---|
| 749 | while (itCorr.hasNext()) {
|
---|
| 750 | cmbCorr* corr = itCorr.next();
|
---|
| 751 | QString prn = corr->_prn;
|
---|
| 752 | QString acName = corr->_acName;
|
---|
| 753 | if (newCorr->_acName == acName && newCorr->_prn == prn) {
|
---|
| 754 | available = true;
|
---|
| 755 | }
|
---|
| 756 | }
|
---|
| 757 | if (!available) {
|
---|
| 758 | corrs.push_back(newCorr);
|
---|
| 759 | }
|
---|
| 760 | else {
|
---|
| 761 | delete newCorr;
|
---|
| 762 | continue;
|
---|
| 763 | }
|
---|
[2986] | 764 | }
|
---|
| 765 |
|
---|
[10038] | 766 | // Process Systems of this Epoch
|
---|
| 767 | // ------------------------------
|
---|
[9258] | 768 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
---|
| 769 | while (itSys.hasNext()) {
|
---|
| 770 | itSys.next();
|
---|
| 771 | char sys = itSys.key();
|
---|
[10038] | 772 | _log.clear();
|
---|
| 773 | QTextStream out(&_log, QIODevice::WriteOnly);
|
---|
| 774 | processSystem(epoTime, sys, out);
|
---|
| 775 | emit newMessage(_log, false);
|
---|
[2927] | 776 | }
|
---|
[2898] | 777 | }
|
---|
| 778 |
|
---|
[10038] | 779 | void bncComb::processSystem(bncTime epoTime, char sys, QTextStream& out) {
|
---|
[3028] | 780 |
|
---|
[9635] | 781 | out << "\n" << "Combination: " << sys << "\n"
|
---|
| 782 | << "--------------------------------" << "\n";
|
---|
[2990] | 783 |
|
---|
[3433] | 784 | // Observation Statistics
|
---|
| 785 | // ----------------------
|
---|
[3455] | 786 | bool masterPresent = false;
|
---|
[3433] | 787 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 788 | while (icAC.hasNext()) {
|
---|
| 789 | cmbAC* AC = icAC.next();
|
---|
[9258] | 790 | AC->numObs[sys] = 0;
|
---|
| 791 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
---|
[3433] | 792 | while (itCorr.hasNext()) {
|
---|
| 793 | cmbCorr* corr = itCorr.next();
|
---|
[6157] | 794 | if (corr->_acName == AC->name) {
|
---|
[9258] | 795 | AC->numObs[sys] += 1;
|
---|
| 796 | if (AC->name == _masterOrbitAC[sys]) {
|
---|
[3453] | 797 | masterPresent = true;
|
---|
| 798 | }
|
---|
[3433] | 799 | }
|
---|
| 800 | }
|
---|
[9635] | 801 | out << AC->name.toLatin1().data() << ": " << AC->numObs[sys] << "\n";
|
---|
[3433] | 802 | }
|
---|
| 803 |
|
---|
[3453] | 804 | // If Master not present, switch to another one
|
---|
| 805 | // --------------------------------------------
|
---|
[4889] | 806 | const unsigned switchMasterAfterGap = 1;
|
---|
[3456] | 807 | if (masterPresent) {
|
---|
[9258] | 808 | _masterMissingEpochs[sys] = 0;
|
---|
[3456] | 809 | }
|
---|
| 810 | else {
|
---|
[9258] | 811 | ++_masterMissingEpochs[sys];
|
---|
| 812 | if (_masterMissingEpochs[sys] < switchMasterAfterGap) {
|
---|
[9635] | 813 | out << "Missing Master, Epoch skipped" << "\n";
|
---|
[10038] | 814 | _buffer.remove(sys);
|
---|
[3455] | 815 | emit newMessage(_log, false);
|
---|
| 816 | return;
|
---|
[3453] | 817 | }
|
---|
[3455] | 818 | else {
|
---|
[9258] | 819 | _masterMissingEpochs[sys] = 0;
|
---|
[3455] | 820 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 821 | while (icAC.hasNext()) {
|
---|
| 822 | cmbAC* AC = icAC.next();
|
---|
[9258] | 823 | if (AC->numObs[sys] > 0) {
|
---|
[3455] | 824 | out << "Switching Master AC "
|
---|
[9258] | 825 | << _masterOrbitAC[sys].toLatin1().data() << " --> "
|
---|
[8204] | 826 | << AC->name.toLatin1().data() << " "
|
---|
[10038] | 827 | << epoTime.datestr().c_str() << " "
|
---|
| 828 | << epoTime.timestr().c_str() << "\n";
|
---|
[9258] | 829 | _masterOrbitAC[sys] = AC->name;
|
---|
[3455] | 830 | break;
|
---|
| 831 | }
|
---|
[3452] | 832 | }
|
---|
| 833 | }
|
---|
| 834 | }
|
---|
| 835 |
|
---|
[6157] | 836 | QMap<QString, cmbCorr*> resCorr;
|
---|
[3472] | 837 |
|
---|
| 838 | // Perform the actual Combination using selected Method
|
---|
| 839 | // ----------------------------------------------------
|
---|
| 840 | t_irc irc;
|
---|
[3475] | 841 | ColumnVector dx;
|
---|
[3472] | 842 | if (_method == filter) {
|
---|
[10038] | 843 | irc = processEpoch_filter(epoTime, sys, out, resCorr, dx);
|
---|
[3472] | 844 | }
|
---|
| 845 | else {
|
---|
[10038] | 846 | irc = processEpoch_singleEpoch(epoTime, sys, out, resCorr, dx);
|
---|
[3472] | 847 | }
|
---|
| 848 |
|
---|
[3475] | 849 | // Update Parameter Values, Print Results
|
---|
| 850 | // --------------------------------------
|
---|
[3472] | 851 | if (irc == success) {
|
---|
[9258] | 852 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 853 | cmbParam* pp = _params[sys][iPar-1];
|
---|
[3475] | 854 | pp->xx += dx(iPar);
|
---|
| 855 | if (pp->type == cmbParam::clkSat) {
|
---|
| 856 | if (resCorr.find(pp->prn) != resCorr.end()) {
|
---|
[9676] | 857 | // set clock result
|
---|
[6160] | 858 | resCorr[pp->prn]->_dClkResult = pp->xx / t_CST::c;
|
---|
[9676] | 859 | // Add Code Biases from SINEX File
|
---|
| 860 | if (_bsx) {
|
---|
| 861 | map<t_frequency::type, double> codeCoeff;
|
---|
| 862 | double channel = double(resCorr[pp->prn]->_eph->slotNum());
|
---|
| 863 | cmbRefSig::coeff(sys, cmbRefSig::cIF, channel, codeCoeff);
|
---|
| 864 | t_frequency::type fType1 = cmbRefSig::toFreq(sys, cmbRefSig::c1);
|
---|
| 865 | t_frequency::type fType2 = cmbRefSig::toFreq(sys, cmbRefSig::c2);
|
---|
[10038] | 866 | if (resCorr[pp->prn]->_satCodeBias == 0) {
|
---|
| 867 | resCorr[pp->prn]->_satCodeBias = new t_satCodeBias();
|
---|
| 868 | }
|
---|
[9676] | 869 | _bsx->determineSsrSatCodeBiases(pp->prn.mid(0,3), codeCoeff[fType1], codeCoeff[fType2], resCorr[pp->prn]->_satCodeBias);
|
---|
| 870 | }
|
---|
[3475] | 871 | }
|
---|
| 872 | }
|
---|
[10038] | 873 | out << epoTime.datestr().c_str() << " "
|
---|
| 874 | << epoTime.timestr().c_str() << " ";
|
---|
[3475] | 875 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
| 876 | out.setFieldWidth(8);
|
---|
| 877 | out.setRealNumberPrecision(4);
|
---|
[9258] | 878 | out << pp->toString(sys) << " "
|
---|
[9635] | 879 | << pp->xx << " +- " << sqrt(_QQ[sys](pp->index,pp->index)) << "\n";
|
---|
[3475] | 880 | out.setFieldWidth(0);
|
---|
| 881 | }
|
---|
[10038] | 882 | printResults(epoTime, out, resCorr);
|
---|
| 883 | dumpResults(epoTime, resCorr);
|
---|
[3472] | 884 | }
|
---|
[10038] | 885 | // Delete Data
|
---|
| 886 | // -----------
|
---|
| 887 | _buffer.remove(sys);
|
---|
[3472] | 888 | }
|
---|
| 889 |
|
---|
| 890 | // Process Epoch - Filter Method
|
---|
| 891 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10038] | 892 | t_irc bncComb::processEpoch_filter(bncTime epoTime, char sys, QTextStream& out,
|
---|
[6157] | 893 | QMap<QString, cmbCorr*>& resCorr,
|
---|
[3475] | 894 | ColumnVector& dx) {
|
---|
[3472] | 895 |
|
---|
[3429] | 896 | // Prediction Step
|
---|
| 897 | // ---------------
|
---|
[9258] | 898 | int nPar = _params[sys].size();
|
---|
[2933] | 899 | ColumnVector x0(nPar);
|
---|
[9258] | 900 | for (int iPar = 1; iPar <= nPar; iPar++) {
|
---|
| 901 | cmbParam* pp = _params[sys][iPar-1];
|
---|
[3455] | 902 | if (pp->epoSpec) {
|
---|
[3451] | 903 | pp->xx = 0.0;
|
---|
[9258] | 904 | _QQ[sys].Row(iPar) = 0.0;
|
---|
| 905 | _QQ[sys].Column(iPar) = 0.0;
|
---|
| 906 | _QQ[sys](iPar,iPar) = pp->sig0 * pp->sig0;
|
---|
[3451] | 907 | }
|
---|
[3455] | 908 | else {
|
---|
[9258] | 909 | _QQ[sys](iPar,iPar) += pp->sigP * pp->sigP;
|
---|
[3455] | 910 | }
|
---|
[2933] | 911 | x0(iPar) = pp->xx;
|
---|
| 912 | }
|
---|
| 913 |
|
---|
[3487] | 914 | // Check Satellite Positions for Outliers
|
---|
| 915 | // --------------------------------------
|
---|
[10038] | 916 | if (checkOrbits(epoTime, sys, out) != success) {
|
---|
[3487] | 917 | return failure;
|
---|
| 918 | }
|
---|
[3441] | 919 |
|
---|
[3455] | 920 | // Update and outlier detection loop
|
---|
| 921 | // ---------------------------------
|
---|
[9258] | 922 | SymmetricMatrix QQ_sav = _QQ[sys];
|
---|
[3455] | 923 | while (true) {
|
---|
[3135] | 924 |
|
---|
[3455] | 925 | Matrix AA;
|
---|
| 926 | ColumnVector ll;
|
---|
| 927 | DiagonalMatrix PP;
|
---|
[3429] | 928 |
|
---|
[9258] | 929 | if (createAmat(sys, AA, ll, PP, x0, resCorr) != success) {
|
---|
[3472] | 930 | return failure;
|
---|
[3441] | 931 | }
|
---|
[2933] | 932 |
|
---|
[6169] | 933 | dx.ReSize(nPar); dx = 0.0;
|
---|
[9258] | 934 | kalman(AA, ll, PP, _QQ[sys], dx);
|
---|
[6164] | 935 |
|
---|
[3429] | 936 | ColumnVector vv = ll - AA * dx;
|
---|
[3080] | 937 |
|
---|
[3429] | 938 | int maxResIndex;
|
---|
[7297] | 939 | double maxRes = vv.maximum_absolute_value1(maxResIndex);
|
---|
[3429] | 940 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
[7297] | 941 | out.setRealNumberPrecision(3);
|
---|
[10038] | 942 | out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str()
|
---|
[3432] | 943 | << " Maximum Residuum " << maxRes << ' '
|
---|
[9258] | 944 | << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
|
---|
[3432] | 945 | if (maxRes > _MAXRES) {
|
---|
[9258] | 946 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 947 | cmbParam* pp = _params[sys][iPar-1];
|
---|
[7297] | 948 | if (pp->type == cmbParam::offACSat &&
|
---|
[9258] | 949 | pp->AC == corrs(sys)[maxResIndex-1]->_acName &&
|
---|
| 950 | pp->prn == corrs(sys)[maxResIndex-1]->_prn.mid(0,3)) {
|
---|
[3432] | 951 | QQ_sav.Row(iPar) = 0.0;
|
---|
| 952 | QQ_sav.Column(iPar) = 0.0;
|
---|
[3455] | 953 | QQ_sav(iPar,iPar) = pp->sig0 * pp->sig0;
|
---|
[3432] | 954 | }
|
---|
| 955 | }
|
---|
| 956 |
|
---|
[9635] | 957 | out << " Outlier" << "\n";
|
---|
[9258] | 958 | _QQ[sys] = QQ_sav;
|
---|
| 959 | corrs(sys).remove(maxResIndex-1);
|
---|
[3432] | 960 | }
|
---|
| 961 | else {
|
---|
[9635] | 962 | out << " OK" << "\n";
|
---|
[6330] | 963 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
| 964 | out.setRealNumberPrecision(4);
|
---|
[9258] | 965 | for (int ii = 0; ii < corrs(sys).size(); ii++) {
|
---|
| 966 | const cmbCorr* corr = corrs(sys)[ii];
|
---|
[10038] | 967 | out << epoTime.datestr().c_str() << ' '
|
---|
| 968 | << epoTime.timestr().c_str() << " "
|
---|
[6962] | 969 | << corr->_acName << ' ' << corr->_prn.mid(0,3);
|
---|
[6330] | 970 | out.setFieldWidth(10);
|
---|
[9635] | 971 | out << " res = " << vv[ii] << "\n";
|
---|
[6330] | 972 | out.setFieldWidth(0);
|
---|
| 973 | }
|
---|
[3432] | 974 | break;
|
---|
| 975 | }
|
---|
| 976 | }
|
---|
| 977 |
|
---|
[3472] | 978 | return success;
|
---|
[2918] | 979 | }
|
---|
[3011] | 980 |
|
---|
[3201] | 981 | // Print results
|
---|
[3011] | 982 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10038] | 983 | void bncComb::printResults(bncTime epoTime, QTextStream& out,
|
---|
[6157] | 984 | const QMap<QString, cmbCorr*>& resCorr) {
|
---|
[3011] | 985 |
|
---|
[6157] | 986 | QMapIterator<QString, cmbCorr*> it(resCorr);
|
---|
[3011] | 987 | while (it.hasNext()) {
|
---|
| 988 | it.next();
|
---|
[6157] | 989 | cmbCorr* corr = it.value();
|
---|
| 990 | const t_eph* eph = corr->_eph;
|
---|
[3015] | 991 | if (eph) {
|
---|
[8542] | 992 | ColumnVector xc(6);
|
---|
[6109] | 993 | ColumnVector vv(3);
|
---|
[10038] | 994 | if (eph->getCrd(epoTime, xc, vv, false) != success) {
|
---|
[9268] | 995 | continue;
|
---|
| 996 | }
|
---|
[10038] | 997 | out << epoTime.datestr().c_str() << " "
|
---|
| 998 | << epoTime.timestr().c_str() << " ";
|
---|
[3015] | 999 | out.setFieldWidth(3);
|
---|
[6962] | 1000 | out << "Full Clock " << corr->_prn.mid(0,3) << " " << corr->_iod << " ";
|
---|
[3015] | 1001 | out.setFieldWidth(14);
|
---|
[9635] | 1002 | out << (xc(4) + corr->_dClkResult) * t_CST::c << "\n";
|
---|
[3370] | 1003 | out.setFieldWidth(0);
|
---|
[3015] | 1004 | }
|
---|
| 1005 | else {
|
---|
[9691] | 1006 | out << "bncComb::printResults bug" << "\n";
|
---|
[3015] | 1007 | }
|
---|
[9676] | 1008 | out.flush();
|
---|
[3011] | 1009 | }
|
---|
| 1010 | }
|
---|
[3202] | 1011 |
|
---|
| 1012 | // Send results to RTNet Decoder and directly to PPP Client
|
---|
| 1013 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10038] | 1014 | void bncComb::dumpResults(bncTime epoTime, const QMap<QString, cmbCorr*>& resCorr) {
|
---|
[3202] | 1015 |
|
---|
[6161] | 1016 | QList<t_orbCorr> orbCorrections;
|
---|
| 1017 | QList<t_clkCorr> clkCorrections;
|
---|
[9676] | 1018 | QList<t_satCodeBias> satCodeBiasList;
|
---|
[6161] | 1019 |
|
---|
[3214] | 1020 | unsigned year, month, day, hour, minute;
|
---|
| 1021 | double sec;
|
---|
[10038] | 1022 | epoTime.civil_date(year, month, day);
|
---|
| 1023 | epoTime.civil_time(hour, minute, sec);
|
---|
[3214] | 1024 |
|
---|
[9676] | 1025 | QString outLines = QString().asprintf("* %4d %2d %2d %d %d %12.8f\n",
|
---|
| 1026 | year, month, day, hour, minute, sec);
|
---|
[3214] | 1027 |
|
---|
[6157] | 1028 | QMapIterator<QString, cmbCorr*> it(resCorr);
|
---|
[3202] | 1029 | while (it.hasNext()) {
|
---|
| 1030 | it.next();
|
---|
[6157] | 1031 | cmbCorr* corr = it.value();
|
---|
[10038] | 1032 |
|
---|
[9676] | 1033 | // ORBIT
|
---|
[10038] | 1034 | t_orbCorr orbCorr(static_cast<t_orbCorr>(*corr->_orbCorr));
|
---|
[7013] | 1035 | orbCorr._staID = "INTERNAL";
|
---|
| 1036 | orbCorrections.push_back(orbCorr);
|
---|
[10038] | 1037 |
|
---|
[9676] | 1038 | // CLOCK
|
---|
[10038] | 1039 | t_clkCorr clkCorr(static_cast<t_clkCorr>(*corr->_clkCorr));
|
---|
[7013] | 1040 | clkCorr._staID = "INTERNAL";
|
---|
| 1041 | clkCorr._dClk = corr->_dClkResult;
|
---|
| 1042 | clkCorr._dotDClk = 0.0;
|
---|
| 1043 | clkCorr._dotDotDClk = 0.0;
|
---|
| 1044 | clkCorrections.push_back(clkCorr);
|
---|
[10038] | 1045 |
|
---|
[9710] | 1046 | // CODE BIASES
|
---|
[10038] | 1047 | t_satCodeBias satCodeBias(static_cast<t_satCodeBias>(*corr->_satCodeBias));
|
---|
[9710] | 1048 | satCodeBias._staID = "INTERNAL";
|
---|
| 1049 | satCodeBiasList.push_back(satCodeBias);
|
---|
[7013] | 1050 |
|
---|
[8542] | 1051 | ColumnVector xc(6);
|
---|
[4978] | 1052 | ColumnVector vv(3);
|
---|
[7013] | 1053 | corr->_eph->setClkCorr(dynamic_cast<const t_clkCorr*>(&clkCorr));
|
---|
| 1054 | corr->_eph->setOrbCorr(dynamic_cast<const t_orbCorr*>(&orbCorr));
|
---|
[10038] | 1055 | if (corr->_eph->getCrd(epoTime, xc, vv, true) != success) {
|
---|
[9268] | 1056 | delete corr;
|
---|
| 1057 | continue;
|
---|
| 1058 | }
|
---|
[7012] | 1059 |
|
---|
[4978] | 1060 | // Correction Phase Center --> CoM
|
---|
| 1061 | // -------------------------------
|
---|
| 1062 | ColumnVector dx(3); dx = 0.0;
|
---|
| 1063 | if (_antex) {
|
---|
[10038] | 1064 | double Mjd = epoTime.mjd() + epoTime.daysec()/86400.0;
|
---|
[6157] | 1065 | if (_antex->satCoMcorrection(corr->_prn, Mjd, xc.Rows(1,3), dx) != success) {
|
---|
[4992] | 1066 | dx = 0;
|
---|
[8204] | 1067 | _log += "antenna not found " + corr->_prn.mid(0,3).toLatin1() + '\n';
|
---|
[3214] | 1068 | }
|
---|
| 1069 | }
|
---|
[7012] | 1070 |
|
---|
| 1071 | outLines += corr->_prn.mid(0,3);
|
---|
[9676] | 1072 | QString hlp = QString().asprintf(" APC 3 %15.4f %15.4f %15.4f"
|
---|
| 1073 | " Clk 1 %15.4f"
|
---|
| 1074 | " Vel 3 %15.4f %15.4f %15.4f"
|
---|
| 1075 | " CoM 3 %15.4f %15.4f %15.4f",
|
---|
| 1076 | xc(1), xc(2), xc(3),
|
---|
| 1077 | xc(4) * t_CST::c,
|
---|
| 1078 | vv(1), vv(2), vv(3),
|
---|
| 1079 | xc(1)-dx(1), xc(2)-dx(2), xc(3)-dx(3));
|
---|
[5337] | 1080 | outLines += hlp;
|
---|
[9676] | 1081 | hlp.clear();
|
---|
[5337] | 1082 |
|
---|
[9676] | 1083 | if (satCodeBias._bias.size()) {
|
---|
| 1084 | hlp = QString().asprintf(" CodeBias %2lu", satCodeBias._bias.size());
|
---|
| 1085 | outLines += hlp;
|
---|
| 1086 | hlp.clear();
|
---|
| 1087 | for (unsigned ii = 0; ii < satCodeBias._bias.size(); ii++) {
|
---|
| 1088 | const t_frqCodeBias& frqCodeBias = satCodeBias._bias[ii];
|
---|
| 1089 | if (!frqCodeBias._rnxType2ch.empty()) {
|
---|
| 1090 | hlp = QString().asprintf(" %s%10.6f", frqCodeBias._rnxType2ch.c_str(), frqCodeBias._value);
|
---|
| 1091 | outLines += hlp;
|
---|
| 1092 | hlp.clear();
|
---|
| 1093 | }
|
---|
| 1094 | }
|
---|
| 1095 | }
|
---|
| 1096 | outLines += "\n";
|
---|
[3214] | 1097 | delete corr;
|
---|
| 1098 | }
|
---|
| 1099 |
|
---|
[5337] | 1100 | outLines += "EOE\n"; // End Of Epoch flag
|
---|
[9710] | 1101 | //cout << outLines.toStdString();
|
---|
[5337] | 1102 |
|
---|
[3215] | 1103 | if (!_rtnetDecoder) {
|
---|
| 1104 | _rtnetDecoder = new bncRtnetDecoder();
|
---|
| 1105 | }
|
---|
[3221] | 1106 |
|
---|
[3215] | 1107 | vector<string> errmsg;
|
---|
[8204] | 1108 | _rtnetDecoder->Decode(outLines.toLatin1().data(), outLines.length(), errmsg);
|
---|
[3215] | 1109 |
|
---|
[5861] | 1110 | // Send new Corrections to PPP etc.
|
---|
| 1111 | // --------------------------------
|
---|
[6161] | 1112 | if (orbCorrections.size() > 0 && clkCorrections.size() > 0) {
|
---|
| 1113 | emit newOrbCorrections(orbCorrections);
|
---|
| 1114 | emit newClkCorrections(clkCorrections);
|
---|
| 1115 | }
|
---|
[9676] | 1116 | if (satCodeBiasList.size()) {
|
---|
| 1117 | emit newCodeBiases(satCodeBiasList);
|
---|
| 1118 | }
|
---|
[3202] | 1119 | }
|
---|
[3455] | 1120 |
|
---|
| 1121 | // Create First Design Matrix and Vector of Measurements
|
---|
| 1122 | ////////////////////////////////////////////////////////////////////////////
|
---|
[9258] | 1123 | t_irc bncComb::createAmat(char sys, Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
|
---|
| 1124 | const ColumnVector& x0, QMap<QString, cmbCorr*>& resCorr) {
|
---|
[3455] | 1125 |
|
---|
[9258] | 1126 | unsigned nPar = _params[sys].size();
|
---|
| 1127 | unsigned nObs = corrs(sys).size();
|
---|
[3455] | 1128 |
|
---|
| 1129 | if (nObs == 0) {
|
---|
| 1130 | return failure;
|
---|
| 1131 | }
|
---|
| 1132 |
|
---|
[9258] | 1133 | int maxSat = _cmbSysPrn[sys];
|
---|
[3455] | 1134 |
|
---|
[9259] | 1135 | const int nCon = (_method == filter) ? 1 + maxSat : 0;
|
---|
[3483] | 1136 |
|
---|
[3455] | 1137 | AA.ReSize(nObs+nCon, nPar); AA = 0.0;
|
---|
| 1138 | ll.ReSize(nObs+nCon); ll = 0.0;
|
---|
| 1139 | PP.ReSize(nObs+nCon); PP = 1.0 / (sigObs * sigObs);
|
---|
| 1140 |
|
---|
| 1141 | int iObs = 0;
|
---|
[9258] | 1142 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
---|
[3455] | 1143 | while (itCorr.hasNext()) {
|
---|
| 1144 | cmbCorr* corr = itCorr.next();
|
---|
[6157] | 1145 | QString prn = corr->_prn;
|
---|
[3487] | 1146 |
|
---|
[3455] | 1147 | ++iObs;
|
---|
| 1148 |
|
---|
[9258] | 1149 | if (corr->_acName == _masterOrbitAC[sys] && resCorr.find(prn) == resCorr.end()) {
|
---|
[6157] | 1150 | resCorr[prn] = new cmbCorr(*corr);
|
---|
[3455] | 1151 | }
|
---|
| 1152 |
|
---|
[9258] | 1153 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 1154 | cmbParam* pp = _params[sys][iPar-1];
|
---|
| 1155 | AA(iObs, iPar) = pp->partial(sys, corr->_acName, prn);
|
---|
[3455] | 1156 | }
|
---|
| 1157 |
|
---|
[10038] | 1158 | ll(iObs) = (corr->_clkCorr->_dClk * t_CST::c - corr->_satCodeBiasIF) - DotProduct(AA.Row(iObs), x0);
|
---|
[9819] | 1159 |
|
---|
[9821] | 1160 | PP(iObs, iObs) *= 1.0 / (corr->_weightFactor * corr->_weightFactor);
|
---|
[3455] | 1161 | }
|
---|
| 1162 |
|
---|
| 1163 | // Regularization
|
---|
| 1164 | // --------------
|
---|
[3474] | 1165 | if (_method == filter) {
|
---|
| 1166 | const double Ph = 1.e6;
|
---|
| 1167 | PP(nObs+1) = Ph;
|
---|
[9258] | 1168 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 1169 | cmbParam* pp = _params[sys][iPar-1];
|
---|
[3465] | 1170 | if ( AA.Column(iPar).maximum_absolute_value() > 0.0 &&
|
---|
[3474] | 1171 | pp->type == cmbParam::clkSat ) {
|
---|
| 1172 | AA(nObs+1, iPar) = 1.0;
|
---|
[3455] | 1173 | }
|
---|
| 1174 | }
|
---|
[9258] | 1175 | unsigned flag = 0;
|
---|
| 1176 | if (sys == 'E') {
|
---|
| 1177 | flag = 1;
|
---|
| 1178 | }
|
---|
[10026] | 1179 | // if (sys == 'R') {
|
---|
| 1180 | // return success;
|
---|
| 1181 | // }
|
---|
[9259] | 1182 | int iCond = 1;
|
---|
| 1183 | // GNSS
|
---|
[9258] | 1184 | for (unsigned iGnss = 1; iGnss <= _cmbSysPrn[sys]; iGnss++) {
|
---|
| 1185 | QString prn = QString("%1%2_%3").arg(sys).arg(iGnss, 2, 10, QChar('0')).arg(flag);
|
---|
[3474] | 1186 | ++iCond;
|
---|
| 1187 | PP(nObs+iCond) = Ph;
|
---|
[9258] | 1188 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 1189 | cmbParam* pp = _params[sys][iPar-1];
|
---|
[7299] | 1190 | if ( pp &&
|
---|
| 1191 | AA.Column(iPar).maximum_absolute_value() > 0.0 &&
|
---|
[7297] | 1192 | pp->type == cmbParam::offACSat &&
|
---|
[3474] | 1193 | pp->prn == prn) {
|
---|
| 1194 | AA(nObs+iCond, iPar) = 1.0;
|
---|
| 1195 | }
|
---|
| 1196 | }
|
---|
| 1197 | }
|
---|
[3455] | 1198 | }
|
---|
| 1199 |
|
---|
| 1200 | return success;
|
---|
| 1201 | }
|
---|
[3470] | 1202 |
|
---|
| 1203 | // Process Epoch - Single-Epoch Method
|
---|
| 1204 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10038] | 1205 | t_irc bncComb::processEpoch_singleEpoch(bncTime epoTime, char sys, QTextStream& out,
|
---|
[6157] | 1206 | QMap<QString, cmbCorr*>& resCorr,
|
---|
[3475] | 1207 | ColumnVector& dx) {
|
---|
[3470] | 1208 |
|
---|
[3487] | 1209 | // Check Satellite Positions for Outliers
|
---|
| 1210 | // --------------------------------------
|
---|
[10038] | 1211 | if (checkOrbits(epoTime, sys, out) != success) {
|
---|
[3487] | 1212 | return failure;
|
---|
| 1213 | }
|
---|
| 1214 |
|
---|
[3482] | 1215 | // Outlier Detection Loop
|
---|
| 1216 | // ----------------------
|
---|
| 1217 | while (true) {
|
---|
[7297] | 1218 |
|
---|
[3482] | 1219 | // Remove Satellites that are not in Master
|
---|
| 1220 | // ----------------------------------------
|
---|
[9258] | 1221 | QMutableVectorIterator<cmbCorr*> it(corrs(sys));
|
---|
[3482] | 1222 | while (it.hasNext()) {
|
---|
| 1223 | cmbCorr* corr = it.next();
|
---|
[6157] | 1224 | QString prn = corr->_prn;
|
---|
[3482] | 1225 | bool foundMaster = false;
|
---|
[9258] | 1226 | QVectorIterator<cmbCorr*> itHlp(corrs(sys));
|
---|
[3482] | 1227 | while (itHlp.hasNext()) {
|
---|
| 1228 | cmbCorr* corrHlp = itHlp.next();
|
---|
[6157] | 1229 | QString prnHlp = corrHlp->_prn;
|
---|
| 1230 | QString ACHlp = corrHlp->_acName;
|
---|
[9258] | 1231 | if (ACHlp == _masterOrbitAC[sys] && prn == prnHlp) {
|
---|
[3482] | 1232 | foundMaster = true;
|
---|
| 1233 | break;
|
---|
| 1234 | }
|
---|
[3476] | 1235 | }
|
---|
[3482] | 1236 | if (!foundMaster) {
|
---|
[3556] | 1237 | delete corr;
|
---|
[3482] | 1238 | it.remove();
|
---|
| 1239 | }
|
---|
[3473] | 1240 | }
|
---|
[7297] | 1241 |
|
---|
[3482] | 1242 | // Count Number of Observations per Satellite and per AC
|
---|
| 1243 | // -----------------------------------------------------
|
---|
| 1244 | QMap<QString, int> numObsPrn;
|
---|
| 1245 | QMap<QString, int> numObsAC;
|
---|
[9258] | 1246 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
---|
[3482] | 1247 | while (itCorr.hasNext()) {
|
---|
| 1248 | cmbCorr* corr = itCorr.next();
|
---|
[6157] | 1249 | QString prn = corr->_prn;
|
---|
| 1250 | QString AC = corr->_acName;
|
---|
[3482] | 1251 | if (numObsPrn.find(prn) == numObsPrn.end()) {
|
---|
| 1252 | numObsPrn[prn] = 1;
|
---|
| 1253 | }
|
---|
| 1254 | else {
|
---|
| 1255 | numObsPrn[prn] += 1;
|
---|
| 1256 | }
|
---|
| 1257 | if (numObsAC.find(AC) == numObsAC.end()) {
|
---|
| 1258 | numObsAC[AC] = 1;
|
---|
| 1259 | }
|
---|
| 1260 | else {
|
---|
| 1261 | numObsAC[AC] += 1;
|
---|
| 1262 | }
|
---|
[3476] | 1263 | }
|
---|
[7297] | 1264 |
|
---|
[9258] | 1265 | // Clean-Up the Parameters
|
---|
| 1266 | // -----------------------
|
---|
| 1267 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 1268 | delete _params[sys][iPar-1];
|
---|
[3474] | 1269 | }
|
---|
[9258] | 1270 | _params[sys].clear();
|
---|
[7297] | 1271 |
|
---|
[3482] | 1272 | // Set new Parameters
|
---|
| 1273 | // ------------------
|
---|
| 1274 | int nextPar = 0;
|
---|
[7297] | 1275 |
|
---|
[3482] | 1276 | QMapIterator<QString, int> itAC(numObsAC);
|
---|
| 1277 | while (itAC.hasNext()) {
|
---|
| 1278 | itAC.next();
|
---|
| 1279 | const QString& AC = itAC.key();
|
---|
| 1280 | int numObs = itAC.value();
|
---|
[9258] | 1281 | if (AC != _masterOrbitAC[sys] && numObs > 0) {
|
---|
| 1282 | _params[sys].push_back(new cmbParam(cmbParam::offACgnss, ++nextPar, AC, ""));
|
---|
[3482] | 1283 | }
|
---|
[7297] | 1284 | }
|
---|
| 1285 |
|
---|
[3482] | 1286 | QMapIterator<QString, int> itPrn(numObsPrn);
|
---|
| 1287 | while (itPrn.hasNext()) {
|
---|
| 1288 | itPrn.next();
|
---|
| 1289 | const QString& prn = itPrn.key();
|
---|
| 1290 | int numObs = itPrn.value();
|
---|
| 1291 | if (numObs > 0) {
|
---|
[9258] | 1292 | _params[sys].push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
|
---|
[3482] | 1293 | }
|
---|
[7297] | 1294 | }
|
---|
| 1295 |
|
---|
[9258] | 1296 | int nPar = _params[sys].size();
|
---|
[7297] | 1297 | ColumnVector x0(nPar);
|
---|
[3482] | 1298 | x0 = 0.0;
|
---|
[7297] | 1299 |
|
---|
[3482] | 1300 | // Create First-Design Matrix
|
---|
| 1301 | // --------------------------
|
---|
| 1302 | Matrix AA;
|
---|
| 1303 | ColumnVector ll;
|
---|
| 1304 | DiagonalMatrix PP;
|
---|
[9258] | 1305 | if (createAmat(sys, AA, ll, PP, x0, resCorr) != success) {
|
---|
[3482] | 1306 | return failure;
|
---|
[3476] | 1307 | }
|
---|
[7297] | 1308 |
|
---|
[3482] | 1309 | ColumnVector vv;
|
---|
| 1310 | try {
|
---|
| 1311 | Matrix ATP = AA.t() * PP;
|
---|
| 1312 | SymmetricMatrix NN; NN << ATP * AA;
|
---|
| 1313 | ColumnVector bb = ATP * ll;
|
---|
[9258] | 1314 | _QQ[sys] = NN.i();
|
---|
| 1315 | dx = _QQ[sys] * bb;
|
---|
[3482] | 1316 | vv = ll - AA * dx;
|
---|
[3476] | 1317 | }
|
---|
[3482] | 1318 | catch (Exception& exc) {
|
---|
[9635] | 1319 | out << exc.what() << "\n";
|
---|
[3482] | 1320 | return failure;
|
---|
[3476] | 1321 | }
|
---|
[3474] | 1322 |
|
---|
[3482] | 1323 | int maxResIndex;
|
---|
[7297] | 1324 | double maxRes = vv.maximum_absolute_value1(maxResIndex);
|
---|
[3482] | 1325 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
[7297] | 1326 | out.setRealNumberPrecision(3);
|
---|
[10038] | 1327 | out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str()
|
---|
[3482] | 1328 | << " Maximum Residuum " << maxRes << ' '
|
---|
[9258] | 1329 | << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
|
---|
[3474] | 1330 |
|
---|
[3482] | 1331 | if (maxRes > _MAXRES) {
|
---|
[9635] | 1332 | out << " Outlier" << "\n";
|
---|
[9258] | 1333 | delete corrs(sys)[maxResIndex-1];
|
---|
| 1334 | corrs(sys).remove(maxResIndex-1);
|
---|
[3474] | 1335 | }
|
---|
[3482] | 1336 | else {
|
---|
[9635] | 1337 | out << " OK" << "\n";
|
---|
[3482] | 1338 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
[7297] | 1339 | out.setRealNumberPrecision(3);
|
---|
[3482] | 1340 | for (int ii = 0; ii < vv.Nrows(); ii++) {
|
---|
[9258] | 1341 | const cmbCorr* corr = corrs(sys)[ii];
|
---|
[10038] | 1342 | out << epoTime.datestr().c_str() << ' '
|
---|
| 1343 | << epoTime.timestr().c_str() << " "
|
---|
[6962] | 1344 | << corr->_acName << ' ' << corr->_prn.mid(0,3);
|
---|
[3482] | 1345 | out.setFieldWidth(6);
|
---|
[9635] | 1346 | out << " res = " << vv[ii] << "\n";
|
---|
[3482] | 1347 | out.setFieldWidth(0);
|
---|
| 1348 | }
|
---|
| 1349 | return success;
|
---|
[3474] | 1350 | }
|
---|
| 1351 |
|
---|
[3473] | 1352 | }
|
---|
[3474] | 1353 |
|
---|
[3482] | 1354 | return failure;
|
---|
[3470] | 1355 | }
|
---|
[3487] | 1356 |
|
---|
| 1357 | // Check Satellite Positions for Outliers
|
---|
| 1358 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10038] | 1359 | t_irc bncComb::checkOrbits(bncTime epoTime, char sys, QTextStream& out) {
|
---|
[3487] | 1360 |
|
---|
[3489] | 1361 | const double MAX_DISPLACEMENT = 0.20;
|
---|
[3488] | 1362 |
|
---|
[3502] | 1363 | // Switch to last ephemeris (if possible)
|
---|
| 1364 | // --------------------------------------
|
---|
[9258] | 1365 | QMutableVectorIterator<cmbCorr*> im(corrs(sys));
|
---|
[3501] | 1366 | while (im.hasNext()) {
|
---|
| 1367 | cmbCorr* corr = im.next();
|
---|
[6157] | 1368 | QString prn = corr->_prn;
|
---|
[6443] | 1369 |
|
---|
[7012] | 1370 | t_eph* ephLast = _ephUser.ephLast(prn);
|
---|
| 1371 | t_eph* ephPrev = _ephUser.ephPrev(prn);
|
---|
[6443] | 1372 |
|
---|
| 1373 | if (ephLast == 0) {
|
---|
[9635] | 1374 | out << "checkOrbit: missing eph (not found) " << corr->_prn.mid(0,3) << "\n";
|
---|
[3556] | 1375 | delete corr;
|
---|
[3501] | 1376 | im.remove();
|
---|
| 1377 | }
|
---|
[6157] | 1378 | else if (corr->_eph == 0) {
|
---|
[9635] | 1379 | out << "checkOrbit: missing eph (zero) " << corr->_prn.mid(0,3) << "\n";
|
---|
[3556] | 1380 | delete corr;
|
---|
[3503] | 1381 | im.remove();
|
---|
| 1382 | }
|
---|
[3502] | 1383 | else {
|
---|
[6443] | 1384 | if ( corr->_eph == ephLast || corr->_eph == ephPrev ) {
|
---|
| 1385 | switchToLastEph(ephLast, corr);
|
---|
[3502] | 1386 | }
|
---|
| 1387 | else {
|
---|
[9635] | 1388 | out << "checkOrbit: missing eph (deleted) " << corr->_prn.mid(0,3) << "\n";
|
---|
[3556] | 1389 | delete corr;
|
---|
[3502] | 1390 | im.remove();
|
---|
| 1391 | }
|
---|
| 1392 | }
|
---|
[3501] | 1393 | }
|
---|
| 1394 |
|
---|
[3488] | 1395 | while (true) {
|
---|
| 1396 |
|
---|
| 1397 | // Compute Mean Corrections for all Satellites
|
---|
| 1398 | // -------------------------------------------
|
---|
[3489] | 1399 | QMap<QString, int> numCorr;
|
---|
[3488] | 1400 | QMap<QString, ColumnVector> meanRao;
|
---|
[9258] | 1401 | QVectorIterator<cmbCorr*> it(corrs(sys));
|
---|
[3488] | 1402 | while (it.hasNext()) {
|
---|
| 1403 | cmbCorr* corr = it.next();
|
---|
[6157] | 1404 | QString prn = corr->_prn;
|
---|
[3488] | 1405 | if (meanRao.find(prn) == meanRao.end()) {
|
---|
| 1406 | meanRao[prn].ReSize(4);
|
---|
[10038] | 1407 | meanRao[prn].Rows(1,3) = corr->_orbCorr->_xr;
|
---|
[7297] | 1408 | meanRao[prn](4) = 1;
|
---|
[3488] | 1409 | }
|
---|
| 1410 | else {
|
---|
[10038] | 1411 | meanRao[prn].Rows(1,3) += corr->_orbCorr->_xr;
|
---|
[7297] | 1412 | meanRao[prn](4) += 1;
|
---|
[3488] | 1413 | }
|
---|
[3489] | 1414 | if (numCorr.find(prn) == numCorr.end()) {
|
---|
| 1415 | numCorr[prn] = 1;
|
---|
| 1416 | }
|
---|
| 1417 | else {
|
---|
| 1418 | numCorr[prn] += 1;
|
---|
| 1419 | }
|
---|
[3487] | 1420 | }
|
---|
[7297] | 1421 |
|
---|
[9258] | 1422 | // Compute Differences wrt. Mean, find Maximum
|
---|
| 1423 | // -------------------------------------------
|
---|
[3488] | 1424 | QMap<QString, cmbCorr*> maxDiff;
|
---|
| 1425 | it.toFront();
|
---|
| 1426 | while (it.hasNext()) {
|
---|
| 1427 | cmbCorr* corr = it.next();
|
---|
[6157] | 1428 | QString prn = corr->_prn;
|
---|
[3488] | 1429 | if (meanRao[prn](4) != 0) {
|
---|
| 1430 | meanRao[prn] /= meanRao[prn](4);
|
---|
| 1431 | meanRao[prn](4) = 0;
|
---|
| 1432 | }
|
---|
[10038] | 1433 | corr->_diffRao = corr->_orbCorr->_xr - meanRao[prn].Rows(1,3);
|
---|
[3488] | 1434 | if (maxDiff.find(prn) == maxDiff.end()) {
|
---|
| 1435 | maxDiff[prn] = corr;
|
---|
| 1436 | }
|
---|
| 1437 | else {
|
---|
[8901] | 1438 | double normMax = maxDiff[prn]->_diffRao.NormFrobenius();
|
---|
| 1439 | double norm = corr->_diffRao.NormFrobenius();
|
---|
[3488] | 1440 | if (norm > normMax) {
|
---|
| 1441 | maxDiff[prn] = corr;
|
---|
| 1442 | }
|
---|
[7297] | 1443 | }
|
---|
[3487] | 1444 | }
|
---|
[7297] | 1445 |
|
---|
[3655] | 1446 | if (_ACs.size() == 1) {
|
---|
| 1447 | break;
|
---|
| 1448 | }
|
---|
| 1449 |
|
---|
[3488] | 1450 | // Remove Outliers
|
---|
| 1451 | // ---------------
|
---|
| 1452 | bool removed = false;
|
---|
[9258] | 1453 | QMutableVectorIterator<cmbCorr*> im(corrs(sys));
|
---|
[3488] | 1454 | while (im.hasNext()) {
|
---|
| 1455 | cmbCorr* corr = im.next();
|
---|
[6157] | 1456 | QString prn = corr->_prn;
|
---|
[3489] | 1457 | if (numCorr[prn] < 2) {
|
---|
[3556] | 1458 | delete corr;
|
---|
[3489] | 1459 | im.remove();
|
---|
| 1460 | }
|
---|
| 1461 | else if (corr == maxDiff[prn]) {
|
---|
[8901] | 1462 | double norm = corr->_diffRao.NormFrobenius();
|
---|
[3488] | 1463 | if (norm > MAX_DISPLACEMENT) {
|
---|
[10038] | 1464 | out << epoTime.datestr().c_str() << " "
|
---|
| 1465 | << epoTime.timestr().c_str() << " "
|
---|
[7297] | 1466 | << "Orbit Outlier: "
|
---|
[8204] | 1467 | << corr->_acName.toLatin1().data() << " "
|
---|
| 1468 | << prn.mid(0,3).toLatin1().data() << " "
|
---|
[7297] | 1469 | << corr->_iod << " "
|
---|
[9635] | 1470 | << norm << "\n";
|
---|
[3556] | 1471 | delete corr;
|
---|
[3488] | 1472 | im.remove();
|
---|
| 1473 | removed = true;
|
---|
| 1474 | }
|
---|
| 1475 | }
|
---|
[3487] | 1476 | }
|
---|
[7297] | 1477 |
|
---|
[3488] | 1478 | if (!removed) {
|
---|
| 1479 | break;
|
---|
| 1480 | }
|
---|
[3487] | 1481 | }
|
---|
| 1482 |
|
---|
| 1483 | return success;
|
---|
| 1484 | }
|
---|
[3588] | 1485 |
|
---|
[7297] | 1486 | //
|
---|
[3588] | 1487 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5583] | 1488 | void bncComb::slotProviderIDChanged(QString mountPoint) {
|
---|
| 1489 | QMutexLocker locker(&_mutex);
|
---|
| 1490 |
|
---|
[8065] | 1491 | QTextStream out(&_log, QIODevice::WriteOnly);
|
---|
| 1492 |
|
---|
[5583] | 1493 | // Find the AC Name
|
---|
| 1494 | // ----------------
|
---|
| 1495 | QString acName;
|
---|
| 1496 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 1497 | while (icAC.hasNext()) {
|
---|
[10038] | 1498 | cmbAC *AC = icAC.next();
|
---|
[5583] | 1499 | if (AC->mountPoint == mountPoint) {
|
---|
| 1500 | acName = AC->name;
|
---|
[10038] | 1501 | out << "Provider ID changed: AC " << AC->name.toLatin1().data() << " "
|
---|
[10081] | 1502 | << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
|
---|
[10038] | 1503 | << "\n";
|
---|
[5583] | 1504 | break;
|
---|
| 1505 | }
|
---|
| 1506 | }
|
---|
| 1507 | if (acName.isEmpty()) {
|
---|
| 1508 | return;
|
---|
| 1509 | }
|
---|
[9258] | 1510 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
---|
| 1511 | while (itSys.hasNext()) {
|
---|
| 1512 | itSys.next();
|
---|
| 1513 | char sys = itSys.key();
|
---|
| 1514 | // Remove all corrections of the corresponding AC
|
---|
| 1515 | // ----------------------------------------------
|
---|
[10038] | 1516 | QVector<cmbCorr*> &corrVec = _buffer[sys].corrs;
|
---|
| 1517 | QMutableVectorIterator<cmbCorr*> it(corrVec);
|
---|
| 1518 | while (it.hasNext()) {
|
---|
| 1519 | cmbCorr *corr = it.next();
|
---|
| 1520 | if (acName == corr->_acName) {
|
---|
| 1521 | delete corr;
|
---|
| 1522 | it.remove();
|
---|
[5583] | 1523 | }
|
---|
| 1524 | }
|
---|
[9258] | 1525 | // Reset Satellite Offsets
|
---|
| 1526 | // -----------------------
|
---|
| 1527 | if (_method == filter) {
|
---|
| 1528 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
[10038] | 1529 | cmbParam *pp = _params[sys][iPar - 1];
|
---|
[9258] | 1530 | if (pp->AC == acName && pp->type == cmbParam::offACSat) {
|
---|
| 1531 | pp->xx = 0.0;
|
---|
[10038] | 1532 | _QQ[sys].Row(iPar) = 0.0;
|
---|
[9258] | 1533 | _QQ[sys].Column(iPar) = 0.0;
|
---|
[10038] | 1534 | _QQ[sys](iPar, iPar) = pp->sig0 * pp->sig0;
|
---|
[9258] | 1535 | }
|
---|
[5585] | 1536 | }
|
---|
| 1537 | }
|
---|
| 1538 | }
|
---|
[5583] | 1539 | }
|
---|