[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 | }
|
---|
[9695] | 364 |
|
---|
| 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 | }
|
---|
[9676] | 602 | //cout << acName.toStdString() << " " << clkCorr._prn.toString().c_str() << " _codeBiasIF: " << newCorr->_codeBiasIF << endl;
|
---|
[9635] | 603 | }
|
---|
| 604 |
|
---|
[6155] | 605 | // Store correction into the buffer
|
---|
| 606 | // --------------------------------
|
---|
[9258] | 607 | QVector<cmbCorr*>& corrs = _buffer[sys][newCorr->_time].corrs;
|
---|
[6155] | 608 | corrs.push_back(newCorr);
|
---|
[2986] | 609 | }
|
---|
| 610 |
|
---|
[3435] | 611 | // Process previous Epoch(s)
|
---|
| 612 | // -------------------------
|
---|
[7392] | 613 | const double outWait = 1.0 * _cmbSampl;
|
---|
[9258] | 614 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
---|
| 615 | while (itSys.hasNext()) {
|
---|
| 616 | itSys.next();
|
---|
| 617 | char sys = itSys.key();
|
---|
| 618 | QListIterator<bncTime> itTime(_buffer[sys].keys());
|
---|
| 619 | while (itTime.hasNext()) {
|
---|
| 620 | bncTime epoTime = itTime.next();
|
---|
| 621 | if (epoTime < lastTime - outWait) {
|
---|
| 622 | _resTime = epoTime;
|
---|
| 623 | processEpoch(sys);
|
---|
| 624 | }
|
---|
[3435] | 625 | }
|
---|
[2927] | 626 | }
|
---|
[2898] | 627 | }
|
---|
| 628 |
|
---|
[7297] | 629 | // Change the correction so that it refers to last received ephemeris
|
---|
[2986] | 630 | ////////////////////////////////////////////////////////////////////////////
|
---|
[7012] | 631 | void bncComb::switchToLastEph(t_eph* lastEph, cmbCorr* corr) {
|
---|
[3028] | 632 |
|
---|
[6155] | 633 | if (corr->_eph == lastEph) {
|
---|
[3429] | 634 | return;
|
---|
| 635 | }
|
---|
[9266] | 636 |
|
---|
[8542] | 637 | ColumnVector oldXC(6);
|
---|
[2987] | 638 | ColumnVector oldVV(3);
|
---|
[9266] | 639 | if (corr->_eph->getCrd(corr->_time, oldXC, oldVV, false) != success) {
|
---|
| 640 | return;
|
---|
| 641 | }
|
---|
[2988] | 642 |
|
---|
[8542] | 643 | ColumnVector newXC(6);
|
---|
[2987] | 644 | ColumnVector newVV(3);
|
---|
[9266] | 645 | if (lastEph->getCrd(corr->_time, newXC, newVV, false) != success) {
|
---|
| 646 | return;
|
---|
| 647 | }
|
---|
[2988] | 648 |
|
---|
| 649 | ColumnVector dX = newXC.Rows(1,3) - oldXC.Rows(1,3);
|
---|
[2989] | 650 | ColumnVector dV = newVV - oldVV;
|
---|
| 651 | double dC = newXC(4) - oldXC(4);
|
---|
[9266] | 652 |
|
---|
[2988] | 653 | ColumnVector dRAO(3);
|
---|
| 654 | XYZ_to_RSW(newXC.Rows(1,3), newVV, dX, dRAO);
|
---|
[2989] | 655 |
|
---|
| 656 | ColumnVector dDotRAO(3);
|
---|
| 657 | XYZ_to_RSW(newXC.Rows(1,3), newVV, dV, dDotRAO);
|
---|
| 658 |
|
---|
[6963] | 659 | QString msg = "switch corr " + corr->_prn.mid(0,3)
|
---|
[6155] | 660 | + QString(" %1 -> %2 %3").arg(corr->_iod,3).arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
|
---|
[3013] | 661 |
|
---|
[8204] | 662 | emit newMessage(msg.toLatin1(), false);
|
---|
[3028] | 663 |
|
---|
[6155] | 664 | corr->_iod = lastEph->IOD();
|
---|
| 665 | corr->_eph = lastEph;
|
---|
| 666 |
|
---|
[6159] | 667 | corr->_orbCorr._xr += dRAO;
|
---|
| 668 | corr->_orbCorr._dotXr += dDotRAO;
|
---|
| 669 | corr->_clkCorr._dClk -= dC;
|
---|
[2986] | 670 | }
|
---|
| 671 |
|
---|
[3429] | 672 | // Process Epoch
|
---|
[2928] | 673 | ////////////////////////////////////////////////////////////////////////////
|
---|
[9258] | 674 | void bncComb::processEpoch(char sys) {
|
---|
[2918] | 675 |
|
---|
[2990] | 676 | _log.clear();
|
---|
| 677 |
|
---|
| 678 | QTextStream out(&_log, QIODevice::WriteOnly);
|
---|
| 679 |
|
---|
[9635] | 680 | out << "\n" << "Combination: " << sys << "\n"
|
---|
| 681 | << "--------------------------------" << "\n";
|
---|
[2990] | 682 |
|
---|
[3433] | 683 | // Observation Statistics
|
---|
| 684 | // ----------------------
|
---|
[3455] | 685 | bool masterPresent = false;
|
---|
[3433] | 686 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 687 | while (icAC.hasNext()) {
|
---|
| 688 | cmbAC* AC = icAC.next();
|
---|
[9258] | 689 | AC->numObs[sys] = 0;
|
---|
| 690 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
---|
[3433] | 691 | while (itCorr.hasNext()) {
|
---|
| 692 | cmbCorr* corr = itCorr.next();
|
---|
[6157] | 693 | if (corr->_acName == AC->name) {
|
---|
[9258] | 694 | AC->numObs[sys] += 1;
|
---|
| 695 | if (AC->name == _masterOrbitAC[sys]) {
|
---|
[3453] | 696 | masterPresent = true;
|
---|
| 697 | }
|
---|
[3433] | 698 | }
|
---|
| 699 | }
|
---|
[9635] | 700 | out << AC->name.toLatin1().data() << ": " << AC->numObs[sys] << "\n";
|
---|
[3433] | 701 | }
|
---|
| 702 |
|
---|
[3453] | 703 | // If Master not present, switch to another one
|
---|
| 704 | // --------------------------------------------
|
---|
[4889] | 705 | const unsigned switchMasterAfterGap = 1;
|
---|
[3456] | 706 | if (masterPresent) {
|
---|
[9258] | 707 | _masterMissingEpochs[sys] = 0;
|
---|
[3456] | 708 | }
|
---|
| 709 | else {
|
---|
[9258] | 710 | ++_masterMissingEpochs[sys];
|
---|
| 711 | if (_masterMissingEpochs[sys] < switchMasterAfterGap) {
|
---|
[9635] | 712 | out << "Missing Master, Epoch skipped" << "\n";
|
---|
[9258] | 713 | _buffer[sys].remove(_resTime);
|
---|
[3455] | 714 | emit newMessage(_log, false);
|
---|
| 715 | return;
|
---|
[3453] | 716 | }
|
---|
[3455] | 717 | else {
|
---|
[9258] | 718 | _masterMissingEpochs[sys] = 0;
|
---|
[3455] | 719 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 720 | while (icAC.hasNext()) {
|
---|
| 721 | cmbAC* AC = icAC.next();
|
---|
[9258] | 722 | if (AC->numObs[sys] > 0) {
|
---|
[3455] | 723 | out << "Switching Master AC "
|
---|
[9258] | 724 | << _masterOrbitAC[sys].toLatin1().data() << " --> "
|
---|
[8204] | 725 | << AC->name.toLatin1().data() << " "
|
---|
[7297] | 726 | << _resTime.datestr().c_str() << " "
|
---|
[9635] | 727 | << _resTime.timestr().c_str() << "\n";
|
---|
[9258] | 728 | _masterOrbitAC[sys] = AC->name;
|
---|
[3455] | 729 | break;
|
---|
| 730 | }
|
---|
[3452] | 731 | }
|
---|
| 732 | }
|
---|
| 733 | }
|
---|
| 734 |
|
---|
[6157] | 735 | QMap<QString, cmbCorr*> resCorr;
|
---|
[3472] | 736 |
|
---|
| 737 | // Perform the actual Combination using selected Method
|
---|
| 738 | // ----------------------------------------------------
|
---|
| 739 | t_irc irc;
|
---|
[3475] | 740 | ColumnVector dx;
|
---|
[3472] | 741 | if (_method == filter) {
|
---|
[9258] | 742 | irc = processEpoch_filter(sys, out, resCorr, dx);
|
---|
[3472] | 743 | }
|
---|
| 744 | else {
|
---|
[9258] | 745 | irc = processEpoch_singleEpoch(sys, out, resCorr, dx);
|
---|
[3472] | 746 | }
|
---|
| 747 |
|
---|
[3475] | 748 | // Update Parameter Values, Print Results
|
---|
| 749 | // --------------------------------------
|
---|
[3472] | 750 | if (irc == success) {
|
---|
[9258] | 751 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 752 | cmbParam* pp = _params[sys][iPar-1];
|
---|
[3475] | 753 | pp->xx += dx(iPar);
|
---|
| 754 | if (pp->type == cmbParam::clkSat) {
|
---|
| 755 | if (resCorr.find(pp->prn) != resCorr.end()) {
|
---|
[9676] | 756 | // set clock result
|
---|
[6160] | 757 | resCorr[pp->prn]->_dClkResult = pp->xx / t_CST::c;
|
---|
[9676] | 758 | // Add Code Biases from SINEX File
|
---|
| 759 | if (_bsx) {
|
---|
| 760 | map<t_frequency::type, double> codeCoeff;
|
---|
| 761 | double channel = double(resCorr[pp->prn]->_eph->slotNum());
|
---|
| 762 | cmbRefSig::coeff(sys, cmbRefSig::cIF, channel, codeCoeff);
|
---|
| 763 | t_frequency::type fType1 = cmbRefSig::toFreq(sys, cmbRefSig::c1);
|
---|
| 764 | t_frequency::type fType2 = cmbRefSig::toFreq(sys, cmbRefSig::c2);
|
---|
| 765 | _bsx->determineSsrSatCodeBiases(pp->prn.mid(0,3), codeCoeff[fType1], codeCoeff[fType2], resCorr[pp->prn]->_satCodeBias);
|
---|
| 766 | }
|
---|
[3475] | 767 | }
|
---|
| 768 | }
|
---|
[7297] | 769 | out << _resTime.datestr().c_str() << " "
|
---|
[3475] | 770 | << _resTime.timestr().c_str() << " ";
|
---|
| 771 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
| 772 | out.setFieldWidth(8);
|
---|
| 773 | out.setRealNumberPrecision(4);
|
---|
[9258] | 774 | out << pp->toString(sys) << " "
|
---|
[9635] | 775 | << pp->xx << " +- " << sqrt(_QQ[sys](pp->index,pp->index)) << "\n";
|
---|
[3475] | 776 | out.setFieldWidth(0);
|
---|
| 777 | }
|
---|
[3472] | 778 | printResults(out, resCorr);
|
---|
| 779 | dumpResults(resCorr);
|
---|
| 780 | }
|
---|
| 781 |
|
---|
| 782 | // Delete Data, emit Message
|
---|
| 783 | // -------------------------
|
---|
[9258] | 784 | _buffer[sys].remove(_resTime);
|
---|
[3472] | 785 | emit newMessage(_log, false);
|
---|
| 786 | }
|
---|
| 787 |
|
---|
| 788 | // Process Epoch - Filter Method
|
---|
| 789 | ////////////////////////////////////////////////////////////////////////////
|
---|
[9258] | 790 | t_irc bncComb::processEpoch_filter(char sys, QTextStream& out,
|
---|
[6157] | 791 | QMap<QString, cmbCorr*>& resCorr,
|
---|
[3475] | 792 | ColumnVector& dx) {
|
---|
[3472] | 793 |
|
---|
[3429] | 794 | // Prediction Step
|
---|
| 795 | // ---------------
|
---|
[9258] | 796 | int nPar = _params[sys].size();
|
---|
[2933] | 797 | ColumnVector x0(nPar);
|
---|
[9258] | 798 | for (int iPar = 1; iPar <= nPar; iPar++) {
|
---|
| 799 | cmbParam* pp = _params[sys][iPar-1];
|
---|
[3455] | 800 | if (pp->epoSpec) {
|
---|
[3451] | 801 | pp->xx = 0.0;
|
---|
[9258] | 802 | _QQ[sys].Row(iPar) = 0.0;
|
---|
| 803 | _QQ[sys].Column(iPar) = 0.0;
|
---|
| 804 | _QQ[sys](iPar,iPar) = pp->sig0 * pp->sig0;
|
---|
[3451] | 805 | }
|
---|
[3455] | 806 | else {
|
---|
[9258] | 807 | _QQ[sys](iPar,iPar) += pp->sigP * pp->sigP;
|
---|
[3455] | 808 | }
|
---|
[2933] | 809 | x0(iPar) = pp->xx;
|
---|
| 810 | }
|
---|
| 811 |
|
---|
[3487] | 812 | // Check Satellite Positions for Outliers
|
---|
| 813 | // --------------------------------------
|
---|
[9258] | 814 | if (checkOrbits(sys, out) != success) {
|
---|
[3487] | 815 | return failure;
|
---|
| 816 | }
|
---|
[3441] | 817 |
|
---|
[3455] | 818 | // Update and outlier detection loop
|
---|
| 819 | // ---------------------------------
|
---|
[9258] | 820 | SymmetricMatrix QQ_sav = _QQ[sys];
|
---|
[3455] | 821 | while (true) {
|
---|
[3135] | 822 |
|
---|
[3455] | 823 | Matrix AA;
|
---|
| 824 | ColumnVector ll;
|
---|
| 825 | DiagonalMatrix PP;
|
---|
[3429] | 826 |
|
---|
[9258] | 827 | if (createAmat(sys, AA, ll, PP, x0, resCorr) != success) {
|
---|
[3472] | 828 | return failure;
|
---|
[3441] | 829 | }
|
---|
[2933] | 830 |
|
---|
[6169] | 831 | dx.ReSize(nPar); dx = 0.0;
|
---|
[9258] | 832 | kalman(AA, ll, PP, _QQ[sys], dx);
|
---|
[6164] | 833 |
|
---|
[3429] | 834 | ColumnVector vv = ll - AA * dx;
|
---|
[3080] | 835 |
|
---|
[3429] | 836 | int maxResIndex;
|
---|
[7297] | 837 | double maxRes = vv.maximum_absolute_value1(maxResIndex);
|
---|
[3429] | 838 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
[7297] | 839 | out.setRealNumberPrecision(3);
|
---|
[3429] | 840 | out << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
|
---|
[3432] | 841 | << " Maximum Residuum " << maxRes << ' '
|
---|
[9258] | 842 | << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
|
---|
[3432] | 843 | if (maxRes > _MAXRES) {
|
---|
[9258] | 844 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 845 | cmbParam* pp = _params[sys][iPar-1];
|
---|
[7297] | 846 | if (pp->type == cmbParam::offACSat &&
|
---|
[9258] | 847 | pp->AC == corrs(sys)[maxResIndex-1]->_acName &&
|
---|
| 848 | pp->prn == corrs(sys)[maxResIndex-1]->_prn.mid(0,3)) {
|
---|
[3432] | 849 | QQ_sav.Row(iPar) = 0.0;
|
---|
| 850 | QQ_sav.Column(iPar) = 0.0;
|
---|
[3455] | 851 | QQ_sav(iPar,iPar) = pp->sig0 * pp->sig0;
|
---|
[3432] | 852 | }
|
---|
| 853 | }
|
---|
| 854 |
|
---|
[9635] | 855 | out << " Outlier" << "\n";
|
---|
[9258] | 856 | _QQ[sys] = QQ_sav;
|
---|
| 857 | corrs(sys).remove(maxResIndex-1);
|
---|
[3432] | 858 | }
|
---|
| 859 | else {
|
---|
[9635] | 860 | out << " OK" << "\n";
|
---|
[6330] | 861 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
| 862 | out.setRealNumberPrecision(4);
|
---|
[9258] | 863 | for (int ii = 0; ii < corrs(sys).size(); ii++) {
|
---|
| 864 | const cmbCorr* corr = corrs(sys)[ii];
|
---|
[6330] | 865 | out << _resTime.datestr().c_str() << ' '
|
---|
| 866 | << _resTime.timestr().c_str() << " "
|
---|
[6962] | 867 | << corr->_acName << ' ' << corr->_prn.mid(0,3);
|
---|
[6330] | 868 | out.setFieldWidth(10);
|
---|
[9635] | 869 | out << " res = " << vv[ii] << "\n";
|
---|
[6330] | 870 | out.setFieldWidth(0);
|
---|
| 871 | }
|
---|
[3432] | 872 | break;
|
---|
| 873 | }
|
---|
| 874 | }
|
---|
| 875 |
|
---|
[3472] | 876 | return success;
|
---|
[2918] | 877 | }
|
---|
[3011] | 878 |
|
---|
[3201] | 879 | // Print results
|
---|
[3011] | 880 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3429] | 881 | void bncComb::printResults(QTextStream& out,
|
---|
[6157] | 882 | const QMap<QString, cmbCorr*>& resCorr) {
|
---|
[3011] | 883 |
|
---|
[6157] | 884 | QMapIterator<QString, cmbCorr*> it(resCorr);
|
---|
[3011] | 885 | while (it.hasNext()) {
|
---|
| 886 | it.next();
|
---|
[6157] | 887 | cmbCorr* corr = it.value();
|
---|
| 888 | const t_eph* eph = corr->_eph;
|
---|
[3015] | 889 | if (eph) {
|
---|
[8542] | 890 | ColumnVector xc(6);
|
---|
[6109] | 891 | ColumnVector vv(3);
|
---|
[9268] | 892 | if (eph->getCrd(_resTime, xc, vv, false) != success) {
|
---|
| 893 | continue;
|
---|
| 894 | }
|
---|
[7297] | 895 | out << _resTime.datestr().c_str() << " "
|
---|
[3429] | 896 | << _resTime.timestr().c_str() << " ";
|
---|
[3015] | 897 | out.setFieldWidth(3);
|
---|
[6962] | 898 | out << "Full Clock " << corr->_prn.mid(0,3) << " " << corr->_iod << " ";
|
---|
[3015] | 899 | out.setFieldWidth(14);
|
---|
[9635] | 900 | out << (xc(4) + corr->_dClkResult) * t_CST::c << "\n";
|
---|
[3370] | 901 | out.setFieldWidth(0);
|
---|
[3015] | 902 | }
|
---|
| 903 | else {
|
---|
[9691] | 904 | out << "bncComb::printResults bug" << "\n";
|
---|
[3015] | 905 | }
|
---|
[9676] | 906 | out.flush();
|
---|
[3011] | 907 | }
|
---|
| 908 | }
|
---|
[3202] | 909 |
|
---|
| 910 | // Send results to RTNet Decoder and directly to PPP Client
|
---|
| 911 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6157] | 912 | void bncComb::dumpResults(const QMap<QString, cmbCorr*>& resCorr) {
|
---|
[3202] | 913 |
|
---|
[6161] | 914 | QList<t_orbCorr> orbCorrections;
|
---|
| 915 | QList<t_clkCorr> clkCorrections;
|
---|
[9676] | 916 | QList<t_satCodeBias> satCodeBiasList;
|
---|
[6161] | 917 |
|
---|
[3214] | 918 | unsigned year, month, day, hour, minute;
|
---|
| 919 | double sec;
|
---|
[3429] | 920 | _resTime.civil_date(year, month, day);
|
---|
| 921 | _resTime.civil_time(hour, minute, sec);
|
---|
[3214] | 922 |
|
---|
[9676] | 923 | QString outLines = QString().asprintf("* %4d %2d %2d %d %d %12.8f\n",
|
---|
| 924 | year, month, day, hour, minute, sec);
|
---|
[3214] | 925 |
|
---|
[6157] | 926 | QMapIterator<QString, cmbCorr*> it(resCorr);
|
---|
[3202] | 927 | while (it.hasNext()) {
|
---|
| 928 | it.next();
|
---|
[6157] | 929 | cmbCorr* corr = it.value();
|
---|
[9676] | 930 | // ORBIT
|
---|
[7013] | 931 | t_orbCorr orbCorr(corr->_orbCorr);
|
---|
| 932 | orbCorr._staID = "INTERNAL";
|
---|
| 933 | orbCorrections.push_back(orbCorr);
|
---|
[9676] | 934 | // CLOCK
|
---|
[7013] | 935 | t_clkCorr clkCorr(corr->_clkCorr);
|
---|
| 936 | clkCorr._staID = "INTERNAL";
|
---|
| 937 | clkCorr._dClk = corr->_dClkResult;
|
---|
| 938 | clkCorr._dotDClk = 0.0;
|
---|
| 939 | clkCorr._dotDotDClk = 0.0;
|
---|
| 940 | clkCorrections.push_back(clkCorr);
|
---|
| 941 |
|
---|
[8542] | 942 | ColumnVector xc(6);
|
---|
[4978] | 943 | ColumnVector vv(3);
|
---|
[7013] | 944 | corr->_eph->setClkCorr(dynamic_cast<const t_clkCorr*>(&clkCorr));
|
---|
| 945 | corr->_eph->setOrbCorr(dynamic_cast<const t_orbCorr*>(&orbCorr));
|
---|
[9268] | 946 | if (corr->_eph->getCrd(_resTime, xc, vv, true) != success) {
|
---|
| 947 | delete corr;
|
---|
| 948 | continue;
|
---|
| 949 | }
|
---|
[7012] | 950 |
|
---|
[4978] | 951 | // Correction Phase Center --> CoM
|
---|
| 952 | // -------------------------------
|
---|
| 953 | ColumnVector dx(3); dx = 0.0;
|
---|
| 954 | if (_antex) {
|
---|
| 955 | double Mjd = _resTime.mjd() + _resTime.daysec()/86400.0;
|
---|
[6157] | 956 | if (_antex->satCoMcorrection(corr->_prn, Mjd, xc.Rows(1,3), dx) != success) {
|
---|
[4992] | 957 | dx = 0;
|
---|
[8204] | 958 | _log += "antenna not found " + corr->_prn.mid(0,3).toLatin1() + '\n';
|
---|
[3214] | 959 | }
|
---|
| 960 | }
|
---|
[7012] | 961 |
|
---|
| 962 | outLines += corr->_prn.mid(0,3);
|
---|
[9676] | 963 | QString hlp = QString().asprintf(" APC 3 %15.4f %15.4f %15.4f"
|
---|
| 964 | " Clk 1 %15.4f"
|
---|
| 965 | " Vel 3 %15.4f %15.4f %15.4f"
|
---|
| 966 | " CoM 3 %15.4f %15.4f %15.4f",
|
---|
| 967 | xc(1), xc(2), xc(3),
|
---|
| 968 | xc(4) * t_CST::c,
|
---|
| 969 | vv(1), vv(2), vv(3),
|
---|
| 970 | xc(1)-dx(1), xc(2)-dx(2), xc(3)-dx(3));
|
---|
[5337] | 971 | outLines += hlp;
|
---|
[9676] | 972 | hlp.clear();
|
---|
[5337] | 973 |
|
---|
[9676] | 974 | // CODE BIASES
|
---|
| 975 | t_satCodeBias satCodeBias(corr->_satCodeBias);
|
---|
| 976 | satCodeBias._staID = "INTERNAL";
|
---|
| 977 | satCodeBiasList.push_back(satCodeBias);
|
---|
[4978] | 978 |
|
---|
[9676] | 979 | if (satCodeBias._bias.size()) {
|
---|
| 980 | hlp = QString().asprintf(" CodeBias %2lu", satCodeBias._bias.size());
|
---|
| 981 | outLines += hlp;
|
---|
| 982 | hlp.clear();
|
---|
| 983 | for (unsigned ii = 0; ii < satCodeBias._bias.size(); ii++) {
|
---|
| 984 | const t_frqCodeBias& frqCodeBias = satCodeBias._bias[ii];
|
---|
| 985 | if (!frqCodeBias._rnxType2ch.empty()) {
|
---|
| 986 | hlp = QString().asprintf(" %s%10.6f", frqCodeBias._rnxType2ch.c_str(), frqCodeBias._value);
|
---|
| 987 | outLines += hlp;
|
---|
| 988 | hlp.clear();
|
---|
| 989 | }
|
---|
| 990 | }
|
---|
| 991 | }
|
---|
| 992 | outLines += "\n";
|
---|
| 993 | //cout << outLines.toStdString();
|
---|
[3214] | 994 | delete corr;
|
---|
| 995 | }
|
---|
| 996 |
|
---|
[5337] | 997 | outLines += "EOE\n"; // End Of Epoch flag
|
---|
| 998 |
|
---|
[3215] | 999 | if (!_rtnetDecoder) {
|
---|
| 1000 | _rtnetDecoder = new bncRtnetDecoder();
|
---|
| 1001 | }
|
---|
[3221] | 1002 |
|
---|
[3215] | 1003 | vector<string> errmsg;
|
---|
[8204] | 1004 | _rtnetDecoder->Decode(outLines.toLatin1().data(), outLines.length(), errmsg);
|
---|
[3215] | 1005 |
|
---|
[5861] | 1006 | // Send new Corrections to PPP etc.
|
---|
| 1007 | // --------------------------------
|
---|
[6161] | 1008 | if (orbCorrections.size() > 0 && clkCorrections.size() > 0) {
|
---|
| 1009 | emit newOrbCorrections(orbCorrections);
|
---|
| 1010 | emit newClkCorrections(clkCorrections);
|
---|
| 1011 | }
|
---|
[9676] | 1012 | if (satCodeBiasList.size()) {
|
---|
| 1013 | emit newCodeBiases(satCodeBiasList);
|
---|
| 1014 | }
|
---|
[3202] | 1015 | }
|
---|
[3455] | 1016 |
|
---|
| 1017 | // Create First Design Matrix and Vector of Measurements
|
---|
| 1018 | ////////////////////////////////////////////////////////////////////////////
|
---|
[9258] | 1019 | t_irc bncComb::createAmat(char sys, Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
|
---|
| 1020 | const ColumnVector& x0, QMap<QString, cmbCorr*>& resCorr) {
|
---|
[3455] | 1021 |
|
---|
[9258] | 1022 | unsigned nPar = _params[sys].size();
|
---|
| 1023 | unsigned nObs = corrs(sys).size();
|
---|
[3455] | 1024 |
|
---|
| 1025 | if (nObs == 0) {
|
---|
| 1026 | return failure;
|
---|
| 1027 | }
|
---|
| 1028 |
|
---|
[9258] | 1029 | int maxSat = _cmbSysPrn[sys];
|
---|
[3455] | 1030 |
|
---|
[9259] | 1031 | const int nCon = (_method == filter) ? 1 + maxSat : 0;
|
---|
[3483] | 1032 |
|
---|
[3455] | 1033 | AA.ReSize(nObs+nCon, nPar); AA = 0.0;
|
---|
| 1034 | ll.ReSize(nObs+nCon); ll = 0.0;
|
---|
| 1035 | PP.ReSize(nObs+nCon); PP = 1.0 / (sigObs * sigObs);
|
---|
| 1036 |
|
---|
| 1037 | int iObs = 0;
|
---|
[9258] | 1038 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
---|
[3455] | 1039 | while (itCorr.hasNext()) {
|
---|
| 1040 | cmbCorr* corr = itCorr.next();
|
---|
[6157] | 1041 | QString prn = corr->_prn;
|
---|
[3487] | 1042 |
|
---|
[3455] | 1043 | ++iObs;
|
---|
| 1044 |
|
---|
[9258] | 1045 | if (corr->_acName == _masterOrbitAC[sys] && resCorr.find(prn) == resCorr.end()) {
|
---|
[6157] | 1046 | resCorr[prn] = new cmbCorr(*corr);
|
---|
[3455] | 1047 | }
|
---|
| 1048 |
|
---|
[9258] | 1049 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 1050 | cmbParam* pp = _params[sys][iPar-1];
|
---|
| 1051 | AA(iObs, iPar) = pp->partial(sys, corr->_acName, prn);
|
---|
[3455] | 1052 | }
|
---|
| 1053 |
|
---|
[9635] | 1054 | ll(iObs) = (corr->_clkCorr._dClk * t_CST::c - corr->_codeBiasIF) - DotProduct(AA.Row(iObs), x0);
|
---|
[3455] | 1055 | }
|
---|
| 1056 |
|
---|
| 1057 | // Regularization
|
---|
| 1058 | // --------------
|
---|
[3474] | 1059 | if (_method == filter) {
|
---|
| 1060 | const double Ph = 1.e6;
|
---|
| 1061 | PP(nObs+1) = Ph;
|
---|
[9258] | 1062 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 1063 | cmbParam* pp = _params[sys][iPar-1];
|
---|
[3465] | 1064 | if ( AA.Column(iPar).maximum_absolute_value() > 0.0 &&
|
---|
[3474] | 1065 | pp->type == cmbParam::clkSat ) {
|
---|
| 1066 | AA(nObs+1, iPar) = 1.0;
|
---|
[3455] | 1067 | }
|
---|
| 1068 | }
|
---|
[9258] | 1069 | unsigned flag = 0;
|
---|
| 1070 | if (sys == 'E') {
|
---|
| 1071 | flag = 1;
|
---|
| 1072 | }
|
---|
[9259] | 1073 | if (sys == 'R') {
|
---|
| 1074 | return success;
|
---|
| 1075 | }
|
---|
| 1076 | int iCond = 1;
|
---|
| 1077 | // GNSS
|
---|
[9258] | 1078 | for (unsigned iGnss = 1; iGnss <= _cmbSysPrn[sys]; iGnss++) {
|
---|
| 1079 | QString prn = QString("%1%2_%3").arg(sys).arg(iGnss, 2, 10, QChar('0')).arg(flag);
|
---|
[3474] | 1080 | ++iCond;
|
---|
| 1081 | PP(nObs+iCond) = Ph;
|
---|
[9258] | 1082 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 1083 | cmbParam* pp = _params[sys][iPar-1];
|
---|
[7299] | 1084 | if ( pp &&
|
---|
| 1085 | AA.Column(iPar).maximum_absolute_value() > 0.0 &&
|
---|
[7297] | 1086 | pp->type == cmbParam::offACSat &&
|
---|
[3474] | 1087 | pp->prn == prn) {
|
---|
| 1088 | AA(nObs+iCond, iPar) = 1.0;
|
---|
| 1089 | }
|
---|
| 1090 | }
|
---|
| 1091 | }
|
---|
[3455] | 1092 | }
|
---|
| 1093 |
|
---|
| 1094 | return success;
|
---|
| 1095 | }
|
---|
[3470] | 1096 |
|
---|
| 1097 | // Process Epoch - Single-Epoch Method
|
---|
| 1098 | ////////////////////////////////////////////////////////////////////////////
|
---|
[9258] | 1099 | t_irc bncComb::processEpoch_singleEpoch(char sys, QTextStream& out,
|
---|
[6157] | 1100 | QMap<QString, cmbCorr*>& resCorr,
|
---|
[3475] | 1101 | ColumnVector& dx) {
|
---|
[3470] | 1102 |
|
---|
[3487] | 1103 | // Check Satellite Positions for Outliers
|
---|
| 1104 | // --------------------------------------
|
---|
[9258] | 1105 | if (checkOrbits(sys, out) != success) {
|
---|
[3487] | 1106 | return failure;
|
---|
| 1107 | }
|
---|
| 1108 |
|
---|
[3482] | 1109 | // Outlier Detection Loop
|
---|
| 1110 | // ----------------------
|
---|
| 1111 | while (true) {
|
---|
[7297] | 1112 |
|
---|
[3482] | 1113 | // Remove Satellites that are not in Master
|
---|
| 1114 | // ----------------------------------------
|
---|
[9258] | 1115 | QMutableVectorIterator<cmbCorr*> it(corrs(sys));
|
---|
[3482] | 1116 | while (it.hasNext()) {
|
---|
| 1117 | cmbCorr* corr = it.next();
|
---|
[6157] | 1118 | QString prn = corr->_prn;
|
---|
[3482] | 1119 | bool foundMaster = false;
|
---|
[9258] | 1120 | QVectorIterator<cmbCorr*> itHlp(corrs(sys));
|
---|
[3482] | 1121 | while (itHlp.hasNext()) {
|
---|
| 1122 | cmbCorr* corrHlp = itHlp.next();
|
---|
[6157] | 1123 | QString prnHlp = corrHlp->_prn;
|
---|
| 1124 | QString ACHlp = corrHlp->_acName;
|
---|
[9258] | 1125 | if (ACHlp == _masterOrbitAC[sys] && prn == prnHlp) {
|
---|
[3482] | 1126 | foundMaster = true;
|
---|
| 1127 | break;
|
---|
| 1128 | }
|
---|
[3476] | 1129 | }
|
---|
[3482] | 1130 | if (!foundMaster) {
|
---|
[3556] | 1131 | delete corr;
|
---|
[3482] | 1132 | it.remove();
|
---|
| 1133 | }
|
---|
[3473] | 1134 | }
|
---|
[7297] | 1135 |
|
---|
[3482] | 1136 | // Count Number of Observations per Satellite and per AC
|
---|
| 1137 | // -----------------------------------------------------
|
---|
| 1138 | QMap<QString, int> numObsPrn;
|
---|
| 1139 | QMap<QString, int> numObsAC;
|
---|
[9258] | 1140 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
---|
[3482] | 1141 | while (itCorr.hasNext()) {
|
---|
| 1142 | cmbCorr* corr = itCorr.next();
|
---|
[6157] | 1143 | QString prn = corr->_prn;
|
---|
| 1144 | QString AC = corr->_acName;
|
---|
[3482] | 1145 | if (numObsPrn.find(prn) == numObsPrn.end()) {
|
---|
| 1146 | numObsPrn[prn] = 1;
|
---|
| 1147 | }
|
---|
| 1148 | else {
|
---|
| 1149 | numObsPrn[prn] += 1;
|
---|
| 1150 | }
|
---|
| 1151 | if (numObsAC.find(AC) == numObsAC.end()) {
|
---|
| 1152 | numObsAC[AC] = 1;
|
---|
| 1153 | }
|
---|
| 1154 | else {
|
---|
| 1155 | numObsAC[AC] += 1;
|
---|
| 1156 | }
|
---|
[3476] | 1157 | }
|
---|
[7297] | 1158 |
|
---|
[9258] | 1159 | // Clean-Up the Parameters
|
---|
| 1160 | // -----------------------
|
---|
| 1161 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 1162 | delete _params[sys][iPar-1];
|
---|
[3474] | 1163 | }
|
---|
[9258] | 1164 | _params[sys].clear();
|
---|
[7297] | 1165 |
|
---|
[3482] | 1166 | // Set new Parameters
|
---|
| 1167 | // ------------------
|
---|
| 1168 | int nextPar = 0;
|
---|
[7297] | 1169 |
|
---|
[3482] | 1170 | QMapIterator<QString, int> itAC(numObsAC);
|
---|
| 1171 | while (itAC.hasNext()) {
|
---|
| 1172 | itAC.next();
|
---|
| 1173 | const QString& AC = itAC.key();
|
---|
| 1174 | int numObs = itAC.value();
|
---|
[9258] | 1175 | if (AC != _masterOrbitAC[sys] && numObs > 0) {
|
---|
| 1176 | _params[sys].push_back(new cmbParam(cmbParam::offACgnss, ++nextPar, AC, ""));
|
---|
[3482] | 1177 | }
|
---|
[7297] | 1178 | }
|
---|
| 1179 |
|
---|
[3482] | 1180 | QMapIterator<QString, int> itPrn(numObsPrn);
|
---|
| 1181 | while (itPrn.hasNext()) {
|
---|
| 1182 | itPrn.next();
|
---|
| 1183 | const QString& prn = itPrn.key();
|
---|
| 1184 | int numObs = itPrn.value();
|
---|
| 1185 | if (numObs > 0) {
|
---|
[9258] | 1186 | _params[sys].push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
|
---|
[3482] | 1187 | }
|
---|
[7297] | 1188 | }
|
---|
| 1189 |
|
---|
[9258] | 1190 | int nPar = _params[sys].size();
|
---|
[7297] | 1191 | ColumnVector x0(nPar);
|
---|
[3482] | 1192 | x0 = 0.0;
|
---|
[7297] | 1193 |
|
---|
[3482] | 1194 | // Create First-Design Matrix
|
---|
| 1195 | // --------------------------
|
---|
| 1196 | Matrix AA;
|
---|
| 1197 | ColumnVector ll;
|
---|
| 1198 | DiagonalMatrix PP;
|
---|
[9258] | 1199 | if (createAmat(sys, AA, ll, PP, x0, resCorr) != success) {
|
---|
[3482] | 1200 | return failure;
|
---|
[3476] | 1201 | }
|
---|
[7297] | 1202 |
|
---|
[3482] | 1203 | ColumnVector vv;
|
---|
| 1204 | try {
|
---|
| 1205 | Matrix ATP = AA.t() * PP;
|
---|
| 1206 | SymmetricMatrix NN; NN << ATP * AA;
|
---|
| 1207 | ColumnVector bb = ATP * ll;
|
---|
[9258] | 1208 | _QQ[sys] = NN.i();
|
---|
| 1209 | dx = _QQ[sys] * bb;
|
---|
[3482] | 1210 | vv = ll - AA * dx;
|
---|
[3476] | 1211 | }
|
---|
[3482] | 1212 | catch (Exception& exc) {
|
---|
[9635] | 1213 | out << exc.what() << "\n";
|
---|
[3482] | 1214 | return failure;
|
---|
[3476] | 1215 | }
|
---|
[3474] | 1216 |
|
---|
[3482] | 1217 | int maxResIndex;
|
---|
[7297] | 1218 | double maxRes = vv.maximum_absolute_value1(maxResIndex);
|
---|
[3482] | 1219 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
[7297] | 1220 | out.setRealNumberPrecision(3);
|
---|
[3482] | 1221 | out << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
|
---|
| 1222 | << " Maximum Residuum " << maxRes << ' '
|
---|
[9258] | 1223 | << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
|
---|
[3474] | 1224 |
|
---|
[3482] | 1225 | if (maxRes > _MAXRES) {
|
---|
[9635] | 1226 | out << " Outlier" << "\n";
|
---|
[9258] | 1227 | delete corrs(sys)[maxResIndex-1];
|
---|
| 1228 | corrs(sys).remove(maxResIndex-1);
|
---|
[3474] | 1229 | }
|
---|
[3482] | 1230 | else {
|
---|
[9635] | 1231 | out << " OK" << "\n";
|
---|
[3482] | 1232 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
[7297] | 1233 | out.setRealNumberPrecision(3);
|
---|
[3482] | 1234 | for (int ii = 0; ii < vv.Nrows(); ii++) {
|
---|
[9258] | 1235 | const cmbCorr* corr = corrs(sys)[ii];
|
---|
[7297] | 1236 | out << _resTime.datestr().c_str() << ' '
|
---|
[3482] | 1237 | << _resTime.timestr().c_str() << " "
|
---|
[6962] | 1238 | << corr->_acName << ' ' << corr->_prn.mid(0,3);
|
---|
[3482] | 1239 | out.setFieldWidth(6);
|
---|
[9635] | 1240 | out << " res = " << vv[ii] << "\n";
|
---|
[3482] | 1241 | out.setFieldWidth(0);
|
---|
| 1242 | }
|
---|
| 1243 | return success;
|
---|
[3474] | 1244 | }
|
---|
| 1245 |
|
---|
[3473] | 1246 | }
|
---|
[3474] | 1247 |
|
---|
[3482] | 1248 | return failure;
|
---|
[3470] | 1249 | }
|
---|
[3487] | 1250 |
|
---|
| 1251 | // Check Satellite Positions for Outliers
|
---|
| 1252 | ////////////////////////////////////////////////////////////////////////////
|
---|
[9258] | 1253 | t_irc bncComb::checkOrbits(char sys, QTextStream& out) {
|
---|
[3487] | 1254 |
|
---|
[3489] | 1255 | const double MAX_DISPLACEMENT = 0.20;
|
---|
[3488] | 1256 |
|
---|
[3502] | 1257 | // Switch to last ephemeris (if possible)
|
---|
| 1258 | // --------------------------------------
|
---|
[9258] | 1259 | QMutableVectorIterator<cmbCorr*> im(corrs(sys));
|
---|
[3501] | 1260 | while (im.hasNext()) {
|
---|
| 1261 | cmbCorr* corr = im.next();
|
---|
[6157] | 1262 | QString prn = corr->_prn;
|
---|
[6443] | 1263 |
|
---|
[7012] | 1264 | t_eph* ephLast = _ephUser.ephLast(prn);
|
---|
| 1265 | t_eph* ephPrev = _ephUser.ephPrev(prn);
|
---|
[6443] | 1266 |
|
---|
| 1267 | if (ephLast == 0) {
|
---|
[9635] | 1268 | out << "checkOrbit: missing eph (not found) " << corr->_prn.mid(0,3) << "\n";
|
---|
[3556] | 1269 | delete corr;
|
---|
[3501] | 1270 | im.remove();
|
---|
| 1271 | }
|
---|
[6157] | 1272 | else if (corr->_eph == 0) {
|
---|
[9635] | 1273 | out << "checkOrbit: missing eph (zero) " << corr->_prn.mid(0,3) << "\n";
|
---|
[3556] | 1274 | delete corr;
|
---|
[3503] | 1275 | im.remove();
|
---|
| 1276 | }
|
---|
[3502] | 1277 | else {
|
---|
[6443] | 1278 | if ( corr->_eph == ephLast || corr->_eph == ephPrev ) {
|
---|
| 1279 | switchToLastEph(ephLast, corr);
|
---|
[3502] | 1280 | }
|
---|
| 1281 | else {
|
---|
[9635] | 1282 | out << "checkOrbit: missing eph (deleted) " << corr->_prn.mid(0,3) << "\n";
|
---|
[3556] | 1283 | delete corr;
|
---|
[3502] | 1284 | im.remove();
|
---|
| 1285 | }
|
---|
| 1286 | }
|
---|
[3501] | 1287 | }
|
---|
| 1288 |
|
---|
[3488] | 1289 | while (true) {
|
---|
| 1290 |
|
---|
| 1291 | // Compute Mean Corrections for all Satellites
|
---|
| 1292 | // -------------------------------------------
|
---|
[3489] | 1293 | QMap<QString, int> numCorr;
|
---|
[3488] | 1294 | QMap<QString, ColumnVector> meanRao;
|
---|
[9258] | 1295 | QVectorIterator<cmbCorr*> it(corrs(sys));
|
---|
[3488] | 1296 | while (it.hasNext()) {
|
---|
| 1297 | cmbCorr* corr = it.next();
|
---|
[6157] | 1298 | QString prn = corr->_prn;
|
---|
[3488] | 1299 | if (meanRao.find(prn) == meanRao.end()) {
|
---|
| 1300 | meanRao[prn].ReSize(4);
|
---|
[6159] | 1301 | meanRao[prn].Rows(1,3) = corr->_orbCorr._xr;
|
---|
[7297] | 1302 | meanRao[prn](4) = 1;
|
---|
[3488] | 1303 | }
|
---|
| 1304 | else {
|
---|
[6159] | 1305 | meanRao[prn].Rows(1,3) += corr->_orbCorr._xr;
|
---|
[7297] | 1306 | meanRao[prn](4) += 1;
|
---|
[3488] | 1307 | }
|
---|
[3489] | 1308 | if (numCorr.find(prn) == numCorr.end()) {
|
---|
| 1309 | numCorr[prn] = 1;
|
---|
| 1310 | }
|
---|
| 1311 | else {
|
---|
| 1312 | numCorr[prn] += 1;
|
---|
| 1313 | }
|
---|
[3487] | 1314 | }
|
---|
[7297] | 1315 |
|
---|
[9258] | 1316 | // Compute Differences wrt. Mean, find Maximum
|
---|
| 1317 | // -------------------------------------------
|
---|
[3488] | 1318 | QMap<QString, cmbCorr*> maxDiff;
|
---|
| 1319 | it.toFront();
|
---|
| 1320 | while (it.hasNext()) {
|
---|
| 1321 | cmbCorr* corr = it.next();
|
---|
[6157] | 1322 | QString prn = corr->_prn;
|
---|
[3488] | 1323 | if (meanRao[prn](4) != 0) {
|
---|
| 1324 | meanRao[prn] /= meanRao[prn](4);
|
---|
| 1325 | meanRao[prn](4) = 0;
|
---|
| 1326 | }
|
---|
[6159] | 1327 | corr->_diffRao = corr->_orbCorr._xr - meanRao[prn].Rows(1,3);
|
---|
[3488] | 1328 | if (maxDiff.find(prn) == maxDiff.end()) {
|
---|
| 1329 | maxDiff[prn] = corr;
|
---|
| 1330 | }
|
---|
| 1331 | else {
|
---|
[8901] | 1332 | double normMax = maxDiff[prn]->_diffRao.NormFrobenius();
|
---|
| 1333 | double norm = corr->_diffRao.NormFrobenius();
|
---|
[3488] | 1334 | if (norm > normMax) {
|
---|
| 1335 | maxDiff[prn] = corr;
|
---|
| 1336 | }
|
---|
[7297] | 1337 | }
|
---|
[3487] | 1338 | }
|
---|
[7297] | 1339 |
|
---|
[3655] | 1340 | if (_ACs.size() == 1) {
|
---|
| 1341 | break;
|
---|
| 1342 | }
|
---|
| 1343 |
|
---|
[3488] | 1344 | // Remove Outliers
|
---|
| 1345 | // ---------------
|
---|
| 1346 | bool removed = false;
|
---|
[9258] | 1347 | QMutableVectorIterator<cmbCorr*> im(corrs(sys));
|
---|
[3488] | 1348 | while (im.hasNext()) {
|
---|
| 1349 | cmbCorr* corr = im.next();
|
---|
[6157] | 1350 | QString prn = corr->_prn;
|
---|
[3489] | 1351 | if (numCorr[prn] < 2) {
|
---|
[3556] | 1352 | delete corr;
|
---|
[3489] | 1353 | im.remove();
|
---|
| 1354 | }
|
---|
| 1355 | else if (corr == maxDiff[prn]) {
|
---|
[8901] | 1356 | double norm = corr->_diffRao.NormFrobenius();
|
---|
[3488] | 1357 | if (norm > MAX_DISPLACEMENT) {
|
---|
[3497] | 1358 | out << _resTime.datestr().c_str() << " "
|
---|
| 1359 | << _resTime.timestr().c_str() << " "
|
---|
[7297] | 1360 | << "Orbit Outlier: "
|
---|
[8204] | 1361 | << corr->_acName.toLatin1().data() << " "
|
---|
| 1362 | << prn.mid(0,3).toLatin1().data() << " "
|
---|
[7297] | 1363 | << corr->_iod << " "
|
---|
[9635] | 1364 | << norm << "\n";
|
---|
[3556] | 1365 | delete corr;
|
---|
[3488] | 1366 | im.remove();
|
---|
| 1367 | removed = true;
|
---|
| 1368 | }
|
---|
| 1369 | }
|
---|
[3487] | 1370 | }
|
---|
[7297] | 1371 |
|
---|
[3488] | 1372 | if (!removed) {
|
---|
| 1373 | break;
|
---|
| 1374 | }
|
---|
[3487] | 1375 | }
|
---|
| 1376 |
|
---|
| 1377 | return success;
|
---|
| 1378 | }
|
---|
[3588] | 1379 |
|
---|
[7297] | 1380 | //
|
---|
[3588] | 1381 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5583] | 1382 | void bncComb::slotProviderIDChanged(QString mountPoint) {
|
---|
| 1383 | QMutexLocker locker(&_mutex);
|
---|
| 1384 |
|
---|
[8065] | 1385 | QTextStream out(&_log, QIODevice::WriteOnly);
|
---|
| 1386 |
|
---|
[5583] | 1387 | // Find the AC Name
|
---|
| 1388 | // ----------------
|
---|
| 1389 | QString acName;
|
---|
| 1390 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 1391 | while (icAC.hasNext()) {
|
---|
| 1392 | cmbAC* AC = icAC.next();
|
---|
| 1393 | if (AC->mountPoint == mountPoint) {
|
---|
| 1394 | acName = AC->name;
|
---|
[8204] | 1395 | out << "Provider ID changed: AC " << AC->name.toLatin1().data() << " "
|
---|
[8065] | 1396 | << _resTime.datestr().c_str() << " "
|
---|
[9635] | 1397 | << _resTime.timestr().c_str() << "\n";
|
---|
[5583] | 1398 | break;
|
---|
| 1399 | }
|
---|
| 1400 | }
|
---|
| 1401 | if (acName.isEmpty()) {
|
---|
| 1402 | return;
|
---|
| 1403 | }
|
---|
[9258] | 1404 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
---|
| 1405 | while (itSys.hasNext()) {
|
---|
| 1406 | itSys.next();
|
---|
| 1407 | char sys = itSys.key();
|
---|
| 1408 | // Remove all corrections of the corresponding AC
|
---|
| 1409 | // ----------------------------------------------
|
---|
| 1410 | QListIterator<bncTime> itTime(_buffer[sys].keys());
|
---|
| 1411 | while (itTime.hasNext()) {
|
---|
| 1412 | bncTime epoTime = itTime.next();
|
---|
| 1413 | QVector<cmbCorr*>& corrVec = _buffer[sys][epoTime].corrs;
|
---|
| 1414 | QMutableVectorIterator<cmbCorr*> it(corrVec);
|
---|
| 1415 | while (it.hasNext()) {
|
---|
| 1416 | cmbCorr* corr = it.next();
|
---|
| 1417 | if (acName == corr->_acName) {
|
---|
| 1418 | delete corr;
|
---|
| 1419 | it.remove();
|
---|
| 1420 | }
|
---|
[5583] | 1421 | }
|
---|
| 1422 | }
|
---|
[5585] | 1423 |
|
---|
[9258] | 1424 | // Reset Satellite Offsets
|
---|
| 1425 | // -----------------------
|
---|
| 1426 | if (_method == filter) {
|
---|
| 1427 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 1428 | cmbParam* pp = _params[sys][iPar-1];
|
---|
| 1429 | if (pp->AC == acName && pp->type == cmbParam::offACSat) {
|
---|
| 1430 | pp->xx = 0.0;
|
---|
| 1431 | _QQ[sys].Row(iPar) = 0.0;
|
---|
| 1432 | _QQ[sys].Column(iPar) = 0.0;
|
---|
| 1433 | _QQ[sys](iPar,iPar) = pp->sig0 * pp->sig0;
|
---|
| 1434 | }
|
---|
[5585] | 1435 | }
|
---|
| 1436 | }
|
---|
| 1437 | }
|
---|
[5583] | 1438 | }
|
---|