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