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