| 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 | *
|
|---|
| 13 | * Changes:
|
|---|
| 14 | *
|
|---|
| 15 | * -----------------------------------------------------------------------*/
|
|---|
| 16 |
|
|---|
| 17 | #include <newmatio.h>
|
|---|
| 18 | #include <iomanip>
|
|---|
| 19 | #include <sstream>
|
|---|
| 20 | #include <map>
|
|---|
| 21 | #include <algorithm>
|
|---|
| 22 |
|
|---|
| 23 | #include "bnccomb.h"
|
|---|
| 24 | #include <combination/bncbiassnx.h>
|
|---|
| 25 | #include "bnccore.h"
|
|---|
| 26 | #include "upload/bncrtnetdecoder.h"
|
|---|
| 27 | #include "bncsettings.h"
|
|---|
| 28 | #include "bncutils.h"
|
|---|
| 29 | #include "bncantex.h"
|
|---|
| 30 | #include "t_prn.h"
|
|---|
| 31 |
|
|---|
| 32 | const double sig0_offAC = 1000.0;
|
|---|
| 33 | const double sigP_offAC = 1000.0;
|
|---|
| 34 |
|
|---|
| 35 | const double sig0_offACSat = 1000.0;
|
|---|
| 36 | const double sigP_offACSat = 0.01;
|
|---|
| 37 |
|
|---|
| 38 | const double sig0_clkSat = 100.0;
|
|---|
| 39 | const double sigP_clkSat = 100.0; //*) White noise may be set to something between a few centimeters and tens of meters.
|
|---|
| 40 | // A large value results in a combination that is equivalent to a single-epoch combination algorithm.
|
|---|
| 41 |
|
|---|
| 42 | const double sigObs = 0.05;
|
|---|
| 43 |
|
|---|
| 44 | using namespace std;
|
|---|
| 45 |
|
|---|
| 46 | // Constructor
|
|---|
| 47 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 48 | bncComb::cmbParam::cmbParam(parType type_, int index_, const QString& ac_, const QString& prn_) {
|
|---|
| 49 |
|
|---|
| 50 | type = type_;
|
|---|
| 51 | index = index_;
|
|---|
| 52 | AC = ac_;
|
|---|
| 53 | prn = prn_;
|
|---|
| 54 | xx = 0.0;
|
|---|
| 55 | eph = 0;
|
|---|
| 56 |
|
|---|
| 57 | if (type == offACgnss) {
|
|---|
| 58 | epoSpec = true;
|
|---|
| 59 | sig0 = sig0_offAC; // 1000.0
|
|---|
| 60 | sigP = sig0; // 1000.0
|
|---|
| 61 | }
|
|---|
| 62 | else if (type == offACSat) {
|
|---|
| 63 | epoSpec = false;
|
|---|
| 64 | sig0 = sig0_offACSat; // 100.0
|
|---|
| 65 | sigP = sigP_offACSat; // 0.01
|
|---|
| 66 | }
|
|---|
| 67 | // combined clock
|
|---|
| 68 | else if (type == clkSat) {
|
|---|
| 69 | epoSpec = true;
|
|---|
| 70 | sig0 = sig0_clkSat; // 100.0
|
|---|
| 71 | sigP = sigP_clkSat; // 10.0
|
|---|
| 72 |
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | // Destructor
|
|---|
| 78 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 79 | bncComb::cmbParam::~cmbParam() {
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | // Partial
|
|---|
| 83 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 84 | double bncComb::cmbParam::partial(char sys, const QString& AC_, const QString& prn_) {
|
|---|
| 85 |
|
|---|
| 86 | if (type == offACgnss) {
|
|---|
| 87 | if (AC == AC_ && prn_[0].toLatin1() == sys) {
|
|---|
| 88 | return 1.0;
|
|---|
| 89 | }
|
|---|
| 90 | }
|
|---|
| 91 | else if (type == offACSat) {
|
|---|
| 92 | if (AC == AC_ && prn == prn_) {
|
|---|
| 93 | return 1.0;
|
|---|
| 94 | }
|
|---|
| 95 | }
|
|---|
| 96 | else if (type == clkSat) {
|
|---|
| 97 | if (prn == prn_) {
|
|---|
| 98 | return 1.0;
|
|---|
| 99 | }
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | return 0.0;
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | //
|
|---|
| 106 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 107 | QString bncComb::cmbParam::toString(char sys) const {
|
|---|
| 108 |
|
|---|
| 109 | QString outStr;
|
|---|
| 110 |
|
|---|
| 111 | if (type == offACgnss) {
|
|---|
| 112 | outStr = "AC Offset " + AC + " " + sys + " ";
|
|---|
| 113 | }
|
|---|
| 114 | else if (type == offACSat) {
|
|---|
| 115 | outStr = "Sat Offset " + AC + " " + prn.mid(0,3);
|
|---|
| 116 | }
|
|---|
| 117 | else if (type == clkSat) {
|
|---|
| 118 | outStr = "Clk Corr " + prn.mid(0,3);
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | return outStr;
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | // Singleton: definition class variable
|
|---|
| 125 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 126 | bncComb* bncComb::instance = nullptr;
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 | // Constructor
|
|---|
| 130 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 131 | bncComb::bncComb() : _ephUser(true) {
|
|---|
| 132 |
|
|---|
| 133 | bncSettings settings;
|
|---|
| 134 |
|
|---|
| 135 | _running = true;
|
|---|
| 136 |
|
|---|
| 137 | QStringList cmbStreams = settings.value("cmbStreams").toStringList();
|
|---|
| 138 |
|
|---|
| 139 | _cmbSampl = settings.value("cmbSampl").toString().split("sec").first().toInt();
|
|---|
| 140 | if (_cmbSampl <= 0) {
|
|---|
| 141 | _cmbSampl = 5;
|
|---|
| 142 | }
|
|---|
| 143 | _useGps = (Qt::CheckState(settings.value("cmbGps").toInt()) == Qt::Checked) ? true : false;
|
|---|
| 144 | if (_useGps) {
|
|---|
| 145 | _cmbSysPrn['G'] = t_prn::MAXPRN_GPS;
|
|---|
| 146 | _masterMissingEpochs['G'] = 0;
|
|---|
| 147 | }
|
|---|
| 148 | _useGlo = (Qt::CheckState(settings.value("cmbGlo").toInt()) == Qt::Checked) ? true : false;
|
|---|
| 149 | if (_useGlo) {
|
|---|
| 150 | _cmbSysPrn['R'] = t_prn::MAXPRN_GLONASS;
|
|---|
| 151 | _masterMissingEpochs['R'] = 0;
|
|---|
| 152 | }
|
|---|
| 153 | _useGal = (Qt::CheckState(settings.value("cmbGal").toInt()) == Qt::Checked) ? true : false;
|
|---|
| 154 | if (_useGal) {
|
|---|
| 155 | _cmbSysPrn['E'] = t_prn::MAXPRN_GALILEO;
|
|---|
| 156 | _masterMissingEpochs['E'] = 0;
|
|---|
| 157 | }
|
|---|
| 158 | _useBds = (Qt::CheckState(settings.value("cmbBds").toInt()) == Qt::Checked) ? true : false;
|
|---|
| 159 | if (_useBds) {
|
|---|
| 160 | _cmbSysPrn['C'] = t_prn::MAXPRN_BDS;
|
|---|
| 161 | _masterMissingEpochs['C'] = 0;
|
|---|
| 162 | }
|
|---|
| 163 | _useQzss = (Qt::CheckState(settings.value("cmbQzss").toInt()) == Qt::Checked) ? true : false;
|
|---|
| 164 | if (_useQzss) {
|
|---|
| 165 | _cmbSysPrn['J'] = t_prn::MAXPRN_QZSS;
|
|---|
| 166 | _masterMissingEpochs['J'] = 0;
|
|---|
| 167 | }
|
|---|
| 168 | _useSbas = (Qt::CheckState(settings.value("cmbSbas").toInt()) == Qt::Checked) ? true : false;
|
|---|
| 169 | if (_useSbas) {
|
|---|
| 170 | _cmbSysPrn['S'] = t_prn::MAXPRN_SBAS;
|
|---|
| 171 | _masterMissingEpochs['S'] = 0;
|
|---|
| 172 | }
|
|---|
| 173 | _useNavic = (Qt::CheckState(settings.value("cmbNavic").toInt()) == Qt::Checked) ? true : false;
|
|---|
| 174 | if (_useNavic) {
|
|---|
| 175 | _cmbSysPrn['I'] = t_prn::MAXPRN_NavIC;
|
|---|
| 176 | _masterMissingEpochs['I'] = 0;
|
|---|
| 177 | }
|
|---|
| 178 |
|
|---|
| 179 | if (cmbStreams.size() >= 1 && !cmbStreams[0].isEmpty()) {
|
|---|
| 180 | QListIterator<QString> it(cmbStreams);
|
|---|
| 181 | while (it.hasNext()) {
|
|---|
| 182 | QStringList hlp = it.next().split(" ");
|
|---|
| 183 | cmbAC* newAC = new cmbAC();
|
|---|
| 184 | newAC->mountPoint = hlp[0];
|
|---|
| 185 | newAC->name = hlp[1];
|
|---|
| 186 | newAC->weightFactor = hlp[2].toDouble();
|
|---|
| 187 | newAC->excludeSats = hlp[3].split(QRegExp("[ ,]"), Qt::SkipEmptyParts);
|
|---|
| 188 | newAC->isAPC = bool(newAC->mountPoint.mid(0,4) == "SSRA");
|
|---|
| 189 | newAC->attitudeSource = (hlp.size() > 4) ? hlp[4] : "Computed";
|
|---|
| 190 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
|---|
| 191 | // init
|
|---|
| 192 | while (itSys.hasNext()) {
|
|---|
| 193 | itSys.next();
|
|---|
| 194 | char sys = itSys.key();
|
|---|
| 195 | if (!_masterOrbitAC.contains(sys) &&
|
|---|
| 196 | !newAC->excludeSats.contains(QString(sys), Qt::CaseSensitive)) {
|
|---|
| 197 | _masterOrbitAC[sys] = newAC->name;
|
|---|
| 198 | _masterIsAPC[sys] = newAC->isAPC;
|
|---|
| 199 | }
|
|---|
| 200 | }
|
|---|
| 201 | _ACs.append(newAC);
|
|---|
| 202 | }
|
|---|
| 203 | }
|
|---|
| 204 |
|
|---|
| 205 | QString ssrFormat;
|
|---|
| 206 | _ssrCorr = 0;
|
|---|
| 207 | QListIterator<QString> it(settings.value("uploadMountpointsOut").toStringList());
|
|---|
| 208 | while (it.hasNext()) {
|
|---|
| 209 | QStringList hlp = it.next().split(",");
|
|---|
| 210 | if (hlp.size() > 7) {
|
|---|
| 211 | ssrFormat = hlp[7];
|
|---|
| 212 | }
|
|---|
| 213 | }
|
|---|
| 214 | if (ssrFormat == "IGS-SSR") {
|
|---|
| 215 | _ssrCorr = new SsrCorrIgs();
|
|---|
| 216 | }
|
|---|
| 217 | else if (ssrFormat == "RTCM-SSR") {
|
|---|
| 218 | _ssrCorr = new SsrCorrRtcm();
|
|---|
| 219 | }
|
|---|
| 220 | else if (ssrFormat == "RTCM-NEW-SSR") {
|
|---|
| 221 | _ssrCorr = new SsrCorrRtcmNew();
|
|---|
| 222 | }
|
|---|
| 223 | else { // default
|
|---|
| 224 | _ssrCorr = new SsrCorrIgs();
|
|---|
| 225 | }
|
|---|
| 226 |
|
|---|
| 227 | _rtnetDecoder = new bncRtnetDecoder();
|
|---|
| 228 |
|
|---|
| 229 | connect(this, SIGNAL(newMessage(QByteArray,bool)), BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
|---|
| 230 | connect(BNC_CORE, SIGNAL(providerIDChanged(QString)), this, SLOT(slotProviderIDChanged(QString)));
|
|---|
| 231 | connect(BNC_CORE, SIGNAL(newOrbCorrections(QList<t_orbCorr>)), this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)));
|
|---|
| 232 | connect(BNC_CORE, SIGNAL(newClkCorrections(QList<t_clkCorr>)), this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)));
|
|---|
| 233 | connect(BNC_CORE, SIGNAL(newCodeBiases(QList<t_satCodeBias>)), this, SLOT(slotNewCodeBiases(QList<t_satCodeBias>)));
|
|---|
| 234 | connect(BNC_CORE, SIGNAL(newPhaseBiases(QList<t_satPhaseBias>)), this, SLOT(slotNewPhaseBiases(QList<t_satPhaseBias>)));
|
|---|
| 235 |
|
|---|
| 236 | // Combination Method
|
|---|
| 237 | // ------------------
|
|---|
| 238 | if (settings.value("cmbMethod").toString() == "Single-Epoch") {
|
|---|
| 239 | _method = singleEpoch;
|
|---|
| 240 | }
|
|---|
| 241 | else {
|
|---|
| 242 | _method = filter;
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 | // Initialize Parameters (model: Clk_Corr = AC_Offset + Sat_Offset + Clk)
|
|---|
| 246 | // ----------------------------------------------------------------------
|
|---|
| 247 | if (_method == filter) {
|
|---|
| 248 | // SYSTEM
|
|---|
| 249 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
|---|
| 250 | while (itSys.hasNext()) {
|
|---|
| 251 | itSys.next();
|
|---|
| 252 | int nextPar = 0;
|
|---|
| 253 | char sys = itSys.key();
|
|---|
| 254 | int maxPrn = itSys.value();
|
|---|
| 255 | // AC
|
|---|
| 256 | QListIterator<cmbAC*> itAc(_ACs);
|
|---|
| 257 | while (itAc.hasNext()) {
|
|---|
| 258 | cmbAC* AC = itAc.next();
|
|---|
| 259 | _params[sys].push_back(new cmbParam(cmbParam::offACgnss, ++nextPar, AC->name, ""));
|
|---|
| 260 | for (int iGnss = 1; iGnss <= maxPrn; iGnss++) {
|
|---|
| 261 | int flag = t_corrSSR::getSsrNavTypeFlag(sys, iGnss);
|
|---|
| 262 | QString prn = QString("%1%2_%3").arg(sys).arg(iGnss, 2, 10, QChar('0')).arg(flag);
|
|---|
| 263 | _params[sys].push_back(new cmbParam(cmbParam::offACSat, ++nextPar, AC->name, prn));
|
|---|
| 264 | }
|
|---|
| 265 | }
|
|---|
| 266 | for (int iGnss = 1; iGnss <= maxPrn; iGnss++) {
|
|---|
| 267 | int flag = t_corrSSR::getSsrNavTypeFlag(sys, iGnss);
|
|---|
| 268 | QString prn = QString("%1%2_%3").arg(sys).arg(iGnss, 2, 10, QChar('0')).arg(flag);
|
|---|
| 269 | _params[sys].push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
|
|---|
| 270 | }
|
|---|
| 271 | // Initialize Variance-Covariance Matrix
|
|---|
| 272 | // -------------------------------------
|
|---|
| 273 | _QQ[sys].ReSize(_params[sys].size());
|
|---|
| 274 | _QQ[sys] = 0.0;
|
|---|
| 275 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 276 | cmbParam* pp = _params[sys][iPar-1];
|
|---|
| 277 | _QQ[sys](iPar,iPar) = pp->sig0 * pp->sig0;
|
|---|
| 278 | }
|
|---|
| 279 | }
|
|---|
| 280 | }
|
|---|
| 281 |
|
|---|
| 282 | // ANTEX File
|
|---|
| 283 | // ----------
|
|---|
| 284 | _antex = 0;
|
|---|
| 285 | QString antexFileName = settings.value("uploadAntexFile").toString();
|
|---|
| 286 | if (!antexFileName.isEmpty()) {
|
|---|
| 287 | _antex = new bncAntex();
|
|---|
| 288 | if (_antex->readFile(antexFileName) != success) {
|
|---|
| 289 | emit newMessage("bncComb: wrong ANTEX file", true);
|
|---|
| 290 | delete _antex;
|
|---|
| 291 | _antex = 0;
|
|---|
| 292 | }
|
|---|
| 293 | else {
|
|---|
| 294 | emit newMessage("bncComb: " + _antex->info().toLatin1(), true);
|
|---|
| 295 | }
|
|---|
| 296 | }
|
|---|
| 297 |
|
|---|
| 298 | // Reference point of the combination: with ACs of both kinds (APC streams
|
|---|
| 299 | // 'SSRA...', CoM streams 'SSRC...') and an ANTEX file, the combination is
|
|---|
| 300 | // done in the CoM frame and the orbits of the APC ACs are converted to
|
|---|
| 301 | // CoM; otherwise in the frame of the master AC (ACs of the other kind are
|
|---|
| 302 | // not used)
|
|---|
| 303 | // ------------------------------------------------------------------------
|
|---|
| 304 | bool hasAPC = false, hasCoM = false;
|
|---|
| 305 | for (const cmbAC* AC : _ACs) {
|
|---|
| 306 | if (AC->isAPC) hasAPC = true; else hasCoM = true;
|
|---|
| 307 | }
|
|---|
| 308 | _cmbCoM = (_antex && hasAPC && hasCoM);
|
|---|
| 309 | if (_cmbCoM) {
|
|---|
| 310 | for (QMap<char, bool>::iterator it = _masterIsAPC.begin(); it != _masterIsAPC.end(); ++it) {
|
|---|
| 311 | it.value() = false;
|
|---|
| 312 | }
|
|---|
| 313 | emit newMessage("bncComb: APC and CoM streams configured - combination in the CoM frame, "
|
|---|
| 314 | "orbits of the APC streams converted to CoM", true);
|
|---|
| 315 | }
|
|---|
| 316 | else if (hasAPC && hasCoM) {
|
|---|
| 317 | emit newMessage("bncComb: APC and CoM streams configured, but no ANTEX file - only the streams "
|
|---|
| 318 | "with the reference point of the master AC are combined", true);
|
|---|
| 319 | }
|
|---|
| 320 | if (!_antex && hasCoM) {
|
|---|
| 321 | emit newMessage("bncComb: CoM streams configured, but no ANTEX file - the combined orbits (INTERNAL) "
|
|---|
| 322 | "may refer to the CoM, while the PPP assumes the APC", true);
|
|---|
| 323 | }
|
|---|
| 324 |
|
|---|
| 325 |
|
|---|
| 326 | // Bias SINEX File
|
|---|
| 327 | // ---------------
|
|---|
| 328 | _bsx = 0;
|
|---|
| 329 | QString bsxFileName = settings.value("cmbBsxFile").toString();
|
|---|
| 330 | if (!bsxFileName.isEmpty()) {
|
|---|
| 331 | _bsx = new bncBiasSnx();
|
|---|
| 332 | if (_bsx->readFile(bsxFileName) != success) {
|
|---|
| 333 | emit newMessage("bncComb: wrong Bias SINEX file", true);
|
|---|
| 334 | delete _bsx;
|
|---|
| 335 | _bsx = 0;
|
|---|
| 336 | }
|
|---|
| 337 | }
|
|---|
| 338 | if (_bsx) {
|
|---|
| 339 | _ms = 3.0 * 3600 * 1000.0;
|
|---|
| 340 | QTimer::singleShot(_ms, this, SLOT(slotReadBiasSnxFile()));
|
|---|
| 341 | }
|
|---|
| 342 |
|
|---|
| 343 | // Maximal Residuum
|
|---|
| 344 | // ----------------
|
|---|
| 345 | _MAX_RES = settings.value("cmbMaxres").toDouble();
|
|---|
| 346 | if (_MAX_RES <= 0.0) {
|
|---|
| 347 | _MAX_RES = 999.0;
|
|---|
| 348 | }
|
|---|
| 349 |
|
|---|
| 350 | // Maximal Displacement
|
|---|
| 351 | // --------------------
|
|---|
| 352 | _MAX_DISPLACEMENT = settings.value("cmbMaxdisplacement").toDouble();
|
|---|
| 353 | if (_MAX_DISPLACEMENT <= 0.0) {
|
|---|
| 354 | _MAX_DISPLACEMENT = 2.0;
|
|---|
| 355 | }
|
|---|
| 356 |
|
|---|
| 357 | // Logfile
|
|---|
| 358 | // -------
|
|---|
| 359 | QString intr = "1 day";
|
|---|
| 360 | QString logFileCmb = settings.value("cmbLogpath").toString();
|
|---|
| 361 | int l = logFileCmb.length();
|
|---|
| 362 | if (logFileCmb.isEmpty()) {
|
|---|
| 363 | _logFile = 0;
|
|---|
| 364 | }
|
|---|
| 365 | else {
|
|---|
| 366 | if (l && logFileCmb[l-1] != QDir::separator() ) {
|
|---|
| 367 | logFileCmb += QDir::separator();
|
|---|
| 368 | }
|
|---|
| 369 |
|
|---|
| 370 | logFileCmb = logFileCmb + "COMB00BNC" + "${V3PROD}" + ".CMB";
|
|---|
| 371 |
|
|---|
| 372 | _logFile = new bncoutf(logFileCmb, intr, _cmbSampl);
|
|---|
| 373 | }
|
|---|
| 374 |
|
|---|
| 375 | _newCorr = 0;
|
|---|
| 376 | }
|
|---|
| 377 |
|
|---|
| 378 | // Destructor
|
|---|
| 379 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 380 | bncComb::~bncComb() {
|
|---|
| 381 |
|
|---|
| 382 | _running = false;
|
|---|
| 383 | #ifndef WIN32
|
|---|
| 384 | sleep(2);
|
|---|
| 385 | #else
|
|---|
| 386 | Sleep(2000);
|
|---|
| 387 | #endif
|
|---|
| 388 |
|
|---|
| 389 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 390 | while (icAC.hasNext()) {
|
|---|
| 391 | delete icAC.next();
|
|---|
| 392 | }
|
|---|
| 393 | _ACs.clear();
|
|---|
| 394 |
|
|---|
| 395 | delete _rtnetDecoder;
|
|---|
| 396 |
|
|---|
| 397 | if (_ssrCorr) {
|
|---|
| 398 | delete _ssrCorr;
|
|---|
| 399 | }
|
|---|
| 400 |
|
|---|
| 401 | if (_newCorr) {
|
|---|
| 402 | delete _newCorr;
|
|---|
| 403 | }
|
|---|
| 404 |
|
|---|
| 405 | delete _antex;
|
|---|
| 406 | delete _bsx;
|
|---|
| 407 | delete _logFile;
|
|---|
| 408 |
|
|---|
| 409 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
|---|
| 410 | while (itSys.hasNext()) {
|
|---|
| 411 | itSys.next();
|
|---|
| 412 | char sys = itSys.key();
|
|---|
| 413 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 414 | delete _params[sys][iPar-1];
|
|---|
| 415 | }
|
|---|
| 416 | _buffer.remove(sys);
|
|---|
| 417 | }
|
|---|
| 418 | _params.clear();
|
|---|
| 419 | _buffer.clear();
|
|---|
| 420 | _cmbSysPrn.clear();
|
|---|
| 421 |
|
|---|
| 422 | while (!_epoClkData.empty()) {
|
|---|
| 423 | delete _epoClkData.front();
|
|---|
| 424 | _epoClkData.pop_front();
|
|---|
| 425 | }
|
|---|
| 426 | }
|
|---|
| 427 |
|
|---|
| 428 | void bncComb::slotReadBiasSnxFile() {
|
|---|
| 429 | bncSettings settings;
|
|---|
| 430 | QString bsxFileName = settings.value("cmbBsxFile").toString();
|
|---|
| 431 |
|
|---|
| 432 | if (bsxFileName.isEmpty()) {
|
|---|
| 433 | emit newMessage("bncComb: no Bias SINEX file specified", true);
|
|---|
| 434 | return;
|
|---|
| 435 | }
|
|---|
| 436 | if (!_bsx) {
|
|---|
| 437 | _bsx = new bncBiasSnx();
|
|---|
| 438 | }
|
|---|
| 439 | if (_bsx->readFile(bsxFileName) != success) {
|
|---|
| 440 | emit newMessage("bncComb: wrong Bias SINEX file", true);
|
|---|
| 441 | delete _bsx;
|
|---|
| 442 | _bsx = 0;
|
|---|
| 443 | }
|
|---|
| 444 | else {
|
|---|
| 445 | emit newMessage("bncComb: successfully read Bias SINEX file", true);
|
|---|
| 446 | }
|
|---|
| 447 |
|
|---|
| 448 | QTimer::singleShot(_ms, this, SLOT(slotReadBiasSnxFile()));
|
|---|
| 449 | }
|
|---|
| 450 |
|
|---|
| 451 |
|
|---|
| 452 | // Remember orbit corrections
|
|---|
| 453 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 454 | void bncComb::slotNewOrbCorrections(QList<t_orbCorr> orbCorrections) {
|
|---|
| 455 | QMutexLocker locker(&_mutex);
|
|---|
| 456 | for (int ii = 0; ii < orbCorrections.size(); ii++) {
|
|---|
| 457 | t_orbCorr& orbCorr = orbCorrections[ii];
|
|---|
| 458 | QString staID(orbCorr._staID.c_str());
|
|---|
| 459 | char sys = orbCorr._prn.system();
|
|---|
| 460 |
|
|---|
| 461 | if (!_cmbSysPrn.contains(sys)){
|
|---|
| 462 | continue;
|
|---|
| 463 | }
|
|---|
| 464 |
|
|---|
| 465 | // Find/Check the AC Name
|
|---|
| 466 | // ----------------------
|
|---|
| 467 | QString acName;
|
|---|
| 468 | QStringList excludeSats;
|
|---|
| 469 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 470 | while (icAC.hasNext()) {
|
|---|
| 471 | cmbAC* AC = icAC.next();
|
|---|
| 472 | if (AC->mountPoint == staID) {
|
|---|
| 473 | acName = AC->name;
|
|---|
| 474 | excludeSats = AC->excludeSats;
|
|---|
| 475 | break;
|
|---|
| 476 | }
|
|---|
| 477 | }
|
|---|
| 478 | if (acName.isEmpty() || excludeSat(orbCorr._prn, excludeSats)) {
|
|---|
| 479 | continue;
|
|---|
| 480 | }
|
|---|
| 481 |
|
|---|
| 482 | // Store the correction
|
|---|
| 483 | // --------------------
|
|---|
| 484 | QMap<t_prn, t_orbCorr>& storage = _orbCorrections[acName];
|
|---|
| 485 | storage[orbCorr._prn] = orbCorr;
|
|---|
| 486 | }
|
|---|
| 487 | }
|
|---|
| 488 |
|
|---|
| 489 | // Remember Satellite Code Biases
|
|---|
| 490 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 491 | void bncComb::slotNewCodeBiases(QList<t_satCodeBias> satCodeBiases) {
|
|---|
| 492 | QMutexLocker locker(&_mutex);
|
|---|
| 493 |
|
|---|
| 494 | for (int ii = 0; ii < satCodeBiases.size(); ii++) {
|
|---|
| 495 | t_satCodeBias& satCodeBias = satCodeBiases[ii];
|
|---|
| 496 | QString staID(satCodeBias._staID.c_str());
|
|---|
| 497 | char sys = satCodeBias._prn.system();
|
|---|
| 498 |
|
|---|
| 499 | if (!_cmbSysPrn.contains(sys)){
|
|---|
| 500 | continue;
|
|---|
| 501 | }
|
|---|
| 502 |
|
|---|
| 503 | // Find/Check the AC Name
|
|---|
| 504 | // ----------------------
|
|---|
| 505 | QString acName;
|
|---|
| 506 | QStringList excludeSats;
|
|---|
| 507 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 508 | while (icAC.hasNext()) {
|
|---|
| 509 | cmbAC* AC = icAC.next();
|
|---|
| 510 | if (AC->mountPoint == staID) {
|
|---|
| 511 | acName = AC->name;
|
|---|
| 512 | excludeSats = AC->excludeSats;
|
|---|
| 513 | break;
|
|---|
| 514 | }
|
|---|
| 515 | }
|
|---|
| 516 | if (acName.isEmpty() || excludeSat(satCodeBias._prn, excludeSats)) {
|
|---|
| 517 | continue;
|
|---|
| 518 | }
|
|---|
| 519 |
|
|---|
| 520 | // Store the correction
|
|---|
| 521 | // --------------------
|
|---|
| 522 | QMap<t_prn, t_satCodeBias>& storage = _satCodeBiases[acName];
|
|---|
| 523 | storage[satCodeBias._prn] = satCodeBias;
|
|---|
| 524 | }
|
|---|
| 525 | return;
|
|---|
| 526 | }
|
|---|
| 527 |
|
|---|
| 528 | // Remember Satellite Phase Biases
|
|---|
| 529 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 530 | void bncComb::slotNewPhaseBiases(QList<t_satPhaseBias> satPhaseBiases) {
|
|---|
| 531 | QMutexLocker locker(&_mutex);
|
|---|
| 532 |
|
|---|
| 533 | for (int ii = 0; ii < satPhaseBiases.size(); ii++) {
|
|---|
| 534 | t_satPhaseBias& satPhaseBias = satPhaseBiases[ii];
|
|---|
| 535 | QString staID(satPhaseBias._staID.c_str());
|
|---|
| 536 | char sys = satPhaseBias._prn.system();
|
|---|
| 537 |
|
|---|
| 538 | if (!_cmbSysPrn.contains(sys)){
|
|---|
| 539 | continue;
|
|---|
| 540 | }
|
|---|
| 541 |
|
|---|
| 542 | // Find/Check the AC Name
|
|---|
| 543 | // ----------------------
|
|---|
| 544 | QString acName;
|
|---|
| 545 | QStringList excludeSats;
|
|---|
| 546 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 547 | while (icAC.hasNext()) {
|
|---|
| 548 | cmbAC* AC = icAC.next();
|
|---|
| 549 | if (AC->mountPoint == staID) {
|
|---|
| 550 | acName = AC->name;
|
|---|
| 551 | excludeSats = AC->excludeSats;
|
|---|
| 552 | break;
|
|---|
| 553 | }
|
|---|
| 554 | }
|
|---|
| 555 | if (acName.isEmpty() || excludeSat(satPhaseBias._prn, excludeSats)) {
|
|---|
| 556 | continue;
|
|---|
| 557 | }
|
|---|
| 558 |
|
|---|
| 559 | // Store the correction
|
|---|
| 560 | // --------------------
|
|---|
| 561 | QMap<t_prn, t_satPhaseBias>& storage = _satPhaseBiases[acName];
|
|---|
| 562 | storage[satPhaseBias._prn] = satPhaseBias;
|
|---|
| 563 | }
|
|---|
| 564 | return;
|
|---|
| 565 | }
|
|---|
| 566 |
|
|---|
| 567 |
|
|---|
| 568 | // True if every AC has delivered clock corrections for an epoch after epoTime
|
|---|
| 569 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 570 | bool bncComb::allACsBeyond(const bncTime& epoTime) const {
|
|---|
| 571 | QListIterator<cmbAC*> itAC(_ACs);
|
|---|
| 572 | while (itAC.hasNext()) {
|
|---|
| 573 | const cmbAC* AC = itAC.next();
|
|---|
| 574 | bncTime acLast = _acLastClkTime.value(AC->name);
|
|---|
| 575 | if (!acLast.valid() || !(acLast > epoTime)) {
|
|---|
| 576 | return false;
|
|---|
| 577 | }
|
|---|
| 578 | }
|
|---|
| 579 | return true;
|
|---|
| 580 | }
|
|---|
| 581 |
|
|---|
| 582 | // Process clock corrections
|
|---|
| 583 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 584 | void bncComb::slotNewClkCorrections(QList<t_clkCorr> clkCorrections) {
|
|---|
| 585 | QMutexLocker locker(&_mutex);
|
|---|
| 586 | const double outWait = 1.0 * _cmbSampl;
|
|---|
| 587 | int currentWeek = 0;
|
|---|
| 588 | double currentSec = 0.0;
|
|---|
| 589 | currentGPSWeeks(currentWeek, currentSec);
|
|---|
| 590 | bncTime currentTime(currentWeek, currentSec);
|
|---|
| 591 |
|
|---|
| 592 | // Loop over all observations (possible different epochs)
|
|---|
| 593 | // -----------------------------------------------------
|
|---|
| 594 | for (int ii = 0; ii < clkCorrections.size(); ii++) {
|
|---|
| 595 | t_clkCorr& newClk = clkCorrections[ii];
|
|---|
| 596 | char sys = newClk._prn.system();
|
|---|
| 597 | if (!_cmbSysPrn.contains(sys)){
|
|---|
| 598 | continue;
|
|---|
| 599 | }
|
|---|
| 600 |
|
|---|
| 601 | // Remember the latest correction epoch of each AC (whether or not the
|
|---|
| 602 | // correction is used), to know when an AC has finished an epoch
|
|---|
| 603 | // --------------------------------------------------------------------
|
|---|
| 604 | QListIterator<cmbAC*> itAC(_ACs);
|
|---|
| 605 | while (itAC.hasNext()) {
|
|---|
| 606 | cmbAC* AC = itAC.next();
|
|---|
| 607 | if (AC->mountPoint == QString(newClk._staID.c_str())) {
|
|---|
| 608 | bncTime& acLast = _acLastClkTime[AC->name];
|
|---|
| 609 | if (!acLast.valid() || newClk._time > acLast) {
|
|---|
| 610 | acLast = newClk._time;
|
|---|
| 611 | }
|
|---|
| 612 | break;
|
|---|
| 613 | }
|
|---|
| 614 | }
|
|---|
| 615 |
|
|---|
| 616 | // Check Modulo Time
|
|---|
| 617 | // -----------------
|
|---|
| 618 | int sec = int(nint(newClk._time.gpssec()*10));
|
|---|
| 619 | if (sec % (_cmbSampl*10) != 0.0) {
|
|---|
| 620 | continue;
|
|---|
| 621 | }
|
|---|
| 622 |
|
|---|
| 623 | // Find/Check the AC Name
|
|---|
| 624 | // ----------------------
|
|---|
| 625 | QString acName;
|
|---|
| 626 | QStringList excludeSats;
|
|---|
| 627 | bool isAPC;
|
|---|
| 628 | QString staID(newClk._staID.c_str());
|
|---|
| 629 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 630 | while (icAC.hasNext()) {
|
|---|
| 631 | cmbAC* AC = icAC.next();
|
|---|
| 632 | if (AC->mountPoint == staID) {
|
|---|
| 633 | acName = AC->name;
|
|---|
| 634 | excludeSats = AC->excludeSats;
|
|---|
| 635 | isAPC = AC->isAPC;
|
|---|
| 636 | break;
|
|---|
| 637 | }
|
|---|
| 638 | }
|
|---|
| 639 | if (acName.isEmpty() || excludeSat(newClk._prn, excludeSats)) {
|
|---|
| 640 | continue;
|
|---|
| 641 | }
|
|---|
| 642 | if (!_cmbCoM && isAPC != _masterIsAPC[sys]) {
|
|---|
| 643 | bncTime& warned = _refPointWarned[acName + sys];
|
|---|
| 644 | if (!warned.valid() || newClk._time - warned >= 3600.0) {
|
|---|
| 645 | warned = newClk._time;
|
|---|
| 646 | emit newMessage("bncComb: " + acName.toLatin1() + " " + QByteArray(1, sys) + " not combined: its orbits refer to the " +
|
|---|
| 647 | (isAPC ? "APC" : "CoM") + ", those of the master AC " + _masterOrbitAC[sys].toLatin1() +
|
|---|
| 648 | " to the " + (isAPC ? "CoM" : "APC") +
|
|---|
| 649 | " (an ANTEX file allows to combine both in the CoM frame)", true);
|
|---|
| 650 | }
|
|---|
| 651 | continue;
|
|---|
| 652 | }
|
|---|
| 653 |
|
|---|
| 654 | // Check regarding current time
|
|---|
| 655 | // ----------------------------
|
|---|
| 656 | if (BNC_CORE->mode() != t_bncCore::batchPostProcessing) {
|
|---|
| 657 | if (fabs(currentTime - newClk._time) > 60.0) { // future or very old data sets
|
|---|
| 658 | #ifdef BNC_DEBUG_CMB
|
|---|
| 659 | emit newMessage("bncComb: future or very old data sets: " + acName.toLatin1() + " " + newClk._prn.toString().c_str() +
|
|---|
| 660 | QString(" %1 ").arg(newClk._time.timestr().c_str()).toLatin1() + "vs. current time" +
|
|---|
| 661 | QString(" %1 ").arg(currentTime.timestr().c_str()).toLatin1(), true);
|
|---|
| 662 | #endif
|
|---|
| 663 | continue;
|
|---|
| 664 | }
|
|---|
| 665 | }
|
|---|
| 666 |
|
|---|
| 667 | // Check Correction Age
|
|---|
| 668 | // --------------------
|
|---|
| 669 | if (_resTime.valid() && newClk._time <= _resTime) {
|
|---|
| 670 | #ifdef BNC_DEBUG_CMB
|
|---|
| 671 | emit newMessage("bncComb: old correction: " + acName.toLatin1() + " " + newClk._prn.toString().c_str() +
|
|---|
| 672 | QString(" %1 ").arg(newClk._time.timestr().c_str()).toLatin1() + "vs. last processing Epoch" +
|
|---|
| 673 | QString(" %1 ").arg(_resTime.timestr().c_str()).toLatin1(), true);
|
|---|
| 674 | #endif
|
|---|
| 675 | continue;
|
|---|
| 676 | }
|
|---|
| 677 |
|
|---|
| 678 | // Set the last time
|
|---|
| 679 | // -----------------
|
|---|
| 680 | if (_lastClkCorrTime.undef() || newClk._time > _lastClkCorrTime) {
|
|---|
| 681 | _lastClkCorrTime = newClk._time;
|
|---|
| 682 | }
|
|---|
| 683 |
|
|---|
| 684 | // Find the corresponding data epoch or create a new one
|
|---|
| 685 | // -----------------------------------------------------
|
|---|
| 686 | epoClkData* epoch = 0;
|
|---|
| 687 | deque<epoClkData*>::const_iterator it;
|
|---|
| 688 | for (it = _epoClkData.begin(); it != _epoClkData.end(); it++) {
|
|---|
| 689 | if (newClk._time == (*it)->_time) {
|
|---|
| 690 | epoch = *it;
|
|---|
| 691 | break;
|
|---|
| 692 | }
|
|---|
| 693 | }
|
|---|
| 694 | if (epoch == 0) {
|
|---|
| 695 | if (_epoClkData.empty() || newClk._time > _epoClkData.back()->_time) {
|
|---|
| 696 | epoch = new epoClkData;
|
|---|
| 697 | epoch->_time = newClk._time;
|
|---|
| 698 | _epoClkData.push_back(epoch);
|
|---|
| 699 | }
|
|---|
| 700 | }
|
|---|
| 701 |
|
|---|
| 702 | // Put data into the epoch
|
|---|
| 703 | // -----------------------
|
|---|
| 704 | if (epoch != 0) {
|
|---|
| 705 | epoch->_clkCorr.push_back(newClk);
|
|---|
| 706 | }
|
|---|
| 707 | }
|
|---|
| 708 |
|
|---|
| 709 | // Make sure the buffer does not grow beyond any limit
|
|---|
| 710 | // ---------------------------------------------------
|
|---|
| 711 | const unsigned MAX_EPODATA_SIZE = 60.0 / _cmbSampl;
|
|---|
| 712 | if (_epoClkData.size() > MAX_EPODATA_SIZE) {
|
|---|
| 713 | delete _epoClkData.front();
|
|---|
| 714 | _epoClkData.pop_front();
|
|---|
| 715 | }
|
|---|
| 716 |
|
|---|
| 717 | // Process the oldest epochs
|
|---|
| 718 | // ------------------------
|
|---|
| 719 | while (_epoClkData.size()) {
|
|---|
| 720 |
|
|---|
| 721 | if (!_lastClkCorrTime.valid()) {
|
|---|
| 722 | return;
|
|---|
| 723 | }
|
|---|
| 724 |
|
|---|
| 725 | const vector<t_clkCorr>& clkCorrVec = _epoClkData.front()->_clkCorr;
|
|---|
| 726 |
|
|---|
| 727 | bncTime epoTime = _epoClkData.front()->_time;
|
|---|
| 728 |
|
|---|
| 729 | if (BNC_CORE->mode() != t_bncCore::batchPostProcessing) {
|
|---|
| 730 | if ((currentTime - epoTime) > 60.0) {
|
|---|
| 731 | delete _epoClkData.front();
|
|---|
| 732 | _epoClkData.pop_front();
|
|---|
| 733 | continue;
|
|---|
| 734 | }
|
|---|
| 735 | }
|
|---|
| 736 | // Process the front epoch as soon as all ACs have delivered corrections
|
|---|
| 737 | // for a later epoch (i.e. have finished this one), at the latest when
|
|---|
| 738 | // the newest correction is maxWait newer (an AC may be late or missing).
|
|---|
| 739 | // Waiting only outWait after the newest correction lost the corrections
|
|---|
| 740 | // of ACs with a few seconds more latency ("old correction").
|
|---|
| 741 | // -----------------------------------------------------------------------
|
|---|
| 742 | const double maxWait = max(10.0, outWait);
|
|---|
| 743 | if (allACsBeyond(epoTime) || epoTime < (_lastClkCorrTime - maxWait)) {
|
|---|
| 744 | _resTime = epoTime;
|
|---|
| 745 | processEpoch(_resTime, clkCorrVec);
|
|---|
| 746 | delete _epoClkData.front();
|
|---|
| 747 | _epoClkData.pop_front();
|
|---|
| 748 | }
|
|---|
| 749 | else {
|
|---|
| 750 | return;
|
|---|
| 751 | }
|
|---|
| 752 | }
|
|---|
| 753 | }
|
|---|
| 754 |
|
|---|
| 755 | // Change the correction so that it refers to last received ephemeris
|
|---|
| 756 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 757 | void bncComb::switchToLastEph(t_eph* lastEph, cmbCorr* corr) {
|
|---|
| 758 |
|
|---|
| 759 | if (corr->_eph == lastEph) {
|
|---|
| 760 | return;
|
|---|
| 761 | }
|
|---|
| 762 |
|
|---|
| 763 | ColumnVector oldXC(6);
|
|---|
| 764 | ColumnVector oldVV(3);
|
|---|
| 765 | if (corr->_eph->getCrd(corr->_time, oldXC, oldVV, false) != success) {
|
|---|
| 766 | return;
|
|---|
| 767 | }
|
|---|
| 768 |
|
|---|
| 769 | ColumnVector newXC(6);
|
|---|
| 770 | ColumnVector newVV(3);
|
|---|
| 771 | if (lastEph->getCrd(corr->_time, newXC, newVV, false) != success) {
|
|---|
| 772 | return;
|
|---|
| 773 | }
|
|---|
| 774 |
|
|---|
| 775 | ColumnVector dX = newXC.Rows(1,3) - oldXC.Rows(1,3);
|
|---|
| 776 | ColumnVector dV = newVV - oldVV;
|
|---|
| 777 | double dC = newXC(4) - oldXC(4);
|
|---|
| 778 |
|
|---|
| 779 | ColumnVector dRAO(3);
|
|---|
| 780 | XYZ_to_RSW(newXC.Rows(1,3), newVV, dX, dRAO);
|
|---|
| 781 |
|
|---|
| 782 | ColumnVector dDotRAO(3);
|
|---|
| 783 | XYZ_to_RSW(newXC.Rows(1,3), newVV, dV, dDotRAO);
|
|---|
| 784 |
|
|---|
| 785 | QString msg = "bncComb: switch corr " + corr->_prn.mid(0,3)
|
|---|
| 786 | + QString(" %1 -> %2 %3").arg(corr->_iod,3).arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
|
|---|
| 787 |
|
|---|
| 788 | emit newMessage(msg.toLatin1(), false);
|
|---|
| 789 |
|
|---|
| 790 | corr->_iod = lastEph->IOD();
|
|---|
| 791 | corr->_eph = lastEph;
|
|---|
| 792 |
|
|---|
| 793 | corr->_orbCorr._xr += dRAO;
|
|---|
| 794 | corr->_orbCorr._dotXr += dDotRAO;
|
|---|
| 795 | corr->_clkCorr._dClk -= dC;
|
|---|
| 796 | }
|
|---|
| 797 |
|
|---|
| 798 | // Process Epoch
|
|---|
| 799 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 800 | void bncComb::processEpoch(bncTime epoTime, const vector<t_clkCorr>& clkCorrVec) {
|
|---|
| 801 | QDateTime now = currentDateAndTimeGPS();
|
|---|
| 802 | bncTime currentTime(now.toString(Qt::ISODate).toStdString());
|
|---|
| 803 | for (unsigned ii = 0; ii < clkCorrVec.size(); ii++) {
|
|---|
| 804 | const t_clkCorr& clkCorr = clkCorrVec[ii];
|
|---|
| 805 | QString staID(clkCorr._staID.c_str());
|
|---|
| 806 | QString prnStr(clkCorr._prn.toInternalString().c_str());
|
|---|
| 807 | char sys = clkCorr._prn.system();
|
|---|
| 808 |
|
|---|
| 809 | // Find/Check the AC Name
|
|---|
| 810 | // ----------------------
|
|---|
| 811 | QString acName;
|
|---|
| 812 | double weigthFactor;
|
|---|
| 813 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 814 | while (icAC.hasNext()) {
|
|---|
| 815 | cmbAC* AC = icAC.next();
|
|---|
| 816 | if (AC->mountPoint == staID) {
|
|---|
| 817 | acName = AC->name;
|
|---|
| 818 | weigthFactor = AC->weightFactor;
|
|---|
| 819 | break;
|
|---|
| 820 | }
|
|---|
| 821 | }
|
|---|
| 822 |
|
|---|
| 823 | // Create new correction
|
|---|
| 824 | // ---------------------
|
|---|
| 825 | _newCorr = new cmbCorr();
|
|---|
| 826 | _newCorr->_prn = prnStr;
|
|---|
| 827 | _newCorr->_time = clkCorr._time;
|
|---|
| 828 | _newCorr->_iod = clkCorr._iod;
|
|---|
| 829 | _newCorr->_acName = acName;
|
|---|
| 830 | _newCorr->_weightFactor = weigthFactor;
|
|---|
| 831 | _newCorr->_clkCorr = clkCorr;
|
|---|
| 832 |
|
|---|
| 833 | // Check orbit correction
|
|---|
| 834 | // ----------------------
|
|---|
| 835 | if (!_orbCorrections.contains(acName)) {
|
|---|
| 836 | delete _newCorr; _newCorr = 0;
|
|---|
| 837 | continue;
|
|---|
| 838 | }
|
|---|
| 839 | else {
|
|---|
| 840 | QMap<t_prn, t_orbCorr>& storage = _orbCorrections[acName];
|
|---|
| 841 | if (!storage.contains(clkCorr._prn) ||
|
|---|
| 842 | storage[clkCorr._prn]._iod != _newCorr->_iod) {
|
|---|
| 843 | delete _newCorr; _newCorr = 0;
|
|---|
| 844 | continue;
|
|---|
| 845 | }
|
|---|
| 846 | else {
|
|---|
| 847 | _newCorr->_orbCorr = storage[clkCorr._prn];
|
|---|
| 848 | }
|
|---|
| 849 | }
|
|---|
| 850 |
|
|---|
| 851 | // Check the Ephemeris
|
|---|
| 852 | //--------------------
|
|---|
| 853 | t_eph* ephLast = _ephUser.ephLast(prnStr);
|
|---|
| 854 | t_eph* ephPrev = _ephUser.ephPrev(prnStr);
|
|---|
| 855 | if (ephLast == 0) {
|
|---|
| 856 | #ifdef BNC_DEBUG_CMB
|
|---|
| 857 | emit newMessage("bncComb: eph not found for " + prnStr.mid(0,3).toLatin1(), true);
|
|---|
| 858 | #endif
|
|---|
| 859 | delete _newCorr; _newCorr = 0;
|
|---|
| 860 | continue;
|
|---|
| 861 | }
|
|---|
| 862 | else if (outDatedBcep(ephLast, currentTime) ||
|
|---|
| 863 | ephLast->checkState() == t_eph::bad ||
|
|---|
| 864 | ephLast->checkState() == t_eph::outdated ||
|
|---|
| 865 | ephLast->checkState() == t_eph::unhealthy) {
|
|---|
| 866 | #ifdef BNC_DEBUG_CMB
|
|---|
| 867 | emit newMessage("bncComb: ephLast not ok (checkState: " + ephLast->checkStateToString().toLatin1() + ") for " + prnStr.mid(0,3).toLatin1(), true);
|
|---|
| 868 | #endif
|
|---|
| 869 | delete _newCorr; _newCorr = 0;
|
|---|
| 870 | continue;
|
|---|
| 871 | }
|
|---|
| 872 | else {
|
|---|
| 873 | if (ephLast->IOD() == _newCorr->_iod) {
|
|---|
| 874 | _newCorr->_eph = ephLast;
|
|---|
| 875 | }
|
|---|
| 876 | else if (ephPrev &&
|
|---|
| 877 | !outDatedBcep(ephPrev, currentTime) && // if not updated in storage
|
|---|
| 878 | ephPrev->checkState() == t_eph::ok && // received
|
|---|
| 879 | ephPrev->IOD() == _newCorr->_iod) {
|
|---|
| 880 | _newCorr->_eph = ephPrev;
|
|---|
| 881 | switchToLastEph(ephLast, _newCorr);
|
|---|
| 882 | }
|
|---|
| 883 | else {
|
|---|
| 884 | #ifdef BNC_DEBUG_CMB
|
|---|
| 885 | emit newMessage("bncComb: eph not found for " + prnStr.mid(0,3).toLatin1() +
|
|---|
| 886 | QString(" with IOD %1").arg(_newCorr->_iod).toLatin1(), true);
|
|---|
| 887 | #endif
|
|---|
| 888 | delete _newCorr; _newCorr = 0;
|
|---|
| 889 | continue;
|
|---|
| 890 | }
|
|---|
| 891 | }
|
|---|
| 892 |
|
|---|
| 893 | // Check satellite code biases
|
|---|
| 894 | // ----------------------------
|
|---|
| 895 | QMap<t_frequency::type, double> codeBiasesRefSig;
|
|---|
| 896 | if (_satCodeBiases.contains(acName)) {
|
|---|
| 897 | QMap<t_prn, t_satCodeBias>& storage = _satCodeBiases[acName];
|
|---|
| 898 | if (storage.contains(clkCorr._prn)) {
|
|---|
| 899 | _newCorr->_satCodeBias = storage[clkCorr._prn];
|
|---|
| 900 | for (unsigned ii = 1; ii < cmbRefSig::cIF; ii++) {
|
|---|
| 901 | t_frequency::type frqType = cmbRefSig::toFreq(sys, static_cast<cmbRefSig::type>(ii));
|
|---|
| 902 | char frqNum = t_frequency::toString(frqType)[1];
|
|---|
| 903 | char attrib = cmbRefSig::toAttrib(sys, static_cast<cmbRefSig::type>(ii));
|
|---|
| 904 | QString rnxType2ch = QString("%1%2").arg(frqNum).arg(attrib);
|
|---|
| 905 | for (unsigned ii = 0; ii < _newCorr->_satCodeBias._bias.size(); ii++) {
|
|---|
| 906 | const t_frqCodeBias& bias = _newCorr->_satCodeBias._bias[ii];
|
|---|
| 907 | if (rnxType2ch.toStdString() == bias._rnxType2ch) {
|
|---|
| 908 | codeBiasesRefSig[frqType] = bias._value;
|
|---|
| 909 | }
|
|---|
| 910 | }
|
|---|
| 911 | }
|
|---|
| 912 | // only with the biases of both reference signals (one of them alone
|
|---|
| 913 | // does not refer the clocks to the reference signals)
|
|---|
| 914 | if (codeBiasesRefSig.size() == 2) {
|
|---|
| 915 | map<t_frequency::type, double> codeCoeff;
|
|---|
| 916 | double channel = double(_newCorr->_eph->slotNum());
|
|---|
| 917 | cmbRefSig::coeff(sys, cmbRefSig::cIF, channel, codeCoeff);
|
|---|
| 918 | map<t_frequency::type, double>::const_iterator it;
|
|---|
| 919 | for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
|
|---|
| 920 | t_frequency::type frqType = it->first;
|
|---|
| 921 | double codeCoeff = it->second;
|
|---|
| 922 | _newCorr->_satCodeBiasIF += codeCoeff * codeBiasesRefSig[frqType];
|
|---|
| 923 | }
|
|---|
| 924 | _acBiasIF[acName][prnStr.mid(0,3)] = _newCorr->_satCodeBiasIF;
|
|---|
| 925 | }
|
|---|
| 926 | else {
|
|---|
| 927 | _acBiasIF[acName].remove(prnStr.mid(0,3));
|
|---|
| 928 | }
|
|---|
| 929 | _newCorr->_satCodeBias._bias.clear();
|
|---|
| 930 | }
|
|---|
| 931 | }
|
|---|
| 932 | // Without the code biases of both reference signals (none at all, or
|
|---|
| 933 | // only one of them, e.g. Galileo HAS for GPS), the AC clock cannot be
|
|---|
| 934 | // referred to the reference signals: it is combined as it is, but
|
|---|
| 935 | // excluded from the clock datum (see createAmat) - warn at most once
|
|---|
| 936 | // per hour per AC and system
|
|---|
| 937 | _newCorr->_refBiasesOK = (codeBiasesRefSig.size() == 2);
|
|---|
| 938 | if (!_newCorr->_refBiasesOK) {
|
|---|
| 939 | _acBiasIF[acName].remove(prnStr.mid(0,3));
|
|---|
| 940 | QString key = acName + sys;
|
|---|
| 941 | bncTime& warned = _refBiasWarned[key];
|
|---|
| 942 | if (!warned.valid() || _newCorr->_time - warned >= 3600.0) {
|
|---|
| 943 | warned = _newCorr->_time;
|
|---|
| 944 | QString missing;
|
|---|
| 945 | for (unsigned ii = 1; ii < cmbRefSig::cIF; ii++) {
|
|---|
| 946 | t_frequency::type frqType = cmbRefSig::toFreq(sys, static_cast<cmbRefSig::type>(ii));
|
|---|
| 947 | if (!codeBiasesRefSig.contains(frqType)) {
|
|---|
| 948 | missing += QString(" C%1%2").arg(t_frequency::toString(frqType)[1])
|
|---|
| 949 | .arg(cmbRefSig::toAttrib(sys, static_cast<cmbRefSig::type>(ii)));
|
|---|
| 950 | }
|
|---|
| 951 | }
|
|---|
| 952 | emit newMessage("bncComb: " + acName.toLatin1() + " provides no code biases for the " +
|
|---|
| 953 | QByteArray(1, sys) + " reference signal(s)" + missing.toLatin1() +
|
|---|
| 954 | " (e.g. " + prnStr.mid(0,3).toLatin1() + ") - these clocks are combined"
|
|---|
| 955 | " without referring them to the reference signals and, as long as other ACs"
|
|---|
| 956 | " provide referred clocks, excluded from the clock datum", false);
|
|---|
| 957 | }
|
|---|
| 958 | }
|
|---|
| 959 |
|
|---|
| 960 | // Check satellite phase biases
|
|---|
| 961 | // ----------------------------
|
|---|
| 962 | if (_satPhaseBiases.contains(acName)) {
|
|---|
| 963 | QMap<t_prn, t_satPhaseBias>& storage = _satPhaseBiases[acName];
|
|---|
| 964 | if (storage.contains(clkCorr._prn)) {
|
|---|
| 965 | // Yaw angle
|
|---|
| 966 | t_satPhaseBias& pb = storage[clkCorr._prn];
|
|---|
| 967 | double dt = _newCorr->_time - pb._time;
|
|---|
| 968 | if (pb._updateInt) {
|
|---|
| 969 | dt -= (0.5 * ssrUpdateInt[pb._updateInt]);
|
|---|
| 970 | }
|
|---|
| 971 | _newCorr->_satYawAngle = pb._yaw + pb._yawRate * dt;
|
|---|
| 972 | _newCorr->_satYawAngleValid = true;
|
|---|
| 973 |
|
|---|
| 974 | // _lambdaIF
|
|---|
| 975 | map<t_frequency::type, double> codeCoeff;
|
|---|
| 976 | double channel = double(_newCorr->_eph->slotNum());
|
|---|
| 977 | cmbRefSig::coeff(sys, cmbRefSig::cIF, channel, codeCoeff);
|
|---|
| 978 | map<t_frequency::type, double>::const_iterator it;
|
|---|
| 979 | for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
|
|---|
| 980 | t_frequency::type frqType = it->first;
|
|---|
| 981 | double codeCoeff = it->second;
|
|---|
| 982 | _newCorr->_lambdaIF += codeCoeff * t_CST::c / t_CST::freq(frqType, channel);
|
|---|
| 983 | }
|
|---|
| 984 | }
|
|---|
| 985 | }
|
|---|
| 986 |
|
|---|
| 987 | // Orbits of an APC AC in a combination in the CoM frame
|
|---|
| 988 | // ------------------------------------------------------
|
|---|
| 989 | if (_cmbCoM) {
|
|---|
| 990 | const cmbAC* AC = 0;
|
|---|
| 991 | for (const cmbAC* ac : _ACs) {
|
|---|
| 992 | if (ac->name == acName) {
|
|---|
| 993 | AC = ac;
|
|---|
| 994 | break;
|
|---|
| 995 | }
|
|---|
| 996 | }
|
|---|
| 997 | if (AC && AC->isAPC && convertApcToCoM(_newCorr, AC) != success) {
|
|---|
| 998 | delete _newCorr; _newCorr = 0;
|
|---|
| 999 | continue;
|
|---|
| 1000 | }
|
|---|
| 1001 | }
|
|---|
| 1002 |
|
|---|
| 1003 | // Store correction into the buffer
|
|---|
| 1004 | // --------------------------------
|
|---|
| 1005 | QVector<cmbCorr*>& corrs = _buffer[sys].corrs;
|
|---|
| 1006 | QVectorIterator<cmbCorr*> itCorr(corrs);
|
|---|
| 1007 | bool available = false;
|
|---|
| 1008 | while (itCorr.hasNext()) {
|
|---|
| 1009 | cmbCorr* corr = itCorr.next();
|
|---|
| 1010 | QString prnStr = corr->_prn;
|
|---|
| 1011 | QString acName = corr->_acName;
|
|---|
| 1012 | if (_newCorr->_acName == acName &&
|
|---|
| 1013 | _newCorr->_prn == prnStr) {
|
|---|
| 1014 | available = true;
|
|---|
| 1015 | }
|
|---|
| 1016 | }
|
|---|
| 1017 |
|
|---|
| 1018 | if (!available) {
|
|---|
| 1019 | corrs.push_back(_newCorr); _newCorr = 0;
|
|---|
| 1020 | }
|
|---|
| 1021 | else {
|
|---|
| 1022 | delete _newCorr; _newCorr = 0;
|
|---|
| 1023 | continue;
|
|---|
| 1024 | }
|
|---|
| 1025 | }
|
|---|
| 1026 |
|
|---|
| 1027 | // Process Systems of this Epoch
|
|---|
| 1028 | // ------------------------------
|
|---|
| 1029 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
|---|
| 1030 | while (itSys.hasNext()) {
|
|---|
| 1031 | itSys.next();
|
|---|
| 1032 | char sys = itSys.key();
|
|---|
| 1033 | _log.clear();
|
|---|
| 1034 | QTextStream out(&_log, QIODevice::WriteOnly);
|
|---|
| 1035 | processSystem(epoTime, sys, out);
|
|---|
| 1036 | out.flush(); // QTextStream buffers: pass the complete log text on
|
|---|
| 1037 | _buffer.remove(sys);
|
|---|
| 1038 | if (_logFile) {
|
|---|
| 1039 | _logFile->write(epoTime.gpsw(),epoTime.gpssec(), QString(_log));
|
|---|
| 1040 | }
|
|---|
| 1041 | }
|
|---|
| 1042 | }
|
|---|
| 1043 |
|
|---|
| 1044 | void bncComb::processSystem(bncTime epoTime, char sys, QTextStream& out) {
|
|---|
| 1045 |
|
|---|
| 1046 | out << "\n"
|
|---|
| 1047 | << epoTime.datestr().c_str() << " "
|
|---|
| 1048 | << epoTime.timestr().c_str() << " "
|
|---|
| 1049 | << "Combination: " << sys << "\n"
|
|---|
| 1050 | << "--------------------------------------" << "\n";
|
|---|
| 1051 |
|
|---|
| 1052 | // Observation Statistics
|
|---|
| 1053 | // ----------------------
|
|---|
| 1054 | bool masterPresent = false;
|
|---|
| 1055 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 1056 | while (icAC.hasNext()) {
|
|---|
| 1057 | cmbAC* AC = icAC.next();
|
|---|
| 1058 | AC->numObs[sys] = 0;
|
|---|
| 1059 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
|---|
| 1060 | while (itCorr.hasNext()) {
|
|---|
| 1061 | cmbCorr* corr = itCorr.next();
|
|---|
| 1062 | if (corr->_acName == AC->name) {
|
|---|
| 1063 | AC->numObs[sys] += 1;
|
|---|
| 1064 | if (AC->name == _masterOrbitAC[sys]) {
|
|---|
| 1065 | masterPresent = true;
|
|---|
| 1066 | }
|
|---|
| 1067 | }
|
|---|
| 1068 | }
|
|---|
| 1069 | out << epoTime.datestr().c_str() << " "
|
|---|
| 1070 | << epoTime.timestr().c_str() << " "
|
|---|
| 1071 | << "Sat Num " << sys << " "
|
|---|
| 1072 | << AC->name.toLatin1().data() << ": " << AC->numObs[sys] << "\n";
|
|---|
| 1073 | }
|
|---|
| 1074 |
|
|---|
| 1075 | // If Master not present, switch to another one
|
|---|
| 1076 | // --------------------------------------------
|
|---|
| 1077 | const unsigned switchMasterAfterGap = 1;
|
|---|
| 1078 | if (masterPresent) {
|
|---|
| 1079 | _masterMissingEpochs[sys] = 0;
|
|---|
| 1080 | }
|
|---|
| 1081 | else {
|
|---|
| 1082 | ++_masterMissingEpochs[sys];
|
|---|
| 1083 | if (_masterMissingEpochs[sys] < switchMasterAfterGap) {
|
|---|
| 1084 | out << "Missing Master, Epoch skipped" << "\n";
|
|---|
| 1085 | _buffer.remove(sys);
|
|---|
| 1086 | emit newMessage(_log, false);
|
|---|
| 1087 | return;
|
|---|
| 1088 | }
|
|---|
| 1089 | else {
|
|---|
| 1090 | _masterMissingEpochs[sys] = 0;
|
|---|
| 1091 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 1092 | while (icAC.hasNext()) {
|
|---|
| 1093 | cmbAC* AC = icAC.next();
|
|---|
| 1094 | if (AC->numObs[sys] > 0) {
|
|---|
| 1095 | out << epoTime.datestr().c_str() << " "
|
|---|
| 1096 | << epoTime.timestr().c_str() << " "
|
|---|
| 1097 | << "Switching Master " << sys << " "
|
|---|
| 1098 | << _masterOrbitAC[sys].toLatin1().data() << " --> "
|
|---|
| 1099 | << AC->name.toLatin1().data() << "\n";
|
|---|
| 1100 | _masterOrbitAC[sys] = AC->name;
|
|---|
| 1101 | _masterIsAPC[sys] = _cmbCoM ? false : AC->isAPC;
|
|---|
| 1102 | break;
|
|---|
| 1103 | }
|
|---|
| 1104 | }
|
|---|
| 1105 | }
|
|---|
| 1106 | }
|
|---|
| 1107 |
|
|---|
| 1108 | QMap<QString, cmbCorr*> masterCorr;
|
|---|
| 1109 |
|
|---|
| 1110 | // Perform the actual Combination using selected Method
|
|---|
| 1111 | // ----------------------------------------------------
|
|---|
| 1112 | t_irc irc;
|
|---|
| 1113 | ColumnVector dx;
|
|---|
| 1114 | if (_method == filter) {
|
|---|
| 1115 | irc = processEpoch_filter(epoTime, sys, out, masterCorr, dx);
|
|---|
| 1116 | }
|
|---|
| 1117 | else {
|
|---|
| 1118 | irc = processEpoch_singleEpoch(epoTime, sys, out, masterCorr, dx);
|
|---|
| 1119 | }
|
|---|
| 1120 |
|
|---|
| 1121 | // Update Parameter Values, Print Results
|
|---|
| 1122 | // --------------------------------------
|
|---|
| 1123 | if (irc == success) {
|
|---|
| 1124 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 1125 | cmbParam* pp = _params[sys][iPar-1];
|
|---|
| 1126 | pp->xx += dx(iPar);
|
|---|
| 1127 | if (pp->type == cmbParam::clkSat) {
|
|---|
| 1128 | if (masterCorr.find(pp->prn) != masterCorr.end()) {
|
|---|
| 1129 | // set clock result
|
|---|
| 1130 | masterCorr[pp->prn]->_dClkResult = pp->xx / t_CST::c;
|
|---|
| 1131 | // Add Code Biases from SINEX File
|
|---|
| 1132 | if (_bsx) {
|
|---|
| 1133 | map<t_frequency::type, double> codeCoeff;
|
|---|
| 1134 | double channel = double(masterCorr[pp->prn]->_eph->slotNum());
|
|---|
| 1135 | cmbRefSig::coeff(sys, cmbRefSig::cIF, channel, codeCoeff);
|
|---|
| 1136 | t_frequency::type fType1 = cmbRefSig::toFreq(sys, cmbRefSig::c1);
|
|---|
| 1137 | t_frequency::type fType2 = cmbRefSig::toFreq(sys, cmbRefSig::c2);
|
|---|
| 1138 | _bsx->determineSsrSatCodeBiases(pp->prn.mid(0,3), codeCoeff[fType1], codeCoeff[fType2], masterCorr[pp->prn]->_satCodeBias);
|
|---|
| 1139 | }
|
|---|
| 1140 | }
|
|---|
| 1141 | }
|
|---|
| 1142 | out << epoTime.datestr().c_str() << " "
|
|---|
| 1143 | << epoTime.timestr().c_str() << " ";
|
|---|
| 1144 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
|---|
| 1145 | out.setFieldWidth(8);
|
|---|
| 1146 | out.setRealNumberPrecision(4);
|
|---|
| 1147 | out << pp->toString(sys) << " "
|
|---|
| 1148 | << pp->xx << " +- " << sqrt(_QQ[sys](pp->index,pp->index)) << "\n";
|
|---|
| 1149 | out.setFieldWidth(0);
|
|---|
| 1150 | out.flush();
|
|---|
| 1151 | }
|
|---|
| 1152 | if (_method == filter) {
|
|---|
| 1153 | checkBiasConsistency(epoTime, sys, out);
|
|---|
| 1154 | checkPersistentOutliers(epoTime, sys, out);
|
|---|
| 1155 | }
|
|---|
| 1156 | printResults(epoTime, out, masterCorr);
|
|---|
| 1157 | dumpResults(epoTime, masterCorr);
|
|---|
| 1158 | }
|
|---|
| 1159 | }
|
|---|
| 1160 |
|
|---|
| 1161 | // Process Epoch - Filter Method
|
|---|
| 1162 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1163 | t_irc bncComb::processEpoch_filter(bncTime epoTime, char sys, QTextStream& out,
|
|---|
| 1164 | QMap<QString, cmbCorr*>& masterCorr,
|
|---|
| 1165 | ColumnVector& dx) {
|
|---|
| 1166 |
|
|---|
| 1167 | // Prediction Step
|
|---|
| 1168 | // ---------------
|
|---|
| 1169 | int nPar = _params[sys].size();
|
|---|
| 1170 | ColumnVector x0(nPar);
|
|---|
| 1171 | for (int iPar = 1; iPar <= nPar; iPar++) {
|
|---|
| 1172 | cmbParam* pp = _params[sys][iPar-1];
|
|---|
| 1173 | if (pp->epoSpec) {
|
|---|
| 1174 | pp->xx = 0.0;
|
|---|
| 1175 | _QQ[sys].Row(iPar) = 0.0;
|
|---|
| 1176 | _QQ[sys].Column(iPar) = 0.0;
|
|---|
| 1177 | _QQ[sys](iPar,iPar) = pp->sig0 * pp->sig0;
|
|---|
| 1178 | }
|
|---|
| 1179 | else {
|
|---|
| 1180 | _QQ[sys](iPar,iPar) += pp->sigP * pp->sigP;
|
|---|
| 1181 | }
|
|---|
| 1182 | x0(iPar) = pp->xx;
|
|---|
| 1183 | }
|
|---|
| 1184 |
|
|---|
| 1185 | // Check Satellite Positions for Outliers
|
|---|
| 1186 | // --------------------------------------
|
|---|
| 1187 | if (checkOrbits(epoTime, sys, out, masterCorr) != success) {
|
|---|
| 1188 | return failure;
|
|---|
| 1189 | }
|
|---|
| 1190 |
|
|---|
| 1191 | // Statistics of persistent outliers
|
|---|
| 1192 | // ---------------------------------
|
|---|
| 1193 | for (int ii = 0; ii < corrs(sys).size(); ii++) {
|
|---|
| 1194 | const cmbCorr* corr = corrs(sys)[ii];
|
|---|
| 1195 | _outlierStat[sys][corr->_acName + ' ' + corr->_prn.mid(0,3)].numEpo += 1;
|
|---|
| 1196 | }
|
|---|
| 1197 |
|
|---|
| 1198 | // Update and outlier detection loop
|
|---|
| 1199 | // ---------------------------------
|
|---|
| 1200 | SymmetricMatrix QQ_sav = _QQ[sys];
|
|---|
| 1201 | while (_running) {
|
|---|
| 1202 |
|
|---|
| 1203 | Matrix AA;
|
|---|
| 1204 | ColumnVector ll;
|
|---|
| 1205 | DiagonalMatrix PP;
|
|---|
| 1206 |
|
|---|
| 1207 | if (createAmat(sys, AA, ll, PP, x0, masterCorr) != success) {
|
|---|
| 1208 | return failure;
|
|---|
| 1209 | }
|
|---|
| 1210 |
|
|---|
| 1211 | dx.ReSize(nPar); dx = 0.0;
|
|---|
| 1212 | kalman(AA, ll, PP, _QQ[sys], dx);
|
|---|
| 1213 |
|
|---|
| 1214 | ColumnVector vv = ll - AA * dx;
|
|---|
| 1215 |
|
|---|
| 1216 | int maxResIndex;
|
|---|
| 1217 | double maxRes = vv.maximum_absolute_value1(maxResIndex);
|
|---|
| 1218 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
|---|
| 1219 | out.setRealNumberPrecision(3);
|
|---|
| 1220 | out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str()
|
|---|
| 1221 | << " Maximum Residuum " << maxRes << ' '
|
|---|
| 1222 | << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
|
|---|
| 1223 | if (maxRes > _MAX_RES) {
|
|---|
| 1224 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 1225 | cmbParam* pp = _params[sys][iPar-1];
|
|---|
| 1226 | if (pp->type == cmbParam::offACSat &&
|
|---|
| 1227 | pp->AC == corrs(sys)[maxResIndex-1]->_acName &&
|
|---|
| 1228 | pp->prn == corrs(sys)[maxResIndex-1]->_prn) {
|
|---|
| 1229 | QQ_sav.Row(iPar) = 0.0;
|
|---|
| 1230 | QQ_sav.Column(iPar) = 0.0;
|
|---|
| 1231 | QQ_sav(iPar,iPar) = pp->sig0 * pp->sig0;
|
|---|
| 1232 | }
|
|---|
| 1233 | }
|
|---|
| 1234 |
|
|---|
| 1235 | out << " Outlier" << "\n";
|
|---|
| 1236 | _outlierStat[sys][corrs(sys)[maxResIndex-1]->_acName + ' ' +
|
|---|
| 1237 | corrs(sys)[maxResIndex-1]->_prn.mid(0,3)].residuals.push_back(maxRes);
|
|---|
| 1238 | _QQ[sys] = QQ_sav;
|
|---|
| 1239 | delete corrs(sys)[maxResIndex-1];
|
|---|
| 1240 | corrs(sys).remove(maxResIndex-1);
|
|---|
| 1241 | }
|
|---|
| 1242 | else {
|
|---|
| 1243 | out << " OK" << "\n";
|
|---|
| 1244 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
|---|
| 1245 | out.setRealNumberPrecision(4);
|
|---|
| 1246 | for (int ii = 0; ii < corrs(sys).size(); ii++) {
|
|---|
| 1247 | const cmbCorr* corr = corrs(sys)[ii];
|
|---|
| 1248 | out << epoTime.datestr().c_str() << ' '
|
|---|
| 1249 | << epoTime.timestr().c_str() << " "
|
|---|
| 1250 | << corr->_acName << ' ' << corr->_prn.mid(0,3);
|
|---|
| 1251 | out.setFieldWidth(10);
|
|---|
| 1252 | out << " res = " << vv[ii] << "\n";
|
|---|
| 1253 | out.setFieldWidth(0);
|
|---|
| 1254 | }
|
|---|
| 1255 | break;
|
|---|
| 1256 | }
|
|---|
| 1257 | }
|
|---|
| 1258 |
|
|---|
| 1259 | return success;
|
|---|
| 1260 | }
|
|---|
| 1261 |
|
|---|
| 1262 | // Check the consistency of the AC code biases with the AC clocks
|
|---|
| 1263 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1264 | // An AC's clocks refer to its own clock signals; the code biases of the
|
|---|
| 1265 | // reference signals refer them to the reference signals (B_IF, ionosphere-
|
|---|
| 1266 | // free combination of these biases, added to the AC clocks). If the code
|
|---|
| 1267 | // biases do not belong to the clocks (e.g. taken from another product), the
|
|---|
| 1268 | // error B_IF is absorbed by the AC's satellite offsets. The satellite offsets
|
|---|
| 1269 | // of each AC are therefore regressed against its B_IF every 5 minutes (from
|
|---|
| 1270 | // 5 minutes after the start); a warning is issued (at most once per hour per
|
|---|
| 1271 | // AC and system) if B_IF varies noticeably between the satellites and the
|
|---|
| 1272 | // offsets clearly follow it.
|
|---|
| 1273 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1274 | void bncComb::checkBiasConsistency(bncTime epoTime, char sys, QTextStream& out) {
|
|---|
| 1275 |
|
|---|
| 1276 | const double CHECK_INT = 300.0; // [s] check interval, first check after start
|
|---|
| 1277 | const unsigned MIN_SAT = 5;
|
|---|
| 1278 | const double MIN_SPREAD = 0.03; // [m] minimum std. deviation of B_IF
|
|---|
| 1279 | const double MIN_SLOPE = 0.3; // 0.5 expected for 2 ACs, -> 1 for more ACs
|
|---|
| 1280 | const double MIN_CORR = 0.7;
|
|---|
| 1281 |
|
|---|
| 1282 | if (!_biasCheckStart[sys].valid()) {
|
|---|
| 1283 | _biasCheckStart[sys] = epoTime;
|
|---|
| 1284 | _biasCheckLast[sys] = epoTime;
|
|---|
| 1285 | return;
|
|---|
| 1286 | }
|
|---|
| 1287 | if (epoTime - _biasCheckLast[sys] < CHECK_INT) {
|
|---|
| 1288 | return;
|
|---|
| 1289 | }
|
|---|
| 1290 | _biasCheckLast[sys] = epoTime;
|
|---|
| 1291 |
|
|---|
| 1292 | QListIterator<cmbAC*> itAc(_ACs);
|
|---|
| 1293 | while (itAc.hasNext()) {
|
|---|
| 1294 | const QString& acName = itAc.next()->name;
|
|---|
| 1295 | if (!_acBiasIF.contains(acName)) {
|
|---|
| 1296 | continue;
|
|---|
| 1297 | }
|
|---|
| 1298 | const QMap<QString, double>& biasIF = _acBiasIF[acName];
|
|---|
| 1299 |
|
|---|
| 1300 | // satellites of this AC in the current epoch with B_IF available
|
|---|
| 1301 | QVector<double> xx, yy;
|
|---|
| 1302 | for (int ii = 0; ii < corrs(sys).size(); ii++) {
|
|---|
| 1303 | const cmbCorr* corr = corrs(sys)[ii];
|
|---|
| 1304 | if (corr->_acName != acName || !biasIF.contains(corr->_prn.mid(0,3))) {
|
|---|
| 1305 | continue;
|
|---|
| 1306 | }
|
|---|
| 1307 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 1308 | const cmbParam* pp = _params[sys][iPar-1];
|
|---|
| 1309 | if (pp->type == cmbParam::offACSat && pp->AC == acName && pp->prn == corr->_prn) {
|
|---|
| 1310 | xx.push_back(biasIF[corr->_prn.mid(0,3)]);
|
|---|
| 1311 | yy.push_back(pp->xx);
|
|---|
| 1312 | break;
|
|---|
| 1313 | }
|
|---|
| 1314 | }
|
|---|
| 1315 | }
|
|---|
| 1316 | unsigned nn = xx.size();
|
|---|
| 1317 | if (nn < MIN_SAT) {
|
|---|
| 1318 | continue;
|
|---|
| 1319 | }
|
|---|
| 1320 | double mx = 0.0, my = 0.0;
|
|---|
| 1321 | for (unsigned ii = 0; ii < nn; ii++) {
|
|---|
| 1322 | mx += xx[ii] / nn;
|
|---|
| 1323 | my += yy[ii] / nn;
|
|---|
| 1324 | }
|
|---|
| 1325 | double sxx = 0.0, syy = 0.0, sxy = 0.0;
|
|---|
| 1326 | for (unsigned ii = 0; ii < nn; ii++) {
|
|---|
| 1327 | sxx += (xx[ii] - mx) * (xx[ii] - mx);
|
|---|
| 1328 | syy += (yy[ii] - my) * (yy[ii] - my);
|
|---|
| 1329 | sxy += (xx[ii] - mx) * (yy[ii] - my);
|
|---|
| 1330 | }
|
|---|
| 1331 | QString key = acName + sys;
|
|---|
| 1332 | double spread = sqrt(sxx / nn);
|
|---|
| 1333 | double slope = (sxx > 0.0) ? sxy / sxx : 0.0;
|
|---|
| 1334 | double corrCoeff = (sxx > 0.0 && syy > 0.0) ? sxy / sqrt(sxx * syy) : 0.0;
|
|---|
| 1335 | if (spread < MIN_SPREAD || slope < MIN_SLOPE || corrCoeff < MIN_CORR) {
|
|---|
| 1336 | if (_biasInconsistent.remove(key)) {
|
|---|
| 1337 | QString msg = QString("%1 %2 code biases consistent with its clocks again, "
|
|---|
| 1338 | "AC used for the clock datum again").arg(acName).arg(sys);
|
|---|
| 1339 | out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str()
|
|---|
| 1340 | << " " << msg << "\n";
|
|---|
| 1341 | emit newMessage("bncComb: " + msg.toLatin1(), true);
|
|---|
| 1342 | resetSatOffsets(sys);
|
|---|
| 1343 | }
|
|---|
| 1344 | continue;
|
|---|
| 1345 | }
|
|---|
| 1346 |
|
|---|
| 1347 | QString refSig;
|
|---|
| 1348 | for (unsigned ii = 1; ii < cmbRefSig::cIF; ii++) {
|
|---|
| 1349 | t_frequency::type frqType = cmbRefSig::toFreq(sys, static_cast<cmbRefSig::type>(ii));
|
|---|
| 1350 | refSig += QString("%1C%2%3").arg(ii > 1 ? "/" : "").arg(t_frequency::toString(frqType)[1])
|
|---|
| 1351 | .arg(cmbRefSig::toAttrib(sys, static_cast<cmbRefSig::type>(ii)));
|
|---|
| 1352 | }
|
|---|
| 1353 | QString msg = QString("%1 %2 code biases (%3) seem inconsistent with its clocks: "
|
|---|
| 1354 | "satellite offsets follow the bias combination B_IF "
|
|---|
| 1355 | "(%4 satellites, B_IF spread %5 m, slope %6, correlation %7)")
|
|---|
| 1356 | .arg(acName).arg(sys).arg(refSig).arg(nn)
|
|---|
| 1357 | .arg(spread, 0, 'f', 3).arg(slope, 0, 'f', 2).arg(corrCoeff, 0, 'f', 2);
|
|---|
| 1358 | if (!_biasInconsistent.contains(key)) {
|
|---|
| 1359 | _biasInconsistent.insert(key);
|
|---|
| 1360 | msg += ", AC excluded from the clock datum";
|
|---|
| 1361 | _biasCheckWarned.remove(key);
|
|---|
| 1362 | resetSatOffsets(sys);
|
|---|
| 1363 | }
|
|---|
| 1364 | out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str()
|
|---|
| 1365 | << " " << msg << "\n";
|
|---|
| 1366 | bncTime& warned = _biasCheckWarned[key];
|
|---|
| 1367 | if (!warned.valid() || epoTime - warned >= 3600.0) {
|
|---|
| 1368 | warned = epoTime;
|
|---|
| 1369 | emit newMessage("bncComb: " + msg.toLatin1(), true);
|
|---|
| 1370 | }
|
|---|
| 1371 | }
|
|---|
| 1372 | }
|
|---|
| 1373 |
|
|---|
| 1374 | // Convert the orbit correction of an APC AC to the satellite's CoM: the
|
|---|
| 1375 | // antenna offset (ANTEX, single reference frequency, attitude as configured
|
|---|
| 1376 | // for the AC) is added to the correction in radial, along-track and
|
|---|
| 1377 | // cross-track direction. The clock correction is not affected.
|
|---|
| 1378 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1379 | t_irc bncComb::convertApcToCoM(cmbCorr* corr, const cmbAC* AC) {
|
|---|
| 1380 | corr->_eph->setOrbCorr(&corr->_orbCorr);
|
|---|
| 1381 | corr->_eph->setClkCorr(&corr->_clkCorr);
|
|---|
| 1382 | ColumnVector xc(6), vv(3);
|
|---|
| 1383 | if (corr->_eph->getCrd(corr->_time, xc, vv, true) != success) {
|
|---|
| 1384 | return failure;
|
|---|
| 1385 | }
|
|---|
| 1386 | bncAntex::e_attMode attMode = bncAntex::ATT_COMPUTED;
|
|---|
| 1387 | double extYaw = 0.0;
|
|---|
| 1388 | if (AC->attitudeSource == "SSR" && corr->_satYawAngleValid) {
|
|---|
| 1389 | attMode = bncAntex::ATT_EXTERNAL;
|
|---|
| 1390 | extYaw = corr->_satYawAngle;
|
|---|
| 1391 | }
|
|---|
| 1392 | else if (AC->attitudeSource == "Nominal") {
|
|---|
| 1393 | attMode = bncAntex::ATT_NOMINAL;
|
|---|
| 1394 | }
|
|---|
| 1395 | double Mjd = corr->_time.mjd() + corr->_time.daysec() / 86400.0;
|
|---|
| 1396 | ColumnVector dx(3); dx = 0.0;
|
|---|
| 1397 | if (_antex->satCoMcorrection(corr->_prn, Mjd, xc.Rows(1,3), vv, dx, attMode, extYaw, AC->name) != success) {
|
|---|
| 1398 | if (_antex->warnNoSatEntry(corr->_prn, corr->_time)) {
|
|---|
| 1399 | emit newMessage("bncComb: no satellite antenna entry valid at " +
|
|---|
| 1400 | QByteArray(corr->_time.datestr().c_str()) + " " + QByteArray(corr->_time.timestr().c_str()) +
|
|---|
| 1401 | " for " + corr->_prn.mid(0,3).toLatin1() +
|
|---|
| 1402 | " in ANTEX file - APC orbit of " + AC->name.toLatin1() + " not converted to CoM, not combined", true);
|
|---|
| 1403 | }
|
|---|
| 1404 | return failure;
|
|---|
| 1405 | }
|
|---|
| 1406 | // X = X_brdc - RSW(xr): X_CoM = X_APC - dx => xr_CoM = xr_APC + RSW(dx)
|
|---|
| 1407 | ColumnVector dRAO(3);
|
|---|
| 1408 | XYZ_to_RSW(xc.Rows(1,3), vv, dx, dRAO);
|
|---|
| 1409 | corr->_orbCorr._xr += dRAO;
|
|---|
| 1410 | return success;
|
|---|
| 1411 | }
|
|---|
| 1412 |
|
|---|
| 1413 | // Report AC satellites rejected as outliers in most epochs
|
|---|
| 1414 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1415 | // A persistent clock difference of one AC for a satellite cannot be absorbed
|
|---|
| 1416 | // by its satellite offset, as the offsets of all ACs of the satellite sum up
|
|---|
| 1417 | // to zero: the correction is rejected again in every epoch. Once per hour
|
|---|
| 1418 | // and system, AC satellites rejected in at least half of their epochs are
|
|---|
| 1419 | // reported.
|
|---|
| 1420 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1421 | void bncComb::checkPersistentOutliers(bncTime epoTime, char sys, QTextStream& out) {
|
|---|
| 1422 |
|
|---|
| 1423 | const double INTERVAL = 3600.0;
|
|---|
| 1424 | const unsigned MIN_EPO = 10;
|
|---|
| 1425 |
|
|---|
| 1426 | if (!_outlierStatStart[sys].valid()) {
|
|---|
| 1427 | _outlierStatStart[sys] = epoTime;
|
|---|
| 1428 | return;
|
|---|
| 1429 | }
|
|---|
| 1430 | if (epoTime - _outlierStatStart[sys] < INTERVAL) {
|
|---|
| 1431 | return;
|
|---|
| 1432 | }
|
|---|
| 1433 | QMapIterator<QString, t_outlierStat> it(_outlierStat[sys]);
|
|---|
| 1434 | while (it.hasNext()) {
|
|---|
| 1435 | it.next();
|
|---|
| 1436 | const t_outlierStat& stat = it.value();
|
|---|
| 1437 | unsigned numOut = stat.residuals.size();
|
|---|
| 1438 | if (stat.numEpo < MIN_EPO || 2 * numOut < stat.numEpo) {
|
|---|
| 1439 | continue;
|
|---|
| 1440 | }
|
|---|
| 1441 | QVector<double> res = stat.residuals;
|
|---|
| 1442 | std::sort(res.begin(), res.end());
|
|---|
| 1443 | double median = (numOut % 2) ? res[numOut/2] : 0.5 * (res[numOut/2-1] + res[numOut/2]);
|
|---|
| 1444 | QString msg = QString("%1 rejected as outlier in %2% of %3 epochs in the last hour "
|
|---|
| 1445 | "(median residual %4 m)")
|
|---|
| 1446 | .arg(it.key()).arg(100.0 * numOut / stat.numEpo, 0, 'f', 0)
|
|---|
| 1447 | .arg(stat.numEpo).arg(median, 0, 'f', 2);
|
|---|
| 1448 | out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str() << " " << msg << "\n";
|
|---|
| 1449 | emit newMessage("bncComb: " + msg.toLatin1(), true);
|
|---|
| 1450 | }
|
|---|
| 1451 | _outlierStat[sys].clear();
|
|---|
| 1452 | _outlierStatStart[sys] = epoTime;
|
|---|
| 1453 | }
|
|---|
| 1454 |
|
|---|
| 1455 | // Re-initialize the satellite offsets of all ACs of a system (after a change
|
|---|
| 1456 | // of the clock datum)
|
|---|
| 1457 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1458 | void bncComb::resetSatOffsets(char sys) {
|
|---|
| 1459 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 1460 | cmbParam* pp = _params[sys][iPar-1];
|
|---|
| 1461 | if (pp->type == cmbParam::offACSat) {
|
|---|
| 1462 | pp->xx = 0.0;
|
|---|
| 1463 | _QQ[sys].Row(iPar) = 0.0;
|
|---|
| 1464 | _QQ[sys].Column(iPar) = 0.0;
|
|---|
| 1465 | _QQ[sys](iPar,iPar) = pp->sig0 * pp->sig0;
|
|---|
| 1466 | }
|
|---|
| 1467 | }
|
|---|
| 1468 | }
|
|---|
| 1469 |
|
|---|
| 1470 | // Print results
|
|---|
| 1471 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1472 | void bncComb::printResults(bncTime epoTime, QTextStream& out,
|
|---|
| 1473 | const QMap<QString, cmbCorr*>& masterCorr) {
|
|---|
| 1474 |
|
|---|
| 1475 | QMapIterator<QString, cmbCorr*> it(masterCorr);
|
|---|
| 1476 | while (it.hasNext()) {
|
|---|
| 1477 | it.next();
|
|---|
| 1478 | cmbCorr* corr = it.value();
|
|---|
| 1479 | const t_eph* eph = corr->_eph;
|
|---|
| 1480 | if (eph) {
|
|---|
| 1481 | ColumnVector xc(6);
|
|---|
| 1482 | ColumnVector vv(3);
|
|---|
| 1483 | if (eph->getCrd(epoTime, xc, vv, false) != success) {
|
|---|
| 1484 | continue;
|
|---|
| 1485 | }
|
|---|
| 1486 | out << epoTime.datestr().c_str() << " "
|
|---|
| 1487 | << epoTime.timestr().c_str() << " ";
|
|---|
| 1488 | out.setFieldWidth(3);
|
|---|
| 1489 | out << "Full Clock " << corr->_prn.mid(0,3) << " " << corr->_iod << " ";
|
|---|
| 1490 | out.setFieldWidth(14);
|
|---|
| 1491 | out << (xc(4) + corr->_dClkResult) * t_CST::c << "\n";
|
|---|
| 1492 | out.setFieldWidth(0);
|
|---|
| 1493 | out.flush();
|
|---|
| 1494 | }
|
|---|
| 1495 | else {
|
|---|
| 1496 | out << "bncComb::printResults bug" << "\n";
|
|---|
| 1497 | }
|
|---|
| 1498 | }
|
|---|
| 1499 | }
|
|---|
| 1500 |
|
|---|
| 1501 | // Send results to RTNet Decoder and directly to PPP Client
|
|---|
| 1502 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1503 | void bncComb::dumpResults(bncTime epoTime, QMap<QString, cmbCorr*>& masterCorr) {
|
|---|
| 1504 |
|
|---|
| 1505 | QList<t_orbCorr> orbCorrections;
|
|---|
| 1506 | QList<t_clkCorr> clkCorrections;
|
|---|
| 1507 | QList<t_satCodeBias> satCodeBiasList;
|
|---|
| 1508 | QList<t_satPhaseBias> satPhaseBiasList;
|
|---|
| 1509 |
|
|---|
| 1510 | unsigned year, month, day, hour, minute;
|
|---|
| 1511 | double sec;
|
|---|
| 1512 | epoTime.civil_date(year, month, day);
|
|---|
| 1513 | epoTime.civil_time(hour, minute, sec);
|
|---|
| 1514 |
|
|---|
| 1515 | QString outLines = QString().asprintf("* %4d %2d %2d %d %d %12.8f\n",
|
|---|
| 1516 | year, month, day, hour, minute, sec);
|
|---|
| 1517 |
|
|---|
| 1518 | QMutableMapIterator<QString, cmbCorr*> it(masterCorr);
|
|---|
| 1519 | while (it.hasNext()) {
|
|---|
| 1520 | it.next();
|
|---|
| 1521 | cmbCorr* corr = it.value();
|
|---|
| 1522 |
|
|---|
| 1523 | // Reject GLONASS corrections whose broadcast ephemeris has exceeded its
|
|---|
| 1524 | // declared validity window. GLONASS nav ephemerides are issued every
|
|---|
| 1525 | // 30 min and are valid for ±900 s around the reference time (TOC).
|
|---|
| 1526 | // t_ephGlo::position() uses Runge-Kutta integration from TOC; beyond
|
|---|
| 1527 | // ±900 s the integration error grows unchecked and propagates into both
|
|---|
| 1528 | // the combined clock estimate and the SP3 position.
|
|---|
| 1529 | if (corr->_eph->prn().system() == 'R') {
|
|---|
| 1530 | double age = epoTime - corr->_eph->TOC();
|
|---|
| 1531 | if (fabs(age) > 900.0) {
|
|---|
| 1532 | emit newMessage(QString().asprintf(
|
|---|
| 1533 | "bncComb: skip %s, GLONASS eph age %.0fs",
|
|---|
| 1534 | corr->_prn.mid(0,3).toLatin1().data(), age).toLatin1(), false);
|
|---|
| 1535 | delete corr;
|
|---|
| 1536 | it.remove();
|
|---|
| 1537 | continue;
|
|---|
| 1538 | }
|
|---|
| 1539 | }
|
|---|
| 1540 |
|
|---|
| 1541 | // ORBIT
|
|---|
| 1542 | t_orbCorr orbCorr(corr->_orbCorr);
|
|---|
| 1543 | orbCorr._staID = "INTERNAL";
|
|---|
| 1544 | orbCorrections.push_back(orbCorr);
|
|---|
| 1545 |
|
|---|
| 1546 | // CLOCK
|
|---|
| 1547 | t_clkCorr clkCorr(corr->_clkCorr);
|
|---|
| 1548 | clkCorr._staID = "INTERNAL";
|
|---|
| 1549 | clkCorr._dClk = corr->_dClkResult;
|
|---|
| 1550 | clkCorr._dotDClk = 0.0;
|
|---|
| 1551 | clkCorr._dotDotDClk = 0.0;
|
|---|
| 1552 | clkCorrections.push_back(clkCorr);
|
|---|
| 1553 |
|
|---|
| 1554 | ColumnVector xc(6);
|
|---|
| 1555 | ColumnVector vv(3);
|
|---|
| 1556 | corr->_eph->setClkCorr(dynamic_cast<const t_clkCorr*>(&clkCorr));
|
|---|
| 1557 | corr->_eph->setOrbCorr(dynamic_cast<const t_orbCorr*>(&orbCorr));
|
|---|
| 1558 |
|
|---|
| 1559 | if (corr->_eph->getCrd(epoTime, xc, vv, true) != success) {
|
|---|
| 1560 | delete corr;
|
|---|
| 1561 | it.remove();
|
|---|
| 1562 | continue;
|
|---|
| 1563 | }
|
|---|
| 1564 |
|
|---|
| 1565 | // Correction Phase Center --> CoM
|
|---|
| 1566 | // -------------------------------
|
|---|
| 1567 | ColumnVector dx(3); dx = 0.0;
|
|---|
| 1568 | ColumnVector apc(3); apc = 0.0;
|
|---|
| 1569 | ColumnVector com(3); com = 0.0;
|
|---|
| 1570 | bool masterIsAPC = true;
|
|---|
| 1571 | if (_antex) {
|
|---|
| 1572 | double Mjd = epoTime.mjd() + epoTime.daysec()/86400.0;
|
|---|
| 1573 | char sys = corr->_eph->prn().system();
|
|---|
| 1574 | masterIsAPC = _masterIsAPC[sys];
|
|---|
| 1575 |
|
|---|
| 1576 | // Determine attitude mode from the master orbit AC for this system
|
|---|
| 1577 | bncAntex::e_attMode attMode = bncAntex::ATT_COMPUTED;
|
|---|
| 1578 | double extYaw = 0.0;
|
|---|
| 1579 | const QString& masterName = _masterOrbitAC[sys];
|
|---|
| 1580 | for (const cmbAC* ac : _ACs) {
|
|---|
| 1581 | if (ac->name == masterName) {
|
|---|
| 1582 | if (ac->attitudeSource == "SSR" && corr->_satYawAngleValid) {
|
|---|
| 1583 | attMode = bncAntex::ATT_EXTERNAL;
|
|---|
| 1584 | extYaw = corr->_satYawAngle;
|
|---|
| 1585 | }
|
|---|
| 1586 | else if (ac->attitudeSource == "Nominal") {
|
|---|
| 1587 | attMode = bncAntex::ATT_NOMINAL;
|
|---|
| 1588 | }
|
|---|
| 1589 | break;
|
|---|
| 1590 | }
|
|---|
| 1591 | }
|
|---|
| 1592 |
|
|---|
| 1593 | if (_antex->satCoMcorrection(corr->_prn, Mjd, xc.Rows(1,3), vv, dx,
|
|---|
| 1594 | attMode, extYaw) != success) {
|
|---|
| 1595 | // without the satellite antenna offset, the orbit cannot be
|
|---|
| 1596 | // converted between antenna phase center and center of mass
|
|---|
| 1597 | if (_antex->warnNoSatEntry(corr->_prn, epoTime)) {
|
|---|
| 1598 | emit newMessage("bncComb: no satellite antenna entry valid at " +
|
|---|
| 1599 | QByteArray(epoTime.datestr().c_str()) + " " + QByteArray(epoTime.timestr().c_str()) +
|
|---|
| 1600 | " for " + corr->_prn.mid(0,3).toLatin1() +
|
|---|
| 1601 | " in ANTEX file - ANTEX file outdated? Satellite not combined", true);
|
|---|
| 1602 | }
|
|---|
| 1603 | orbCorrections.pop_back();
|
|---|
| 1604 | clkCorrections.pop_back();
|
|---|
| 1605 | delete corr;
|
|---|
| 1606 | it.remove();
|
|---|
| 1607 | continue;
|
|---|
| 1608 | }
|
|---|
| 1609 | QString glonassYawLog = _antex->takeGlonassYawLog();
|
|---|
| 1610 | if (!glonassYawLog.isEmpty()) {
|
|---|
| 1611 | emit newMessage(("bncComb: " + glonassYawLog.trimmed()).toLatin1(), false);
|
|---|
| 1612 | }
|
|---|
| 1613 | QString gpsYawLog = _antex->takeGpsYawLog();
|
|---|
| 1614 | if (!gpsYawLog.isEmpty()) {
|
|---|
| 1615 | emit newMessage(("bncComb: " + gpsYawLog.trimmed()).toLatin1(), false);
|
|---|
| 1616 | }
|
|---|
| 1617 | QString onYawLog = _antex->takeOnYawLog();
|
|---|
| 1618 | if (!onYawLog.isEmpty()) {
|
|---|
| 1619 | emit newMessage(("bncComb: " + onYawLog.trimmed()).toLatin1(), false);
|
|---|
| 1620 | }
|
|---|
| 1621 | }
|
|---|
| 1622 | if (masterIsAPC) {
|
|---|
| 1623 | apc(1) = xc(1);
|
|---|
| 1624 | apc(2) = xc(2);
|
|---|
| 1625 | apc(3) = xc(3);
|
|---|
| 1626 | com(1) = xc(1)-dx(1);
|
|---|
| 1627 | com(2) = xc(2)-dx(2);
|
|---|
| 1628 | com(3) = xc(3)-dx(3);
|
|---|
| 1629 | }
|
|---|
| 1630 | else {
|
|---|
| 1631 | com(1) = xc(1);
|
|---|
| 1632 | com(2) = xc(2);
|
|---|
| 1633 | com(3) = xc(3);
|
|---|
| 1634 | apc(1) = xc(1)+dx(1);
|
|---|
| 1635 | apc(2) = xc(2)+dx(2);
|
|---|
| 1636 | apc(3) = xc(3)+dx(3);
|
|---|
| 1637 | }
|
|---|
| 1638 |
|
|---|
| 1639 | // The combined corrections passed on to the PPP (INTERNAL) always refer
|
|---|
| 1640 | // to the APC: orbits combined in the CoM frame are converted
|
|---|
| 1641 | if (!masterIsAPC && _antex) {
|
|---|
| 1642 | ColumnVector dRAO(3);
|
|---|
| 1643 | XYZ_to_RSW(xc.Rows(1,3), vv, dx, dRAO);
|
|---|
| 1644 | orbCorrections.back()._xr -= dRAO;
|
|---|
| 1645 | }
|
|---|
| 1646 |
|
|---|
| 1647 | outLines += corr->_prn.mid(0,3);
|
|---|
| 1648 | QString hlp = QString().asprintf(
|
|---|
| 1649 | " APC 3 %15.4f %15.4f %15.4f"
|
|---|
| 1650 | " Clk 1 %15.4f"
|
|---|
| 1651 | " Vel 3 %15.4f %15.4f %15.4f"
|
|---|
| 1652 | " CoM 3 %15.4f %15.4f %15.4f",
|
|---|
| 1653 | apc(1), apc(2), apc(3),
|
|---|
| 1654 | xc(4) * t_CST::c,
|
|---|
| 1655 | vv(1), vv(2), vv(3),
|
|---|
| 1656 | com(1), com(2), com(3));
|
|---|
| 1657 | outLines += hlp;
|
|---|
| 1658 | hlp.clear();
|
|---|
| 1659 |
|
|---|
| 1660 | // CODE BIASES
|
|---|
| 1661 | if (corr->_satCodeBias._bias.size()) {
|
|---|
| 1662 | t_satCodeBias satCodeBias(corr->_satCodeBias);
|
|---|
| 1663 | satCodeBias._staID = "INTERNAL";
|
|---|
| 1664 | satCodeBias._ssrIOD = -1; // combined, not any single provider's solution
|
|---|
| 1665 | satCodeBias._ssrProviderID = -1;
|
|---|
| 1666 | satCodeBiasList.push_back(satCodeBias);
|
|---|
| 1667 | hlp = QString().asprintf(" CodeBias %2lu", satCodeBias._bias.size());
|
|---|
| 1668 | outLines += hlp;
|
|---|
| 1669 | hlp.clear();
|
|---|
| 1670 | for (unsigned ii = 0; ii < satCodeBias._bias.size(); ii++) {
|
|---|
| 1671 | const t_frqCodeBias& frqCodeBias = satCodeBias._bias[ii];
|
|---|
| 1672 | if (!frqCodeBias._rnxType2ch.empty()) {
|
|---|
| 1673 | hlp = QString().asprintf(" %s%12.6f",
|
|---|
| 1674 | frqCodeBias._rnxType2ch.c_str(),
|
|---|
| 1675 | frqCodeBias._value);
|
|---|
| 1676 | outLines += hlp;
|
|---|
| 1677 | hlp.clear();
|
|---|
| 1678 | }
|
|---|
| 1679 | }
|
|---|
| 1680 | }
|
|---|
| 1681 | // PHASE BIASES
|
|---|
| 1682 | /* can be added as soon as yaw agles from the ACs have useful values
|
|---|
| 1683 | t_satPhaseBias satPhaseBias(corr->_satPhaseBias);
|
|---|
| 1684 | satPhaseBias._staID = "INTERNAL";
|
|---|
| 1685 | satPhaseBias._yaw = corr->_satYawAngle;
|
|---|
| 1686 | satPhaseBiasList.push_back(satPhaseBias);
|
|---|
| 1687 | hlp = QString().asprintf(" YawAngle %1.4f", satPhaseBias._yaw);
|
|---|
| 1688 | outLines += hlp;
|
|---|
| 1689 | hlp.clear();
|
|---|
| 1690 | hlp = QString().asprintf(" PhaseBias %2lu", satPhaseBias._bias.size());
|
|---|
| 1691 | outLines += hlp;
|
|---|
| 1692 | hlp.clear();
|
|---|
| 1693 | for (unsigned ii = 0; ii < satPhaseBias._bias.size(); ii++) {
|
|---|
| 1694 | const t_frqPhaseBias& frqPhaseBias = satPhaseBias._bias[ii];
|
|---|
| 1695 | if (!frqPhaseBias._rnxType2ch.empty()) {
|
|---|
| 1696 | hlp = QString().asprintf(" %s%10.6f%3d%3d%3d",
|
|---|
| 1697 | frqPhaseBias._rnxType2ch.c_str(),
|
|---|
| 1698 | frqPhaseBias._value,
|
|---|
| 1699 | frqPhaseBias._fixIndicator,
|
|---|
| 1700 | frqPhaseBias._fixWideLaneIndicator,
|
|---|
| 1701 | frqPhaseBias._jumpCounter);
|
|---|
| 1702 | outLines += hlp;
|
|---|
| 1703 | hlp.clear();
|
|---|
| 1704 | }
|
|---|
| 1705 | }*/
|
|---|
| 1706 | outLines += "\n";
|
|---|
| 1707 | delete corr;
|
|---|
| 1708 | it.remove();
|
|---|
| 1709 | }
|
|---|
| 1710 | outLines += "EOE\n"; // End Of Epoch flag
|
|---|
| 1711 | //cout << outLines.toStdString();
|
|---|
| 1712 |
|
|---|
| 1713 | vector<string> errmsg;
|
|---|
| 1714 | _rtnetDecoder->Decode(outLines.toLatin1().data(), outLines.length(), errmsg);
|
|---|
| 1715 |
|
|---|
| 1716 | // Send new Corrections to PPP etc.
|
|---|
| 1717 | // --------------------------------
|
|---|
| 1718 | if (orbCorrections.size() > 0 && clkCorrections.size() > 0) {
|
|---|
| 1719 | emit newOrbCorrections(orbCorrections);
|
|---|
| 1720 | emit newClkCorrections(clkCorrections);
|
|---|
| 1721 | }
|
|---|
| 1722 | if (satCodeBiasList.size()) {
|
|---|
| 1723 | emit newCodeBiases(satCodeBiasList);
|
|---|
| 1724 | }
|
|---|
| 1725 | }
|
|---|
| 1726 |
|
|---|
| 1727 | // Create First Design Matrix and Vector of Measurements
|
|---|
| 1728 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1729 | t_irc bncComb::createAmat(char sys, Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP, const ColumnVector& x0, const QMap<QString, cmbCorr*>& masterCorr) {
|
|---|
| 1730 |
|
|---|
| 1731 | unsigned nPar = _params[sys].size();
|
|---|
| 1732 | unsigned nObs = corrs(sys).size();
|
|---|
| 1733 |
|
|---|
| 1734 | if (nObs == 0) {
|
|---|
| 1735 | return failure;
|
|---|
| 1736 | }
|
|---|
| 1737 |
|
|---|
| 1738 | int maxSat = _cmbSysPrn[sys];
|
|---|
| 1739 |
|
|---|
| 1740 | // AC clocks not referred to the reference signals are excluded from the
|
|---|
| 1741 | // zero-sum conditions of the satellite offsets (the clock datum): those of
|
|---|
| 1742 | // ACs whose code biases are inconsistent with their clocks (see
|
|---|
| 1743 | // checkBiasConsistency) and those without the code biases of both
|
|---|
| 1744 | // reference signals. This applies as long as another AC provides referred
|
|---|
| 1745 | // corrections; the sum of the excluded offsets of an AC is constrained to
|
|---|
| 1746 | // zero instead.
|
|---|
| 1747 | QSet<QString> excludedOff; // "AC PRN" (full PRN)
|
|---|
| 1748 | QStringList excludedACs; // ACs with excluded offsets
|
|---|
| 1749 | if (_method == filter) {
|
|---|
| 1750 | bool referredAC = false;
|
|---|
| 1751 | for (int ii = 0; ii < corrs(sys).size(); ii++) {
|
|---|
| 1752 | const cmbCorr* corr = corrs(sys)[ii];
|
|---|
| 1753 | if (_biasInconsistent.contains(corr->_acName + sys) || !corr->_refBiasesOK) {
|
|---|
| 1754 | excludedOff.insert(corr->_acName + ' ' + corr->_prn);
|
|---|
| 1755 | if (!excludedACs.contains(corr->_acName)) {
|
|---|
| 1756 | excludedACs << corr->_acName;
|
|---|
| 1757 | }
|
|---|
| 1758 | }
|
|---|
| 1759 | else {
|
|---|
| 1760 | referredAC = true;
|
|---|
| 1761 | }
|
|---|
| 1762 | }
|
|---|
| 1763 | if (!referredAC) {
|
|---|
| 1764 | excludedOff.clear();
|
|---|
| 1765 | excludedACs.clear();
|
|---|
| 1766 | }
|
|---|
| 1767 | }
|
|---|
| 1768 |
|
|---|
| 1769 | const int nCon = (_method == filter) ? 1 + maxSat + excludedACs.size() : 0;
|
|---|
| 1770 |
|
|---|
| 1771 | AA.ReSize(nObs+nCon, nPar); AA = 0.0;
|
|---|
| 1772 | ll.ReSize(nObs+nCon); ll = 0.0;
|
|---|
| 1773 | PP.ReSize(nObs+nCon); PP = 1.0 / (sigObs * sigObs);
|
|---|
| 1774 |
|
|---|
| 1775 | int iObs = 0;
|
|---|
| 1776 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
|---|
| 1777 | while (itCorr.hasNext()) {
|
|---|
| 1778 | cmbCorr* corr = itCorr.next();
|
|---|
| 1779 | QString prn = corr->_prn;
|
|---|
| 1780 |
|
|---|
| 1781 | ++iObs;
|
|---|
| 1782 |
|
|---|
| 1783 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 1784 | cmbParam* pp = _params[sys][iPar-1];
|
|---|
| 1785 | AA(iObs, iPar) = pp->partial(sys, corr->_acName, prn);
|
|---|
| 1786 | }
|
|---|
| 1787 | // Consistency corrections to keep the combined clock consistent to masterOrbit
|
|---|
| 1788 | // ----------------------------------------------------------------------------
|
|---|
| 1789 | double dC_orb = DotProduct((corr->_satPos - masterCorr[prn]->_satPos), corr->_satPos);
|
|---|
| 1790 | dC_orb /= masterCorr[prn]->_satPos.NormFrobenius();
|
|---|
| 1791 | double dC_att = (corr->_satYawAngle - masterCorr[prn]->_satYawAngle) / (2 * M_PI);
|
|---|
| 1792 | dC_att *= corr->_lambdaIF;
|
|---|
| 1793 | double dC_apriori_corr = dC_orb;// + dC_att; can be added if useful values are provided by the ACs
|
|---|
| 1794 |
|
|---|
| 1795 | // Clock referred to the ionosphere-free combination of the reference
|
|---|
| 1796 | // signals: dt - (alpha b1 + beta b2) with biases in Bias-SINEX sign
|
|---|
| 1797 | // (subtracted from observations, Banville et al. 2020, Eq. 1). The code
|
|---|
| 1798 | // biases taken from the SSR streams have the opposite sign (added to
|
|---|
| 1799 | // observations), hence + _satCodeBiasIF.
|
|---|
| 1800 | ll(iObs) = ((corr->_clkCorr._dClk * t_CST::c) - dC_apriori_corr + corr->_satCodeBiasIF) - DotProduct(AA.Row(iObs), x0);
|
|---|
| 1801 |
|
|---|
| 1802 | PP(iObs, iObs) *= 1.0 / (corr->_weightFactor * corr->_weightFactor);
|
|---|
| 1803 | }
|
|---|
| 1804 |
|
|---|
| 1805 | // Regularization
|
|---|
| 1806 | // --------------
|
|---|
| 1807 | if (_method == filter) {
|
|---|
| 1808 | const double Ph = 1.e6;
|
|---|
| 1809 | PP(nObs+1) = Ph;
|
|---|
| 1810 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 1811 | cmbParam* pp = _params[sys][iPar-1];
|
|---|
| 1812 | if ( AA.Column(iPar).maximum_absolute_value() > 0.0 &&
|
|---|
| 1813 | pp->type == cmbParam::clkSat ) {
|
|---|
| 1814 | AA(nObs+1, iPar) = 1.0;
|
|---|
| 1815 | }
|
|---|
| 1816 | }
|
|---|
| 1817 | //if (sys == 'R') {
|
|---|
| 1818 | // return success;
|
|---|
| 1819 | // }
|
|---|
| 1820 | int iCond = 1;
|
|---|
| 1821 | QSet<int> offExcluded; // offsets excluded from the zero-sum condition of their satellite
|
|---|
| 1822 | QSet<QString> acsInDatum; // ACs with at least one offset in the zero-sum conditions
|
|---|
| 1823 | // GNSS
|
|---|
| 1824 | for (unsigned iGnss = 1; iGnss <= _cmbSysPrn[sys]; iGnss++) {
|
|---|
| 1825 | int flag = t_corrSSR::getSsrNavTypeFlag(sys, iGnss);
|
|---|
| 1826 | QString prn = QString("%1%2_%3").arg(sys).arg(iGnss, 2, 10, QChar('0')).arg(flag);
|
|---|
| 1827 | ++iCond;
|
|---|
| 1828 | PP(nObs+iCond) = Ph;
|
|---|
| 1829 | QList<int> offAll, offConsistent;
|
|---|
| 1830 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 1831 | cmbParam* pp = _params[sys][iPar-1];
|
|---|
| 1832 | if ( pp &&
|
|---|
| 1833 | AA.Column(iPar).maximum_absolute_value() > 0.0 &&
|
|---|
| 1834 | pp->type == cmbParam::offACSat &&
|
|---|
| 1835 | pp->prn == prn) {
|
|---|
| 1836 | offAll << iPar;
|
|---|
| 1837 | if (!excludedOff.contains(pp->AC + ' ' + pp->prn)) {
|
|---|
| 1838 | offConsistent << iPar;
|
|---|
| 1839 | }
|
|---|
| 1840 | }
|
|---|
| 1841 | }
|
|---|
| 1842 | // satellite observed by inconsistent ACs only: all its offsets are used
|
|---|
| 1843 | const QList<int>& offUsed = offConsistent.isEmpty() ? offAll : offConsistent;
|
|---|
| 1844 | for (int iPar : offAll) {
|
|---|
| 1845 | if (offUsed.contains(iPar)) {
|
|---|
| 1846 | AA(nObs+iCond, iPar) = 1.0;
|
|---|
| 1847 | acsInDatum.insert(_params[sys][iPar-1]->AC);
|
|---|
| 1848 | }
|
|---|
| 1849 | else {
|
|---|
| 1850 | offExcluded << iPar;
|
|---|
| 1851 | }
|
|---|
| 1852 | }
|
|---|
| 1853 | }
|
|---|
| 1854 | // ACs with all their offsets excluded from the zero-sum conditions above:
|
|---|
| 1855 | // the sum of their offsets is constrained to zero (otherwise not
|
|---|
| 1856 | // separable from the AC's epoch offset)
|
|---|
| 1857 | for (const QString& acName : excludedACs) {
|
|---|
| 1858 | ++iCond;
|
|---|
| 1859 | if (acsInDatum.contains(acName)) {
|
|---|
| 1860 | continue;
|
|---|
| 1861 | }
|
|---|
| 1862 | PP(nObs+iCond) = Ph;
|
|---|
| 1863 | for (int iPar : offExcluded) {
|
|---|
| 1864 | if (_params[sys][iPar-1]->AC == acName) {
|
|---|
| 1865 | AA(nObs+iCond, iPar) = 1.0;
|
|---|
| 1866 | }
|
|---|
| 1867 | }
|
|---|
| 1868 | }
|
|---|
| 1869 | }
|
|---|
| 1870 |
|
|---|
| 1871 | return success;
|
|---|
| 1872 | }
|
|---|
| 1873 |
|
|---|
| 1874 | // Process Epoch - Single-Epoch Method
|
|---|
| 1875 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1876 | t_irc bncComb::processEpoch_singleEpoch(bncTime epoTime, char sys, QTextStream& out,
|
|---|
| 1877 | QMap<QString, cmbCorr*>& masterCorr,
|
|---|
| 1878 | ColumnVector& dx) {
|
|---|
| 1879 |
|
|---|
| 1880 | // Check Satellite Positions for Outliers
|
|---|
| 1881 | // --------------------------------------
|
|---|
| 1882 | if (checkOrbits(epoTime, sys, out, masterCorr) != success) {
|
|---|
| 1883 | return failure;
|
|---|
| 1884 | }
|
|---|
| 1885 |
|
|---|
| 1886 | // Outlier Detection Loop
|
|---|
| 1887 | // ----------------------
|
|---|
| 1888 | while (_running) {
|
|---|
| 1889 | // Count Number of Observations per Satellite and per AC
|
|---|
| 1890 | // -----------------------------------------------------
|
|---|
| 1891 | QMap<QString, int> numObsPrn;
|
|---|
| 1892 | QMap<QString, int> numObsAC;
|
|---|
| 1893 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
|---|
| 1894 | while (itCorr.hasNext()) {
|
|---|
| 1895 | cmbCorr* corr = itCorr.next();
|
|---|
| 1896 | QString prn = corr->_prn;
|
|---|
| 1897 | QString AC = corr->_acName;
|
|---|
| 1898 | if (numObsPrn.find(prn) == numObsPrn.end()) {
|
|---|
| 1899 | numObsPrn[prn] = 1;
|
|---|
| 1900 | }
|
|---|
| 1901 | else {
|
|---|
| 1902 | numObsPrn[prn] += 1;
|
|---|
| 1903 | }
|
|---|
| 1904 | if (numObsAC.find(AC) == numObsAC.end()) {
|
|---|
| 1905 | numObsAC[AC] = 1;
|
|---|
| 1906 | }
|
|---|
| 1907 | else {
|
|---|
| 1908 | numObsAC[AC] += 1;
|
|---|
| 1909 | }
|
|---|
| 1910 | }
|
|---|
| 1911 |
|
|---|
| 1912 | // Clean-Up the Parameters
|
|---|
| 1913 | // -----------------------
|
|---|
| 1914 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 1915 | delete _params[sys][iPar-1];
|
|---|
| 1916 | }
|
|---|
| 1917 | _params[sys].clear();
|
|---|
| 1918 |
|
|---|
| 1919 | // Set new Parameters
|
|---|
| 1920 | // ------------------
|
|---|
| 1921 | int nextPar = 0;
|
|---|
| 1922 |
|
|---|
| 1923 | QMapIterator<QString, int> itAC(numObsAC);
|
|---|
| 1924 | while (itAC.hasNext()) {
|
|---|
| 1925 | itAC.next();
|
|---|
| 1926 | const QString& AC = itAC.key();
|
|---|
| 1927 | int numObs = itAC.value();
|
|---|
| 1928 | if (AC != _masterOrbitAC[sys] && numObs > 0) {
|
|---|
| 1929 | _params[sys].push_back(new cmbParam(cmbParam::offACgnss, ++nextPar, AC, ""));
|
|---|
| 1930 | }
|
|---|
| 1931 | }
|
|---|
| 1932 |
|
|---|
| 1933 | QMapIterator<QString, int> itPrn(numObsPrn);
|
|---|
| 1934 | while (itPrn.hasNext()) {
|
|---|
| 1935 | itPrn.next();
|
|---|
| 1936 | const QString& prn = itPrn.key();
|
|---|
| 1937 | int numObs = itPrn.value();
|
|---|
| 1938 | if (numObs > 0) {
|
|---|
| 1939 | _params[sys].push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
|
|---|
| 1940 | }
|
|---|
| 1941 | }
|
|---|
| 1942 |
|
|---|
| 1943 | int nPar = _params[sys].size();
|
|---|
| 1944 | ColumnVector x0(nPar);
|
|---|
| 1945 | x0 = 0.0;
|
|---|
| 1946 |
|
|---|
| 1947 | // Create First-Design Matrix
|
|---|
| 1948 | // --------------------------
|
|---|
| 1949 | Matrix AA;
|
|---|
| 1950 | ColumnVector ll;
|
|---|
| 1951 | DiagonalMatrix PP;
|
|---|
| 1952 | if (createAmat(sys, AA, ll, PP, x0, masterCorr) != success) {
|
|---|
| 1953 | return failure;
|
|---|
| 1954 | }
|
|---|
| 1955 |
|
|---|
| 1956 | ColumnVector vv;
|
|---|
| 1957 | try {
|
|---|
| 1958 | Matrix ATP = AA.t() * PP;
|
|---|
| 1959 | SymmetricMatrix NN; NN << ATP * AA;
|
|---|
| 1960 | ColumnVector bb = ATP * ll;
|
|---|
| 1961 | _QQ[sys] = NN.i();
|
|---|
| 1962 | dx = _QQ[sys] * bb;
|
|---|
| 1963 | vv = ll - AA * dx;
|
|---|
| 1964 | }
|
|---|
| 1965 | catch (Exception& exc) {
|
|---|
| 1966 | out << exc.what() << "\n";
|
|---|
| 1967 | return failure;
|
|---|
| 1968 | }
|
|---|
| 1969 |
|
|---|
| 1970 | int maxResIndex;
|
|---|
| 1971 | double maxRes = vv.maximum_absolute_value1(maxResIndex);
|
|---|
| 1972 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
|---|
| 1973 | out.setRealNumberPrecision(3);
|
|---|
| 1974 | out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str()
|
|---|
| 1975 | << " Maximum Residuum " << maxRes << ' '
|
|---|
| 1976 | << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
|
|---|
| 1977 |
|
|---|
| 1978 | if (maxRes > _MAX_RES) {
|
|---|
| 1979 | out << " Outlier" << "\n";
|
|---|
| 1980 | delete corrs(sys)[maxResIndex-1];
|
|---|
| 1981 | corrs(sys).remove(maxResIndex-1);
|
|---|
| 1982 | }
|
|---|
| 1983 | else {
|
|---|
| 1984 | out << " OK" << "\n";
|
|---|
| 1985 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
|---|
| 1986 | out.setRealNumberPrecision(3);
|
|---|
| 1987 | for (int ii = 0; ii < vv.Nrows(); ii++) {
|
|---|
| 1988 | const cmbCorr* corr = corrs(sys)[ii];
|
|---|
| 1989 | out << epoTime.datestr().c_str() << ' '
|
|---|
| 1990 | << epoTime.timestr().c_str() << " "
|
|---|
| 1991 | << corr->_acName << ' ' << corr->_prn.mid(0,3);
|
|---|
| 1992 | out.setFieldWidth(6);
|
|---|
| 1993 | out << " res = " << vv[ii] << "\n";
|
|---|
| 1994 | out.setFieldWidth(0);
|
|---|
| 1995 | }
|
|---|
| 1996 | return success;
|
|---|
| 1997 | }
|
|---|
| 1998 |
|
|---|
| 1999 | }
|
|---|
| 2000 |
|
|---|
| 2001 | return failure;
|
|---|
| 2002 | }
|
|---|
| 2003 |
|
|---|
| 2004 | // Check Satellite Positions for Outliers
|
|---|
| 2005 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 2006 | t_irc bncComb::checkOrbits(bncTime epoTime, char sys, QTextStream& out, QMap<QString, cmbCorr*>& masterCorr) {
|
|---|
| 2007 |
|
|---|
| 2008 | // Switch to last ephemeris (if possible)
|
|---|
| 2009 | // --------------------------------------
|
|---|
| 2010 | QMutableVectorIterator<cmbCorr*> im(corrs(sys));
|
|---|
| 2011 | while (im.hasNext()) {
|
|---|
| 2012 | cmbCorr* corr = im.next();
|
|---|
| 2013 | QString prn = corr->_prn;
|
|---|
| 2014 |
|
|---|
| 2015 | t_eph* ephLast = _ephUser.ephLast(prn);
|
|---|
| 2016 | t_eph* ephPrev = _ephUser.ephPrev(prn);
|
|---|
| 2017 |
|
|---|
| 2018 | if (ephLast == 0) {
|
|---|
| 2019 | out << "checkOrbit: missing eph (not found) " << corr->_prn.mid(0,3) << "\n";
|
|---|
| 2020 | delete corr;
|
|---|
| 2021 | im.remove();
|
|---|
| 2022 | }
|
|---|
| 2023 | else if (corr->_eph == 0) {
|
|---|
| 2024 | out << "checkOrbit: missing eph (zero) " << corr->_prn.mid(0,3) << "\n";
|
|---|
| 2025 | delete corr;
|
|---|
| 2026 | im.remove();
|
|---|
| 2027 | }
|
|---|
| 2028 | // a newer ephemeris may have arrived (or an older one been re-classified)
|
|---|
| 2029 | // since the correction was accepted - never switch to an unusable one
|
|---|
| 2030 | else if (ephLast->checkState() == t_eph::bad ||
|
|---|
| 2031 | ephLast->checkState() == t_eph::outdated ||
|
|---|
| 2032 | ephLast->checkState() == t_eph::unhealthy) {
|
|---|
| 2033 | out << "checkOrbit: last eph not ok (" << ephLast->checkStateToString() << ") " << corr->_prn.mid(0,3) << "\n";
|
|---|
| 2034 | delete corr;
|
|---|
| 2035 | im.remove();
|
|---|
| 2036 | }
|
|---|
| 2037 | else {
|
|---|
| 2038 | if ( corr->_eph == ephLast ||
|
|---|
| 2039 | corr->_eph == ephPrev ) {
|
|---|
| 2040 | switchToLastEph(ephLast, corr);
|
|---|
| 2041 |
|
|---|
| 2042 | ColumnVector xc(6);
|
|---|
| 2043 | ColumnVector vv(3);
|
|---|
| 2044 | if (corr->_eph->getCrd(corr->_time, xc, vv, false) != success) {
|
|---|
| 2045 | delete corr;
|
|---|
| 2046 | im.remove();
|
|---|
| 2047 | }
|
|---|
| 2048 | else {
|
|---|
| 2049 | corr->_satPos = xc.Rows(1,3);
|
|---|
| 2050 | }
|
|---|
| 2051 | }
|
|---|
| 2052 | else {
|
|---|
| 2053 | out << "checkOrbit: missing eph (deleted) " << corr->_prn.mid(0,3) << "\n";
|
|---|
| 2054 | delete corr;
|
|---|
| 2055 | im.remove();
|
|---|
| 2056 | }
|
|---|
| 2057 | }
|
|---|
| 2058 | }
|
|---|
| 2059 |
|
|---|
| 2060 | QSet<QString> singleACSats; // satellites skipped: corrections from < 2 ACs
|
|---|
| 2061 | QSet<QString> singleACNames;
|
|---|
| 2062 |
|
|---|
| 2063 | while (_running) {
|
|---|
| 2064 |
|
|---|
| 2065 | // Compute Mean Corrections for all Satellites
|
|---|
| 2066 | // -------------------------------------------
|
|---|
| 2067 | QMap<QString, int> numCorr;
|
|---|
| 2068 | QMap<QString, ColumnVector> meanRao;
|
|---|
| 2069 | QVectorIterator<cmbCorr*> it(corrs(sys));
|
|---|
| 2070 | while (it.hasNext()) {
|
|---|
| 2071 | cmbCorr* corr = it.next();
|
|---|
| 2072 | QString prn = corr->_prn;
|
|---|
| 2073 |
|
|---|
| 2074 | if (meanRao.find(prn) == meanRao.end()) {
|
|---|
| 2075 | meanRao[prn].ReSize(4);
|
|---|
| 2076 | meanRao[prn].Rows(1,3) = corr->_orbCorr._xr;
|
|---|
| 2077 | meanRao[prn](4) = 1;
|
|---|
| 2078 | }
|
|---|
| 2079 | else {
|
|---|
| 2080 | meanRao[prn].Rows(1,3) += corr->_orbCorr._xr;
|
|---|
| 2081 | meanRao[prn](4) += 1;
|
|---|
| 2082 | }
|
|---|
| 2083 | if (numCorr.find(prn) == numCorr.end()) {
|
|---|
| 2084 | numCorr[prn] = 1;
|
|---|
| 2085 | }
|
|---|
| 2086 | else {
|
|---|
| 2087 | numCorr[prn] += 1;
|
|---|
| 2088 | }
|
|---|
| 2089 | }
|
|---|
| 2090 |
|
|---|
| 2091 | // Compute Differences wrt. Mean, find Maximum
|
|---|
| 2092 | // -------------------------------------------
|
|---|
| 2093 | QMap<QString, cmbCorr*> maxDiff;
|
|---|
| 2094 | it.toFront();
|
|---|
| 2095 | while (it.hasNext()) {
|
|---|
| 2096 | cmbCorr* corr = it.next();
|
|---|
| 2097 | QString prn = corr->_prn;
|
|---|
| 2098 | if (meanRao[prn](4) != 0) {
|
|---|
| 2099 | meanRao[prn] /= meanRao[prn](4);
|
|---|
| 2100 | meanRao[prn](4) = 0;
|
|---|
| 2101 | }
|
|---|
| 2102 | corr->_diffRao2Mean = corr->_orbCorr._xr - meanRao[prn].Rows(1,3);
|
|---|
| 2103 |
|
|---|
| 2104 | if (maxDiff.find(prn) == maxDiff.end()) {
|
|---|
| 2105 | maxDiff[prn] = corr;
|
|---|
| 2106 | }
|
|---|
| 2107 | else {
|
|---|
| 2108 | double normMax = maxDiff[prn]->_diffRao2Mean.NormFrobenius();
|
|---|
| 2109 | double norm = corr->_diffRao2Mean.NormFrobenius();
|
|---|
| 2110 | if (norm > normMax) {
|
|---|
| 2111 | maxDiff[prn] = corr;
|
|---|
| 2112 | }
|
|---|
| 2113 | }
|
|---|
| 2114 | }
|
|---|
| 2115 |
|
|---|
| 2116 | if (_ACs.size() == 1) {
|
|---|
| 2117 | QVectorIterator<cmbCorr*> it(corrs(sys));
|
|---|
| 2118 | while (it.hasNext()) {
|
|---|
| 2119 | cmbCorr* corr = it.next();
|
|---|
| 2120 | QString prn = corr->_prn;
|
|---|
| 2121 | if (corr->_acName == _masterOrbitAC[sys] && masterCorr.find(prn) == masterCorr.end()) {
|
|---|
| 2122 | masterCorr[prn] = new cmbCorr(*corr);
|
|---|
| 2123 | }
|
|---|
| 2124 | }
|
|---|
| 2125 | break;
|
|---|
| 2126 | }
|
|---|
| 2127 |
|
|---|
| 2128 | // Remove Outliers
|
|---|
| 2129 | // ---------------
|
|---|
| 2130 | bool removed = false;
|
|---|
| 2131 | QMutableVectorIterator<cmbCorr*> im(corrs(sys));
|
|---|
| 2132 | while (im.hasNext()) {
|
|---|
| 2133 | cmbCorr* corr = im.next();
|
|---|
| 2134 | QString prn = corr->_prn;
|
|---|
| 2135 | if (numCorr[prn] < 2) {
|
|---|
| 2136 | singleACSats.insert(prn.mid(0,3));
|
|---|
| 2137 | singleACNames.insert(corr->_acName);
|
|---|
| 2138 | delete corr;
|
|---|
| 2139 | im.remove();
|
|---|
| 2140 | }
|
|---|
| 2141 | else if (corr == maxDiff[prn]) {
|
|---|
| 2142 | double norm = corr->_diffRao2Mean.NormFrobenius();
|
|---|
| 2143 | if (norm > _MAX_DISPLACEMENT) {
|
|---|
| 2144 | out << epoTime.datestr().c_str() << " "
|
|---|
| 2145 | << epoTime.timestr().c_str() << " "
|
|---|
| 2146 | << "Orbit Outlier: "
|
|---|
| 2147 | << corr->_acName.toLatin1().data() << " "
|
|---|
| 2148 | << prn.mid(0,3).toLatin1().data() << " "
|
|---|
| 2149 | << corr->_iod << " "
|
|---|
| 2150 | << norm << "\n";
|
|---|
| 2151 | delete corr;
|
|---|
| 2152 | im.remove();
|
|---|
| 2153 | removed = true;
|
|---|
| 2154 | }
|
|---|
| 2155 | }
|
|---|
| 2156 | }
|
|---|
| 2157 | // Set master orbit
|
|---|
| 2158 | // -----------------------------------------
|
|---|
| 2159 | if (!removed) {
|
|---|
| 2160 | QVectorIterator<cmbCorr*> it(corrs(sys));
|
|---|
| 2161 | while (it.hasNext()) {
|
|---|
| 2162 | cmbCorr* corr = it.next();
|
|---|
| 2163 | QString prn = corr->_prn;
|
|---|
| 2164 | if (corr->_acName == _masterOrbitAC[sys] && masterCorr.find(prn) == masterCorr.end()) {
|
|---|
| 2165 | masterCorr[prn] = new cmbCorr(*corr);
|
|---|
| 2166 | }
|
|---|
| 2167 | }
|
|---|
| 2168 | // Remove satellites that are not in masterOrbit
|
|---|
| 2169 | // and compute differences wrt. masterOrbit
|
|---|
| 2170 | // ----------------------------------------------
|
|---|
| 2171 | QMutableVectorIterator<cmbCorr*> im(corrs(sys));
|
|---|
| 2172 | while (im.hasNext()) {
|
|---|
| 2173 | cmbCorr* corr = im.next();
|
|---|
| 2174 | QString prn = corr->_prn;
|
|---|
| 2175 | if (masterCorr.find(prn) == masterCorr.end()) {
|
|---|
| 2176 | delete corr;
|
|---|
| 2177 | im.remove();
|
|---|
| 2178 | }
|
|---|
| 2179 | }
|
|---|
| 2180 | break;
|
|---|
| 2181 | }
|
|---|
| 2182 | }
|
|---|
| 2183 |
|
|---|
| 2184 |
|
|---|
| 2185 | // Satellites with corrections from fewer than 2 ACs cannot be checked for
|
|---|
| 2186 | // orbit outliers and are skipped (e.g. if an AC is missing): log it, in
|
|---|
| 2187 | // the combination log every epoch, in the BNC log at most once per hour
|
|---|
| 2188 | // -------------------------------------------------------------------------
|
|---|
| 2189 | if (!singleACSats.isEmpty()) {
|
|---|
| 2190 | QStringList sats = singleACSats.values(); sats.sort();
|
|---|
| 2191 | QStringList acs = singleACNames.values(); acs.sort();
|
|---|
| 2192 | QString msg = QString("%1 satellite(s) skipped, corrections from fewer than 2 ACs (only %2): %3")
|
|---|
| 2193 | .arg(sats.size()).arg(acs.join(",")).arg(sats.join(" "));
|
|---|
| 2194 | out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str() << " " << msg << "\n";
|
|---|
| 2195 | bncTime& warned = _singleACWarned[sys];
|
|---|
| 2196 | if (!warned.valid() || epoTime - warned >= 3600.0) {
|
|---|
| 2197 | warned = epoTime;
|
|---|
| 2198 | emit newMessage("bncComb: " + QByteArray(1, sys) + " " + msg.toLatin1(), false);
|
|---|
| 2199 | }
|
|---|
| 2200 | }
|
|---|
| 2201 | return success;
|
|---|
| 2202 | }
|
|---|
| 2203 |
|
|---|
| 2204 | //
|
|---|
| 2205 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 2206 | void bncComb::slotProviderIDChanged(QString mountPoint) {
|
|---|
| 2207 | QMutexLocker locker(&_mutex);
|
|---|
| 2208 |
|
|---|
| 2209 | QTextStream out(&_log, QIODevice::WriteOnly);
|
|---|
| 2210 |
|
|---|
| 2211 | // Find the AC Name
|
|---|
| 2212 | // ----------------
|
|---|
| 2213 | QString acName;
|
|---|
| 2214 | QListIterator<cmbAC*> icAC(_ACs);
|
|---|
| 2215 | while (icAC.hasNext()) {
|
|---|
| 2216 | cmbAC *AC = icAC.next();
|
|---|
| 2217 | if (AC->mountPoint == mountPoint) {
|
|---|
| 2218 | acName = AC->name;
|
|---|
| 2219 | out << "SSR Provider or Service changed: AC " << AC->name.toLatin1().data() << " "
|
|---|
| 2220 | << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
|
|---|
| 2221 | << "\n";
|
|---|
| 2222 | break;
|
|---|
| 2223 | }
|
|---|
| 2224 | }
|
|---|
| 2225 | if (acName.isEmpty()) {
|
|---|
| 2226 | return;
|
|---|
| 2227 | }
|
|---|
| 2228 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
|---|
| 2229 | while (itSys.hasNext()) {
|
|---|
| 2230 | itSys.next();
|
|---|
| 2231 | char sys = itSys.key();
|
|---|
| 2232 | // Remove all corrections of the corresponding AC
|
|---|
| 2233 | // ----------------------------------------------
|
|---|
| 2234 | QVector<cmbCorr*> &corrVec = _buffer[sys].corrs;
|
|---|
| 2235 | QMutableVectorIterator<cmbCorr*> it(corrVec);
|
|---|
| 2236 | while (it.hasNext()) {
|
|---|
| 2237 | cmbCorr *corr = it.next();
|
|---|
| 2238 | if (acName == corr->_acName) {
|
|---|
| 2239 | delete corr;
|
|---|
| 2240 | it.remove();
|
|---|
| 2241 | }
|
|---|
| 2242 | }
|
|---|
| 2243 | // Reset Satellite Offsets
|
|---|
| 2244 | // -----------------------
|
|---|
| 2245 | if (_method == filter) {
|
|---|
| 2246 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
|---|
| 2247 | cmbParam *pp = _params[sys][iPar - 1];
|
|---|
| 2248 | if (pp->AC == acName && pp->type == cmbParam::offACSat) {
|
|---|
| 2249 | pp->xx = 0.0;
|
|---|
| 2250 | _QQ[sys].Row(iPar) = 0.0;
|
|---|
| 2251 | _QQ[sys].Column(iPar) = 0.0;
|
|---|
| 2252 | _QQ[sys](iPar, iPar) = pp->sig0 * pp->sig0;
|
|---|
| 2253 | }
|
|---|
| 2254 | }
|
|---|
| 2255 | }
|
|---|
| 2256 | }
|
|---|
| 2257 | }
|
|---|
| 2258 |
|
|---|
| 2259 | //
|
|---|
| 2260 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 2261 | bool bncComb::excludeSat(const t_prn& prn, const QStringList excludeSats) const {
|
|---|
| 2262 | QStringListIterator it(excludeSats);
|
|---|
| 2263 | while (it.hasNext()) {
|
|---|
| 2264 | string prnStr = it.next().toLatin1().data();
|
|---|
| 2265 | if (prnStr == prn.toString() || // prn
|
|---|
| 2266 | prnStr == prn.toString().substr(0,1)) { // sys
|
|---|
| 2267 | return true;
|
|---|
| 2268 | }
|
|---|
| 2269 | }
|
|---|
| 2270 | return false;
|
|---|
| 2271 | }
|
|---|