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