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