[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 | *
|
---|
| 13 | * Changes:
|
---|
| 14 | *
|
---|
| 15 | * -----------------------------------------------------------------------*/
|
---|
| 16 |
|
---|
[2933] | 17 | #include <newmatio.h>
|
---|
[2921] | 18 | #include <iomanip>
|
---|
[3214] | 19 | #include <sstream>
|
---|
[2898] | 20 |
|
---|
| 21 | #include "bnccomb.h"
|
---|
| 22 | #include "bncapp.h"
|
---|
[3201] | 23 | #include "upload/bncrtnetdecoder.h"
|
---|
[2910] | 24 | #include "bncsettings.h"
|
---|
[2933] | 25 | #include "bncmodel.h"
|
---|
[2988] | 26 | #include "bncutils.h"
|
---|
[3027] | 27 | #include "bncpppclient.h"
|
---|
[3181] | 28 | #include "bncsp3.h"
|
---|
[3052] | 29 | #include "bncantex.h"
|
---|
[3055] | 30 | #include "bnctides.h"
|
---|
[2898] | 31 |
|
---|
[3455] | 32 | const int moduloTime = 10;
|
---|
[2898] | 33 |
|
---|
[3455] | 34 | const double sig0_offAC = 1000.0;
|
---|
| 35 | const double sig0_offACSat = 100.0;
|
---|
[3468] | 36 | const double sigP_offACSat = 0.01;
|
---|
[3455] | 37 | const double sig0_clkSat = 100.0;
|
---|
| 38 |
|
---|
| 39 | const double sigObs = 0.05;
|
---|
| 40 |
|
---|
[3483] | 41 | const int MAXPRN_GPS = 32;
|
---|
| 42 | const int MAXPRN_GLONASS = 24;
|
---|
[3134] | 43 |
|
---|
[3455] | 44 | using namespace std;
|
---|
| 45 |
|
---|
[3474] | 46 | // Auxiliary Class for Single-Differences
|
---|
| 47 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 48 | class t_sDiff {
|
---|
| 49 | public:
|
---|
| 50 | QMap<QString, double> diff;
|
---|
| 51 | };
|
---|
| 52 |
|
---|
[2898] | 53 | // Constructor
|
---|
| 54 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3429] | 55 | cmbParam::cmbParam(parType type_, int index_,
|
---|
| 56 | const QString& ac_, const QString& prn_) {
|
---|
[3032] | 57 |
|
---|
[3433] | 58 | type = type_;
|
---|
| 59 | index = index_;
|
---|
| 60 | AC = ac_;
|
---|
| 61 | prn = prn_;
|
---|
| 62 | xx = 0.0;
|
---|
[3455] | 63 | eph = 0;
|
---|
[3429] | 64 |
|
---|
[3485] | 65 | if (type == offACgps) {
|
---|
[3455] | 66 | epoSpec = true;
|
---|
| 67 | sig0 = sig0_offAC;
|
---|
| 68 | sigP = sig0;
|
---|
[3429] | 69 | }
|
---|
[3485] | 70 | else if (type == offACglo) {
|
---|
| 71 | epoSpec = true;
|
---|
| 72 | sig0 = sig0_offAC;
|
---|
| 73 | sigP = sig0;
|
---|
| 74 | }
|
---|
[3429] | 75 | else if (type == offACSat) {
|
---|
[3455] | 76 | epoSpec = false;
|
---|
| 77 | sig0 = sig0_offACSat;
|
---|
| 78 | sigP = sigP_offACSat;
|
---|
[3429] | 79 | }
|
---|
| 80 | else if (type == clkSat) {
|
---|
[3455] | 81 | epoSpec = true;
|
---|
| 82 | sig0 = sig0_clkSat;
|
---|
| 83 | sigP = sig0;
|
---|
[3429] | 84 | }
|
---|
[2933] | 85 | }
|
---|
| 86 |
|
---|
| 87 | // Destructor
|
---|
| 88 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 89 | cmbParam::~cmbParam() {
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | // Partial
|
---|
| 93 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3429] | 94 | double cmbParam::partial(const QString& AC_, const QString& prn_) {
|
---|
[2933] | 95 |
|
---|
[3485] | 96 | if (type == offACgps) {
|
---|
| 97 | if (AC == AC_ && prn_[0] == 'G') {
|
---|
[2934] | 98 | return 1.0;
|
---|
| 99 | }
|
---|
| 100 | }
|
---|
[3485] | 101 | else if (type == offACglo) {
|
---|
| 102 | if (AC == AC_ && prn_[0] == 'R') {
|
---|
| 103 | return 1.0;
|
---|
| 104 | }
|
---|
| 105 | }
|
---|
[3429] | 106 | else if (type == offACSat) {
|
---|
| 107 | if (AC == AC_ && prn == prn_) {
|
---|
[2933] | 108 | return 1.0;
|
---|
| 109 | }
|
---|
| 110 | }
|
---|
[3429] | 111 | else if (type == clkSat) {
|
---|
| 112 | if (prn == prn_) {
|
---|
[2933] | 113 | return 1.0;
|
---|
| 114 | }
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | return 0.0;
|
---|
| 118 | }
|
---|
| 119 |
|
---|
[2990] | 120 | //
|
---|
| 121 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 122 | QString cmbParam::toString() const {
|
---|
[2933] | 123 |
|
---|
[2990] | 124 | QString outStr;
|
---|
| 125 |
|
---|
[3485] | 126 | if (type == offACgps) {
|
---|
| 127 | outStr = "AC offset GPS " + AC;
|
---|
[2990] | 128 | }
|
---|
[3485] | 129 | else if (type == offACglo) {
|
---|
| 130 | outStr = "AC offset GLO " + AC;
|
---|
| 131 | }
|
---|
[3429] | 132 | else if (type == offACSat) {
|
---|
[2992] | 133 | outStr = "Sat Offset " + AC + " " + prn;
|
---|
[2990] | 134 | }
|
---|
[3429] | 135 | else if (type == clkSat) {
|
---|
[2992] | 136 | outStr = "Clk Corr " + prn;
|
---|
[2990] | 137 | }
|
---|
[2933] | 138 |
|
---|
[2990] | 139 | return outStr;
|
---|
| 140 | }
|
---|
| 141 |
|
---|
[2933] | 142 | // Constructor
|
---|
| 143 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2898] | 144 | bncComb::bncComb() {
|
---|
[2910] | 145 |
|
---|
| 146 | bncSettings settings;
|
---|
| 147 |
|
---|
| 148 | QStringList combineStreams = settings.value("combineStreams").toStringList();
|
---|
[2918] | 149 |
|
---|
[3455] | 150 | _masterMissingEpochs = 0;
|
---|
| 151 |
|
---|
[3143] | 152 | if (combineStreams.size() >= 1 && !combineStreams[0].isEmpty()) {
|
---|
[2910] | 153 | QListIterator<QString> it(combineStreams);
|
---|
| 154 | while (it.hasNext()) {
|
---|
| 155 | QStringList hlp = it.next().split(" ");
|
---|
[2918] | 156 | cmbAC* newAC = new cmbAC();
|
---|
| 157 | newAC->mountPoint = hlp[0];
|
---|
| 158 | newAC->name = hlp[1];
|
---|
| 159 | newAC->weight = hlp[2].toDouble();
|
---|
[3453] | 160 | if (_masterOrbitAC.isEmpty()) {
|
---|
| 161 | _masterOrbitAC = newAC->name;
|
---|
| 162 | }
|
---|
[3429] | 163 | _ACs.append(newAC);
|
---|
[2910] | 164 | }
|
---|
| 165 | }
|
---|
[2927] | 166 |
|
---|
[3211] | 167 | _rtnetDecoder = 0;
|
---|
[3201] | 168 |
|
---|
[2990] | 169 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
| 170 | ((bncApp*)qApp), SLOT(slotMessage(const QByteArray,bool)));
|
---|
[2933] | 171 |
|
---|
[3470] | 172 | // Combination Method
|
---|
| 173 | // ------------------
|
---|
[3481] | 174 | if (settings.value("cmbMethod").toString() == "Single-Epoch") {
|
---|
| 175 | _method = singleEpoch;
|
---|
[3470] | 176 | }
|
---|
| 177 | else {
|
---|
[3481] | 178 | _method = filter;
|
---|
[3470] | 179 | }
|
---|
[3032] | 180 |
|
---|
[3484] | 181 | // Use Glonass
|
---|
| 182 | // -----------
|
---|
| 183 | if ( Qt::CheckState(settings.value("pppGLONASS").toInt()) == Qt::Checked) {
|
---|
| 184 | _useGlonass = true;
|
---|
| 185 | }
|
---|
| 186 | else {
|
---|
| 187 | _useGlonass = false;
|
---|
| 188 | }
|
---|
| 189 |
|
---|
[3032] | 190 | // Initialize Parameters (model: Clk_Corr = AC_Offset + Sat_Offset + Clk)
|
---|
| 191 | // ----------------------------------------------------------------------
|
---|
[3470] | 192 | if (_method == filter) {
|
---|
| 193 | int nextPar = 0;
|
---|
| 194 | QListIterator<cmbAC*> it(_ACs);
|
---|
| 195 | while (it.hasNext()) {
|
---|
| 196 | cmbAC* AC = it.next();
|
---|
[3485] | 197 | _params.push_back(new cmbParam(cmbParam::offACgps, ++nextPar, AC->name, ""));
|
---|
[3470] | 198 | for (int iGps = 1; iGps <= MAXPRN_GPS; iGps++) {
|
---|
| 199 | QString prn = QString("G%1").arg(iGps, 2, 10, QChar('0'));
|
---|
| 200 | _params.push_back(new cmbParam(cmbParam::offACSat, ++nextPar,
|
---|
| 201 | AC->name, prn));
|
---|
| 202 | }
|
---|
[3483] | 203 | if (_useGlonass) {
|
---|
[3485] | 204 | _params.push_back(new cmbParam(cmbParam::offACglo, ++nextPar, AC->name, ""));
|
---|
[3483] | 205 | for (int iGlo = 1; iGlo <= MAXPRN_GLONASS; iGlo++) {
|
---|
| 206 | QString prn = QString("R%1").arg(iGlo, 2, 10, QChar('0'));
|
---|
| 207 | _params.push_back(new cmbParam(cmbParam::offACSat, ++nextPar,
|
---|
| 208 | AC->name, prn));
|
---|
| 209 | }
|
---|
| 210 | }
|
---|
[3470] | 211 | }
|
---|
[3134] | 212 | for (int iGps = 1; iGps <= MAXPRN_GPS; iGps++) {
|
---|
| 213 | QString prn = QString("G%1").arg(iGps, 2, 10, QChar('0'));
|
---|
[3470] | 214 | _params.push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
|
---|
[2991] | 215 | }
|
---|
[3483] | 216 | if (_useGlonass) {
|
---|
| 217 | for (int iGlo = 1; iGlo <= MAXPRN_GLONASS; iGlo++) {
|
---|
| 218 | QString prn = QString("R%1").arg(iGlo, 2, 10, QChar('0'));
|
---|
| 219 | _params.push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
|
---|
| 220 | }
|
---|
| 221 | }
|
---|
[3470] | 222 |
|
---|
| 223 | // Initialize Variance-Covariance Matrix
|
---|
| 224 | // -------------------------------------
|
---|
| 225 | _QQ.ReSize(_params.size());
|
---|
| 226 | _QQ = 0.0;
|
---|
| 227 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 228 | cmbParam* pp = _params[iPar-1];
|
---|
| 229 | _QQ(iPar,iPar) = pp->sig0 * pp->sig0;
|
---|
| 230 | }
|
---|
[2991] | 231 | }
|
---|
[2933] | 232 |
|
---|
[3052] | 233 | // ANTEX File
|
---|
| 234 | // ----------
|
---|
| 235 | _antex = 0;
|
---|
| 236 | QString antexFileName = settings.value("pppAntex").toString();
|
---|
| 237 | if (!antexFileName.isEmpty()) {
|
---|
| 238 | _antex = new bncAntex();
|
---|
| 239 | if (_antex->readFile(antexFileName) != success) {
|
---|
| 240 | emit newMessage("wrong ANTEX file", true);
|
---|
| 241 | delete _antex;
|
---|
| 242 | _antex = 0;
|
---|
| 243 | }
|
---|
| 244 | }
|
---|
[3138] | 245 |
|
---|
[3329] | 246 | // Maximal Residuum
|
---|
| 247 | // ----------------
|
---|
| 248 | _MAXRES = settings.value("cmbMaxres").toDouble();
|
---|
| 249 | if (_MAXRES <= 0.0) {
|
---|
| 250 | _MAXRES = 999.0;
|
---|
| 251 | }
|
---|
[2898] | 252 | }
|
---|
| 253 |
|
---|
| 254 | // Destructor
|
---|
| 255 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 256 | bncComb::~bncComb() {
|
---|
[3429] | 257 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 258 | while (icAC.hasNext()) {
|
---|
| 259 | delete icAC.next();
|
---|
[2918] | 260 | }
|
---|
[3201] | 261 | delete _rtnetDecoder;
|
---|
[3052] | 262 | delete _antex;
|
---|
[3296] | 263 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 264 | delete _params[iPar-1];
|
---|
| 265 | }
|
---|
[3434] | 266 | QVectorIterator<cmbCorr*> itCorr(corrs());
|
---|
[3429] | 267 | while (itCorr.hasNext()) {
|
---|
| 268 | delete itCorr.next();
|
---|
| 269 | }
|
---|
[2898] | 270 | }
|
---|
| 271 |
|
---|
[2928] | 272 | // Read and store one correction line
|
---|
[2898] | 273 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 274 | void bncComb::processCorrLine(const QString& staID, const QString& line) {
|
---|
[2906] | 275 | QMutexLocker locker(&_mutex);
|
---|
[2913] | 276 |
|
---|
[3431] | 277 | // Find the AC Name
|
---|
| 278 | // ----------------
|
---|
| 279 | QString acName;
|
---|
| 280 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 281 | while (icAC.hasNext()) {
|
---|
| 282 | cmbAC* AC = icAC.next();
|
---|
| 283 | if (AC->mountPoint == staID) {
|
---|
| 284 | acName = AC->name;
|
---|
| 285 | break;
|
---|
| 286 | }
|
---|
| 287 | }
|
---|
| 288 | if (acName.isEmpty()) {
|
---|
| 289 | return;
|
---|
| 290 | }
|
---|
| 291 |
|
---|
[2918] | 292 | // Read the Correction
|
---|
| 293 | // -------------------
|
---|
[3429] | 294 | cmbCorr* newCorr = new cmbCorr();
|
---|
[3431] | 295 | newCorr->acName = acName;
|
---|
[2913] | 296 | if (!newCorr->readLine(line) == success) {
|
---|
| 297 | delete newCorr;
|
---|
| 298 | return;
|
---|
| 299 | }
|
---|
| 300 |
|
---|
[3483] | 301 | // Check Glonass
|
---|
| 302 | // -------------
|
---|
| 303 | if (!_useGlonass) {
|
---|
| 304 | if (newCorr->prn[0] == 'R') {
|
---|
| 305 | delete newCorr;
|
---|
| 306 | return;
|
---|
| 307 | }
|
---|
| 308 | }
|
---|
| 309 |
|
---|
[3274] | 310 | // Check Modulo Time
|
---|
| 311 | // -----------------
|
---|
| 312 | if (int(newCorr->tt.gpssec()) % moduloTime != 0.0) {
|
---|
| 313 | delete newCorr;
|
---|
| 314 | return;
|
---|
| 315 | }
|
---|
| 316 |
|
---|
[3299] | 317 | // Delete old corrections
|
---|
| 318 | // ----------------------
|
---|
[3437] | 319 | if (_resTime.valid() && newCorr->tt <= _resTime) {
|
---|
[2924] | 320 | delete newCorr;
|
---|
| 321 | return;
|
---|
| 322 | }
|
---|
| 323 |
|
---|
[3029] | 324 | // Check the Ephemeris
|
---|
| 325 | //--------------------
|
---|
[2986] | 326 | if (_eph.find(newCorr->prn) == _eph.end()) {
|
---|
| 327 | delete newCorr;
|
---|
| 328 | return;
|
---|
| 329 | }
|
---|
| 330 | else {
|
---|
| 331 | t_eph* lastEph = _eph[newCorr->prn]->last;
|
---|
| 332 | t_eph* prevEph = _eph[newCorr->prn]->prev;
|
---|
[3029] | 333 | if (lastEph && lastEph->IOD() == newCorr->iod) {
|
---|
| 334 | newCorr->eph = lastEph;
|
---|
[2986] | 335 | }
|
---|
[3029] | 336 | else if (prevEph && prevEph->IOD() == newCorr->iod) {
|
---|
| 337 | newCorr->eph = prevEph;
|
---|
[3429] | 338 | switchToLastEph(lastEph, newCorr);
|
---|
[3029] | 339 | }
|
---|
| 340 | else {
|
---|
[2986] | 341 | delete newCorr;
|
---|
| 342 | return;
|
---|
| 343 | }
|
---|
| 344 | }
|
---|
| 345 |
|
---|
[3435] | 346 | // Process previous Epoch(s)
|
---|
| 347 | // -------------------------
|
---|
| 348 | QListIterator<bncTime> itTime(_buffer.keys());
|
---|
| 349 | while (itTime.hasNext()) {
|
---|
| 350 | bncTime epoTime = itTime.next();
|
---|
[3438] | 351 | if (epoTime < newCorr->tt - moduloTime) {
|
---|
[3435] | 352 | _resTime = epoTime;
|
---|
| 353 | processEpoch();
|
---|
| 354 | }
|
---|
[2927] | 355 | }
|
---|
| 356 |
|
---|
[3429] | 357 | // Merge or add the correction
|
---|
| 358 | // ---------------------------
|
---|
[3435] | 359 | QVector<cmbCorr*>& corrs = _buffer[newCorr->tt].corrs;
|
---|
[3429] | 360 | cmbCorr* existingCorr = 0;
|
---|
[3435] | 361 | QVectorIterator<cmbCorr*> itCorr(corrs);
|
---|
[3429] | 362 | while (itCorr.hasNext()) {
|
---|
| 363 | cmbCorr* hlp = itCorr.next();
|
---|
| 364 | if (hlp->prn == newCorr->prn && hlp->acName == newCorr->prn) {
|
---|
| 365 | existingCorr = hlp;
|
---|
[2918] | 366 | break;
|
---|
| 367 | }
|
---|
| 368 | }
|
---|
[3429] | 369 | if (existingCorr) {
|
---|
[3298] | 370 | delete newCorr;
|
---|
[3429] | 371 | existingCorr->readLine(line); // merge (multiple messages)
|
---|
[2918] | 372 | }
|
---|
[2919] | 373 | else {
|
---|
[3435] | 374 | corrs.append(newCorr);
|
---|
[2919] | 375 | }
|
---|
[2898] | 376 | }
|
---|
| 377 |
|
---|
[2986] | 378 | // Change the correction so that it refers to last received ephemeris
|
---|
| 379 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3029] | 380 | void bncComb::switchToLastEph(const t_eph* lastEph, t_corr* corr) {
|
---|
[3028] | 381 |
|
---|
[3429] | 382 | if (corr->eph == lastEph) {
|
---|
| 383 | return;
|
---|
| 384 | }
|
---|
| 385 |
|
---|
[2987] | 386 | ColumnVector oldXC(4);
|
---|
| 387 | ColumnVector oldVV(3);
|
---|
[3029] | 388 | corr->eph->position(corr->tt.gpsw(), corr->tt.gpssec(),
|
---|
| 389 | oldXC.data(), oldVV.data());
|
---|
[2988] | 390 |
|
---|
[2987] | 391 | ColumnVector newXC(4);
|
---|
| 392 | ColumnVector newVV(3);
|
---|
[3029] | 393 | lastEph->position(corr->tt.gpsw(), corr->tt.gpssec(),
|
---|
[2987] | 394 | newXC.data(), newVV.data());
|
---|
[2988] | 395 |
|
---|
| 396 | ColumnVector dX = newXC.Rows(1,3) - oldXC.Rows(1,3);
|
---|
[2989] | 397 | ColumnVector dV = newVV - oldVV;
|
---|
| 398 | double dC = newXC(4) - oldXC(4);
|
---|
| 399 |
|
---|
[2988] | 400 | ColumnVector dRAO(3);
|
---|
| 401 | XYZ_to_RSW(newXC.Rows(1,3), newVV, dX, dRAO);
|
---|
[2989] | 402 |
|
---|
| 403 | ColumnVector dDotRAO(3);
|
---|
| 404 | XYZ_to_RSW(newXC.Rows(1,3), newVV, dV, dDotRAO);
|
---|
| 405 |
|
---|
[3455] | 406 | QString msg = "switch corr " + corr->prn
|
---|
[3029] | 407 | + QString(" %1 -> %2 %3").arg(corr->iod,3)
|
---|
[3013] | 408 | .arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
|
---|
| 409 |
|
---|
[3029] | 410 | emit newMessage(msg.toAscii(), false);
|
---|
[3028] | 411 |
|
---|
[3029] | 412 | corr->iod = lastEph->IOD();
|
---|
| 413 | corr->eph = lastEph;
|
---|
[3031] | 414 | corr->rao += dRAO;
|
---|
| 415 | corr->dotRao += dDotRAO;
|
---|
[3029] | 416 | corr->dClk -= dC;
|
---|
[2986] | 417 | }
|
---|
| 418 |
|
---|
[3429] | 419 | // Process Epoch
|
---|
[2928] | 420 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3429] | 421 | void bncComb::processEpoch() {
|
---|
[2918] | 422 |
|
---|
[2990] | 423 | _log.clear();
|
---|
| 424 |
|
---|
| 425 | QTextStream out(&_log, QIODevice::WriteOnly);
|
---|
| 426 |
|
---|
[3472] | 427 | out << endl << "Combination:" << endl
|
---|
| 428 | << "------------------------------" << endl;
|
---|
[2990] | 429 |
|
---|
[3433] | 430 | // Observation Statistics
|
---|
| 431 | // ----------------------
|
---|
[3455] | 432 | bool masterPresent = false;
|
---|
[3433] | 433 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 434 | while (icAC.hasNext()) {
|
---|
| 435 | cmbAC* AC = icAC.next();
|
---|
| 436 | AC->numObs = 0;
|
---|
[3434] | 437 | QVectorIterator<cmbCorr*> itCorr(corrs());
|
---|
[3433] | 438 | while (itCorr.hasNext()) {
|
---|
| 439 | cmbCorr* corr = itCorr.next();
|
---|
| 440 | if (corr->acName == AC->name) {
|
---|
| 441 | AC->numObs += 1;
|
---|
[3453] | 442 | if (AC->name == _masterOrbitAC) {
|
---|
| 443 | masterPresent = true;
|
---|
| 444 | }
|
---|
[3433] | 445 | }
|
---|
| 446 | }
|
---|
| 447 | out << AC->name.toAscii().data() << ": " << AC->numObs << endl;
|
---|
| 448 | }
|
---|
| 449 |
|
---|
[3453] | 450 | // If Master not present, switch to another one
|
---|
| 451 | // --------------------------------------------
|
---|
[3456] | 452 | if (masterPresent) {
|
---|
| 453 | _masterMissingEpochs = 0;
|
---|
| 454 | }
|
---|
| 455 | else {
|
---|
[3455] | 456 | ++_masterMissingEpochs;
|
---|
[3459] | 457 | if (_masterMissingEpochs < 10) {
|
---|
[3457] | 458 | out << "Missing Master, Epoch skipped" << endl;
|
---|
[3455] | 459 | _buffer.remove(_resTime);
|
---|
| 460 | emit newMessage(_log, false);
|
---|
| 461 | return;
|
---|
[3453] | 462 | }
|
---|
[3455] | 463 | else {
|
---|
| 464 | _masterMissingEpochs = 0;
|
---|
| 465 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 466 | while (icAC.hasNext()) {
|
---|
| 467 | cmbAC* AC = icAC.next();
|
---|
| 468 | if (AC->numObs > 0) {
|
---|
| 469 | out << "Switching Master AC "
|
---|
| 470 | << _masterOrbitAC.toAscii().data() << " --> "
|
---|
| 471 | << AC->name.toAscii().data() << " "
|
---|
| 472 | << _resTime.datestr().c_str() << " "
|
---|
| 473 | << _resTime.timestr().c_str() << endl;
|
---|
| 474 | _masterOrbitAC = AC->name;
|
---|
| 475 | break;
|
---|
| 476 | }
|
---|
[3452] | 477 | }
|
---|
| 478 | }
|
---|
| 479 | }
|
---|
| 480 |
|
---|
[3472] | 481 | QMap<QString, t_corr*> resCorr;
|
---|
| 482 |
|
---|
| 483 | // Perform the actual Combination using selected Method
|
---|
| 484 | // ----------------------------------------------------
|
---|
| 485 | t_irc irc;
|
---|
[3475] | 486 | ColumnVector dx;
|
---|
[3472] | 487 | if (_method == filter) {
|
---|
[3475] | 488 | irc = processEpoch_filter(out, resCorr, dx);
|
---|
[3472] | 489 | }
|
---|
| 490 | else {
|
---|
[3475] | 491 | irc = processEpoch_singleEpoch(out, resCorr, dx);
|
---|
[3472] | 492 | }
|
---|
| 493 |
|
---|
[3475] | 494 | // Update Parameter Values, Print Results
|
---|
| 495 | // --------------------------------------
|
---|
[3472] | 496 | if (irc == success) {
|
---|
[3475] | 497 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 498 | cmbParam* pp = _params[iPar-1];
|
---|
| 499 | pp->xx += dx(iPar);
|
---|
| 500 | if (pp->type == cmbParam::clkSat) {
|
---|
| 501 | if (resCorr.find(pp->prn) != resCorr.end()) {
|
---|
| 502 | resCorr[pp->prn]->dClk = pp->xx / t_CST::c;
|
---|
| 503 | }
|
---|
| 504 | }
|
---|
| 505 | out << _resTime.datestr().c_str() << " "
|
---|
| 506 | << _resTime.timestr().c_str() << " ";
|
---|
| 507 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
| 508 | out.setFieldWidth(8);
|
---|
| 509 | out.setRealNumberPrecision(4);
|
---|
| 510 | out << pp->toString() << " "
|
---|
| 511 | << pp->xx << " +- " << sqrt(_QQ(pp->index,pp->index)) << endl;
|
---|
| 512 | out.setFieldWidth(0);
|
---|
| 513 | }
|
---|
[3472] | 514 | printResults(out, resCorr);
|
---|
| 515 | dumpResults(resCorr);
|
---|
| 516 | }
|
---|
| 517 |
|
---|
| 518 | // Delete Data, emit Message
|
---|
| 519 | // -------------------------
|
---|
| 520 | _buffer.remove(_resTime);
|
---|
| 521 | emit newMessage(_log, false);
|
---|
| 522 | }
|
---|
| 523 |
|
---|
| 524 | // Process Epoch - Filter Method
|
---|
| 525 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 526 | t_irc bncComb::processEpoch_filter(QTextStream& out,
|
---|
[3475] | 527 | QMap<QString, t_corr*>& resCorr,
|
---|
| 528 | ColumnVector& dx) {
|
---|
[3472] | 529 |
|
---|
[3429] | 530 | // Prediction Step
|
---|
| 531 | // ---------------
|
---|
[3472] | 532 | int nPar = _params.size();
|
---|
[2933] | 533 | ColumnVector x0(nPar);
|
---|
| 534 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
[3455] | 535 | cmbParam* pp = _params[iPar-1];
|
---|
| 536 | if (pp->epoSpec) {
|
---|
[3451] | 537 | pp->xx = 0.0;
|
---|
[3455] | 538 | _QQ.Row(iPar) = 0.0;
|
---|
| 539 | _QQ.Column(iPar) = 0.0;
|
---|
| 540 | _QQ(iPar,iPar) = pp->sig0 * pp->sig0;
|
---|
[3451] | 541 | }
|
---|
[3455] | 542 | else {
|
---|
| 543 | _QQ(iPar,iPar) += pp->sigP * pp->sigP;
|
---|
| 544 | }
|
---|
[2933] | 545 | x0(iPar) = pp->xx;
|
---|
| 546 | }
|
---|
| 547 |
|
---|
[3455] | 548 | SymmetricMatrix QQ_sav = _QQ;
|
---|
[3441] | 549 |
|
---|
[3455] | 550 | // Update and outlier detection loop
|
---|
| 551 | // ---------------------------------
|
---|
| 552 | while (true) {
|
---|
[3135] | 553 |
|
---|
[3455] | 554 | Matrix AA;
|
---|
| 555 | ColumnVector ll;
|
---|
| 556 | DiagonalMatrix PP;
|
---|
[3429] | 557 |
|
---|
[3455] | 558 | if (createAmat(AA, ll, PP, x0, resCorr) != success) {
|
---|
[3472] | 559 | return failure;
|
---|
[3441] | 560 | }
|
---|
[2933] | 561 |
|
---|
[3429] | 562 | bncModel::kalman(AA, ll, PP, _QQ, dx);
|
---|
| 563 | ColumnVector vv = ll - AA * dx;
|
---|
[3080] | 564 |
|
---|
[3429] | 565 | int maxResIndex;
|
---|
| 566 | double maxRes = vv.maximum_absolute_value1(maxResIndex);
|
---|
| 567 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
| 568 | out.setRealNumberPrecision(3);
|
---|
| 569 | out << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
|
---|
[3432] | 570 | << " Maximum Residuum " << maxRes << ' '
|
---|
[3434] | 571 | << corrs()[maxResIndex-1]->acName << ' ' << corrs()[maxResIndex-1]->prn;
|
---|
[3080] | 572 |
|
---|
[3432] | 573 | if (maxRes > _MAXRES) {
|
---|
| 574 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 575 | cmbParam* pp = _params[iPar-1];
|
---|
| 576 | if (pp->type == cmbParam::offACSat &&
|
---|
[3434] | 577 | pp->AC == corrs()[maxResIndex-1]->acName &&
|
---|
| 578 | pp->prn == corrs()[maxResIndex-1]->prn) {
|
---|
[3432] | 579 | QQ_sav.Row(iPar) = 0.0;
|
---|
| 580 | QQ_sav.Column(iPar) = 0.0;
|
---|
[3455] | 581 | QQ_sav(iPar,iPar) = pp->sig0 * pp->sig0;
|
---|
[3432] | 582 | }
|
---|
| 583 | }
|
---|
| 584 |
|
---|
| 585 | out << " Outlier" << endl;
|
---|
| 586 | _QQ = QQ_sav;
|
---|
[3455] | 587 | corrs().remove(maxResIndex-1);
|
---|
[3432] | 588 | }
|
---|
| 589 | else {
|
---|
| 590 | out << " OK" << endl;
|
---|
| 591 | break;
|
---|
| 592 | }
|
---|
| 593 | }
|
---|
| 594 |
|
---|
[3472] | 595 | return success;
|
---|
[2918] | 596 | }
|
---|
[3011] | 597 |
|
---|
[3201] | 598 | // Print results
|
---|
[3011] | 599 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3429] | 600 | void bncComb::printResults(QTextStream& out,
|
---|
[3011] | 601 | const QMap<QString, t_corr*>& resCorr) {
|
---|
| 602 |
|
---|
| 603 | QMapIterator<QString, t_corr*> it(resCorr);
|
---|
| 604 | while (it.hasNext()) {
|
---|
| 605 | it.next();
|
---|
| 606 | t_corr* corr = it.value();
|
---|
[3029] | 607 | const t_eph* eph = corr->eph;
|
---|
[3015] | 608 | if (eph) {
|
---|
| 609 | double xx, yy, zz, cc;
|
---|
[3429] | 610 | eph->position(_resTime.gpsw(), _resTime.gpssec(), xx, yy, zz, cc);
|
---|
[3015] | 611 |
|
---|
[3429] | 612 | out << _resTime.datestr().c_str() << " "
|
---|
| 613 | << _resTime.timestr().c_str() << " ";
|
---|
[3015] | 614 | out.setFieldWidth(3);
|
---|
| 615 | out << "Full Clock " << corr->prn << " " << corr->iod << " ";
|
---|
| 616 | out.setFieldWidth(14);
|
---|
| 617 | out << (cc + corr->dClk) * t_CST::c << endl;
|
---|
[3370] | 618 | out.setFieldWidth(0);
|
---|
[3015] | 619 | }
|
---|
| 620 | else {
|
---|
| 621 | out << "bncComb::printResuls bug" << endl;
|
---|
| 622 | }
|
---|
[3011] | 623 | }
|
---|
| 624 | }
|
---|
[3202] | 625 |
|
---|
| 626 | // Send results to RTNet Decoder and directly to PPP Client
|
---|
| 627 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3429] | 628 | void bncComb::dumpResults(const QMap<QString, t_corr*>& resCorr) {
|
---|
[3202] | 629 |
|
---|
[3214] | 630 | ostringstream out; out.setf(std::ios::fixed);
|
---|
[3216] | 631 | QStringList corrLines;
|
---|
[3214] | 632 |
|
---|
| 633 | unsigned year, month, day, hour, minute;
|
---|
| 634 | double sec;
|
---|
[3429] | 635 | _resTime.civil_date(year, month, day);
|
---|
| 636 | _resTime.civil_time(hour, minute, sec);
|
---|
[3214] | 637 |
|
---|
| 638 | out << "* "
|
---|
| 639 | << setw(4) << year << " "
|
---|
| 640 | << setw(2) << month << " "
|
---|
| 641 | << setw(2) << day << " "
|
---|
| 642 | << setw(2) << hour << " "
|
---|
| 643 | << setw(2) << minute << " "
|
---|
| 644 | << setw(12) << setprecision(8) << sec << " "
|
---|
| 645 | << endl;
|
---|
| 646 |
|
---|
[3202] | 647 | QMapIterator<QString, t_corr*> it(resCorr);
|
---|
| 648 | while (it.hasNext()) {
|
---|
| 649 | it.next();
|
---|
| 650 | t_corr* corr = it.value();
|
---|
| 651 |
|
---|
[3214] | 652 | double dT = 60.0;
|
---|
[3202] | 653 |
|
---|
[3214] | 654 | for (int iTime = 1; iTime <= 2; iTime++) {
|
---|
| 655 |
|
---|
[3429] | 656 | bncTime time12 = (iTime == 1) ? _resTime : _resTime + dT;
|
---|
[3214] | 657 |
|
---|
| 658 | ColumnVector xc(4);
|
---|
| 659 | ColumnVector vv(3);
|
---|
| 660 | corr->eph->position(time12.gpsw(), time12.gpssec(),
|
---|
| 661 | xc.data(), vv.data());
|
---|
| 662 | bncPPPclient::applyCorr(time12, corr, xc, vv);
|
---|
| 663 |
|
---|
| 664 | // Relativistic Correction
|
---|
| 665 | // -----------------------
|
---|
| 666 | double relCorr = - 2.0 * DotProduct(xc.Rows(1,3),vv) / t_CST::c / t_CST::c;
|
---|
| 667 | xc(4) -= relCorr;
|
---|
| 668 |
|
---|
| 669 | // Code Biases
|
---|
| 670 | // -----------
|
---|
| 671 | double dcbP1C1 = 0.0;
|
---|
| 672 | double dcbP1P2 = 0.0;
|
---|
| 673 |
|
---|
| 674 | // Correction Phase Center --> CoM
|
---|
| 675 | // -------------------------------
|
---|
| 676 | ColumnVector dx(3); dx = 0.0;
|
---|
| 677 | if (_antex) {
|
---|
| 678 | double Mjd = time12.mjd() + time12.daysec()/86400.0;
|
---|
| 679 | if (_antex->satCoMcorrection(corr->prn, Mjd, xc.Rows(1,3), dx) == success) {
|
---|
| 680 | xc(1) -= dx(1);
|
---|
| 681 | xc(2) -= dx(2);
|
---|
| 682 | xc(3) -= dx(3);
|
---|
| 683 | }
|
---|
| 684 | else {
|
---|
| 685 | cout << "antenna not found" << endl;
|
---|
| 686 | }
|
---|
| 687 | }
|
---|
| 688 |
|
---|
| 689 | if (iTime == 1) {
|
---|
| 690 | out << 'P' << corr->prn.toAscii().data()
|
---|
| 691 | << setw(14) << setprecision(6) << xc(1) / 1000.0
|
---|
| 692 | << setw(14) << setprecision(6) << xc(2) / 1000.0
|
---|
| 693 | << setw(14) << setprecision(6) << xc(3) / 1000.0
|
---|
| 694 | << setw(14) << setprecision(6) << xc(4) * 1e6
|
---|
| 695 | << setw(14) << setprecision(6) << relCorr * 1e6
|
---|
| 696 | << setw(8) << setprecision(3) << dx(1)
|
---|
| 697 | << setw(8) << setprecision(3) << dx(2)
|
---|
| 698 | << setw(8) << setprecision(3) << dx(3)
|
---|
| 699 | << setw(8) << setprecision(3) << dcbP1C1
|
---|
| 700 | << setw(8) << setprecision(3) << dcbP1P2
|
---|
| 701 | << setw(6) << setprecision(1) << dT;
|
---|
[3216] | 702 |
|
---|
[3218] | 703 | QString line;
|
---|
[3217] | 704 | int messageType = COTYPE_GPSCOMBINED;
|
---|
[3218] | 705 | int updateInt = 0;
|
---|
| 706 | line.sprintf("%d %d %d %.1f %s"
|
---|
| 707 | " %3d"
|
---|
| 708 | " %8.3f %8.3f %8.3f %8.3f"
|
---|
| 709 | " %10.5f %10.5f %10.5f %10.5f"
|
---|
[3262] | 710 | " %10.5f %10.5f %10.5f %10.5f INTERNAL",
|
---|
[3218] | 711 | messageType, updateInt, time12.gpsw(), time12.gpssec(),
|
---|
| 712 | corr->prn.toAscii().data(),
|
---|
| 713 | corr->iod,
|
---|
[3219] | 714 | corr->dClk * t_CST::c,
|
---|
[3218] | 715 | corr->rao[0],
|
---|
| 716 | corr->rao[1],
|
---|
| 717 | corr->rao[2],
|
---|
[3219] | 718 | corr->dotDClk * t_CST::c,
|
---|
[3218] | 719 | corr->dotRao[0],
|
---|
| 720 | corr->dotRao[1],
|
---|
| 721 | corr->dotRao[2],
|
---|
[3262] | 722 | corr->dotDotDClk * t_CST::c,
|
---|
| 723 | corr->dotDotRao[0],
|
---|
| 724 | corr->dotDotRao[1],
|
---|
| 725 | corr->dotDotRao[2]);
|
---|
[3220] | 726 | corrLines << line;
|
---|
[3214] | 727 | }
|
---|
| 728 | else {
|
---|
| 729 | out << setw(14) << setprecision(6) << xc(1) / 1000.0
|
---|
| 730 | << setw(14) << setprecision(6) << xc(2) / 1000.0
|
---|
| 731 | << setw(14) << setprecision(6) << xc(3) / 1000.0 << endl;
|
---|
| 732 | }
|
---|
| 733 | }
|
---|
| 734 |
|
---|
| 735 | delete corr;
|
---|
| 736 | }
|
---|
[3228] | 737 | out << "EOE" << endl; // End Of Epoch flag
|
---|
[3214] | 738 |
|
---|
[3215] | 739 | if (!_rtnetDecoder) {
|
---|
| 740 | _rtnetDecoder = new bncRtnetDecoder();
|
---|
| 741 | }
|
---|
[3221] | 742 |
|
---|
[3215] | 743 | vector<string> errmsg;
|
---|
[3221] | 744 | _rtnetDecoder->Decode((char*) out.str().data(), out.str().size(), errmsg);
|
---|
[3215] | 745 |
|
---|
[3216] | 746 | // Optionally send new Corrections to PPP
|
---|
| 747 | // --------------------------------------
|
---|
| 748 | bncApp* app = (bncApp*) qApp;
|
---|
| 749 | if (app->_bncPPPclient) {
|
---|
| 750 | app->_bncPPPclient->slotNewCorrections(corrLines);
|
---|
| 751 | }
|
---|
[3202] | 752 | }
|
---|
[3455] | 753 |
|
---|
| 754 | // Create First Design Matrix and Vector of Measurements
|
---|
| 755 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 756 | t_irc bncComb::createAmat(Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
|
---|
| 757 | const ColumnVector& x0,
|
---|
| 758 | QMap<QString, t_corr*>& resCorr) {
|
---|
| 759 |
|
---|
| 760 | unsigned nPar = _params.size();
|
---|
| 761 | unsigned nObs = corrs().size();
|
---|
| 762 |
|
---|
| 763 | if (nObs == 0) {
|
---|
| 764 | return failure;
|
---|
| 765 | }
|
---|
| 766 |
|
---|
[3483] | 767 | int MAXPRN = MAXPRN_GPS;
|
---|
[3486] | 768 | // if (_useGlonass) {
|
---|
| 769 | // MAXPRN = MAXPRN_GPS + MAXPRN_GLONASS;
|
---|
| 770 | // }
|
---|
[3455] | 771 |
|
---|
[3483] | 772 | const int nCon = (_method == filter) ? 1 + MAXPRN : 0;
|
---|
| 773 |
|
---|
[3455] | 774 | AA.ReSize(nObs+nCon, nPar); AA = 0.0;
|
---|
| 775 | ll.ReSize(nObs+nCon); ll = 0.0;
|
---|
| 776 | PP.ReSize(nObs+nCon); PP = 1.0 / (sigObs * sigObs);
|
---|
| 777 |
|
---|
| 778 | int iObs = 0;
|
---|
| 779 |
|
---|
| 780 | QVectorIterator<cmbCorr*> itCorr(corrs());
|
---|
| 781 | while (itCorr.hasNext()) {
|
---|
| 782 | cmbCorr* corr = itCorr.next();
|
---|
| 783 | QString prn = corr->prn;
|
---|
| 784 | switchToLastEph(_eph[prn]->last, corr);
|
---|
| 785 | ++iObs;
|
---|
| 786 |
|
---|
[3476] | 787 | if (corr->acName == _masterOrbitAC && resCorr.find(prn) == resCorr.end()) {
|
---|
| 788 | resCorr[prn] = new t_corr(*corr);
|
---|
[3455] | 789 | }
|
---|
| 790 |
|
---|
| 791 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 792 | cmbParam* pp = _params[iPar-1];
|
---|
| 793 | AA(iObs, iPar) = pp->partial(corr->acName, prn);
|
---|
| 794 | }
|
---|
| 795 |
|
---|
| 796 | ll(iObs) = corr->dClk * t_CST::c - DotProduct(AA.Row(iObs), x0);
|
---|
| 797 | }
|
---|
| 798 |
|
---|
| 799 | // Regularization
|
---|
| 800 | // --------------
|
---|
[3474] | 801 | if (_method == filter) {
|
---|
| 802 | const double Ph = 1.e6;
|
---|
| 803 | PP(nObs+1) = Ph;
|
---|
[3461] | 804 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 805 | cmbParam* pp = _params[iPar-1];
|
---|
[3465] | 806 | if ( AA.Column(iPar).maximum_absolute_value() > 0.0 &&
|
---|
[3474] | 807 | pp->type == cmbParam::clkSat ) {
|
---|
| 808 | AA(nObs+1, iPar) = 1.0;
|
---|
[3455] | 809 | }
|
---|
| 810 | }
|
---|
[3474] | 811 | int iCond = 1;
|
---|
| 812 | for (int iGps = 1; iGps <= MAXPRN_GPS; iGps++) {
|
---|
| 813 | QString prn = QString("G%1").arg(iGps, 2, 10, QChar('0'));
|
---|
| 814 | ++iCond;
|
---|
| 815 | PP(nObs+iCond) = Ph;
|
---|
| 816 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 817 | cmbParam* pp = _params[iPar-1];
|
---|
| 818 | if ( AA.Column(iPar).maximum_absolute_value() > 0.0 &&
|
---|
| 819 | pp->type == cmbParam::offACSat &&
|
---|
| 820 | pp->prn == prn) {
|
---|
| 821 | AA(nObs+iCond, iPar) = 1.0;
|
---|
| 822 | }
|
---|
| 823 | }
|
---|
| 824 | }
|
---|
[3486] | 825 | // if (_useGlonass) {
|
---|
| 826 | // for (int iGlo = 1; iGlo <= MAXPRN_GLONASS; iGlo++) {
|
---|
| 827 | // QString prn = QString("R%1").arg(iGlo, 2, 10, QChar('0'));
|
---|
| 828 | // ++iCond;
|
---|
| 829 | // PP(nObs+iCond) = Ph;
|
---|
| 830 | // for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 831 | // cmbParam* pp = _params[iPar-1];
|
---|
| 832 | // if ( AA.Column(iPar).maximum_absolute_value() > 0.0 &&
|
---|
| 833 | // pp->type == cmbParam::offACSat &&
|
---|
| 834 | // pp->prn == prn) {
|
---|
| 835 | // AA(nObs+iCond, iPar) = 1.0;
|
---|
| 836 | // }
|
---|
| 837 | // }
|
---|
| 838 | // }
|
---|
| 839 | // }
|
---|
[3455] | 840 | }
|
---|
| 841 |
|
---|
| 842 | return success;
|
---|
| 843 | }
|
---|
[3470] | 844 |
|
---|
| 845 | // Process Epoch - Single-Epoch Method
|
---|
| 846 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3472] | 847 | t_irc bncComb::processEpoch_singleEpoch(QTextStream& out,
|
---|
[3475] | 848 | QMap<QString, t_corr*>& resCorr,
|
---|
| 849 | ColumnVector& dx) {
|
---|
[3470] | 850 |
|
---|
[3482] | 851 | // Outlier Detection Loop
|
---|
| 852 | // ----------------------
|
---|
| 853 | while (true) {
|
---|
| 854 |
|
---|
| 855 | // Remove Satellites that are not in Master
|
---|
| 856 | // ----------------------------------------
|
---|
| 857 | QMutableVectorIterator<cmbCorr*> it(corrs());
|
---|
| 858 | while (it.hasNext()) {
|
---|
| 859 | cmbCorr* corr = it.next();
|
---|
| 860 | QString prn = corr->prn;
|
---|
| 861 | bool foundMaster = false;
|
---|
| 862 | QVectorIterator<cmbCorr*> itHlp(corrs());
|
---|
| 863 | while (itHlp.hasNext()) {
|
---|
| 864 | cmbCorr* corrHlp = itHlp.next();
|
---|
| 865 | QString prnHlp = corrHlp->prn;
|
---|
| 866 | QString ACHlp = corrHlp->acName;
|
---|
| 867 | if (ACHlp == _masterOrbitAC && prn == prnHlp) {
|
---|
| 868 | foundMaster = true;
|
---|
| 869 | break;
|
---|
| 870 | }
|
---|
[3476] | 871 | }
|
---|
[3482] | 872 | if (!foundMaster) {
|
---|
| 873 | it.remove();
|
---|
| 874 | }
|
---|
[3473] | 875 | }
|
---|
[3482] | 876 |
|
---|
| 877 | // Count Number of Observations per Satellite and per AC
|
---|
| 878 | // -----------------------------------------------------
|
---|
| 879 | QMap<QString, int> numObsPrn;
|
---|
| 880 | QMap<QString, int> numObsAC;
|
---|
| 881 | QVectorIterator<cmbCorr*> itCorr(corrs());
|
---|
| 882 | while (itCorr.hasNext()) {
|
---|
| 883 | cmbCorr* corr = itCorr.next();
|
---|
| 884 | QString prn = corr->prn;
|
---|
| 885 | QString AC = corr->acName;
|
---|
| 886 | if (numObsPrn.find(prn) == numObsPrn.end()) {
|
---|
| 887 | numObsPrn[prn] = 1;
|
---|
| 888 | }
|
---|
| 889 | else {
|
---|
| 890 | numObsPrn[prn] += 1;
|
---|
| 891 | }
|
---|
| 892 | if (numObsAC.find(AC) == numObsAC.end()) {
|
---|
| 893 | numObsAC[AC] = 1;
|
---|
| 894 | }
|
---|
| 895 | else {
|
---|
| 896 | numObsAC[AC] += 1;
|
---|
| 897 | }
|
---|
[3476] | 898 | }
|
---|
[3482] | 899 |
|
---|
| 900 | // Clean-Up the Paramters
|
---|
| 901 | // ----------------------
|
---|
| 902 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 903 | delete _params[iPar-1];
|
---|
[3474] | 904 | }
|
---|
[3482] | 905 | _params.clear();
|
---|
| 906 |
|
---|
| 907 | // Set new Parameters
|
---|
| 908 | // ------------------
|
---|
| 909 | int nextPar = 0;
|
---|
| 910 |
|
---|
| 911 | QMapIterator<QString, int> itAC(numObsAC);
|
---|
| 912 | while (itAC.hasNext()) {
|
---|
| 913 | itAC.next();
|
---|
| 914 | const QString& AC = itAC.key();
|
---|
| 915 | int numObs = itAC.value();
|
---|
| 916 | if (AC != _masterOrbitAC && numObs > 0) {
|
---|
[3485] | 917 | _params.push_back(new cmbParam(cmbParam::offACgps, ++nextPar, AC, ""));
|
---|
| 918 | if (_useGlonass) {
|
---|
| 919 | _params.push_back(new cmbParam(cmbParam::offACglo, ++nextPar, AC, ""));
|
---|
| 920 | }
|
---|
[3482] | 921 | }
|
---|
| 922 | }
|
---|
| 923 |
|
---|
| 924 | QMapIterator<QString, int> itPrn(numObsPrn);
|
---|
| 925 | while (itPrn.hasNext()) {
|
---|
| 926 | itPrn.next();
|
---|
| 927 | const QString& prn = itPrn.key();
|
---|
| 928 | int numObs = itPrn.value();
|
---|
| 929 | if (numObs > 0) {
|
---|
| 930 | _params.push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
|
---|
| 931 | }
|
---|
| 932 | }
|
---|
| 933 |
|
---|
| 934 | int nPar = _params.size();
|
---|
| 935 | ColumnVector x0(nPar);
|
---|
| 936 | x0 = 0.0;
|
---|
| 937 |
|
---|
| 938 | // Create First-Design Matrix
|
---|
| 939 | // --------------------------
|
---|
| 940 | Matrix AA;
|
---|
| 941 | ColumnVector ll;
|
---|
| 942 | DiagonalMatrix PP;
|
---|
| 943 | if (createAmat(AA, ll, PP, x0, resCorr) != success) {
|
---|
| 944 | return failure;
|
---|
[3476] | 945 | }
|
---|
[3482] | 946 |
|
---|
| 947 | ColumnVector vv;
|
---|
| 948 | try {
|
---|
| 949 | Matrix ATP = AA.t() * PP;
|
---|
| 950 | SymmetricMatrix NN; NN << ATP * AA;
|
---|
| 951 | ColumnVector bb = ATP * ll;
|
---|
| 952 | _QQ = NN.i();
|
---|
| 953 | dx = _QQ * bb;
|
---|
| 954 | vv = ll - AA * dx;
|
---|
[3476] | 955 | }
|
---|
[3482] | 956 | catch (Exception& exc) {
|
---|
| 957 | out << exc.what() << endl;
|
---|
| 958 | return failure;
|
---|
[3476] | 959 | }
|
---|
[3474] | 960 |
|
---|
[3482] | 961 | int maxResIndex;
|
---|
| 962 | double maxRes = vv.maximum_absolute_value1(maxResIndex);
|
---|
| 963 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
| 964 | out.setRealNumberPrecision(3);
|
---|
| 965 | out << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
|
---|
| 966 | << " Maximum Residuum " << maxRes << ' '
|
---|
| 967 | << corrs()[maxResIndex-1]->acName << ' ' << corrs()[maxResIndex-1]->prn;
|
---|
[3474] | 968 |
|
---|
[3482] | 969 | if (maxRes > _MAXRES) {
|
---|
| 970 | out << " Outlier" << endl;
|
---|
| 971 | corrs().remove(maxResIndex-1);
|
---|
[3474] | 972 | }
|
---|
[3482] | 973 | else {
|
---|
| 974 | out << " OK" << endl;
|
---|
| 975 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
| 976 | out.setRealNumberPrecision(3);
|
---|
| 977 | for (int ii = 0; ii < vv.Nrows(); ii++) {
|
---|
| 978 | const cmbCorr* corr = corrs()[ii];
|
---|
| 979 | out << _resTime.datestr().c_str() << ' '
|
---|
| 980 | << _resTime.timestr().c_str() << " "
|
---|
| 981 | << corr->acName << ' ' << corr->prn;
|
---|
| 982 | out.setFieldWidth(6);
|
---|
| 983 | out << " dClk = " << corr->dClk * t_CST::c << " res = " << vv[ii] << endl;
|
---|
| 984 | out.setFieldWidth(0);
|
---|
| 985 | }
|
---|
| 986 | return success;
|
---|
[3474] | 987 | }
|
---|
| 988 |
|
---|
[3473] | 989 | }
|
---|
[3474] | 990 |
|
---|
[3482] | 991 | return failure;
|
---|
[3470] | 992 | }
|
---|