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