[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++) {
|
---|
[10038] | 450 | t_clkCorr* newClk = new t_clkCorr(clkCorrections[ii]);
|
---|
[6155] | 451 |
|
---|
[10038] | 452 | char sys = newClk->_prn.system();
|
---|
[9296] | 453 | if (!_cmbSysPrn.contains(sys)){
|
---|
[10038] | 454 | delete newClk;
|
---|
[9296] | 455 | continue;
|
---|
| 456 | }
|
---|
| 457 |
|
---|
[10038] | 458 | // Check Modulo Time
|
---|
[6155] | 459 | // -----------------
|
---|
[10038] | 460 | int sec = int(nint(newClk->_time.gpssec()*10));
|
---|
| 461 | if (sec % (_cmbSampl*10) != 0.0) {
|
---|
| 462 | delete newClk;
|
---|
| 463 | continue;
|
---|
[3483] | 464 | }
|
---|
| 465 |
|
---|
[6155] | 466 | // Find/Check the AC Name
|
---|
| 467 | // ----------------------
|
---|
| 468 | QString acName;
|
---|
[10116] | 469 | bool isAPC;
|
---|
[10038] | 470 | QString staID(newClk->_staID.c_str());
|
---|
[6155] | 471 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 472 | while (icAC.hasNext()) {
|
---|
| 473 | cmbAC* AC = icAC.next();
|
---|
| 474 | if (AC->mountPoint == staID) {
|
---|
| 475 | acName = AC->name;
|
---|
[10116] | 476 | isAPC = AC->isAPC;
|
---|
[6155] | 477 | break;
|
---|
| 478 | }
|
---|
[3588] | 479 | }
|
---|
[10116] | 480 | if (acName.isEmpty() || isAPC != _masterIsAPC[sys]) {
|
---|
[10038] | 481 | delete newClk;
|
---|
[6155] | 482 | continue;
|
---|
| 483 | }
|
---|
[3588] | 484 |
|
---|
[10098] | 485 | // Check regarding current time
|
---|
| 486 | // ----------------------------
|
---|
[10192] | 487 | if (BNC_CORE->mode() != t_bncCore::batchPostProcessing) {
|
---|
[10200] | 488 | if ((newClk->_time >= currentTime) || // future time stamp
|
---|
[10192] | 489 | (currentTime - newClk->_time) > 60.0) { // very old data sets
|
---|
| 490 | #ifdef BNC_DEBUG_CMB
|
---|
[10200] | 491 | emit newMessage("bncComb: future or very old data sets: " + acName.toLatin1() + " " + newClk->_prn.toString().c_str() +
|
---|
[10192] | 492 | QString(" %1 ").arg(newClk->_time.timestr().c_str()).toLatin1() + "vs. current time" +
|
---|
| 493 | QString(" %1 ").arg(currentTime.timestr().c_str()).toLatin1(), true);
|
---|
| 494 | #endif
|
---|
| 495 | delete newClk;
|
---|
| 496 | continue;
|
---|
| 497 | }
|
---|
[10098] | 498 | }
|
---|
| 499 |
|
---|
[6155] | 500 | // Check Correction Age
|
---|
| 501 | // --------------------
|
---|
[10042] | 502 | if (_resTime.valid() && newClk->_time <= _resTime) {
|
---|
[10077] | 503 | #ifdef BNC_DEBUG_CMB
|
---|
[10038] | 504 | emit newMessage("bncComb: old correction: " + acName.toLatin1() + " " + newClk->_prn.toString().c_str() +
|
---|
[10042] | 505 | QString(" %1 ").arg(newClk->_time.timestr().c_str()).toLatin1() + "vs. last processing Epoch" +
|
---|
| 506 | QString(" %1 ").arg(_resTime.timestr().c_str()).toLatin1(), true);
|
---|
[10077] | 507 | #endif
|
---|
[10038] | 508 | delete newClk;
|
---|
[6155] | 509 | continue;
|
---|
| 510 | }
|
---|
[7297] | 511 |
|
---|
[10153] | 512 | // Set the last time
|
---|
| 513 | // -----------------
|
---|
| 514 | if (_lastClkCorrTime.undef() || newClk->_time > _lastClkCorrTime) {
|
---|
| 515 | _lastClkCorrTime = newClk->_time;
|
---|
| 516 | }
|
---|
| 517 |
|
---|
[10038] | 518 | // Find the corresponding data epoch or create a new one
|
---|
| 519 | // -----------------------------------------------------
|
---|
| 520 | epoClkData* epoch = 0;
|
---|
| 521 | deque<epoClkData*>::const_iterator it;
|
---|
| 522 | for (it = _epoClkData.begin(); it != _epoClkData.end(); it++) {
|
---|
| 523 | if (newClk->_time == (*it)->_time) {
|
---|
| 524 | epoch = *it;
|
---|
| 525 | break;
|
---|
| 526 | }
|
---|
| 527 | }
|
---|
| 528 | if (epoch == 0) {
|
---|
| 529 | if (_epoClkData.empty() || newClk->_time > _epoClkData.back()->_time) {
|
---|
| 530 | epoch = new epoClkData;
|
---|
| 531 | epoch->_time = newClk->_time;
|
---|
| 532 | _epoClkData.push_back(epoch);
|
---|
| 533 | }
|
---|
| 534 | }
|
---|
| 535 |
|
---|
| 536 | // Put data into the epoch
|
---|
| 537 | // -----------------------
|
---|
| 538 | if (epoch != 0) {
|
---|
| 539 | epoch->_clkCorr.push_back(newClk);
|
---|
| 540 | }
|
---|
| 541 | else {
|
---|
| 542 | delete newClk;
|
---|
| 543 | }
|
---|
| 544 | }
|
---|
| 545 |
|
---|
| 546 | // Make sure the buffer does not grow beyond any limit
|
---|
| 547 | // ---------------------------------------------------
|
---|
[10200] | 548 | const unsigned MAX_EPODATA_SIZE = 60.0 / _cmbSampl;
|
---|
[10038] | 549 | if (_epoClkData.size() > MAX_EPODATA_SIZE) {
|
---|
| 550 | delete _epoClkData.front();
|
---|
| 551 | _epoClkData.pop_front();
|
---|
| 552 | }
|
---|
| 553 |
|
---|
| 554 | // Process the oldest epochs
|
---|
| 555 | // ------------------------
|
---|
| 556 | while (_epoClkData.size()) {
|
---|
| 557 |
|
---|
[10042] | 558 | if (!_lastClkCorrTime.valid()) {
|
---|
[10038] | 559 | return;
|
---|
| 560 | }
|
---|
| 561 |
|
---|
| 562 | const vector<t_clkCorr*>& clkCorrVec = _epoClkData.front()->_clkCorr;
|
---|
| 563 |
|
---|
| 564 | bncTime epoTime = _epoClkData.front()->_time;
|
---|
| 565 |
|
---|
[10200] | 566 | if (BNC_CORE->mode() != t_bncCore::batchPostProcessing) {
|
---|
| 567 | if ((currentTime - epoTime) > 60.0) {
|
---|
| 568 | delete _epoClkData.front();
|
---|
| 569 | _epoClkData.pop_front();
|
---|
| 570 | continue;
|
---|
| 571 | }
|
---|
[10043] | 572 | }
|
---|
[10038] | 573 | // Process the front epoch
|
---|
| 574 | // -----------------------
|
---|
| 575 | if (epoTime < (_lastClkCorrTime - outWait)) {
|
---|
[10042] | 576 | _resTime = epoTime;
|
---|
| 577 | processEpoch(_resTime, clkCorrVec);
|
---|
[10038] | 578 | delete _epoClkData.front();
|
---|
| 579 | _epoClkData.pop_front();
|
---|
| 580 | }
|
---|
| 581 | else {
|
---|
| 582 | return;
|
---|
| 583 | }
|
---|
| 584 | }
|
---|
| 585 | }
|
---|
| 586 |
|
---|
| 587 | // Change the correction so that it refers to last received ephemeris
|
---|
| 588 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 589 | void bncComb::switchToLastEph(t_eph* lastEph, cmbCorr* corr) {
|
---|
| 590 |
|
---|
| 591 | if (corr->_eph == lastEph) {
|
---|
| 592 | return;
|
---|
| 593 | }
|
---|
| 594 |
|
---|
| 595 | ColumnVector oldXC(6);
|
---|
| 596 | ColumnVector oldVV(3);
|
---|
| 597 | if (corr->_eph->getCrd(corr->_time, oldXC, oldVV, false) != success) {
|
---|
| 598 | return;
|
---|
| 599 | }
|
---|
| 600 |
|
---|
| 601 | ColumnVector newXC(6);
|
---|
| 602 | ColumnVector newVV(3);
|
---|
| 603 | if (lastEph->getCrd(corr->_time, newXC, newVV, false) != success) {
|
---|
| 604 | return;
|
---|
| 605 | }
|
---|
| 606 |
|
---|
| 607 | ColumnVector dX = newXC.Rows(1,3) - oldXC.Rows(1,3);
|
---|
| 608 | ColumnVector dV = newVV - oldVV;
|
---|
| 609 | double dC = newXC(4) - oldXC(4);
|
---|
| 610 |
|
---|
| 611 | ColumnVector dRAO(3);
|
---|
| 612 | XYZ_to_RSW(newXC.Rows(1,3), newVV, dX, dRAO);
|
---|
| 613 |
|
---|
| 614 | ColumnVector dDotRAO(3);
|
---|
| 615 | XYZ_to_RSW(newXC.Rows(1,3), newVV, dV, dDotRAO);
|
---|
| 616 |
|
---|
| 617 | QString msg = "switch corr " + corr->_prn.mid(0,3)
|
---|
| 618 | + QString(" %1 -> %2 %3").arg(corr->_iod,3).arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
|
---|
| 619 |
|
---|
| 620 | emit newMessage(msg.toLatin1(), false);
|
---|
| 621 |
|
---|
| 622 | corr->_iod = lastEph->IOD();
|
---|
| 623 | corr->_eph = lastEph;
|
---|
| 624 |
|
---|
[10216] | 625 | corr->_orbCorr._xr += dRAO;
|
---|
| 626 | corr->_orbCorr._dotXr += dDotRAO;
|
---|
| 627 | corr->_clkCorr._dClk -= dC;
|
---|
[10038] | 628 | }
|
---|
| 629 |
|
---|
| 630 | // Process Epoch
|
---|
| 631 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 632 | void bncComb::processEpoch(bncTime epoTime, const vector<t_clkCorr*>& clkCorrVec) {
|
---|
| 633 |
|
---|
| 634 | for (unsigned ii = 0; ii < clkCorrVec.size(); ii++) {
|
---|
| 635 | const t_clkCorr* clkCorr = clkCorrVec.at(ii);
|
---|
| 636 | QString staID(clkCorr->_staID.c_str());
|
---|
| 637 | QString prn(clkCorr->_prn.toInternalString().c_str());
|
---|
| 638 | char sys = clkCorr->_prn.system();
|
---|
| 639 |
|
---|
| 640 | // Find/Check the AC Name
|
---|
| 641 | // ----------------------
|
---|
| 642 | QString acName;
|
---|
| 643 | double weigthFactor;
|
---|
| 644 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 645 | while (icAC.hasNext()) {
|
---|
| 646 | cmbAC* AC = icAC.next();
|
---|
| 647 | if (AC->mountPoint == staID) {
|
---|
| 648 | acName = AC->name;
|
---|
| 649 | weigthFactor = AC->weightFactor;
|
---|
| 650 | break;
|
---|
| 651 | }
|
---|
| 652 | }
|
---|
| 653 |
|
---|
[6155] | 654 | // Create new correction
|
---|
| 655 | // ---------------------
|
---|
[10038] | 656 | cmbCorr* newCorr = new cmbCorr();
|
---|
| 657 | newCorr->_prn = prn;
|
---|
| 658 | newCorr->_time = clkCorr->_time;
|
---|
| 659 | newCorr->_iod = clkCorr->_iod;
|
---|
| 660 | newCorr->_acName = acName;
|
---|
[9821] | 661 | newCorr->_weightFactor = weigthFactor;
|
---|
[10216] | 662 | newCorr->_clkCorr = t_clkCorr(static_cast<t_clkCorr>(*clkCorr));
|
---|
[6155] | 663 |
|
---|
[6156] | 664 | // Check orbit correction
|
---|
| 665 | // ----------------------
|
---|
| 666 | if (!_orbCorrections.contains(acName)) {
|
---|
| 667 | delete newCorr;
|
---|
| 668 | continue;
|
---|
| 669 | }
|
---|
| 670 | else {
|
---|
[10216] | 671 | QMap<t_prn, t_orbCorr>& storage = _orbCorrections[acName];
|
---|
[10038] | 672 | if (!storage.contains(clkCorr->_prn) ||
|
---|
[10216] | 673 | storage[clkCorr->_prn]._iod != newCorr->_iod) {
|
---|
[6156] | 674 | delete newCorr;
|
---|
| 675 | continue;
|
---|
| 676 | }
|
---|
| 677 | else {
|
---|
[10038] | 678 | newCorr->_orbCorr = storage[clkCorr->_prn];
|
---|
[6156] | 679 | }
|
---|
| 680 | }
|
---|
| 681 |
|
---|
[6155] | 682 | // Check the Ephemeris
|
---|
| 683 | //--------------------
|
---|
[7012] | 684 | t_eph* ephLast = _ephUser.ephLast(prn);
|
---|
| 685 | t_eph* ephPrev = _ephUser.ephPrev(prn);
|
---|
[6443] | 686 | if (ephLast == 0) {
|
---|
[9676] | 687 | #ifdef BNC_DEBUG_CMB
|
---|
[10216] | 688 | //emit newMessage("bncComb: eph not found for " + prn.mid(0,3).toLatin1(), true);
|
---|
[9676] | 689 | #endif
|
---|
[6155] | 690 | delete newCorr;
|
---|
| 691 | continue;
|
---|
[2986] | 692 | }
|
---|
[9268] | 693 | else if (ephLast->checkState() == t_eph::bad ||
|
---|
| 694 | ephLast->checkState() == t_eph::outdated ||
|
---|
| 695 | ephLast->checkState() == t_eph::unhealthy) {
|
---|
[9676] | 696 | #ifdef BNC_DEBUG_CMB
|
---|
[10216] | 697 | // emit newMessage("bncComb: ephLast not ok (checkState: " + ephLast->checkStateToString().toLatin1() + ") for " + prn.mid(0,3).toLatin1(), true);
|
---|
[9676] | 698 | #endif
|
---|
[9266] | 699 | delete newCorr;
|
---|
| 700 | continue;
|
---|
| 701 | }
|
---|
[3029] | 702 | else {
|
---|
[6443] | 703 | if (ephLast->IOD() == newCorr->_iod) {
|
---|
| 704 | newCorr->_eph = ephLast;
|
---|
[6155] | 705 | }
|
---|
[9268] | 706 | else if (ephPrev && ephPrev->checkState() == t_eph::ok &&
|
---|
| 707 | ephPrev->IOD() == newCorr->_iod) {
|
---|
[6443] | 708 | newCorr->_eph = ephPrev;
|
---|
| 709 | switchToLastEph(ephLast, newCorr);
|
---|
[6155] | 710 | }
|
---|
| 711 | else {
|
---|
[9676] | 712 | #ifdef BNC_DEBUG_CMB
|
---|
[10216] | 713 | // emit newMessage("bncComb: eph not found for " + prn.mid(0,3).toLatin1() +
|
---|
| 714 | // QString(" with IOD %1").arg(newCorr->_iod).toLatin1(), true);
|
---|
[9676] | 715 | #endif
|
---|
[6155] | 716 | delete newCorr;
|
---|
| 717 | continue;
|
---|
| 718 | }
|
---|
[2986] | 719 | }
|
---|
[6155] | 720 |
|
---|
[9635] | 721 | // Check satellite code biases
|
---|
| 722 | // ----------------------------
|
---|
[9819] | 723 | if (_satCodeBiases.contains(acName)) {
|
---|
[10216] | 724 | QMap<t_prn, t_satCodeBias>& storage = _satCodeBiases[acName];
|
---|
[10038] | 725 | if (storage.contains(clkCorr->_prn)) {
|
---|
| 726 | newCorr->_satCodeBias = storage[clkCorr->_prn];
|
---|
[9676] | 727 | QMap<t_frequency::type, double> codeBiasesRefSig;
|
---|
| 728 | for (unsigned ii = 1; ii < cmbRefSig::cIF; ii++) {
|
---|
[10038] | 729 | t_frequency::type frqType = cmbRefSig::toFreq(sys, static_cast<cmbRefSig::type>(ii));
|
---|
[9635] | 730 | char frqNum = t_frequency::toString(frqType)[1];
|
---|
[10038] | 731 | char attrib = cmbRefSig::toAttrib(sys, static_cast<cmbRefSig::type>(ii));
|
---|
[9676] | 732 | QString rnxType2ch = QString("%1%2").arg(frqNum).arg(attrib);
|
---|
[10216] | 733 | for (unsigned ii = 0; ii < newCorr->_satCodeBias._bias.size(); ii++) {
|
---|
| 734 | const t_frqCodeBias& bias = newCorr->_satCodeBias._bias[ii];
|
---|
[9676] | 735 | if (rnxType2ch.toStdString() == bias._rnxType2ch) {
|
---|
| 736 | codeBiasesRefSig[frqType] = bias._value;
|
---|
[9635] | 737 | }
|
---|
| 738 | }
|
---|
| 739 | }
|
---|
[9819] | 740 | if (codeBiasesRefSig.size() == 2) {
|
---|
| 741 | map<t_frequency::type, double> codeCoeff;
|
---|
| 742 | double channel = double(newCorr->_eph->slotNum());
|
---|
| 743 | cmbRefSig::coeff(sys, cmbRefSig::cIF, channel, codeCoeff);
|
---|
| 744 | map<t_frequency::type, double>::const_iterator it;
|
---|
| 745 | for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
|
---|
| 746 | t_frequency::type frqType = it->first;
|
---|
| 747 | newCorr->_satCodeBiasIF += it->second * codeBiasesRefSig[frqType];
|
---|
| 748 | }
|
---|
[9676] | 749 | }
|
---|
[10216] | 750 | newCorr->_satCodeBias._bias.clear();
|
---|
[9635] | 751 | }
|
---|
| 752 | }
|
---|
| 753 |
|
---|
[6155] | 754 | // Store correction into the buffer
|
---|
| 755 | // --------------------------------
|
---|
[10038] | 756 | QVector<cmbCorr*>& corrs = _buffer[sys].corrs;
|
---|
| 757 |
|
---|
| 758 | QVectorIterator<cmbCorr*> itCorr(corrs);
|
---|
| 759 | bool available = false;
|
---|
| 760 | while (itCorr.hasNext()) {
|
---|
| 761 | cmbCorr* corr = itCorr.next();
|
---|
| 762 | QString prn = corr->_prn;
|
---|
| 763 | QString acName = corr->_acName;
|
---|
| 764 | if (newCorr->_acName == acName && newCorr->_prn == prn) {
|
---|
| 765 | available = true;
|
---|
| 766 | }
|
---|
| 767 | }
|
---|
| 768 | if (!available) {
|
---|
| 769 | corrs.push_back(newCorr);
|
---|
| 770 | }
|
---|
| 771 | else {
|
---|
| 772 | delete newCorr;
|
---|
| 773 | continue;
|
---|
| 774 | }
|
---|
[2986] | 775 | }
|
---|
| 776 |
|
---|
[10038] | 777 | // Process Systems of this Epoch
|
---|
| 778 | // ------------------------------
|
---|
[9258] | 779 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
---|
| 780 | while (itSys.hasNext()) {
|
---|
| 781 | itSys.next();
|
---|
| 782 | char sys = itSys.key();
|
---|
[10038] | 783 | _log.clear();
|
---|
| 784 | QTextStream out(&_log, QIODevice::WriteOnly);
|
---|
| 785 | processSystem(epoTime, sys, out);
|
---|
| 786 | emit newMessage(_log, false);
|
---|
[2927] | 787 | }
|
---|
[2898] | 788 | }
|
---|
| 789 |
|
---|
[10038] | 790 | void bncComb::processSystem(bncTime epoTime, char sys, QTextStream& out) {
|
---|
[3028] | 791 |
|
---|
[9635] | 792 | out << "\n" << "Combination: " << sys << "\n"
|
---|
| 793 | << "--------------------------------" << "\n";
|
---|
[2990] | 794 |
|
---|
[3433] | 795 | // Observation Statistics
|
---|
| 796 | // ----------------------
|
---|
[3455] | 797 | bool masterPresent = false;
|
---|
[3433] | 798 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 799 | while (icAC.hasNext()) {
|
---|
| 800 | cmbAC* AC = icAC.next();
|
---|
[9258] | 801 | AC->numObs[sys] = 0;
|
---|
| 802 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
---|
[3433] | 803 | while (itCorr.hasNext()) {
|
---|
| 804 | cmbCorr* corr = itCorr.next();
|
---|
[6157] | 805 | if (corr->_acName == AC->name) {
|
---|
[9258] | 806 | AC->numObs[sys] += 1;
|
---|
| 807 | if (AC->name == _masterOrbitAC[sys]) {
|
---|
[3453] | 808 | masterPresent = true;
|
---|
| 809 | }
|
---|
[3433] | 810 | }
|
---|
| 811 | }
|
---|
[9635] | 812 | out << AC->name.toLatin1().data() << ": " << AC->numObs[sys] << "\n";
|
---|
[3433] | 813 | }
|
---|
| 814 |
|
---|
[3453] | 815 | // If Master not present, switch to another one
|
---|
| 816 | // --------------------------------------------
|
---|
[4889] | 817 | const unsigned switchMasterAfterGap = 1;
|
---|
[3456] | 818 | if (masterPresent) {
|
---|
[9258] | 819 | _masterMissingEpochs[sys] = 0;
|
---|
[3456] | 820 | }
|
---|
| 821 | else {
|
---|
[9258] | 822 | ++_masterMissingEpochs[sys];
|
---|
| 823 | if (_masterMissingEpochs[sys] < switchMasterAfterGap) {
|
---|
[9635] | 824 | out << "Missing Master, Epoch skipped" << "\n";
|
---|
[10038] | 825 | _buffer.remove(sys);
|
---|
[3455] | 826 | emit newMessage(_log, false);
|
---|
| 827 | return;
|
---|
[3453] | 828 | }
|
---|
[3455] | 829 | else {
|
---|
[9258] | 830 | _masterMissingEpochs[sys] = 0;
|
---|
[3455] | 831 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 832 | while (icAC.hasNext()) {
|
---|
| 833 | cmbAC* AC = icAC.next();
|
---|
[9258] | 834 | if (AC->numObs[sys] > 0) {
|
---|
[3455] | 835 | out << "Switching Master AC "
|
---|
[9258] | 836 | << _masterOrbitAC[sys].toLatin1().data() << " --> "
|
---|
[8204] | 837 | << AC->name.toLatin1().data() << " "
|
---|
[10038] | 838 | << epoTime.datestr().c_str() << " "
|
---|
| 839 | << epoTime.timestr().c_str() << "\n";
|
---|
[9258] | 840 | _masterOrbitAC[sys] = AC->name;
|
---|
[10116] | 841 | _masterIsAPC[sys] = AC->isAPC;
|
---|
[3455] | 842 | break;
|
---|
| 843 | }
|
---|
[3452] | 844 | }
|
---|
| 845 | }
|
---|
| 846 | }
|
---|
| 847 |
|
---|
[6157] | 848 | QMap<QString, cmbCorr*> resCorr;
|
---|
[3472] | 849 |
|
---|
| 850 | // Perform the actual Combination using selected Method
|
---|
| 851 | // ----------------------------------------------------
|
---|
| 852 | t_irc irc;
|
---|
[3475] | 853 | ColumnVector dx;
|
---|
[3472] | 854 | if (_method == filter) {
|
---|
[10038] | 855 | irc = processEpoch_filter(epoTime, sys, out, resCorr, dx);
|
---|
[3472] | 856 | }
|
---|
| 857 | else {
|
---|
[10038] | 858 | irc = processEpoch_singleEpoch(epoTime, sys, out, resCorr, dx);
|
---|
[3472] | 859 | }
|
---|
| 860 |
|
---|
[3475] | 861 | // Update Parameter Values, Print Results
|
---|
| 862 | // --------------------------------------
|
---|
[3472] | 863 | if (irc == success) {
|
---|
[9258] | 864 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 865 | cmbParam* pp = _params[sys][iPar-1];
|
---|
[3475] | 866 | pp->xx += dx(iPar);
|
---|
| 867 | if (pp->type == cmbParam::clkSat) {
|
---|
| 868 | if (resCorr.find(pp->prn) != resCorr.end()) {
|
---|
[9676] | 869 | // set clock result
|
---|
[6160] | 870 | resCorr[pp->prn]->_dClkResult = pp->xx / t_CST::c;
|
---|
[9676] | 871 | // Add Code Biases from SINEX File
|
---|
| 872 | if (_bsx) {
|
---|
| 873 | map<t_frequency::type, double> codeCoeff;
|
---|
| 874 | double channel = double(resCorr[pp->prn]->_eph->slotNum());
|
---|
| 875 | cmbRefSig::coeff(sys, cmbRefSig::cIF, channel, codeCoeff);
|
---|
| 876 | t_frequency::type fType1 = cmbRefSig::toFreq(sys, cmbRefSig::c1);
|
---|
| 877 | t_frequency::type fType2 = cmbRefSig::toFreq(sys, cmbRefSig::c2);
|
---|
| 878 | _bsx->determineSsrSatCodeBiases(pp->prn.mid(0,3), codeCoeff[fType1], codeCoeff[fType2], resCorr[pp->prn]->_satCodeBias);
|
---|
| 879 | }
|
---|
[3475] | 880 | }
|
---|
| 881 | }
|
---|
[10038] | 882 | out << epoTime.datestr().c_str() << " "
|
---|
| 883 | << epoTime.timestr().c_str() << " ";
|
---|
[3475] | 884 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
| 885 | out.setFieldWidth(8);
|
---|
| 886 | out.setRealNumberPrecision(4);
|
---|
[9258] | 887 | out << pp->toString(sys) << " "
|
---|
[9635] | 888 | << pp->xx << " +- " << sqrt(_QQ[sys](pp->index,pp->index)) << "\n";
|
---|
[3475] | 889 | out.setFieldWidth(0);
|
---|
| 890 | }
|
---|
[10038] | 891 | printResults(epoTime, out, resCorr);
|
---|
| 892 | dumpResults(epoTime, resCorr);
|
---|
[3472] | 893 | }
|
---|
[10216] | 894 |
|
---|
[10038] | 895 | _buffer.remove(sys);
|
---|
[3472] | 896 | }
|
---|
| 897 |
|
---|
| 898 | // Process Epoch - Filter Method
|
---|
| 899 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10038] | 900 | t_irc bncComb::processEpoch_filter(bncTime epoTime, char sys, QTextStream& out,
|
---|
[6157] | 901 | QMap<QString, cmbCorr*>& resCorr,
|
---|
[3475] | 902 | ColumnVector& dx) {
|
---|
[3472] | 903 |
|
---|
[3429] | 904 | // Prediction Step
|
---|
| 905 | // ---------------
|
---|
[9258] | 906 | int nPar = _params[sys].size();
|
---|
[2933] | 907 | ColumnVector x0(nPar);
|
---|
[9258] | 908 | for (int iPar = 1; iPar <= nPar; iPar++) {
|
---|
| 909 | cmbParam* pp = _params[sys][iPar-1];
|
---|
[3455] | 910 | if (pp->epoSpec) {
|
---|
[3451] | 911 | pp->xx = 0.0;
|
---|
[9258] | 912 | _QQ[sys].Row(iPar) = 0.0;
|
---|
| 913 | _QQ[sys].Column(iPar) = 0.0;
|
---|
| 914 | _QQ[sys](iPar,iPar) = pp->sig0 * pp->sig0;
|
---|
[3451] | 915 | }
|
---|
[3455] | 916 | else {
|
---|
[9258] | 917 | _QQ[sys](iPar,iPar) += pp->sigP * pp->sigP;
|
---|
[3455] | 918 | }
|
---|
[2933] | 919 | x0(iPar) = pp->xx;
|
---|
| 920 | }
|
---|
| 921 |
|
---|
[3487] | 922 | // Check Satellite Positions for Outliers
|
---|
| 923 | // --------------------------------------
|
---|
[10038] | 924 | if (checkOrbits(epoTime, sys, out) != success) {
|
---|
[3487] | 925 | return failure;
|
---|
| 926 | }
|
---|
[3441] | 927 |
|
---|
[3455] | 928 | // Update and outlier detection loop
|
---|
| 929 | // ---------------------------------
|
---|
[9258] | 930 | SymmetricMatrix QQ_sav = _QQ[sys];
|
---|
[3455] | 931 | while (true) {
|
---|
[3135] | 932 |
|
---|
[3455] | 933 | Matrix AA;
|
---|
| 934 | ColumnVector ll;
|
---|
| 935 | DiagonalMatrix PP;
|
---|
[3429] | 936 |
|
---|
[9258] | 937 | if (createAmat(sys, AA, ll, PP, x0, resCorr) != success) {
|
---|
[3472] | 938 | return failure;
|
---|
[3441] | 939 | }
|
---|
[2933] | 940 |
|
---|
[6169] | 941 | dx.ReSize(nPar); dx = 0.0;
|
---|
[9258] | 942 | kalman(AA, ll, PP, _QQ[sys], dx);
|
---|
[6164] | 943 |
|
---|
[3429] | 944 | ColumnVector vv = ll - AA * dx;
|
---|
[3080] | 945 |
|
---|
[3429] | 946 | int maxResIndex;
|
---|
[7297] | 947 | double maxRes = vv.maximum_absolute_value1(maxResIndex);
|
---|
[3429] | 948 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
[7297] | 949 | out.setRealNumberPrecision(3);
|
---|
[10038] | 950 | out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str()
|
---|
[3432] | 951 | << " Maximum Residuum " << maxRes << ' '
|
---|
[9258] | 952 | << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
|
---|
[3432] | 953 | if (maxRes > _MAXRES) {
|
---|
[9258] | 954 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 955 | cmbParam* pp = _params[sys][iPar-1];
|
---|
[7297] | 956 | if (pp->type == cmbParam::offACSat &&
|
---|
[9258] | 957 | pp->AC == corrs(sys)[maxResIndex-1]->_acName &&
|
---|
| 958 | pp->prn == corrs(sys)[maxResIndex-1]->_prn.mid(0,3)) {
|
---|
[3432] | 959 | QQ_sav.Row(iPar) = 0.0;
|
---|
| 960 | QQ_sav.Column(iPar) = 0.0;
|
---|
[3455] | 961 | QQ_sav(iPar,iPar) = pp->sig0 * pp->sig0;
|
---|
[3432] | 962 | }
|
---|
| 963 | }
|
---|
| 964 |
|
---|
[9635] | 965 | out << " Outlier" << "\n";
|
---|
[9258] | 966 | _QQ[sys] = QQ_sav;
|
---|
| 967 | corrs(sys).remove(maxResIndex-1);
|
---|
[3432] | 968 | }
|
---|
| 969 | else {
|
---|
[9635] | 970 | out << " OK" << "\n";
|
---|
[6330] | 971 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
| 972 | out.setRealNumberPrecision(4);
|
---|
[9258] | 973 | for (int ii = 0; ii < corrs(sys).size(); ii++) {
|
---|
| 974 | const cmbCorr* corr = corrs(sys)[ii];
|
---|
[10038] | 975 | out << epoTime.datestr().c_str() << ' '
|
---|
| 976 | << epoTime.timestr().c_str() << " "
|
---|
[6962] | 977 | << corr->_acName << ' ' << corr->_prn.mid(0,3);
|
---|
[6330] | 978 | out.setFieldWidth(10);
|
---|
[9635] | 979 | out << " res = " << vv[ii] << "\n";
|
---|
[6330] | 980 | out.setFieldWidth(0);
|
---|
| 981 | }
|
---|
[3432] | 982 | break;
|
---|
| 983 | }
|
---|
| 984 | }
|
---|
| 985 |
|
---|
[3472] | 986 | return success;
|
---|
[2918] | 987 | }
|
---|
[3011] | 988 |
|
---|
[3201] | 989 | // Print results
|
---|
[3011] | 990 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10038] | 991 | void bncComb::printResults(bncTime epoTime, QTextStream& out,
|
---|
[6157] | 992 | const QMap<QString, cmbCorr*>& resCorr) {
|
---|
[3011] | 993 |
|
---|
[6157] | 994 | QMapIterator<QString, cmbCorr*> it(resCorr);
|
---|
[3011] | 995 | while (it.hasNext()) {
|
---|
| 996 | it.next();
|
---|
[6157] | 997 | cmbCorr* corr = it.value();
|
---|
| 998 | const t_eph* eph = corr->_eph;
|
---|
[3015] | 999 | if (eph) {
|
---|
[8542] | 1000 | ColumnVector xc(6);
|
---|
[6109] | 1001 | ColumnVector vv(3);
|
---|
[10038] | 1002 | if (eph->getCrd(epoTime, xc, vv, false) != success) {
|
---|
[9268] | 1003 | continue;
|
---|
| 1004 | }
|
---|
[10038] | 1005 | out << epoTime.datestr().c_str() << " "
|
---|
| 1006 | << epoTime.timestr().c_str() << " ";
|
---|
[3015] | 1007 | out.setFieldWidth(3);
|
---|
[6962] | 1008 | out << "Full Clock " << corr->_prn.mid(0,3) << " " << corr->_iod << " ";
|
---|
[3015] | 1009 | out.setFieldWidth(14);
|
---|
[9635] | 1010 | out << (xc(4) + corr->_dClkResult) * t_CST::c << "\n";
|
---|
[3370] | 1011 | out.setFieldWidth(0);
|
---|
[3015] | 1012 | }
|
---|
| 1013 | else {
|
---|
[9691] | 1014 | out << "bncComb::printResults bug" << "\n";
|
---|
[3015] | 1015 | }
|
---|
[9676] | 1016 | out.flush();
|
---|
[3011] | 1017 | }
|
---|
| 1018 | }
|
---|
[3202] | 1019 |
|
---|
| 1020 | // Send results to RTNet Decoder and directly to PPP Client
|
---|
| 1021 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10038] | 1022 | void bncComb::dumpResults(bncTime epoTime, const QMap<QString, cmbCorr*>& resCorr) {
|
---|
[3202] | 1023 |
|
---|
[6161] | 1024 | QList<t_orbCorr> orbCorrections;
|
---|
| 1025 | QList<t_clkCorr> clkCorrections;
|
---|
[9676] | 1026 | QList<t_satCodeBias> satCodeBiasList;
|
---|
[6161] | 1027 |
|
---|
[3214] | 1028 | unsigned year, month, day, hour, minute;
|
---|
| 1029 | double sec;
|
---|
[10038] | 1030 | epoTime.civil_date(year, month, day);
|
---|
| 1031 | epoTime.civil_time(hour, minute, sec);
|
---|
[3214] | 1032 |
|
---|
[9676] | 1033 | QString outLines = QString().asprintf("* %4d %2d %2d %d %d %12.8f\n",
|
---|
| 1034 | year, month, day, hour, minute, sec);
|
---|
[3214] | 1035 |
|
---|
[6157] | 1036 | QMapIterator<QString, cmbCorr*> it(resCorr);
|
---|
[3202] | 1037 | while (it.hasNext()) {
|
---|
| 1038 | it.next();
|
---|
[6157] | 1039 | cmbCorr* corr = it.value();
|
---|
[10038] | 1040 |
|
---|
[9676] | 1041 | // ORBIT
|
---|
[10216] | 1042 | t_orbCorr orbCorr(corr->_orbCorr);
|
---|
[7013] | 1043 | orbCorr._staID = "INTERNAL";
|
---|
| 1044 | orbCorrections.push_back(orbCorr);
|
---|
[10038] | 1045 |
|
---|
[9676] | 1046 | // CLOCK
|
---|
[10216] | 1047 | t_clkCorr clkCorr(corr->_clkCorr);
|
---|
[7013] | 1048 | clkCorr._staID = "INTERNAL";
|
---|
| 1049 | clkCorr._dClk = corr->_dClkResult;
|
---|
| 1050 | clkCorr._dotDClk = 0.0;
|
---|
| 1051 | clkCorr._dotDotDClk = 0.0;
|
---|
| 1052 | clkCorrections.push_back(clkCorr);
|
---|
[10038] | 1053 |
|
---|
[8542] | 1054 | ColumnVector xc(6);
|
---|
[4978] | 1055 | ColumnVector vv(3);
|
---|
[7013] | 1056 | corr->_eph->setClkCorr(dynamic_cast<const t_clkCorr*>(&clkCorr));
|
---|
| 1057 | corr->_eph->setOrbCorr(dynamic_cast<const t_orbCorr*>(&orbCorr));
|
---|
[10038] | 1058 | if (corr->_eph->getCrd(epoTime, xc, vv, true) != success) {
|
---|
[9268] | 1059 | delete corr;
|
---|
| 1060 | continue;
|
---|
| 1061 | }
|
---|
[7012] | 1062 |
|
---|
[4978] | 1063 | // Correction Phase Center --> CoM
|
---|
| 1064 | // -------------------------------
|
---|
[10153] | 1065 | ColumnVector dx(3); dx = 0.0;
|
---|
[10116] | 1066 | ColumnVector apc(3); apc = 0.0;
|
---|
| 1067 | ColumnVector com(3); com = 0.0;
|
---|
| 1068 | bool masterIsAPC = true;
|
---|
[4978] | 1069 | if (_antex) {
|
---|
[10038] | 1070 | double Mjd = epoTime.mjd() + epoTime.daysec()/86400.0;
|
---|
[10116] | 1071 | char sys = corr->_eph->prn().system();
|
---|
| 1072 | masterIsAPC = _masterIsAPC[sys];
|
---|
[6157] | 1073 | if (_antex->satCoMcorrection(corr->_prn, Mjd, xc.Rows(1,3), dx) != success) {
|
---|
[4992] | 1074 | dx = 0;
|
---|
[8204] | 1075 | _log += "antenna not found " + corr->_prn.mid(0,3).toLatin1() + '\n';
|
---|
[3214] | 1076 | }
|
---|
| 1077 | }
|
---|
[10116] | 1078 | if (masterIsAPC) {
|
---|
| 1079 | apc(1) = xc(1);
|
---|
| 1080 | apc(2) = xc(2);
|
---|
| 1081 | apc(3) = xc(3);
|
---|
| 1082 | com(1) = xc(1)-dx(1);
|
---|
| 1083 | com(2) = xc(2)-dx(2);
|
---|
| 1084 | com(3) = xc(3)-dx(3);
|
---|
| 1085 | }
|
---|
| 1086 | else {
|
---|
| 1087 | com(1) = xc(1);
|
---|
| 1088 | com(2) = xc(2);
|
---|
| 1089 | com(3) = xc(3);
|
---|
| 1090 | apc(1) = xc(1)+dx(1);
|
---|
| 1091 | apc(2) = xc(2)+dx(2);
|
---|
| 1092 | apc(3) = xc(3)+dx(3);
|
---|
| 1093 | }
|
---|
[7012] | 1094 |
|
---|
| 1095 | outLines += corr->_prn.mid(0,3);
|
---|
[10109] | 1096 | QString hlp = QString().asprintf(
|
---|
| 1097 | " APC 3 %15.4f %15.4f %15.4f"
|
---|
[9676] | 1098 | " Clk 1 %15.4f"
|
---|
| 1099 | " Vel 3 %15.4f %15.4f %15.4f"
|
---|
| 1100 | " CoM 3 %15.4f %15.4f %15.4f",
|
---|
[10116] | 1101 | apc(1), apc(2), apc(3),
|
---|
[9676] | 1102 | xc(4) * t_CST::c,
|
---|
| 1103 | vv(1), vv(2), vv(3),
|
---|
[10116] | 1104 | com(1), com(2), com(3));
|
---|
[5337] | 1105 | outLines += hlp;
|
---|
[9676] | 1106 | hlp.clear();
|
---|
[5337] | 1107 |
|
---|
[10101] | 1108 | // CODE BIASES
|
---|
[10216] | 1109 | if (corr->_satCodeBias._bias.size()) {
|
---|
| 1110 | t_satCodeBias satCodeBias(corr->_satCodeBias);
|
---|
[10101] | 1111 | satCodeBias._staID = "INTERNAL";
|
---|
| 1112 | satCodeBiasList.push_back(satCodeBias);
|
---|
[9676] | 1113 | hlp = QString().asprintf(" CodeBias %2lu", satCodeBias._bias.size());
|
---|
| 1114 | outLines += hlp;
|
---|
| 1115 | hlp.clear();
|
---|
| 1116 | for (unsigned ii = 0; ii < satCodeBias._bias.size(); ii++) {
|
---|
| 1117 | const t_frqCodeBias& frqCodeBias = satCodeBias._bias[ii];
|
---|
| 1118 | if (!frqCodeBias._rnxType2ch.empty()) {
|
---|
| 1119 | hlp = QString().asprintf(" %s%10.6f", frqCodeBias._rnxType2ch.c_str(), frqCodeBias._value);
|
---|
| 1120 | outLines += hlp;
|
---|
| 1121 | hlp.clear();
|
---|
| 1122 | }
|
---|
| 1123 | }
|
---|
| 1124 | }
|
---|
| 1125 | outLines += "\n";
|
---|
[3214] | 1126 | delete corr;
|
---|
| 1127 | }
|
---|
| 1128 |
|
---|
[5337] | 1129 | outLines += "EOE\n"; // End Of Epoch flag
|
---|
[9710] | 1130 | //cout << outLines.toStdString();
|
---|
[5337] | 1131 |
|
---|
[3215] | 1132 | if (!_rtnetDecoder) {
|
---|
| 1133 | _rtnetDecoder = new bncRtnetDecoder();
|
---|
| 1134 | }
|
---|
[3221] | 1135 |
|
---|
[3215] | 1136 | vector<string> errmsg;
|
---|
[8204] | 1137 | _rtnetDecoder->Decode(outLines.toLatin1().data(), outLines.length(), errmsg);
|
---|
[3215] | 1138 |
|
---|
[5861] | 1139 | // Send new Corrections to PPP etc.
|
---|
| 1140 | // --------------------------------
|
---|
[6161] | 1141 | if (orbCorrections.size() > 0 && clkCorrections.size() > 0) {
|
---|
| 1142 | emit newOrbCorrections(orbCorrections);
|
---|
| 1143 | emit newClkCorrections(clkCorrections);
|
---|
| 1144 | }
|
---|
[9676] | 1145 | if (satCodeBiasList.size()) {
|
---|
| 1146 | emit newCodeBiases(satCodeBiasList);
|
---|
| 1147 | }
|
---|
[3202] | 1148 | }
|
---|
[3455] | 1149 |
|
---|
| 1150 | // Create First Design Matrix and Vector of Measurements
|
---|
| 1151 | ////////////////////////////////////////////////////////////////////////////
|
---|
[9258] | 1152 | t_irc bncComb::createAmat(char sys, Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
|
---|
| 1153 | const ColumnVector& x0, QMap<QString, cmbCorr*>& resCorr) {
|
---|
[3455] | 1154 |
|
---|
[9258] | 1155 | unsigned nPar = _params[sys].size();
|
---|
| 1156 | unsigned nObs = corrs(sys).size();
|
---|
[3455] | 1157 |
|
---|
| 1158 | if (nObs == 0) {
|
---|
| 1159 | return failure;
|
---|
| 1160 | }
|
---|
| 1161 |
|
---|
[9258] | 1162 | int maxSat = _cmbSysPrn[sys];
|
---|
[3455] | 1163 |
|
---|
[9259] | 1164 | const int nCon = (_method == filter) ? 1 + maxSat : 0;
|
---|
[3483] | 1165 |
|
---|
[3455] | 1166 | AA.ReSize(nObs+nCon, nPar); AA = 0.0;
|
---|
| 1167 | ll.ReSize(nObs+nCon); ll = 0.0;
|
---|
| 1168 | PP.ReSize(nObs+nCon); PP = 1.0 / (sigObs * sigObs);
|
---|
| 1169 |
|
---|
| 1170 | int iObs = 0;
|
---|
[9258] | 1171 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
---|
[3455] | 1172 | while (itCorr.hasNext()) {
|
---|
| 1173 | cmbCorr* corr = itCorr.next();
|
---|
[6157] | 1174 | QString prn = corr->_prn;
|
---|
[3487] | 1175 |
|
---|
[3455] | 1176 | ++iObs;
|
---|
| 1177 |
|
---|
[9258] | 1178 | if (corr->_acName == _masterOrbitAC[sys] && resCorr.find(prn) == resCorr.end()) {
|
---|
[6157] | 1179 | resCorr[prn] = new cmbCorr(*corr);
|
---|
[3455] | 1180 | }
|
---|
| 1181 |
|
---|
[9258] | 1182 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 1183 | cmbParam* pp = _params[sys][iPar-1];
|
---|
| 1184 | AA(iObs, iPar) = pp->partial(sys, corr->_acName, prn);
|
---|
[3455] | 1185 | }
|
---|
| 1186 |
|
---|
[10216] | 1187 | ll(iObs) = (corr->_clkCorr._dClk * t_CST::c - corr->_satCodeBiasIF) - DotProduct(AA.Row(iObs), x0);
|
---|
[9819] | 1188 |
|
---|
[9821] | 1189 | PP(iObs, iObs) *= 1.0 / (corr->_weightFactor * corr->_weightFactor);
|
---|
[3455] | 1190 | }
|
---|
| 1191 |
|
---|
| 1192 | // Regularization
|
---|
| 1193 | // --------------
|
---|
[3474] | 1194 | if (_method == filter) {
|
---|
| 1195 | const double Ph = 1.e6;
|
---|
| 1196 | PP(nObs+1) = Ph;
|
---|
[9258] | 1197 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 1198 | cmbParam* pp = _params[sys][iPar-1];
|
---|
[3465] | 1199 | if ( AA.Column(iPar).maximum_absolute_value() > 0.0 &&
|
---|
[3474] | 1200 | pp->type == cmbParam::clkSat ) {
|
---|
| 1201 | AA(nObs+1, iPar) = 1.0;
|
---|
[3455] | 1202 | }
|
---|
| 1203 | }
|
---|
[9258] | 1204 | unsigned flag = 0;
|
---|
| 1205 | if (sys == 'E') {
|
---|
| 1206 | flag = 1;
|
---|
| 1207 | }
|
---|
[10026] | 1208 | // if (sys == 'R') {
|
---|
| 1209 | // return success;
|
---|
| 1210 | // }
|
---|
[9259] | 1211 | int iCond = 1;
|
---|
| 1212 | // GNSS
|
---|
[9258] | 1213 | for (unsigned iGnss = 1; iGnss <= _cmbSysPrn[sys]; iGnss++) {
|
---|
| 1214 | QString prn = QString("%1%2_%3").arg(sys).arg(iGnss, 2, 10, QChar('0')).arg(flag);
|
---|
[3474] | 1215 | ++iCond;
|
---|
| 1216 | PP(nObs+iCond) = Ph;
|
---|
[9258] | 1217 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 1218 | cmbParam* pp = _params[sys][iPar-1];
|
---|
[7299] | 1219 | if ( pp &&
|
---|
| 1220 | AA.Column(iPar).maximum_absolute_value() > 0.0 &&
|
---|
[7297] | 1221 | pp->type == cmbParam::offACSat &&
|
---|
[3474] | 1222 | pp->prn == prn) {
|
---|
| 1223 | AA(nObs+iCond, iPar) = 1.0;
|
---|
| 1224 | }
|
---|
| 1225 | }
|
---|
| 1226 | }
|
---|
[3455] | 1227 | }
|
---|
| 1228 |
|
---|
| 1229 | return success;
|
---|
| 1230 | }
|
---|
[3470] | 1231 |
|
---|
| 1232 | // Process Epoch - Single-Epoch Method
|
---|
| 1233 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10038] | 1234 | t_irc bncComb::processEpoch_singleEpoch(bncTime epoTime, char sys, QTextStream& out,
|
---|
[6157] | 1235 | QMap<QString, cmbCorr*>& resCorr,
|
---|
[3475] | 1236 | ColumnVector& dx) {
|
---|
[3470] | 1237 |
|
---|
[3487] | 1238 | // Check Satellite Positions for Outliers
|
---|
| 1239 | // --------------------------------------
|
---|
[10038] | 1240 | if (checkOrbits(epoTime, sys, out) != success) {
|
---|
[3487] | 1241 | return failure;
|
---|
| 1242 | }
|
---|
| 1243 |
|
---|
[3482] | 1244 | // Outlier Detection Loop
|
---|
| 1245 | // ----------------------
|
---|
| 1246 | while (true) {
|
---|
[7297] | 1247 |
|
---|
[3482] | 1248 | // Remove Satellites that are not in Master
|
---|
| 1249 | // ----------------------------------------
|
---|
[9258] | 1250 | QMutableVectorIterator<cmbCorr*> it(corrs(sys));
|
---|
[3482] | 1251 | while (it.hasNext()) {
|
---|
| 1252 | cmbCorr* corr = it.next();
|
---|
[6157] | 1253 | QString prn = corr->_prn;
|
---|
[3482] | 1254 | bool foundMaster = false;
|
---|
[9258] | 1255 | QVectorIterator<cmbCorr*> itHlp(corrs(sys));
|
---|
[3482] | 1256 | while (itHlp.hasNext()) {
|
---|
| 1257 | cmbCorr* corrHlp = itHlp.next();
|
---|
[6157] | 1258 | QString prnHlp = corrHlp->_prn;
|
---|
| 1259 | QString ACHlp = corrHlp->_acName;
|
---|
[9258] | 1260 | if (ACHlp == _masterOrbitAC[sys] && prn == prnHlp) {
|
---|
[3482] | 1261 | foundMaster = true;
|
---|
| 1262 | break;
|
---|
| 1263 | }
|
---|
[3476] | 1264 | }
|
---|
[3482] | 1265 | if (!foundMaster) {
|
---|
[3556] | 1266 | delete corr;
|
---|
[3482] | 1267 | it.remove();
|
---|
| 1268 | }
|
---|
[3473] | 1269 | }
|
---|
[7297] | 1270 |
|
---|
[3482] | 1271 | // Count Number of Observations per Satellite and per AC
|
---|
| 1272 | // -----------------------------------------------------
|
---|
| 1273 | QMap<QString, int> numObsPrn;
|
---|
| 1274 | QMap<QString, int> numObsAC;
|
---|
[9258] | 1275 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
---|
[3482] | 1276 | while (itCorr.hasNext()) {
|
---|
| 1277 | cmbCorr* corr = itCorr.next();
|
---|
[6157] | 1278 | QString prn = corr->_prn;
|
---|
| 1279 | QString AC = corr->_acName;
|
---|
[3482] | 1280 | if (numObsPrn.find(prn) == numObsPrn.end()) {
|
---|
| 1281 | numObsPrn[prn] = 1;
|
---|
| 1282 | }
|
---|
| 1283 | else {
|
---|
| 1284 | numObsPrn[prn] += 1;
|
---|
| 1285 | }
|
---|
| 1286 | if (numObsAC.find(AC) == numObsAC.end()) {
|
---|
| 1287 | numObsAC[AC] = 1;
|
---|
| 1288 | }
|
---|
| 1289 | else {
|
---|
| 1290 | numObsAC[AC] += 1;
|
---|
| 1291 | }
|
---|
[3476] | 1292 | }
|
---|
[7297] | 1293 |
|
---|
[9258] | 1294 | // Clean-Up the Parameters
|
---|
| 1295 | // -----------------------
|
---|
| 1296 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
| 1297 | delete _params[sys][iPar-1];
|
---|
[3474] | 1298 | }
|
---|
[9258] | 1299 | _params[sys].clear();
|
---|
[7297] | 1300 |
|
---|
[3482] | 1301 | // Set new Parameters
|
---|
| 1302 | // ------------------
|
---|
| 1303 | int nextPar = 0;
|
---|
[7297] | 1304 |
|
---|
[3482] | 1305 | QMapIterator<QString, int> itAC(numObsAC);
|
---|
| 1306 | while (itAC.hasNext()) {
|
---|
| 1307 | itAC.next();
|
---|
| 1308 | const QString& AC = itAC.key();
|
---|
| 1309 | int numObs = itAC.value();
|
---|
[9258] | 1310 | if (AC != _masterOrbitAC[sys] && numObs > 0) {
|
---|
| 1311 | _params[sys].push_back(new cmbParam(cmbParam::offACgnss, ++nextPar, AC, ""));
|
---|
[3482] | 1312 | }
|
---|
[7297] | 1313 | }
|
---|
| 1314 |
|
---|
[3482] | 1315 | QMapIterator<QString, int> itPrn(numObsPrn);
|
---|
| 1316 | while (itPrn.hasNext()) {
|
---|
| 1317 | itPrn.next();
|
---|
| 1318 | const QString& prn = itPrn.key();
|
---|
| 1319 | int numObs = itPrn.value();
|
---|
| 1320 | if (numObs > 0) {
|
---|
[9258] | 1321 | _params[sys].push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
|
---|
[3482] | 1322 | }
|
---|
[7297] | 1323 | }
|
---|
| 1324 |
|
---|
[9258] | 1325 | int nPar = _params[sys].size();
|
---|
[7297] | 1326 | ColumnVector x0(nPar);
|
---|
[3482] | 1327 | x0 = 0.0;
|
---|
[7297] | 1328 |
|
---|
[3482] | 1329 | // Create First-Design Matrix
|
---|
| 1330 | // --------------------------
|
---|
| 1331 | Matrix AA;
|
---|
| 1332 | ColumnVector ll;
|
---|
| 1333 | DiagonalMatrix PP;
|
---|
[9258] | 1334 | if (createAmat(sys, AA, ll, PP, x0, resCorr) != success) {
|
---|
[3482] | 1335 | return failure;
|
---|
[3476] | 1336 | }
|
---|
[7297] | 1337 |
|
---|
[3482] | 1338 | ColumnVector vv;
|
---|
| 1339 | try {
|
---|
| 1340 | Matrix ATP = AA.t() * PP;
|
---|
| 1341 | SymmetricMatrix NN; NN << ATP * AA;
|
---|
| 1342 | ColumnVector bb = ATP * ll;
|
---|
[9258] | 1343 | _QQ[sys] = NN.i();
|
---|
| 1344 | dx = _QQ[sys] * bb;
|
---|
[3482] | 1345 | vv = ll - AA * dx;
|
---|
[3476] | 1346 | }
|
---|
[3482] | 1347 | catch (Exception& exc) {
|
---|
[9635] | 1348 | out << exc.what() << "\n";
|
---|
[3482] | 1349 | return failure;
|
---|
[3476] | 1350 | }
|
---|
[3474] | 1351 |
|
---|
[3482] | 1352 | int maxResIndex;
|
---|
[7297] | 1353 | double maxRes = vv.maximum_absolute_value1(maxResIndex);
|
---|
[3482] | 1354 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
[7297] | 1355 | out.setRealNumberPrecision(3);
|
---|
[10038] | 1356 | out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str()
|
---|
[3482] | 1357 | << " Maximum Residuum " << maxRes << ' '
|
---|
[9258] | 1358 | << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
|
---|
[3474] | 1359 |
|
---|
[3482] | 1360 | if (maxRes > _MAXRES) {
|
---|
[9635] | 1361 | out << " Outlier" << "\n";
|
---|
[9258] | 1362 | delete corrs(sys)[maxResIndex-1];
|
---|
| 1363 | corrs(sys).remove(maxResIndex-1);
|
---|
[3474] | 1364 | }
|
---|
[3482] | 1365 | else {
|
---|
[9635] | 1366 | out << " OK" << "\n";
|
---|
[3482] | 1367 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
[7297] | 1368 | out.setRealNumberPrecision(3);
|
---|
[3482] | 1369 | for (int ii = 0; ii < vv.Nrows(); ii++) {
|
---|
[9258] | 1370 | const cmbCorr* corr = corrs(sys)[ii];
|
---|
[10038] | 1371 | out << epoTime.datestr().c_str() << ' '
|
---|
| 1372 | << epoTime.timestr().c_str() << " "
|
---|
[6962] | 1373 | << corr->_acName << ' ' << corr->_prn.mid(0,3);
|
---|
[3482] | 1374 | out.setFieldWidth(6);
|
---|
[9635] | 1375 | out << " res = " << vv[ii] << "\n";
|
---|
[3482] | 1376 | out.setFieldWidth(0);
|
---|
| 1377 | }
|
---|
| 1378 | return success;
|
---|
[3474] | 1379 | }
|
---|
| 1380 |
|
---|
[3473] | 1381 | }
|
---|
[3474] | 1382 |
|
---|
[3482] | 1383 | return failure;
|
---|
[3470] | 1384 | }
|
---|
[3487] | 1385 |
|
---|
| 1386 | // Check Satellite Positions for Outliers
|
---|
| 1387 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10038] | 1388 | t_irc bncComb::checkOrbits(bncTime epoTime, char sys, QTextStream& out) {
|
---|
[3487] | 1389 |
|
---|
[10153] | 1390 | const double MAX_DISPLACEMENT_INIT = 0.50;
|
---|
[3488] | 1391 |
|
---|
[10153] | 1392 | double MAX_DISPLACEMENT = MAX_DISPLACEMENT_INIT;
|
---|
| 1393 | if (sys == 'C') {
|
---|
| 1394 | MAX_DISPLACEMENT *= 10.0;
|
---|
| 1395 | }
|
---|
| 1396 | if (sys == 'R') {
|
---|
| 1397 | MAX_DISPLACEMENT *= 2.0;
|
---|
| 1398 | }
|
---|
| 1399 |
|
---|
[3502] | 1400 | // Switch to last ephemeris (if possible)
|
---|
| 1401 | // --------------------------------------
|
---|
[9258] | 1402 | QMutableVectorIterator<cmbCorr*> im(corrs(sys));
|
---|
[3501] | 1403 | while (im.hasNext()) {
|
---|
| 1404 | cmbCorr* corr = im.next();
|
---|
[6157] | 1405 | QString prn = corr->_prn;
|
---|
[6443] | 1406 |
|
---|
[7012] | 1407 | t_eph* ephLast = _ephUser.ephLast(prn);
|
---|
| 1408 | t_eph* ephPrev = _ephUser.ephPrev(prn);
|
---|
[6443] | 1409 |
|
---|
| 1410 | if (ephLast == 0) {
|
---|
[9635] | 1411 | out << "checkOrbit: missing eph (not found) " << corr->_prn.mid(0,3) << "\n";
|
---|
[3556] | 1412 | delete corr;
|
---|
[3501] | 1413 | im.remove();
|
---|
| 1414 | }
|
---|
[6157] | 1415 | else if (corr->_eph == 0) {
|
---|
[9635] | 1416 | out << "checkOrbit: missing eph (zero) " << corr->_prn.mid(0,3) << "\n";
|
---|
[3556] | 1417 | delete corr;
|
---|
[3503] | 1418 | im.remove();
|
---|
| 1419 | }
|
---|
[3502] | 1420 | else {
|
---|
[6443] | 1421 | if ( corr->_eph == ephLast || corr->_eph == ephPrev ) {
|
---|
| 1422 | switchToLastEph(ephLast, corr);
|
---|
[3502] | 1423 | }
|
---|
| 1424 | else {
|
---|
[9635] | 1425 | out << "checkOrbit: missing eph (deleted) " << corr->_prn.mid(0,3) << "\n";
|
---|
[3556] | 1426 | delete corr;
|
---|
[3502] | 1427 | im.remove();
|
---|
| 1428 | }
|
---|
| 1429 | }
|
---|
[3501] | 1430 | }
|
---|
| 1431 |
|
---|
[3488] | 1432 | while (true) {
|
---|
| 1433 |
|
---|
| 1434 | // Compute Mean Corrections for all Satellites
|
---|
| 1435 | // -------------------------------------------
|
---|
[3489] | 1436 | QMap<QString, int> numCorr;
|
---|
[3488] | 1437 | QMap<QString, ColumnVector> meanRao;
|
---|
[9258] | 1438 | QVectorIterator<cmbCorr*> it(corrs(sys));
|
---|
[3488] | 1439 | while (it.hasNext()) {
|
---|
| 1440 | cmbCorr* corr = it.next();
|
---|
[6157] | 1441 | QString prn = corr->_prn;
|
---|
[3488] | 1442 | if (meanRao.find(prn) == meanRao.end()) {
|
---|
| 1443 | meanRao[prn].ReSize(4);
|
---|
[10216] | 1444 | meanRao[prn].Rows(1,3) = corr->_orbCorr._xr;
|
---|
[7297] | 1445 | meanRao[prn](4) = 1;
|
---|
[3488] | 1446 | }
|
---|
| 1447 | else {
|
---|
[10216] | 1448 | meanRao[prn].Rows(1,3) += corr->_orbCorr._xr;
|
---|
[7297] | 1449 | meanRao[prn](4) += 1;
|
---|
[3488] | 1450 | }
|
---|
[3489] | 1451 | if (numCorr.find(prn) == numCorr.end()) {
|
---|
| 1452 | numCorr[prn] = 1;
|
---|
| 1453 | }
|
---|
| 1454 | else {
|
---|
| 1455 | numCorr[prn] += 1;
|
---|
| 1456 | }
|
---|
[3487] | 1457 | }
|
---|
[7297] | 1458 |
|
---|
[9258] | 1459 | // Compute Differences wrt. Mean, find Maximum
|
---|
| 1460 | // -------------------------------------------
|
---|
[3488] | 1461 | QMap<QString, cmbCorr*> maxDiff;
|
---|
| 1462 | it.toFront();
|
---|
| 1463 | while (it.hasNext()) {
|
---|
| 1464 | cmbCorr* corr = it.next();
|
---|
[6157] | 1465 | QString prn = corr->_prn;
|
---|
[3488] | 1466 | if (meanRao[prn](4) != 0) {
|
---|
| 1467 | meanRao[prn] /= meanRao[prn](4);
|
---|
| 1468 | meanRao[prn](4) = 0;
|
---|
| 1469 | }
|
---|
[10216] | 1470 | corr->_diffRao = corr->_orbCorr._xr - meanRao[prn].Rows(1,3);
|
---|
[3488] | 1471 | if (maxDiff.find(prn) == maxDiff.end()) {
|
---|
| 1472 | maxDiff[prn] = corr;
|
---|
| 1473 | }
|
---|
| 1474 | else {
|
---|
[8901] | 1475 | double normMax = maxDiff[prn]->_diffRao.NormFrobenius();
|
---|
| 1476 | double norm = corr->_diffRao.NormFrobenius();
|
---|
[3488] | 1477 | if (norm > normMax) {
|
---|
| 1478 | maxDiff[prn] = corr;
|
---|
| 1479 | }
|
---|
[7297] | 1480 | }
|
---|
[3487] | 1481 | }
|
---|
[7297] | 1482 |
|
---|
[3655] | 1483 | if (_ACs.size() == 1) {
|
---|
| 1484 | break;
|
---|
| 1485 | }
|
---|
| 1486 |
|
---|
[3488] | 1487 | // Remove Outliers
|
---|
| 1488 | // ---------------
|
---|
| 1489 | bool removed = false;
|
---|
[9258] | 1490 | QMutableVectorIterator<cmbCorr*> im(corrs(sys));
|
---|
[3488] | 1491 | while (im.hasNext()) {
|
---|
| 1492 | cmbCorr* corr = im.next();
|
---|
[6157] | 1493 | QString prn = corr->_prn;
|
---|
[3489] | 1494 | if (numCorr[prn] < 2) {
|
---|
[3556] | 1495 | delete corr;
|
---|
[3489] | 1496 | im.remove();
|
---|
| 1497 | }
|
---|
| 1498 | else if (corr == maxDiff[prn]) {
|
---|
[8901] | 1499 | double norm = corr->_diffRao.NormFrobenius();
|
---|
[3488] | 1500 | if (norm > MAX_DISPLACEMENT) {
|
---|
[10038] | 1501 | out << epoTime.datestr().c_str() << " "
|
---|
| 1502 | << epoTime.timestr().c_str() << " "
|
---|
[7297] | 1503 | << "Orbit Outlier: "
|
---|
[8204] | 1504 | << corr->_acName.toLatin1().data() << " "
|
---|
| 1505 | << prn.mid(0,3).toLatin1().data() << " "
|
---|
[7297] | 1506 | << corr->_iod << " "
|
---|
[9635] | 1507 | << norm << "\n";
|
---|
[3556] | 1508 | delete corr;
|
---|
[3488] | 1509 | im.remove();
|
---|
| 1510 | removed = true;
|
---|
| 1511 | }
|
---|
| 1512 | }
|
---|
[3487] | 1513 | }
|
---|
[7297] | 1514 |
|
---|
[3488] | 1515 | if (!removed) {
|
---|
| 1516 | break;
|
---|
| 1517 | }
|
---|
[3487] | 1518 | }
|
---|
| 1519 |
|
---|
| 1520 | return success;
|
---|
| 1521 | }
|
---|
[3588] | 1522 |
|
---|
[7297] | 1523 | //
|
---|
[3588] | 1524 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5583] | 1525 | void bncComb::slotProviderIDChanged(QString mountPoint) {
|
---|
| 1526 | QMutexLocker locker(&_mutex);
|
---|
| 1527 |
|
---|
[8065] | 1528 | QTextStream out(&_log, QIODevice::WriteOnly);
|
---|
| 1529 |
|
---|
[5583] | 1530 | // Find the AC Name
|
---|
| 1531 | // ----------------
|
---|
| 1532 | QString acName;
|
---|
| 1533 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
| 1534 | while (icAC.hasNext()) {
|
---|
[10038] | 1535 | cmbAC *AC = icAC.next();
|
---|
[5583] | 1536 | if (AC->mountPoint == mountPoint) {
|
---|
| 1537 | acName = AC->name;
|
---|
[10038] | 1538 | out << "Provider ID changed: AC " << AC->name.toLatin1().data() << " "
|
---|
[10081] | 1539 | << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
|
---|
[10038] | 1540 | << "\n";
|
---|
[5583] | 1541 | break;
|
---|
| 1542 | }
|
---|
| 1543 | }
|
---|
| 1544 | if (acName.isEmpty()) {
|
---|
| 1545 | return;
|
---|
| 1546 | }
|
---|
[9258] | 1547 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
---|
| 1548 | while (itSys.hasNext()) {
|
---|
| 1549 | itSys.next();
|
---|
| 1550 | char sys = itSys.key();
|
---|
| 1551 | // Remove all corrections of the corresponding AC
|
---|
| 1552 | // ----------------------------------------------
|
---|
[10038] | 1553 | QVector<cmbCorr*> &corrVec = _buffer[sys].corrs;
|
---|
| 1554 | QMutableVectorIterator<cmbCorr*> it(corrVec);
|
---|
| 1555 | while (it.hasNext()) {
|
---|
| 1556 | cmbCorr *corr = it.next();
|
---|
| 1557 | if (acName == corr->_acName) {
|
---|
| 1558 | delete corr;
|
---|
| 1559 | it.remove();
|
---|
[5583] | 1560 | }
|
---|
| 1561 | }
|
---|
[9258] | 1562 | // Reset Satellite Offsets
|
---|
| 1563 | // -----------------------
|
---|
| 1564 | if (_method == filter) {
|
---|
| 1565 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
[10038] | 1566 | cmbParam *pp = _params[sys][iPar - 1];
|
---|
[9258] | 1567 | if (pp->AC == acName && pp->type == cmbParam::offACSat) {
|
---|
| 1568 | pp->xx = 0.0;
|
---|
[10038] | 1569 | _QQ[sys].Row(iPar) = 0.0;
|
---|
[9258] | 1570 | _QQ[sys].Column(iPar) = 0.0;
|
---|
[10038] | 1571 | _QQ[sys](iPar, iPar) = pp->sig0 * pp->sig0;
|
---|
[9258] | 1572 | }
|
---|
[5585] | 1573 | }
|
---|
| 1574 | }
|
---|
| 1575 | }
|
---|
[5583] | 1576 | }
|
---|