source: ntrip/trunk/BNC/src/ssrQc.cpp@ 11212

Last change on this file since 11212 was 11212, checked in by stuerze, 2 days ago

SSR QC and clock combination improved

File size: 81.5 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters.
3//
4// Copyright (C) 2007
5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
7// Czech Technical University Prague, Department of Geodesy
8// http://www.fsv.cvut.cz
9//
10// Email: euref-ip@bkg.bund.de
11//
12// This program is free software; you can redistribute it and/or
13// modify it under the terms of the GNU General Public License
14// as published by the Free Software Foundation, version 2.
15//
16// This program is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program; if not, write to the Free Software
23// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
25/* -------------------------------------------------------------------------
26 * BKG NTRIP Client
27 * -------------------------------------------------------------------------
28 *
29 * Class: t_ssrQc
30 *
31 * Purpose: Quality control of decoded SSR streams
32 *
33 * Created: 05-Oct-2026
34 *
35 * Changes:
36 *
37 * -----------------------------------------------------------------------*/
38
39#include <algorithm>
40#include <cmath>
41#include <iomanip>
42
43#include "ssrQc.h"
44#include "ssrRefSig.h"
45#include "combination/bncbiassnx.h"
46#include "bnccore.h"
47#include "bncutils.h"
48#include "bncconst.h"
49#include "bncsettings.h"
50#include "combination/bnccomb.h"
51#include "bncantex.h"
52
53using namespace std;
54
55namespace {
56 const double MAX_CLK_JUMP = 0.5; // [m] clock change beyond its rate between consecutive epochs
57 const double EPH_WARMUP = 120.0; // [s] no ephemeris checks at the start
58 const double EPH_EARLY_MAX = 300.0; // [s] IOD received this much later still counted as early
59 const double EPH_IOD_REUSE = 21600.0; // [s] an outdated data set this far from the epoch: IOD reused
60 const unsigned EPH_KEPT = 30; // data sets kept per satellite
61 const double CMP_SAMPL = 30.0; // [s] sampling of the stream comparison
62 const double CMP_DELAY = 60.0; // [s] epochs compared when data this much newer arrived
63 const double HIST_LENGTH = 300.0; // [s] corrections kept for the comparison
64 const double DEV_MIN = 0.05; // [m] deviating satellites: RMS above max(DEV_MIN,
65 const double DEV_FACTOR = 3.0; // DEV_FACTOR x median RMS of the system)
66 const double ATT_ONSET = 20.0 * M_PI / 180.0; // [rad] change of the yaw difference starting a turn
67 const double ATT_STABLE = 2.0 * M_PI / 180.0; // [rad] yaw difference stable again ...
68 const double ATT_STABLE_T = 600.0; // [s] ... for this time: end of the turn
69 const double ATT_REF_FROM = 900.0; // [s] reference before the turn: samples from 15 min
70 const double ATT_REF_TO = 300.0; // to 5 min before the current epoch
71 const double ATT_MAX_GAP = 600.0; // [s] longer gaps interrupt a turn
72 const double ATT_MAX_TURN = 10800.0; // [s] a turn is closed after 3 h at the latest
73 const double ATT_MIN_PRED = 0.03; // [m] smaller predicted clock changes are not assessed
74 const double VTEC_CMP_SAMPL = 300.0; // [s] sampling of the VTEC comparison
75 const double VTEC_CMP_DELAY = 120.0; // [s] VTEC epochs compared when data this much newer arrived
76 const double VTEC_HIST = 3600.0; // [s] VTEC models kept for the comparison
77 const double VTEC_GRID_LAT = 10.0; // [deg] grid of the VTEC evaluation, latitudes -80 ... 80
78 const double VTEC_GRID_LON = 15.0; // [deg]
79 const double MW_SAMPL = 300.0; // [s] sampling of the Melbourne-Wuebbena check
80 const double MW_MAX_AGE = 900.0; // [s] phase biases older than this are not used
81 const int MW_MIN_SAT = 4; // satellites needed for the common offset
82 const double MW_OK = 0.10; // [cycles] RMS of the fractional parts: consistent below,
83 const double MW_BAD = 0.15; // not consistent above (uniform: 0.29)
84
85 double tKey(const bncTime& tt) {
86 return tt.gpsw() * 604800.0 + tt.gpssec();
87 }
88 const char* TYPE_NAME[] = {"ORBIT", "CLOCK", "CODE_BIAS", "PHASE_BIAS", "VTEC"};
89
90 double median(QVector<double> vv) {
91 if (vv.isEmpty()) {
92 return 0.0;
93 }
94 std::sort(vv.begin(), vv.end());
95 int nn = vv.size();
96 return (nn % 2) ? vv[nn/2] : 0.5 * (vv[nn/2-1] + vv[nn/2]);
97 }
98
99 bncTime currentTime() {
100 int week = 0;
101 double sec = 0.0;
102 currentGPSWeeks(week, sec);
103 return bncTime(week, sec);
104 }
105
106 // satellite list "G01 G05(12)", counts shown if not all epochs concerned
107 QString satList(const QMap<QString, unsigned>& sats, unsigned maxNum = 20) {
108 QString str;
109 unsigned num = 0;
110 QMapIterator<QString, unsigned> it(sats);
111 while (it.hasNext()) {
112 it.next();
113 if (++num > maxNum) {
114 str += QString(" ... (%1 satellites)").arg(sats.size());
115 break;
116 }
117 str += " " + it.key();
118 if (it.value() > 0) {
119 str += QString("(%1)").arg(it.value());
120 }
121 }
122 return str.isEmpty() ? " -" : str;
123 }
124}
125
126// Constructor
127////////////////////////////////////////////////////////////////////////////
128t_ssrQc::t_ssrQc(const QString& dirName, double interval, const QStringList& streams,
129 const QString& reference) : _ephUser(true, EPH_KEPT) {
130 _ephUser.useEphMounts("SSR QC");
131 _dirName = dirName;
132 _reference = reference.isEmpty() ? QString("CONSENSUS") : reference;
133 _interval = interval > 0.0 ? interval : 3600.0;
134 // "ALL" or a list of streams; streams with a leading '!' are excluded
135 // (from the reports and from the consensus)
136 bool all = false;
137 for (const QString& sta : streams) {
138 if (sta.startsWith('!')) {
139 _excluded.insert(sta.mid(1));
140 }
141 else if (sta.toUpper() == "ALL") {
142 all = true;
143 }
144 else {
145 _streams.insert(sta);
146 }
147 }
148 if (all) {
149 _streams.clear();
150 }
151
152 BNC_CORE->connectMessages(this, "ssrqc");
153 BNC_CORE->connectLogRecords(this, "ssrqc");
154 for (const QString& err : t_ssrRefSig::init()) {
155 emit newLogRecord(t_logRecord::message(t_logRecord::warning, ("SSR QC: " + err).toLatin1()), true);
156 }
157 // reference code biases from a Bias SINEX file (optional)
158 _bsxRef = 0;
159 bncSettings settings;
160 QString bsxFile = settings.value("ssrQcBiasFile").toString();
161 expandEnvVar(bsxFile);
162 if (!bsxFile.isEmpty()) {
163 _bsxRef = new bncBiasSnx(true);
164 if (_bsxRef->readFile(bsxFile) == success) {
165 _bsxName = QFileInfo(bsxFile).fileName();
166 }
167 else {
168 emit newLogRecord(t_logRecord::message(t_logRecord::warning, ("SSR QC: wrong Bias SINEX file " + bsxFile).toLatin1()), true);
169 delete _bsxRef;
170 _bsxRef = 0;
171 }
172 }
173 _antex = 0;
174 QString antexFile = settings.value("ssrQcAntexFile").toString();
175 expandEnvVar(antexFile);
176 if (!antexFile.isEmpty()) {
177 _antex = new bncAntex();
178 if (_antex->readFile(antexFile) != success || _antex->numSatPrns() == 0) {
179 emit newLogRecord(t_logRecord::message(t_logRecord::warning, ("SSR QC: wrong ANTEX file " + antexFile + " - no attitude check").toLatin1()), true);
180 delete _antex;
181 _antex = 0;
182 }
183 }
184 connect(BNC_CORE, SIGNAL(newOrbCorrections(QList<t_orbCorr>)),
185 this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)), Qt::DirectConnection);
186 connect(BNC_CORE, SIGNAL(newClkCorrections(QList<t_clkCorr>)),
187 this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)), Qt::DirectConnection);
188 connect(BNC_CORE, SIGNAL(newCodeBiases(QList<t_satCodeBias>)),
189 this, SLOT(slotNewCodeBiases(QList<t_satCodeBias>)), Qt::DirectConnection);
190 connect(BNC_CORE, SIGNAL(newPhaseBiases(QList<t_satPhaseBias>)),
191 this, SLOT(slotNewPhaseBiases(QList<t_satPhaseBias>)), Qt::DirectConnection);
192 connect(BNC_CORE, SIGNAL(newTec(t_vTec)),
193 this, SLOT(slotNewTec(t_vTec)), Qt::DirectConnection);
194 // combined corrections (stream INTERNAL)
195 if (bncComb::exists()) {
196 connect(BNC_CMB, SIGNAL(newOrbCorrections(QList<t_orbCorr>)),
197 this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)), Qt::DirectConnection);
198 connect(BNC_CMB, SIGNAL(newClkCorrections(QList<t_clkCorr>)),
199 this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)), Qt::DirectConnection);
200 }
201}
202
203// Stream selected for the QC
204////////////////////////////////////////////////////////////////////////////
205bool t_ssrQc::selected(const string& staID) const {
206 QString sta = QString::fromStdString(staID);
207 return !_excluded.contains(sta) && (_streams.isEmpty() || _streams.contains(sta));
208}
209
210// Analysis center of a stream: the 3 characters of the AC in mountpoints
211// like SSRA00CNE1 or OSBC00WHU1, otherwise the stream name itself
212////////////////////////////////////////////////////////////////////////////
213QString t_ssrQc::acOf(const QString& staID) {
214 static const QRegularExpression re("^(?:SSR[AC]|OSB[AC]|IONO)[0-9]{2}([A-Z0-9]{3})[0-9]$");
215 QRegularExpressionMatch mm = re.match(staID);
216 return mm.hasMatch() ? mm.captured(1) : staID;
217}
218
219// Solution of an AC: AC and the two digits of the mountpoint, e.g. GFZ00 for
220// SSRA00GFZ0/SSRC00GFZ1 and GFZ01 for SSRA01GFZ0; the streams of a solution
221// (formats, APC/CoM) have one vote in the consensus
222////////////////////////////////////////////////////////////////////////////
223QString t_ssrQc::solOf(const QString& staID) {
224 static const QRegularExpression re("^(?:SSR[AC]|OSB[AC]|IONO)([0-9]{2})([A-Z0-9]{3})[0-9]$");
225 QRegularExpressionMatch mm = re.match(staID);
226 return mm.hasMatch() ? mm.captured(2) + mm.captured(1) : staID;
227}
228
229// AC of a solution (GFZ01 -> GFZ)
230////////////////////////////////////////////////////////////////////////////
231QString t_ssrQc::acOfSol(const QString& sol) {
232 static const QRegularExpression re("^([A-Z0-9]{3})[0-9]{2}$");
233 QRegularExpressionMatch mm = re.match(sol);
234 return mm.hasMatch() ? mm.captured(1) : sol;
235}
236
237// Stream part of the consensus: not excluded, and not a combination product
238// (INTERNAL, IGS combinations), as these are derived from the other streams
239////////////////////////////////////////////////////////////////////////////
240bool t_ssrQc::votes(const QString& staID) const {
241 return !_excluded.contains(staID) && staID != "INTERNAL" && acOf(staID) != "IGS";
242}
243
244// Daily QC file of a stream: <staID>_S_<YYYYDDD>0000_01D_QC.txt
245////////////////////////////////////////////////////////////////////////////
246ofstream& t_ssrQc::streamOut(const QString& staID, const bncTime& time) {
247 unsigned year, month, day;
248 time.civil_date(year, month, day);
249 QDate date(year, month, day);
250 QString name = QDir(_dirName).filePath(QString("%1_S_%2%3%4_01D_QC.txt").arg(staID)
251 .arg(year).arg(date.dayOfYear(), 3, 10, QChar('0')).arg("0000"));
252 if (_outNames.value(staID) != name) {
253 delete _outs.value(staID, 0);
254 bool exists = QFile::exists(name);
255 ofstream* out = new ofstream(name.toLocal8Bit().data(), ios_base::out | ios_base::app);
256 if (!exists) {
257 *out << "SSR QC of stream " << staID.toStdString() << ", report interval " << _interval << " s" << endl
258 << "Checks: epochs and update intervals, gaps (interval > 2 x max(declared, median)), latency,"
259 << " completeness w.r.t. healthy broadcast ephemerides," << endl
260 << "IOD matching, code and phase bias signals, phase bias indicators, Melbourne-Wuebbena consistency"
261 << " with the other ACs, yaw angle, code biases of the reference signals, clock jumps > "
262 << MAX_CLK_JUMP << " m, largest orbit corrections, VTEC models (system V)" << endl
263 << "Reference signals of the clocks: " << t_ssrRefSig::currentString().toStdString() << endl;
264 }
265 _outs[staID] = out;
266 _outNames[staID] = name;
267 }
268 return *_outs[staID];
269}
270
271// Destructor
272////////////////////////////////////////////////////////////////////////////
273t_ssrQc::~t_ssrQc() {
274 QMutexLocker locker(&_mutex);
275 writeReport(true);
276 for (ofstream* out : _outs) {
277 delete out;
278 }
279 delete _bsxRef;
280 delete _antex;
281}
282
283// Key of the epoch statistics
284////////////////////////////////////////////////////////////////////////////
285QString t_ssrQc::key(const string& staID, char sys, e_type type) {
286 return QString("%1 %2 %3").arg(staID.c_str()).arg(sys).arg(int(type));
287}
288
289// Reference signals of the clocks (as in the combination, option ssrRefSignals)
290////////////////////////////////////////////////////////////////////////////
291bool t_ssrQc::refSignals(char sys, QString& sig1, QString& sig2,
292 t_frequency::type& frq1, t_frequency::type& frq2) {
293 t_ssrRefSig::t_pair pair;
294 if (!t_ssrRefSig::get(sys, pair)) {
295 return false;
296 }
297 sig1 = QString::fromStdString(pair.sig1());
298 sig2 = QString::fromStdString(pair.sig2());
299 frq1 = pair.frq1;
300 frq2 = pair.frq2;
301 return true;
302}
303
304// Start a new report interval if the epoch is beyond the current one
305////////////////////////////////////////////////////////////////////////////
306void t_ssrQc::checkInterval(const bncTime& time) {
307 if (!_intervalStart.valid()) {
308 double sec = floor(time.gpssec() / _interval) * _interval;
309 _intervalStart = bncTime(time.gpsw(), sec);
310 }
311 // stream comparison of the epochs already complete for all streams
312 if (!_nextCmpEpoch.valid()) {
313 double sec = ceil(time.gpssec() / CMP_SAMPL) * CMP_SAMPL;
314 _nextCmpEpoch = bncTime(time.gpsw(), sec);
315 }
316 while (time - _nextCmpEpoch >= CMP_DELAY) {
317 compareEpoch(_nextCmpEpoch);
318 _nextCmpEpoch = _nextCmpEpoch + CMP_SAMPL;
319 }
320 // Melbourne-Wuebbena check of the phase biases
321 if (!_pbLast.isEmpty()) {
322 if (!_nextMwCmp.valid()) {
323 double sec = ceil(time.gpssec() / MW_SAMPL) * MW_SAMPL;
324 _nextMwCmp = bncTime(time.gpsw(), sec);
325 }
326 while (time - _nextMwCmp >= CMP_DELAY) {
327 compareMw(_nextMwCmp);
328 _nextMwCmp = _nextMwCmp + MW_SAMPL;
329 }
330 }
331 // VTEC comparison
332 if (!_vtecHist.isEmpty()) {
333 if (!_nextVtecCmp.valid()) {
334 double sec = ceil(time.gpssec() / VTEC_CMP_SAMPL) * VTEC_CMP_SAMPL;
335 _nextVtecCmp = bncTime(time.gpsw(), sec);
336 }
337 while (time - _nextVtecCmp >= VTEC_CMP_DELAY) {
338 compareVtec(_nextVtecCmp);
339 _nextVtecCmp = _nextVtecCmp + VTEC_CMP_SAMPL;
340 }
341 }
342 if (time - _intervalStart >= _interval) {
343 writeReport(false);
344 double sec = floor(time.gpssec() / _interval) * _interval;
345 _intervalStart = bncTime(time.gpsw(), sec);
346 }
347 if (!_lastTime.valid() || _lastTime < time) {
348 _lastTime = time;
349 }
350}
351
352// Epoch statistics
353////////////////////////////////////////////////////////////////////////////
354void t_ssrQc::newEpoch(const string& staID, char sys, e_type type, const bncTime& time,
355 unsigned updateInt, const QString& prn) {
356 QString sta = QString::fromStdString(staID);
357 if (!_staStart.contains(sta)) {
358 _staStart[sta] = time;
359 }
360 if (!_staLast.contains(sta) || _staLast[sta] < time) {
361 _staLast[sta] = time;
362 }
363 t_epoStat& stat = _epoStat[key(staID, sys, type)];
364 if (updateInt < unsigned(ssrUpdateInt.size())) {
365 stat.nominal = ssrUpdateInt[updateInt];
366 }
367 stat.sats.insert(prn);
368 if (!stat.last.valid() || stat.last < time) {
369 if (stat.last.valid()) {
370 stat.intervals.push_back(time - stat.last);
371 }
372 stat.last = time;
373 stat.numEpo += 1;
374 stat.latencies.push_back(currentTime() - time);
375 }
376 else if (time < stat.last) {
377 stat.numOutOfOrder += 1;
378 }
379}
380
381// Broadcast ephemeris the correction refers to
382////////////////////////////////////////////////////////////////////////////
383void t_ssrQc::checkEph(t_satStat& stat, const QString& satKey, const QString& prnInt,
384 unsigned iod, const bncTime& time, const string& staID) {
385 // not before all broadcast ephemerides may have been received
386 if (time - _staStart[QString::fromStdString(staID)] < EPH_WARMUP) {
387 return;
388 }
389 if (!_ephUser.ephLast(prnInt)) {
390 stat.noEph += 1;
391 return;
392 }
393 // any data set kept, not only the last two: Galileo has a new IODnav every
394 // 10 minutes, and ACs keep one for up to an hour
395 t_eph* eph = _ephUser.ephWithIOD(prnInt, iod);
396 // an IOD used again later (GLONASS tb every day, GPS IODE) is another data set
397 if (eph && outDatedBcep(eph, time) && fabs(time - eph->TOC()) > EPH_IOD_REUSE) {
398 eph = 0;
399 }
400 if (!eph) {
401 // received later from the ephemeris stream(s)? decided in resolvePendingIod
402 t_pendingIod& pending = _pendingIod[satKey][iod];
403 if (pending.num == 0) {
404 pending.prnInt = prnInt;
405 pending.first = currentTime();
406 }
407 pending.num += 1;
408 }
409 else if (eph->checkState() == t_eph::unhealthy || eph->checkState() == t_eph::bad) {
410 stat.ephUnhealthy += 1;
411 }
412 else if (outDatedBcep(eph, time)) {
413 stat.ephOutdated += 1;
414 }
415 if (_pendingIod.contains(satKey)) {
416 resolvePendingIod(satKey, false);
417 }
418}
419
420// Corrections referring to an IOD not received before: counted as early if
421// the ephemeris stream(s) delivered the data set later, as unknown if not
422// within EPH_EARLY_MAX (or at the end of the report interval, final)
423////////////////////////////////////////////////////////////////////////////
424void t_ssrQc::resolvePendingIod(const QString& satKey, bool final) {
425 t_satStat& stat = _satStat[satKey];
426 QMap<unsigned, t_pendingIod>& pend = _pendingIod[satKey];
427 QMutableMapIterator<unsigned, t_pendingIod> it(pend);
428 while (it.hasNext()) {
429 it.next();
430 const t_pendingIod& pending = it.value();
431 t_eph* eph = _ephUser.ephWithIOD(pending.prnInt, it.key());
432 if (eph && eph->receptDateTime().isValid()) {
433 bncTime recept(eph->receptDateTime().toString(Qt::ISODate).toStdString());
434 if (recept >= pending.first) {
435 stat.iodEarly += pending.num;
436 stat.maxEarly = max(stat.maxEarly, recept - pending.first);
437 it.remove();
438 continue;
439 }
440 }
441 if (final || currentTime() - pending.first > EPH_EARLY_MAX) {
442 stat.iodUnknown += pending.num;
443 it.remove();
444 }
445 }
446 if (pend.isEmpty()) {
447 _pendingIod.remove(satKey);
448 }
449}
450
451// Orbit corrections
452////////////////////////////////////////////////////////////////////////////
453void t_ssrQc::slotNewOrbCorrections(QList<t_orbCorr> orbCorrections) {
454 QMutexLocker locker(&_mutex);
455 for (const t_orbCorr& corr : orbCorrections) {
456 if (!_excluded.contains(QString::fromStdString(corr._staID)) || corr._staID == _reference.toStdString()) {
457 storeHist(&corr, 0);
458 }
459 if (!selected(corr._staID)) continue;
460 QString prn = QString::fromStdString(corr._prn.toString());
461 checkInterval(corr._time);
462 newEpoch(corr._staID, corr._prn.system(), ORB, corr._time, corr._updateInt, prn);
463 t_satStat& stat = _satStat[QString::fromStdString(corr._staID) + ' ' + prn];
464 stat.numOrb += 1;
465 checkEph(stat, QString::fromStdString(corr._staID) + ' ' + prn,
466 QString::fromStdString(corr._prn.toInternalString()), corr._iod, corr._time, corr._staID);
467 double radial = fabs(corr._xr[0]);
468 double alongCross = max(fabs(corr._xr[1]), fabs(corr._xr[2]));
469 stat.maxRadial = max(stat.maxRadial, radial);
470 stat.maxAlongCross = max(stat.maxAlongCross, alongCross);
471 }
472}
473
474// Clock corrections
475////////////////////////////////////////////////////////////////////////////
476void t_ssrQc::slotNewClkCorrections(QList<t_clkCorr> clkCorrections) {
477 QMutexLocker locker(&_mutex);
478 for (const t_clkCorr& corr : clkCorrections) {
479 if (!_excluded.contains(QString::fromStdString(corr._staID)) || corr._staID == _reference.toStdString()) {
480 storeHist(0, &corr);
481 }
482 if (!selected(corr._staID)) continue;
483 QString prn = QString::fromStdString(corr._prn.toString());
484 checkInterval(corr._time);
485 newEpoch(corr._staID, corr._prn.system(), CLK, corr._time, corr._updateInt, prn);
486 t_satStat& stat = _satStat[QString::fromStdString(corr._staID) + ' ' + prn];
487 stat.numClk += 1;
488 checkEph(stat, QString::fromStdString(corr._staID) + ' ' + prn,
489 QString::fromStdString(corr._prn.toInternalString()), corr._iod, corr._time, corr._staID);
490
491 // jump: change between consecutive epochs (same IOD) beyond the clock rate
492 double clk = corr._dClk * t_CST::c;
493 if (stat.lastClkTime.valid() && stat.lastIod == corr._iod) {
494 double dt = corr._time - stat.lastClkTime;
495 int nominal = (corr._updateInt < unsigned(ssrUpdateInt.size())) ? ssrUpdateInt[corr._updateInt] : 0;
496 if (dt > 0.0 && dt <= max(2.0 * nominal, 60.0)) {
497 double jump = fabs(clk - stat.lastClk - corr._dotDClk * t_CST::c * dt);
498 stat.maxJump = max(stat.maxJump, jump);
499 if (jump > MAX_CLK_JUMP) {
500 stat.clkJumps += 1;
501 }
502 }
503 }
504 stat.lastClkTime = corr._time;
505 stat.lastIod = corr._iod;
506 stat.lastClk = clk;
507 }
508}
509
510// Code biases
511////////////////////////////////////////////////////////////////////////////
512void t_ssrQc::slotNewCodeBiases(QList<t_satCodeBias> codeBiases) {
513 QMutexLocker locker(&_mutex);
514 for (const t_satCodeBias& bias : codeBiases) {
515 bool sel = selected(bias._staID);
516 if (_excluded.contains(QString::fromStdString(bias._staID)) && bias._staID != _reference.toStdString()) continue;
517 char sys = bias._prn.system();
518 QString prn = QString::fromStdString(bias._prn.toString());
519 if (sel) {
520 checkInterval(bias._time);
521 newEpoch(bias._staID, sys, CBIAS, bias._time, bias._updateInt, prn);
522 }
523 QString staSys = QString("%1 %2").arg(bias._staID.c_str()).arg(sys);
524 QMap<QString, double> values;
525 for (const t_frqCodeBias& frqBias : bias._bias) {
526 QString sig = QString::fromStdString(frqBias._rnxType2ch);
527 _codeSignals[staSys].insert(sig);
528 values[sig] = frqBias._value;
529 }
530 if (!values.isEmpty()) {
531 _cbLast[QString::fromStdString(bias._staID)][prn] = values;
532 }
533 t_satStat& stat = _satStat[QString::fromStdString(bias._staID) + ' ' + prn];
534 QString sig1, sig2;
535 t_frequency::type frq1, frq2;
536 if (refSignals(sys, sig1, sig2, frq1, frq2)) {
537 stat.missingRefSig.clear();
538 if (!values.contains(sig1)) stat.missingRefSig.insert("C" + sig1);
539 if (!values.contains(sig2)) stat.missingRefSig.insert("C" + sig2);
540 stat.refBiasOK = stat.missingRefSig.isEmpty();
541 if (stat.refBiasOK) {
542 double channel = 0.0;
543 if (sys == 'R') {
544 t_eph* eph = _ephUser.ephLast(QString::fromStdString(bias._prn.toInternalString()));
545 if (!eph) {
546 stat.refBiasOK = false;
547 continue;
548 }
549 channel = eph->slotNum();
550 }
551 double f1 = t_CST::freq(frq1, channel);
552 double f2 = t_CST::freq(frq2, channel);
553 stat.biasIF = (f1 * f1 * values[sig1] - f2 * f2 * values[sig2]) / (f1 * f1 - f2 * f2);
554 }
555 }
556 }
557}
558
559// Phase biases
560////////////////////////////////////////////////////////////////////////////
561void t_ssrQc::slotNewPhaseBiases(QList<t_satPhaseBias> phaseBiases) {
562 QMutexLocker locker(&_mutex);
563 for (const t_satPhaseBias& bias : phaseBiases) {
564 QString staID = QString::fromStdString(bias._staID);
565 QString prn = QString::fromStdString(bias._prn.toString());
566 // latest biases for the Melbourne-Wuebbena check (also as other AC)
567 if (!_excluded.contains(staID) || staID == _reference) {
568 t_pbLast& pl = _pbLast[staID][prn];
569 pl.time = bias._time;
570 pl.values.clear();
571 for (const t_frqPhaseBias& frqBias : bias._bias) {
572 pl.values[QString::fromStdString(frqBias._rnxType2ch)] = frqBias._value;
573 }
574 }
575 if (!selected(bias._staID)) continue;
576 checkInterval(bias._time);
577 newEpoch(bias._staID, bias._prn.system(), PBIAS, bias._time, bias._updateInt, prn);
578 QString staSys = QString("%1 %2").arg(staID).arg(bias._prn.system());
579 t_satStat& stat = _satStat[staID + ' ' + prn];
580 t_pbIndStat& ind = _pbIndStat[staSys];
581 ind.numRec++;
582 ind.format[(bias._ssrFormat == ssrRtcmNew) ? "new RTCM-SSR" :
583 (bias._ssrFormat == ssrRtcmOld) ? "old RTCM-SSR" : "IGS-SSR"]++;
584 if (bias._ssrFormat != ssrRtcmNew) { // new RTCM-SSR: no consistency indicators
585 ind.dispInd[bias._dispBiasConsistInd]++;
586 ind.mwInd[bias._MelbWuebConsistInd]++;
587 }
588 bool jumped = false; // counted once per record, not per signal
589 for (const t_frqPhaseBias& frqBias : bias._bias) {
590 QString sig = QString::fromStdString(frqBias._rnxType2ch);
591 _phaseSignals[staSys].insert(sig);
592 ind.intInd[sig][frqBias._fixIndicator]++;
593 ind.wlInd[sig][frqBias._fixWideLaneIndicator]++;
594 QString jumpKey = staID + ' ' + prn + ' ' + sig;
595 if (_pbJumpLast.contains(jumpKey) && _pbJumpLast[jumpKey] != frqBias._jumpCounter) {
596 jumped = true;
597 }
598 _pbJumpLast[jumpKey] = frqBias._jumpCounter;
599 }
600 if (jumped) {
601 stat.pbJumps++;
602 }
603 // Yaw angle: new RTCM-SSR has an indicator, old RTCM-SSR and IGS-SSR always
604 // carry the field, providers without attitude information send zeros
605 stat.numPB++;
606 bool yawProvided = (bias._ssrFormat == ssrRtcmNew) ? (bias._satYawInfoInd != 0)
607 : (bias._yaw != 0.0 || bias._yawRate != 0.0);
608 if (yawProvided) {
609 stat.numYaw++;
610 t_yawLast& yl = _yawLast[QString::fromStdString(bias._staID)][QString::fromStdString(bias._prn.toString())];
611 double dt = 0.0;
612 if (bias._updateInt < unsigned(ssrUpdateInt.size())) {
613 dt = 0.5 * ssrUpdateInt[bias._updateInt]; // reference time in the middle of the interval
614 }
615 yl.time = bias._time + dt;
616 yl.yaw = bias._yaw;
617 yl.rate = bias._yawRate;
618 }
619 }
620}
621
622// Melbourne-Wuebbena combination of the phase and code biases of the
623// reference signals of a stream and satellite in wide-lane cycles:
624// (f1 b_L1 - f2 b_L2) / (f1 - f2) - (f1 b_C1 + f2 b_C2) / (f1 + f2)
625// The phase bias of a frequency is that of the reference signal or, if not
626// provided, of another signal of the frequency; the code biases are those
627// of the reference signals (as used for the clocks and a combination; with
628// the code bias of the phase signal instead, e.g. C1C for CNES' L1C, CNES and
629// NRCan agreed less on 2026-10-02)
630////////////////////////////////////////////////////////////////////////////
631bool t_ssrQc::mwBias(const QString& staID, const QString& prn, char sys, const bncTime& tt, double& mwCyc) {
632 QString sig1, sig2;
633 t_frequency::type frq1, frq2;
634 if (sys == 'R' || !refSignals(sys, sig1, sig2, frq1, frq2)) {
635 return false; // GLONASS FDMA: no integer wide-lane ambiguities between satellites
636 }
637 if (!_pbLast.value(staID).contains(prn) || !_cbLast.value(staID).contains(prn)) {
638 return false;
639 }
640 const t_pbLast& pl = _pbLast[staID][prn];
641 if (fabs(tt - pl.time) > MW_MAX_AGE) {
642 return false;
643 }
644 const QMap<QString, double>& cb = _cbLast[staID][prn];
645 auto biases = [&pl, &cb](const QString& sig, double& phase, double& code) {
646 QString used;
647 if (pl.values.contains(sig)) {
648 used = sig;
649 }
650 else {
651 QMapIterator<QString, double> it(pl.values);
652 while (it.hasNext()) {
653 it.next();
654 if (it.key()[0] == sig[0]) {
655 used = it.key();
656 break;
657 }
658 }
659 }
660 if (used.isEmpty()) {
661 return false;
662 }
663 if (!cb.contains(sig)) {
664 return false;
665 }
666 phase = pl.values[used];
667 code = cb[sig];
668 return true;
669 };
670 double pb1, pb2, cb1, cb2;
671 if (!biases(sig1, pb1, cb1) || !biases(sig2, pb2, cb2)) {
672 return false;
673 }
674 double f1 = t_CST::freq(frq1, 0);
675 double f2 = t_CST::freq(frq2, 0);
676 double mw = (f1 * pb1 - f2 * pb2) / (f1 - f2) - (f1 * cb1 + f2 * cb2) / (f1 + f2);
677 mwCyc = mw / (t_CST::c / (f1 - f2));
678 return true;
679}
680
681// Melbourne-Wuebbena check of one epoch: per pair of streams of different
682// ACs and system, the fractional parts of the MW differences of the
683// satellites about their common (circular mean) offset
684////////////////////////////////////////////////////////////////////////////
685void t_ssrQc::compareMw(const bncTime& tt) {
686 QStringList streams = _pbLast.keys();
687 for (const QString& staA : streams) {
688 if (!selected(staA.toStdString())) continue;
689 for (const QString& staB : streams) {
690 if (staB == staA || !votes(staB) || acOf(staB) == acOf(staA)) continue;
691 QMap<char, QMap<QString, double> > diff; // system, PRN: MW difference [cycles]
692 for (const QString& prn : _pbLast[staA].keys()) {
693 char sys = prn[0].toLatin1();
694 double mwA, mwB;
695 if (mwBias(staA, prn, sys, tt, mwA) && mwBias(staB, prn, sys, tt, mwB)) {
696 diff[sys][prn] = mwA - mwB;
697 }
698 }
699 QMapIterator<char, QMap<QString, double> > itSys(diff);
700 while (itSys.hasNext()) {
701 itSys.next();
702 const QMap<QString, double>& dd = itSys.value();
703 if (dd.size() < MW_MIN_SAT) continue;
704 double sSin = 0.0, sCos = 0.0;
705 for (double val : dd) {
706 sSin += sin(2.0 * M_PI * val);
707 sCos += cos(2.0 * M_PI * val);
708 }
709 double offset = atan2(sSin, sCos) / (2.0 * M_PI);
710 t_mwStat& ms = _mwStat[staA][staB][itSys.key()];
711 ms.numEpo++;
712 ms.offset = offset;
713 QMapIterator<QString, double> itD(dd);
714 while (itD.hasNext()) {
715 itD.next();
716 double res = itD.value() - offset;
717 res -= floor(res + 0.5); // fractional part in [-0.5, 0.5)
718 ms.numRes++;
719 ms.sRes2 += res * res;
720 QPair<unsigned, double>& sr = ms.satRes[itD.key()];
721 sr.first++;
722 sr.second += res * res;
723 }
724 }
725 }
726 }
727}
728
729// Reference DCBs (bias(base) - bias(signal)) of a satellite: median of the
730// other ACs (one vote per AC, own AC left out, combinations not voting) or
731// the selected reference stream, or from the Bias SINEX file
732////////////////////////////////////////////////////////////////////////////
733bool t_ssrQc::refDcbs(const QString& staID, const QString& prn, const QString& base, bool fromFile,
734 QMap<QString, double>& dcbs, const QString& onlyAC, QMap<QString, int>* numVotes) {
735 dcbs.clear();
736 if (numVotes) {
737 numVotes->clear();
738 }
739 if (fromFile) {
740 if (!_bsxRef) {
741 return false;
742 }
743 char sys = prn[0].toLatin1();
744 t_ssrRefSig::t_pair pair;
745 if (!t_ssrRefSig::get(sys, pair)) {
746 return false;
747 }
748 // the DCBs do not depend on the coefficients (as long as they add up to 1)
749 double f1 = t_CST::freq(pair.frq1, 0.0);
750 double f2 = t_CST::freq(pair.frq2, 0.0);
751 double aIF1 = f1 * f1 / (f1 * f1 - f2 * f2);
752 double aIF2 = -f2 * f2 / (f1 * f1 - f2 * f2);
753 t_satCodeBias satCodeBias;
754 _bsxRef->determineSsrSatCodeBiases(prn, aIF1, aIF2, satCodeBias);
755 QMap<QString, double> osb;
756 for (const t_frqCodeBias& bb : satCodeBias._bias) {
757 osb[QString::fromStdString(bb._rnxType2ch)] = bb._value;
758 }
759 if (!osb.contains(base)) {
760 return false;
761 }
762 for (auto it = osb.constBegin(); it != osb.constEnd(); ++it) {
763 if (it.key() != base) {
764 dcbs[it.key()] = osb[base] - it.value();
765 }
766 }
767 return !dcbs.isEmpty();
768 }
769
770 // per AC: DCBs of its streams
771 QMap<QString, QMap<QString, QVector<double> > > acDcbs; // AC, signal
772 for (auto itS = _cbLast.constBegin(); itS != _cbLast.constEnd(); ++itS) {
773 const QString& sta = itS.key();
774 if (sta == staID) {
775 continue;
776 }
777 if (_reference == "CONSENSUS") {
778 if (!votes(sta)) {
779 continue;
780 }
781 if (onlyAC.isEmpty() ? (acOf(sta) == acOf(staID))
782 : (solOf(sta) != onlyAC || solOf(sta) == solOf(staID))) {
783 continue;
784 }
785 }
786 else if (sta != _reference) {
787 continue;
788 }
789 if (!itS.value().contains(prn)) {
790 continue;
791 }
792 const QMap<QString, double>& bb = itS.value()[prn];
793 if (!bb.contains(base)) {
794 continue;
795 }
796 for (auto it = bb.constBegin(); it != bb.constEnd(); ++it) {
797 if (it.key() != base) {
798 acDcbs[solOf(sta)][it.key()].append(bb[base] - it.value());
799 }
800 }
801 }
802 QMap<QString, QVector<double> > votesPerSig;
803 for (auto itA = acDcbs.constBegin(); itA != acDcbs.constEnd(); ++itA) {
804 for (auto it = itA.value().constBegin(); it != itA.value().constEnd(); ++it) {
805 votesPerSig[it.key()].append(median(it.value()));
806 }
807 }
808 for (auto it = votesPerSig.constBegin(); it != votesPerSig.constEnd(); ++it) {
809 dcbs[it.key()] = median(it.value());
810 if (numVotes) {
811 (*numVotes)[it.key()] = it.value().size();
812 }
813 }
814 return !dcbs.isEmpty();
815}
816
817// Code bias check: the DCBs of the stream (relative to the first reference
818// signal, otherwise to another common signal) compared with a reference;
819// DCBs do not depend on the clock datum. A sign opposite to the reference
820// for most DCBs indicates the SINEX instead of the SSR sign convention.
821// References: the Bias SINEX file, the selected reference stream, or each
822// other AC separately (a median of two ACs cannot decide which one is wrong)
823////////////////////////////////////////////////////////////////////////////
824void t_ssrQc::compareCodeBiases(const QString& staID, char sys, QStringList& lines) {
825 const double MIN_DCB = 0.3; // [m] DCBs used for the sign check
826 const double MIN_DEV = 0.5; // [m] deviating DCBs: > max(MIN_DEV, DEV_FACTOR x median)
827 const int MIN_VOTE = 3; // ACs needed for a consensus DCB (deviating satellites)
828 if (!_cbLast.contains(staID)) {
829 return;
830 }
831 t_ssrRefSig::t_pair pair;
832 if (!t_ssrRefSig::get(sys, pair)) {
833 return;
834 }
835 const QString ref1 = QString::fromStdString(pair.sig1());
836
837 class t_cmp {
838 public:
839 unsigned numSat = 0, numSign = 0, numOpp = 0;
840 double sumSqr = 0.0;
841 QVector<double> absDiffs;
842 QMap<QString, QPair<QString, double> > maxDiff; // PRN: signal, difference
843 QSet<QString> bases;
844 bool opposite() const {return numSign >= 5 && numOpp > numSign / 2;}
845 double rms() const {return absDiffs.isEmpty() ? 0.0 : sqrt(sumSqr / absDiffs.size());}
846 };
847 // mode 0: file, 1: reference stream or median of the other ACs, 2: one other AC
848 auto compare = [&](int mode, const QString& onlyAC) {
849 t_cmp cc;
850 for (auto itP = _cbLast[staID].constBegin(); itP != _cbLast[staID].constEnd(); ++itP) {
851 const QString& prn = itP.key();
852 if (prn[0].toLatin1() != sys) {
853 continue;
854 }
855 const QMap<QString, double>& bb = itP.value();
856 QStringList candidates = QStringList() << ref1 << bb.keys();
857 QMap<QString, double> dcbs;
858 QMap<QString, int> numVotes;
859 QString base;
860 for (const QString& cand : candidates) {
861 if (bb.contains(cand) && refDcbs(staID, prn, cand, mode == 0, dcbs, onlyAC, &numVotes)) {
862 base = cand;
863 break;
864 }
865 }
866 if (base.isEmpty()) {
867 continue;
868 }
869 bool used = false;
870 for (auto it = dcbs.constBegin(); it != dcbs.constEnd(); ++it) {
871 if (!bb.contains(it.key())) {
872 continue;
873 }
874 if (mode == 1 && _reference == "CONSENSUS" && numVotes.value(it.key()) < MIN_VOTE) {
875 continue;
876 }
877 double dcb = bb[base] - bb[it.key()];
878 double diff = dcb - it.value();
879 used = true;
880 cc.sumSqr += diff * diff;
881 cc.absDiffs.append(fabs(diff));
882 if (fabs(diff) > fabs(cc.maxDiff.value(prn).second)) {
883 cc.maxDiff[prn] = qMakePair("C" + it.key(), diff);
884 }
885 if (fabs(it.value()) >= MIN_DCB) {
886 cc.numSign++;
887 if (dcb * it.value() < 0.0) {
888 cc.numOpp++;
889 }
890 }
891 }
892 if (used) {
893 cc.numSat++;
894 cc.bases.insert("C" + base);
895 }
896 }
897 return cc;
898 };
899 auto baseStr = [](const t_cmp& cc) {
900 QStringList ll = cc.bases.values();
901 ll.sort();
902 return ll.join("/");
903 };
904 auto deviating = [&](const t_cmp& cc, const QString& refName) {
905 if (cc.absDiffs.isEmpty() || cc.opposite()) {
906 return;
907 }
908 double limit = std::max(MIN_DEV, DEV_FACTOR * median(cc.absDiffs));
909 QStringList devs;
910 for (auto it = cc.maxDiff.constBegin(); it != cc.maxDiff.constEnd(); ++it) {
911 if (fabs(it.value().second) > limit) {
912 devs << QString("%1(%2 %3)").arg(it.key()).arg(it.value().first).arg(it.value().second, 0, 'f', 2);
913 }
914 }
915 if (!devs.isEmpty()) {
916 lines << QString("satellites with DCBs deviating from %1 [m]: %2").arg(refName).arg(devs.join(" "));
917 }
918 };
919
920 // Bias SINEX file or the selected reference stream
921 for (int mode = 0; mode < 2; mode++) {
922 if ((mode == 0 && !_bsxRef) || (mode == 1 && _reference == "CONSENSUS")) {
923 continue;
924 }
925 QString refName = (mode == 0) ? QString("Bias SINEX file %1").arg(_bsxName) : _reference;
926 t_cmp cc = compare(mode, QString());
927 if (cc.absDiffs.isEmpty()) {
928 continue;
929 }
930 lines << QString("code biases compared with %1 (DCBs to %2, %3 satellites, %4 DCBs): RMS of the differences "
931 "%5 m, opposite sign for %6 of %7 DCBs (|DCB| >= %8 m)")
932 .arg(refName).arg(baseStr(cc)).arg(cc.numSat).arg(cc.absDiffs.size())
933 .arg(cc.rms(), 0, 'f', 3).arg(cc.numOpp).arg(cc.numSign).arg(MIN_DCB, 0, 'f', 1);
934 if (cc.opposite()) {
935 lines << QString("code biases with the opposite sign of %1 for %2 of %3 DCBs - "
936 "SINEX sign convention instead of the SSR one?").arg(refName).arg(cc.numOpp).arg(cc.numSign);
937 }
938 deviating(cc, refName);
939 }
940
941 // Each other AC separately, and the median of the other ACs for deviating satellites
942 if (_reference == "CONSENSUS") {
943 QSet<QString> acs;
944 for (auto itS = _cbLast.constBegin(); itS != _cbLast.constEnd(); ++itS) {
945 if (itS.key() != staID && votes(itS.key()) && solOf(itS.key()) != solOf(staID)) {
946 acs.insert(solOf(itS.key()));
947 }
948 }
949 QStringList acList = acs.values();
950 acList.sort();
951 QStringList items;
952 QStringList oppACs;
953 int numACs = 0;
954 QSet<QString> bases;
955 for (const QString& ac : acList) {
956 t_cmp cc = compare(2, ac);
957 if (cc.absDiffs.isEmpty()) {
958 continue;
959 }
960 bases.unite(cc.bases);
961 items << QString("%1 RMS %2 m, opposite sign %3/%4").arg(ac).arg(cc.rms(), 0, 'f', 2)
962 .arg(cc.numOpp).arg(cc.numSign);
963 // the sign rule counts the solutions of other ACs only
964 if (acOfSol(ac) != acOf(staID)) {
965 numACs++;
966 if (cc.opposite()) {
967 oppACs << ac;
968 }
969 }
970 }
971 if (!items.isEmpty()) {
972 QStringList ll = bases.values();
973 ll.sort();
974 lines << QString("code biases compared with the other solutions (DCBs to %1): %2").arg(ll.join("/")).arg(items.join("; "));
975 if (numACs >= 2 && oppACs.size() > numACs / 2) {
976 lines << QString("code biases with the opposite sign of %1 of %2 solutions of other ACs (%3) - "
977 "SINEX sign convention instead of the SSR one?")
978 .arg(oppACs.size()).arg(numACs).arg(oppACs.join(" "));
979 }
980 deviating(compare(1, QString()), QString("the median of the other ACs (at least %1 solutions)").arg(MIN_VOTE));
981 }
982 }
983}
984
985// Reference point of the orbits of a stream: APC (SSRA...), CoM (SSRC...);
986// the combined stream INTERNAL refers to the APC
987////////////////////////////////////////////////////////////////////////////
988char t_ssrQc::refPoint(const QString& staID) const {
989 if (staID == "INTERNAL") {
990 return 'A'; // the combined corrections always refer to the APC
991 }
992 const QString& sta = staID;
993 if (sta.startsWith("SSRA")) return 'A';
994 if (sta.startsWith("SSRC")) return 'C';
995 return '?';
996}
997
998// Keep the recent orbit and clock corrections of a stream
999////////////////////////////////////////////////////////////////////////////
1000void t_ssrQc::storeHist(const t_orbCorr* orb, const t_clkCorr* clk) {
1001 if (orb) {
1002 QMap<double, t_orbCorr>& hist = _orbHist[QString::fromStdString(orb->_staID)]
1003 [QString::fromStdString(orb->_prn.toInternalString())];
1004 hist[tKey(orb->_time)] = *orb;
1005 while (!hist.isEmpty() && hist.firstKey() < tKey(orb->_time) - HIST_LENGTH) {
1006 hist.erase(hist.begin());
1007 }
1008 }
1009 if (clk) {
1010 QMap<double, t_clkCorr>& hist = _clkHist[QString::fromStdString(clk->_staID)]
1011 [QString::fromStdString(clk->_prn.toInternalString())];
1012 hist[tKey(clk->_time)] = *clk;
1013 while (!hist.isEmpty() && hist.firstKey() < tKey(clk->_time) - HIST_LENGTH) {
1014 hist.erase(hist.begin());
1015 }
1016 }
1017}
1018
1019// Compare the orbits and clocks of all streams at epoch tt
1020////////////////////////////////////////////////////////////////////////////
1021void t_ssrQc::compareEpoch(const bncTime& tt) {
1022 double tk = tKey(tt);
1023
1024 // Satellite positions and clocks of all streams (latest corrections <= tt)
1025 QMap<QString, QMap<QString, t_satCrd> > crd; // stream, PRN (external)
1026 QMapIterator<QString, QMap<QString, QMap<double, t_clkCorr> > > itSta(_clkHist);
1027 while (itSta.hasNext()) {
1028 itSta.next();
1029 const QString& staID = itSta.key();
1030 QMapIterator<QString, QMap<double, t_clkCorr> > itPrn(itSta.value());
1031 while (itPrn.hasNext()) {
1032 itPrn.next();
1033 const QString& prnInt = itPrn.key();
1034 QMap<double, t_clkCorr>::const_iterator itC = itPrn.value().upperBound(tk);
1035 if (itC == itPrn.value().constBegin()) {
1036 continue;
1037 }
1038 const t_clkCorr& clk = (--itC).value();
1039 const QMap<double, t_orbCorr>& orbHist = _orbHist[staID][prnInt];
1040 QMap<double, t_orbCorr>::const_iterator itO = orbHist.upperBound(tk);
1041 if (itO == orbHist.constBegin()) {
1042 continue;
1043 }
1044 const t_orbCorr& orb = (--itO).value();
1045 t_eph* eph = _ephUser.ephWithIOD(prnInt, orb._iod);
1046 if (eph && outDatedBcep(eph, tt) && fabs(tt - eph->TOC()) > EPH_IOD_REUSE) {
1047 eph = 0;
1048 }
1049 if (!eph || clk._iod != orb._iod) {
1050 continue;
1051 }
1052 eph->setOrbCorr(&orb);
1053 eph->setClkCorr(&clk);
1054 ColumnVector xc(6), vv(3);
1055 if (eph->getCrd(tt, xc, vv, true) != success) {
1056 continue;
1057 }
1058 t_satCrd& sc = crd[staID][QString::fromStdString(clk._prn.toString())];
1059 sc.xx = xc.Rows(1,3);
1060 sc.vv = vv;
1061 sc.vFrame = eph->ssrFrameVel(xc, vv);
1062 sc.clk = xc(4) * t_CST::c;
1063 sc.refPoint = refPoint(staID);
1064 // clock referred to the reference signals (as in the combination):
1065 // + B_IF of the stream's code biases; the combination (INTERNAL)
1066 // refers to them already
1067 sc.clkOK = (staID == "INTERNAL");
1068 QString satKey = staID + ' ' + QString::fromStdString(clk._prn.toString());
1069 if (!sc.clkOK && _satStat.contains(satKey) && _satStat[satKey].refBiasOK) {
1070 sc.clk += _satStat[satKey].biasIF;
1071 sc.clkOK = true;
1072 }
1073 }
1074 }
1075
1076 // Satellites per system
1077 QMap<char, QSet<QString> > satsSys;
1078 QMapIterator<QString, QMap<QString, t_satCrd> > itCrd(crd);
1079 while (itCrd.hasNext()) {
1080 itCrd.next();
1081 for (const QString& prn : itCrd.value().keys()) {
1082 satsSys[prn[0].toLatin1()].insert(prn);
1083 }
1084 }
1085
1086 QMapIterator<char, QSet<QString> > itSys(satsSys);
1087 while (itSys.hasNext()) {
1088 itSys.next();
1089 const QSet<QString>& sats = itSys.value();
1090 QStringList staList;
1091 for (const QString& staID : crd.keys()) {
1092 for (const QString& prn : sats) {
1093 if (crd[staID].contains(prn)) {
1094 staList << staID;
1095 break;
1096 }
1097 }
1098 }
1099
1100 // Consensus: one value per AC (median of its streams), so that an AC
1101 // with several streams (formats, APC/CoM) has one vote; the streams of
1102 // the AC compared are left out (leave-one-AC-out)
1103 auto acClocks = [&](const QString& prn, const QMap<QString, double>& off, bool useOff) {
1104 QMap<QString, QVector<double> > perAC;
1105 for (const QString& oo : staList) {
1106 if (!votes(oo) || !crd[oo].contains(prn) || !crd[oo][prn].clkOK) continue;
1107 if (useOff && !off.contains(oo)) continue;
1108 perAC[solOf(oo)] << crd[oo][prn].clk - (useOff ? off[oo] : 0.0);
1109 }
1110 QMap<QString, double> res;
1111 for (const QString& ac : perAC.keys()) res[ac] = median(perAC[ac]);
1112 return res;
1113 };
1114
1115 // Clock datum: offset of each stream w.r.t. the per-satellite consensus
1116 // of all ACs (or w.r.t. the reference stream)
1117 QMap<QString, double> offset;
1118 QMap<QString, double> noOff;
1119 QMap<QString, QMap<QString, double> > rawAC; // PRN, AC
1120 if (_reference == "CONSENSUS") {
1121 for (const QString& prn : sats) rawAC[prn] = acClocks(prn, noOff, false);
1122 }
1123 for (const QString& staID : staList) {
1124 QVector<double> diffs;
1125 for (const QString& prn : sats) {
1126 if (!crd[staID].contains(prn) || !crd[staID][prn].clkOK) continue;
1127 if (_reference == "CONSENSUS") {
1128 if (rawAC[prn].size() >= 3) diffs << crd[staID][prn].clk - median(rawAC[prn].values().toVector());
1129 }
1130 else if (crd.value(_reference).contains(prn) && crd[_reference][prn].clkOK) {
1131 diffs << crd[staID][prn].clk - crd[_reference][prn].clk;
1132 }
1133 }
1134 if (!diffs.isEmpty()) {
1135 offset[staID] = median(diffs);
1136 }
1137 }
1138 QMap<QString, QMap<QString, double> > alignedAC; // PRN, AC
1139 if (_reference == "CONSENSUS") {
1140 for (const QString& prn : sats) alignedAC[prn] = acClocks(prn, offset, true);
1141 }
1142
1143 // Differences of each selected stream to its reference
1144 for (const QString& staID : staList) {
1145 if (!selected(staID.toStdString()) || staID == _reference) {
1146 continue;
1147 }
1148 const QString ownAC = acOf(staID);
1149 QMap<QString, double> dClk;
1150 QMap<QString, ColumnVector> dRac;
1151 for (const QString& prn : sats) {
1152 if (!crd[staID].contains(prn)) continue;
1153 const t_satCrd& sc = crd[staID][prn];
1154 QVector<double> clks, xs[3];
1155 if (_reference == "CONSENSUS") {
1156 QMapIterator<QString, double> itA(alignedAC[prn]);
1157 while (itA.hasNext()) {
1158 itA.next();
1159 if (acOfSol(itA.key()) != ownAC) clks << itA.value();
1160 }
1161 // orbits: per AC the median of its streams with the same reference point
1162 QMap<QString, QVector<double> > perAC[3];
1163 for (const QString& oo : staList) {
1164 if (!votes(oo) || acOf(oo) == ownAC || !crd[oo].contains(prn)) continue;
1165 const t_satCrd& rc = crd[oo][prn];
1166 if (rc.refPoint != sc.refPoint || sc.refPoint == '?') continue;
1167 for (int ii = 0; ii < 3; ii++) perAC[ii][solOf(oo)] << rc.xx[ii];
1168 }
1169 for (const QString& ac : perAC[0].keys()) {
1170 for (int ii = 0; ii < 3; ii++) xs[ii] << median(perAC[ii][ac]);
1171 }
1172 if (clks.size() < 2) clks.clear();
1173 if (xs[0].size() < 2) for (int ii = 0; ii < 3; ii++) xs[ii].clear();
1174 }
1175 else {
1176 if (!crd.value(_reference).contains(prn)) continue;
1177 const t_satCrd& rc = crd[_reference][prn];
1178 if (rc.clkOK) clks << rc.clk;
1179 if (rc.refPoint == sc.refPoint && sc.refPoint != '?') {
1180 for (int ii = 0; ii < 3; ii++) xs[ii] << rc.xx[ii];
1181 }
1182 }
1183 if (sc.clkOK && offset.contains(staID) && !clks.isEmpty()) {
1184 dClk[prn] = sc.clk - offset[staID] - median(clks);
1185 }
1186 else if (!sc.clkOK) {
1187 _cmpStat[staID][prn].clkNotReferred += 1;
1188 }
1189 if (!xs[0].isEmpty()) {
1190 ColumnVector dx(3);
1191 for (int ii = 0; ii < 3; ii++) dx[ii] = sc.xx[ii] - median(xs[ii]);
1192 ColumnVector er = sc.xx / sc.xx.NormFrobenius();
1193 ColumnVector ec = crossproduct(sc.xx, sc.vFrame);
1194 ec /= ec.NormFrobenius();
1195 ColumnVector ea = crossproduct(ec, er);
1196 ColumnVector rac(3);
1197 rac[0] = DotProduct(dx, er);
1198 rac[1] = DotProduct(dx, ea);
1199 rac[2] = DotProduct(dx, ec);
1200 dRac[prn] = rac;
1201 }
1202 }
1203 if (dClk.isEmpty() && dRac.isEmpty()) {
1204 continue;
1205 }
1206 // remaining common clock offset of this stream and epoch
1207 double off = dClk.isEmpty() ? 0.0 : median(dClk.values().toVector());
1208 _cmpEpochs[staID] += 1;
1209 QSet<QString> prns;
1210 for (const QString& prn : dClk.keys()) prns.insert(prn);
1211 for (const QString& prn : dRac.keys()) prns.insert(prn);
1212 for (const QString& prn : prns) {
1213 t_cmpStat& stat = _cmpStat[staID][prn];
1214 if (dRac.contains(prn)) {
1215 const ColumnVector& rac = dRac[prn];
1216 stat.numOrb += 1;
1217 stat.sR += rac[0] * rac[0];
1218 stat.sA += rac[1] * rac[1];
1219 stat.sC += rac[2] * rac[2];
1220 }
1221 if (dClk.contains(prn)) {
1222 double dc = dClk[prn] - off;
1223 if (_antex && _yawLast.value(staID).contains(prn)) {
1224 attitudeSample(staID, prn, tt, crd[staID][prn].xx, crd[staID][prn].vv, dc);
1225 }
1226 stat.numClk += 1;
1227 stat.sClk += dc * dc;
1228 stat.mClk += dc;
1229 if (dRac.contains(prn)) {
1230 double sis = dRac[prn][0] - dc;
1231 stat.numSis += 1;
1232 stat.sSis += sis * sis;
1233 stat.mSis += sis;
1234 }
1235 }
1236 }
1237 }
1238 }
1239}
1240
1241// Attitude check: one sample per comparison epoch for a stream sending the
1242// yaw angle. The yaw difference of BNC's attitude model ('Computed') minus
1243// the stream is followed continuously over time; the predicted clock
1244// difference of the stream to an AC following the model is
1245// lambda_IF * dpsi / 2pi (see combination, dC_att). A turn starts when the
1246// yaw difference changes by more than ATT_ONSET against the samples 5-15
1247// minutes before, and ends when it is stable again for ATT_STABLE_T.
1248////////////////////////////////////////////////////////////////////////////
1249void t_ssrQc::attitudeSample(const QString& staID, const QString& prn, const bncTime& tt,
1250 const ColumnVector& xx, const ColumnVector& vv, double dc) {
1251 const t_yawLast& yl = _yawLast[staID][prn];
1252 double age = tt - yl.time;
1253 if (!yl.time.valid() || fabs(age) > 120.0) {
1254 return;
1255 }
1256 double psiAC = yl.yaw + yl.rate * age;
1257
1258 // model yaw, once per satellite and epoch (model state in time order)
1259 double tk = tKey(tt);
1260 if (tk != _psiModelT) {
1261 _psiModel.clear();
1262 _psiModelT = tk;
1263 }
1264 if (!_psiModel.contains(prn)) {
1265 ColumnVector dx(3);
1266 double psiM = 0.0;
1267 double Mjd = tt.mjd() + tt.daysec() / 86400.0;
1268 if (_antex->satCoMcorrection(prn, Mjd, xx, vv, dx, bncAntex::ATT_COMPUTED, 0.0,
1269 "ssrQc", &psiM) != success) {
1270 return;
1271 }
1272 _psiModel[prn] = psiM;
1273 }
1274
1275 // ionosphere-free wavelength of the reference signals, c / (f1 + f2)
1276 QString sig1, sig2;
1277 t_frequency::type frq1, frq2;
1278 if (!refSignals(prn[0].toLatin1(), sig1, sig2, frq1, frq2)) {
1279 return;
1280 }
1281 double lambda = t_CST::c / (t_CST::freq(frq1, 0) + t_CST::freq(frq2, 0));
1282
1283 t_attTrack& tr = _attTrack[staID][prn];
1284 if (tr.hasLast && tk - tr.lastT > ATT_MAX_GAP) {
1285 if (tr.active) {
1286 attitudeEvent(staID, prn, tr, "interrupted by a gap");
1287 }
1288 tr = t_attTrack();
1289 }
1290 double dpsi = remainder(_psiModel[prn] - psiAC, 2.0 * M_PI);
1291 if (tr.hasLast) {
1292 dpsi = tr.lastDPsi + remainder(dpsi - tr.lastDPsi, 2.0 * M_PI);
1293 }
1294 tr.hasLast = true;
1295 tr.lastDPsi = dpsi;
1296 tr.lastT = tk;
1297 t_attSample smp;
1298 smp.t = tk;
1299 smp.dc = dc;
1300 smp.p = lambda * dpsi / (2.0 * M_PI);
1301 smp.dpsi = dpsi;
1302
1303 if (!tr.active) {
1304 tr.hist << smp;
1305 while (!tr.hist.isEmpty() && tk - tr.hist.first().t > ATT_REF_FROM) {
1306 tr.hist.removeFirst();
1307 }
1308 // reference: samples 5 to 15 minutes before
1309 QVector<double> rDc, rP, rPsi;
1310 for (const t_attSample& hh : tr.hist) {
1311 if (tk - hh.t >= ATT_REF_TO) {
1312 rDc << hh.dc; rP << hh.p; rPsi << hh.dpsi;
1313 }
1314 }
1315 if (rPsi.size() >= 3 && fabs(dpsi - median(rPsi)) > ATT_ONSET) {
1316 tr.active = true;
1317 tr.dc0 = median(rDc);
1318 tr.p0 = median(rP);
1319 tr.dpsi0 = median(rPsi);
1320 for (const t_attSample& hh : tr.hist) {
1321 if (tk - hh.t < ATT_REF_TO) tr.event << hh; // the beginning of the turn
1322 }
1323 tr.hist.clear();
1324 }
1325 return;
1326 }
1327
1328 tr.event << smp;
1329 // end: yaw difference stable for ATT_STABLE_T, or the turn too long
1330 double tStart = tr.event.first().t;
1331 bool stable = (tk - tStart >= ATT_STABLE_T);
1332 if (stable) {
1333 for (int ii = tr.event.size() - 1; ii >= 0 && tk - tr.event[ii].t <= ATT_STABLE_T; ii--) {
1334 if (fabs(tr.event[ii].dpsi - dpsi) > ATT_STABLE) {
1335 stable = false;
1336 break;
1337 }
1338 }
1339 }
1340 if (stable || tk - tStart > ATT_MAX_TURN) {
1341 attitudeEvent(staID, prn, tr, stable ? "" : "closed after 3 h");
1342 double keepPsi = tr.lastDPsi, keepT = tr.lastT;
1343 tr = t_attTrack();
1344 tr.hasLast = true;
1345 tr.lastDPsi = keepPsi;
1346 tr.lastT = keepT;
1347 tr.hist << smp;
1348 }
1349}
1350
1351// Assessment of a turn: observed clock change of the stream relative to the
1352// consensus against the predicted one (regression slope, RMS reduction)
1353////////////////////////////////////////////////////////////////////////////
1354void t_ssrQc::attitudeEvent(const QString& staID, const QString& prn, t_attTrack& tr,
1355 const QString& end) {
1356 if (tr.event.size() < 3) {
1357 return;
1358 }
1359 double sxx = 0.0, sxy = 0.0, syy = 0.0, srr = 0.0, maxX = 0.0, maxPsi = 0.0;
1360 for (const t_attSample& ss : tr.event) {
1361 double x = ss.p - tr.p0;
1362 double y = ss.dc - tr.dc0;
1363 sxx += x * x; sxy += x * y; syy += y * y; srr += (y - x) * (y - x);
1364 if (fabs(x) > fabs(maxX)) maxX = x;
1365 if (fabs(ss.dpsi - tr.dpsi0) > fabs(maxPsi)) maxPsi = ss.dpsi - tr.dpsi0;
1366 }
1367 int nn = tr.event.size();
1368 // changes at the end of the turn: mean of the last 5 minutes
1369 double tEnd = tr.event.last().t, xEnd = 0.0, yEnd = 0.0;
1370 int nEnd = 0;
1371 for (const t_attSample& ss : tr.event) {
1372 if (tEnd - ss.t <= 300.0) {
1373 xEnd += ss.p - tr.p0; yEnd += ss.dc - tr.dc0; ++nEnd;
1374 }
1375 }
1376 xEnd /= nEnd; yEnd /= nEnd;
1377 double rmsObs = sqrt(syy / nn);
1378 double rmsRes = sqrt(srr / nn);
1379 double slope = (sxx > 0.0) ? sxy / sxx : 0.0;
1380
1381 bncTime t1, t2;
1382 t1.set(int(tr.event.first().t / 604800.0), fmod(tr.event.first().t, 604800.0));
1383 t2.set(int(tEnd / 604800.0), fmod(tEnd, 604800.0));
1384 QString verdict;
1385 if (fabs(maxX) < ATT_MIN_PRED) {
1386 // the consensus is assumed to follow BNC's attitude model; a larger clock
1387 // change shows that the other ACs model this turn differently
1388 verdict = (rmsObs >= ATT_MIN_PRED) ? "clock change not explained by the yaw difference "
1389 "(the other ACs model this turn differently?)"
1390 : "predicted change too small to assess";
1391 }
1392 else if (slope > 0.7 && slope < 1.3 && rmsRes < 0.5 * rmsObs) {
1393 verdict = "SSR yaw consistent with the clocks";
1394 }
1395 else {
1396 verdict = "SSR yaw NOT consistent with the clocks";
1397 }
1398 QString line = QString("attitude check %1 %2-%3: yaw difference to the model %4 deg, clock change vs. "
1399 "consensus %5 cm, predicted %6 cm (max %7 cm), slope %8, clock RMS %9 -> %10 cm: %11")
1400 .arg(prn).arg(QString::fromStdString(t1.timestr(0))).arg(QString::fromStdString(t2.timestr(0)))
1401 .arg(maxPsi * 180.0 / M_PI, 0, 'f', 0)
1402 .arg(yEnd * 100.0, 0, 'f', 1).arg(xEnd * 100.0, 0, 'f', 1).arg(maxX * 100.0, 0, 'f', 1)
1403 .arg(slope, 0, 'f', 2).arg(rmsObs * 100.0, 0, 'f', 1).arg(rmsRes * 100.0, 0, 'f', 1)
1404 .arg(verdict);
1405 if (!end.isEmpty()) {
1406 line += " (" + end + ")";
1407 }
1408 _attEvents[staID][prn[0].toLatin1()] << line;
1409}
1410
1411// Ionospheric model (VTEC)
1412////////////////////////////////////////////////////////////////////////////
1413void t_ssrQc::slotNewTec(t_vTec vTec) {
1414 QMutexLocker locker(&_mutex);
1415 if (vTec._layers.empty()) {
1416 return;
1417 }
1418 QString sta = QString::fromStdString(vTec._staID);
1419 if (!_excluded.contains(sta) || sta == _reference) {
1420 QMap<double, t_vTec>& hist = _vtecHist[sta];
1421 hist[tKey(vTec._time)] = vTec;
1422 while (!hist.isEmpty() && tKey(vTec._time) - hist.firstKey() > VTEC_HIST) {
1423 hist.erase(hist.begin());
1424 }
1425 }
1426 if (selected(vTec._staID)) {
1427 newEpoch(vTec._staID, 'V', VTEC, vTec._time, vTec._updateInt, "VTEC");
1428 QStringList layers;
1429 for (const t_vTecLayer& layer : vTec._layers) {
1430 layers << QString("%1 km (degree/order %2/%3)").arg(layer._height / 1000.0, 0, 'f', 0)
1431 .arg(layer._C.Nrows() - 1).arg(layer._C.Ncols() - 1);
1432 }
1433 _vtecStat[sta].model = QString("%1 layer(s): %2").arg(vTec._layers.size()).arg(layers.join(", "));
1434 }
1435 checkInterval(vTec._time);
1436}
1437
1438// VTEC [TECU] of a model at a geocentric latitude and longitude [rad] and
1439// epoch: spherical harmonics in the sun-fixed frame as used in PPP, sum of
1440// the layers (negative layer values set to zero as in PPP)
1441////////////////////////////////////////////////////////////////////////////
1442double t_ssrQc::vtecAt(const t_vTec& vTec, double lat, double lon, const bncTime& tt, bool& negative) {
1443 double epoch = fmod(tt.gpssec(), 86400.0);
1444 double lonS = fmod(lon + (epoch - 50400.0) * M_PI / 43200.0, 2.0 * M_PI);
1445 double vtec = 0.0;
1446 negative = false;
1447 for (const t_vTecLayer& layer : vTec._layers) {
1448 int N = layer._C.Nrows() - 1;
1449 int M = layer._C.Ncols() - 1;
1450 double vv = 0.0;
1451 for (int n = 0; n <= N; n++) {
1452 for (int m = 0; m <= min(n, M); m++) {
1453 double pnm = associatedLegendreFunction(n, m, sin(lat));
1454 double fac = (m == 0) ? sqrt(2.0 * n + 1.0)
1455 : sqrt(2.0 * (2.0 * n + 1.0) * factorial(n - m) / factorial(n + m));
1456 vv += (layer._C[n][m] * cos(m * lonS) + layer._S[n][m] * sin(m * lonS)) * pnm * fac;
1457 }
1458 }
1459 if (vv < 0.0) {
1460 negative = true;
1461 vv = 0.0;
1462 }
1463 vtec += vv;
1464 }
1465 return vtec;
1466}
1467
1468// VTEC comparison: each model (latest one not older than twice its update
1469// interval) evaluated on a global grid and compared with the median of the
1470// other AC solutions (one vote per solution, own AC left out, combination
1471// products not voting) or with the reference stream
1472////////////////////////////////////////////////////////////////////////////
1473void t_ssrQc::compareVtec(const bncTime& tt) {
1474 double tk = tKey(tt);
1475
1476 QMap<QString, const t_vTec*> models;
1477 QMapIterator<QString, QMap<double, t_vTec> > itH(_vtecHist);
1478 while (itH.hasNext()) {
1479 itH.next();
1480 QMap<double, t_vTec>::const_iterator it = itH.value().upperBound(tk);
1481 if (it == itH.value().constBegin()) {
1482 continue;
1483 }
1484 --it;
1485 const t_vTec& vTec = it.value();
1486 double interval = (vTec._updateInt < unsigned(ssrUpdateInt.size()) && ssrUpdateInt[vTec._updateInt] > 0)
1487 ? ssrUpdateInt[vTec._updateInt] : VTEC_CMP_SAMPL;
1488 double maxAge = min(3600.0, max(120.0, 2.0 * interval));
1489 if (tk - it.key() <= maxAge) {
1490 models[itH.key()] = &vTec;
1491 }
1492 }
1493 if (models.isEmpty()) {
1494 return;
1495 }
1496
1497 // grid values of all models
1498 QVector<QPair<double, double> > grid;
1499 for (double lat = -80.0; lat <= 80.0 + 1e-6; lat += VTEC_GRID_LAT) {
1500 for (double lon = -180.0; lon < 180.0 - 1e-6; lon += VTEC_GRID_LON) {
1501 grid << QPair<double, double>(lat * M_PI / 180.0, lon * M_PI / 180.0);
1502 }
1503 }
1504 QMap<QString, QVector<double> > val;
1505 QMapIterator<QString, const t_vTec*> itM(models);
1506 while (itM.hasNext()) {
1507 itM.next();
1508 QVector<double>& vv = val[itM.key()];
1509 vv.resize(grid.size());
1510 bool selectedSta = selected(itM.key().toStdString());
1511 t_vtecStat* st = selectedSta ? &_vtecStat[itM.key()] : 0;
1512 for (int ii = 0; ii < grid.size(); ii++) {
1513 bool negative = false;
1514 vv[ii] = vtecAt(*itM.value(), grid[ii].first, grid[ii].second, tt, negative);
1515 if (st) {
1516 if (st->numGrid == 0 || vv[ii] < st->minVal) st->minVal = vv[ii];
1517 if (st->numGrid == 0 || vv[ii] > st->maxVal) st->maxVal = vv[ii];
1518 st->numGrid += 1;
1519 if (negative) st->numNeg += 1;
1520 }
1521 }
1522 }
1523
1524 // comparison
1525 for (const QString& staID : models.keys()) {
1526 if (!selected(staID.toStdString())) {
1527 continue;
1528 }
1529 QMap<QString, QStringList> perSol; // solution: streams
1530 for (const QString& oo : models.keys()) {
1531 if (oo == staID) continue;
1532 if (_reference == "CONSENSUS") {
1533 if (!votes(oo) || acOf(oo) == acOf(staID)) continue;
1534 }
1535 else if (oo != _reference) {
1536 continue;
1537 }
1538 perSol[solOf(oo)] << oo;
1539 }
1540 if (perSol.isEmpty()) {
1541 continue;
1542 }
1543 t_vtecStat& st = _vtecStat[staID];
1544 st.numCmp += 1;
1545 st.numSol += perSol.size();
1546 for (int ii = 0; ii < grid.size(); ii++) {
1547 QVector<double> solVal;
1548 for (const QStringList& streams : perSol) {
1549 QVector<double> vv;
1550 for (const QString& oo : streams) vv << val[oo][ii];
1551 solVal << median(vv);
1552 }
1553 double diff = val[staID][ii] - median(solVal);
1554 st.numDiff += 1;
1555 st.sDiff += diff;
1556 st.sDiff2 += diff * diff;
1557 st.maxAbs = max(st.maxAbs, fabs(diff));
1558 }
1559 }
1560}
1561
1562
1563// Write the report of the current interval and reset the statistics
1564////////////////////////////////////////////////////////////////////////////
1565void t_ssrQc::writeReport(bool final) {
1566 if (_epoStat.isEmpty()) {
1567 return;
1568 }
1569 bncTime endTime = final ? _lastTime : _intervalStart + _interval;
1570
1571 // IODs not received: early or unknown (pending ones younger than
1572 // EPH_EARLY_MAX are decided in the next interval)
1573 for (const QString& satKey : _pendingIod.keys()) {
1574 resolvePendingIod(satKey, final);
1575 }
1576
1577 // Healthy and current broadcast ephemerides per system
1578 QMap<char, QSet<QString> > ephSats;
1579 for (const QString& prnInt : _ephUser.prnList()) {
1580 t_eph* eph = _ephUser.ephLast(prnInt);
1581 if (eph && eph->checkState() == t_eph::ok && !outDatedBcep(eph, endTime)) {
1582 ephSats[eph->prn().system()].insert(QString::fromStdString(eph->prn().toString()));
1583 }
1584 }
1585
1586 // Streams and systems
1587 QMap<QString, QSet<char> > streams;
1588 QMapIterator<QString, t_epoStat> itEpo(_epoStat);
1589 while (itEpo.hasNext()) {
1590 itEpo.next();
1591 QStringList hlp = itEpo.key().split(' ');
1592 streams[hlp[0]].insert(hlp[1][0].toLatin1());
1593 }
1594
1595 QMapIterator<QString, QSet<char> > itSta(streams);
1596 while (itSta.hasNext()) {
1597 itSta.next();
1598 const QString& staID = itSta.key();
1599 QList<char> systems = itSta.value().values();
1600 std::sort(systems.begin(), systems.end());
1601 ofstream& out = streamOut(staID, _intervalStart);
1602 if (final) {
1603 endTime = _staLast.value(staID, _lastTime);
1604 if (endTime < _intervalStart) { // stream without data in the last interval
1605 endTime = _lastTime;
1606 }
1607 }
1608 out << endl << "=== SSR QC " << staID.toStdString() << ' '
1609 << _intervalStart.datestr() << ' ' << _intervalStart.timestr(0)
1610 << " - " << endTime.datestr() << ' ' << endTime.timestr(0)
1611 << (final ? " (end of data)" : "") << " ===" << endl
1612 << " Sys Type Epochs Interval nom/med/max [s] Gaps Out-of-order"
1613 << " Latency med/max [s] Sats" << endl;
1614 for (char sys : systems) {
1615 for (int type = ORB; type <= VTEC; type++) {
1616 QString kk = QString("%1 %2 %3").arg(staID).arg(sys).arg(type);
1617 if (!_epoStat.contains(kk)) {
1618 continue;
1619 }
1620 const t_epoStat& stat = _epoStat[kk];
1621 double medInt = median(stat.intervals);
1622 double maxInt = stat.intervals.isEmpty() ? 0.0 :
1623 *std::max_element(stat.intervals.begin(), stat.intervals.end());
1624 double ref = max(double(stat.nominal), medInt);
1625 unsigned gaps = 0;
1626 for (double dt : stat.intervals) {
1627 if (ref > 0.0 && dt > 2.0 * ref) {
1628 ++gaps;
1629 }
1630 }
1631 double maxLat = stat.latencies.isEmpty() ? 0.0 :
1632 *std::max_element(stat.latencies.begin(), stat.latencies.end());
1633 out << " " << sys << " " << left << setw(10) << TYPE_NAME[type] << right
1634 << setw(8) << stat.numEpo
1635 << setw(10) << stat.nominal << " /" << setw(6) << setprecision(1) << fixed << medInt
1636 << " /" << setw(7) << maxInt
1637 << setw(6) << gaps << setw(14) << stat.numOutOfOrder
1638 << setw(10) << median(stat.latencies) << " /" << setw(7) << maxLat
1639 << setw(7) << stat.sats.size() << endl;
1640 }
1641 }
1642
1643 // Per system: completeness, ephemeris, biases, plausibility
1644 for (char sys : systems) {
1645 // Ionosphere (VTEC): model, values on the grid, comparison
1646 if (sys == 'V') {
1647 QStringList lines;
1648 QString kk = QString("%1 %2 %3").arg(staID).arg(sys).arg(int(VTEC));
1649 if (_epoStat.contains(kk)) {
1650 const t_epoStat& stat = _epoStat[kk];
1651 double medInt = median(stat.intervals);
1652 if (stat.nominal > 0 && stat.intervals.size() > 1 &&
1653 (medInt > 1.5 * stat.nominal || medInt < stat.nominal / 1.5)) {
1654 lines << QString("VTEC: declared update interval %1 s, actual %2 s")
1655 .arg(stat.nominal).arg(medInt, 0, 'f', 1);
1656 }
1657 }
1658 if (_vtecStat.contains(staID)) {
1659 const t_vtecStat& vs = _vtecStat[staID];
1660 if (!vs.model.isEmpty()) {
1661 lines << "VTEC model: " + vs.model;
1662 }
1663 if (vs.numGrid) {
1664 lines << QString("VTEC on a global %1 x %2 deg grid: %3 ... %4 TECU, negative (set to zero) %5 %")
1665 .arg(VTEC_GRID_LAT, 0, 'f', 0).arg(VTEC_GRID_LON, 0, 'f', 0)
1666 .arg(vs.minVal, 0, 'f', 1).arg(vs.maxVal, 0, 'f', 1)
1667 .arg(100.0 * vs.numNeg / vs.numGrid, 0, 'f', 1);
1668 }
1669 if (vs.numDiff) {
1670 QString refText = (_reference == "CONSENSUS")
1671 ? QString("consensus of the other ACs (%1 solutions on average)")
1672 .arg(double(vs.numSol) / vs.numCmp, 0, 'f', 1)
1673 : QString("stream %1").arg(_reference);
1674 double mean = vs.sDiff / vs.numDiff;
1675 double rms = sqrt(vs.sDiff2 / vs.numDiff);
1676 lines << QString("VTEC comparison with %1, %2 epochs: mean %3 TECU, RMS %4 TECU, max |diff| %5 TECU")
1677 .arg(refText).arg(vs.numCmp).arg(mean, 0, 'f', 2).arg(rms, 0, 'f', 2)
1678 .arg(vs.maxAbs, 0, 'f', 1);
1679 }
1680 else {
1681 lines << "VTEC not compared: no other model available";
1682 }
1683 }
1684 for (const QString& line : lines) {
1685 out << " " << sys << " " << line.toStdString() << endl;
1686 }
1687 continue;
1688 }
1689 QMap<QString, unsigned> iodEarly, outdated;
1690 double maxEarly = 0.0;
1691 QMap<QString, unsigned> missOrb, missClk, missCB, missPB, iodUnknown, unhealthy, noEph,
1692 jumps, missRef, noYaw, yawPartly, pbJumps;
1693 unsigned numPB = 0, numYaw = 0, yawSats = 0;
1694 double maxRadial = 0.0, maxAlongCross = 0.0;
1695 QString maxRadialPrn, maxAlongCrossPrn;
1696 QVector<double> biasIF;
1697 double maxBiasIF = 0.0;
1698 QString biasIFPrn;
1699 const QSet<QString>& ephs = ephSats[sys];
1700 for (int type = ORB; type <= PBIAS; type++) {
1701 QString kk = QString("%1 %2 %3").arg(staID).arg(sys).arg(type);
1702 if (!_epoStat.contains(kk)) {
1703 continue;
1704 }
1705 QMap<QString, unsigned>& miss = (type == ORB) ? missOrb : (type == CLK) ? missClk :
1706 (type == CBIAS) ? missCB : missPB;
1707 for (const QString& prn : ephs) {
1708 if (!_epoStat[kk].sats.contains(prn)) {
1709 miss[prn] = 0;
1710 }
1711 }
1712 }
1713 QMapIterator<QString, t_satStat> itSat(_satStat);
1714 while (itSat.hasNext()) {
1715 itSat.next();
1716 QStringList hlp = itSat.key().split(' ');
1717 if (hlp[0] != staID || hlp[1][0].toLatin1() != sys) {
1718 continue;
1719 }
1720 const QString& prn = hlp[1];
1721 const t_satStat& stat = itSat.value();
1722 if (stat.iodUnknown) iodUnknown[prn] = stat.iodUnknown;
1723 if (stat.iodEarly) {
1724 iodEarly[prn] = stat.iodEarly;
1725 maxEarly = max(maxEarly, stat.maxEarly);
1726 }
1727 if (stat.ephOutdated) outdated[prn] = stat.ephOutdated;
1728 if (stat.ephUnhealthy) unhealthy[prn] = stat.ephUnhealthy;
1729 if (stat.noEph) noEph[prn] = stat.noEph;
1730 if (stat.clkJumps) jumps[prn] = stat.clkJumps;
1731 if (stat.pbJumps) pbJumps[prn] = stat.pbJumps;
1732 if (stat.maxRadial > maxRadial) {
1733 maxRadial = stat.maxRadial;
1734 maxRadialPrn = prn;
1735 }
1736 if (stat.maxAlongCross > maxAlongCross) {
1737 maxAlongCross = stat.maxAlongCross;
1738 maxAlongCrossPrn = prn;
1739 }
1740 // only satellites with corrections (providers list satellites
1741 // without corrections with zero biases, e.g. GMV E14/E18)
1742 if (!stat.missingRefSig.isEmpty() && (stat.numClk || stat.numOrb)) {
1743 QStringList sigs = stat.missingRefSig.values();
1744 sigs.sort();
1745 missRef[prn + "[" + sigs.join("/") + "]"] = 0;
1746 }
1747 if (stat.refBiasOK) {
1748 biasIF.push_back(stat.biasIF);
1749 if (biasIFPrn.isEmpty() || fabs(stat.biasIF) > maxBiasIF) {
1750 maxBiasIF = fabs(stat.biasIF);
1751 biasIFPrn = prn;
1752 }
1753 }
1754 if (stat.numPB) {
1755 numPB += stat.numPB;
1756 numYaw += stat.numYaw;
1757 if (stat.numYaw) {
1758 yawSats++;
1759 if (stat.numYaw < stat.numPB) {
1760 yawPartly[prn] = stat.numPB - stat.numYaw;
1761 }
1762 }
1763 else {
1764 noYaw[prn] = 0;
1765 }
1766 }
1767 }
1768 // only findings are listed
1769 QStringList lines;
1770 for (int type = ORB; type <= PBIAS; type++) {
1771 QString kk = QString("%1 %2 %3").arg(staID).arg(sys).arg(type);
1772 if (_epoStat.contains(kk)) {
1773 const t_epoStat& stat = _epoStat[kk];
1774 double medInt = median(stat.intervals);
1775 if (stat.nominal > 0 && stat.intervals.size() > 1 &&
1776 (medInt > 1.5 * stat.nominal || medInt < stat.nominal / 1.5)) {
1777 lines << QString("%1: declared update interval %2 s, actual %3 s")
1778 .arg(TYPE_NAME[type]).arg(stat.nominal).arg(medInt, 0, 'f', 1);
1779 }
1780 }
1781 }
1782 auto addSats = [&lines](const QString& text, const QMap<QString, unsigned>& sats) {
1783 if (!sats.isEmpty()) {
1784 lines << text + ":" + satList(sats);
1785 }
1786 };
1787 addSats("orbit corrections missing (healthy broadcast ephemeris available)", missOrb);
1788 addSats("clock corrections missing (healthy broadcast ephemeris available)", missClk);
1789 addSats("code biases missing (healthy broadcast ephemeris available)", missCB);
1790 addSats("phase biases missing (healthy broadcast ephemeris available)", missPB);
1791 addSats("corrections referring to an IOD of no received broadcast ephemeris", iodUnknown);
1792 if (!iodEarly.isEmpty()) {
1793 addSats(QString("corrections referring to an IOD received from the ephemeris stream(s) "
1794 "only later (up to %1 s)").arg(maxEarly, 0, 'f', 0), iodEarly);
1795 }
1796 addSats("corrections referring to a broadcast ephemeris outside its validity", outdated);
1797 addSats("corrections for unhealthy broadcast ephemeris", unhealthy);
1798 addSats("corrections for satellites without broadcast ephemeris", noEph);
1799 QString staSys = QString("%1 %2").arg(staID).arg(sys);
1800 if (_codeSignals.contains(staSys)) {
1801 QStringList sigs = _codeSignals[staSys].values();
1802 sigs.sort();
1803 lines << "code bias signals: " + sigs.join(" ");
1804 addSats("code biases of the reference signals missing", missRef);
1805 if (biasIF.size() > 1) {
1806 double mean = 0.0;
1807 for (double bb : biasIF) mean += bb / biasIF.size();
1808 double var = 0.0;
1809 for (double bb : biasIF) var += (bb - mean) * (bb - mean) / biasIF.size();
1810 // the median shows whether the clocks refer to other signals (all
1811 // satellites) or single satellites have inconsistent biases
1812 QVector<double> absIF;
1813 for (double bb : biasIF) absIF << fabs(bb);
1814 lines << QString("ionosphere-free combination B_IF of the reference signal biases: "
1815 "std. dev. %1 m, median |B_IF| %2 m, max |B_IF| %3 m (%4) (%5 satellites)")
1816 .arg(sqrt(var), 0, 'f', 3).arg(median(absIF), 0, 'f', 3).arg(maxBiasIF, 0, 'f', 3)
1817 .arg(biasIFPrn).arg(biasIF.size());
1818 }
1819 }
1820 compareCodeBiases(staID, sys, lines);
1821 if (_phaseSignals.contains(staSys)) {
1822 QStringList sigs = _phaseSignals[staSys].values();
1823 sigs.sort();
1824 lines << "phase bias signals: " + sigs.join(" ");
1825 }
1826 if (_pbIndStat.contains(staSys)) {
1827 const t_pbIndStat& ind = _pbIndStat[staSys];
1828 // value list "1" or "0 (12 %), 1 (88 %)"
1829 auto values = [](const QMap<int, unsigned>& counts) {
1830 unsigned total = 0;
1831 for (unsigned nn : counts) total += nn;
1832 QStringList parts;
1833 QMapIterator<int, unsigned> it(counts);
1834 while (it.hasNext()) {
1835 it.next();
1836 parts << ((counts.size() == 1) ? QString::number(it.key())
1837 : QString("%1 (%2 %)").arg(it.key())
1838 .arg(100.0 * it.value() / total, 0, 'f', 0));
1839 }
1840 return parts.join(", ");
1841 };
1842 QStringList formats = ind.format.keys();
1843 QString line = "phase bias format and indicators: " + formats.join("/");
1844 if (!ind.mwInd.isEmpty()) {
1845 line += QString(", dispersive bias consistency indicator %1, MW consistency indicator %2")
1846 .arg(values(ind.dispInd)).arg(values(ind.mwInd));
1847 }
1848 else {
1849 line += " (no consistency indicators)";
1850 }
1851 lines << line;
1852 QStringList sigParts;
1853 QMapIterator<QString, QMap<int, unsigned> > itSig(ind.intInd);
1854 while (itSig.hasNext()) {
1855 itSig.next();
1856 sigParts << QString("%1 integer %2 / wide-lane %3").arg(itSig.key())
1857 .arg(values(itSig.value())).arg(values(ind.wlInd.value(itSig.key())));
1858 }
1859 if (!sigParts.isEmpty()) {
1860 lines << "phase bias integer / wide-lane integer indicators: " + sigParts.join("; ");
1861 }
1862 addSats("phase bias discontinuity counter changes", pbJumps);
1863 }
1864 bool mwAny = false;
1865 for (const QMap<char, t_mwStat>& mm : _mwStat.value(staID)) {
1866 mwAny = mwAny || mm.contains(sys);
1867 }
1868 QString mwSig1, mwSig2;
1869 t_frequency::type mwFrq1, mwFrq2;
1870 if (mwAny && refSignals(sys, mwSig1, mwSig2, mwFrq1, mwFrq2)) {
1871 // phase signals used (see mwBias)
1872 QStringList used;
1873 QStringList pSigs = _phaseSignals.value(staSys).values();
1874 pSigs.sort();
1875 for (const QString& sig : {mwSig1, mwSig2}) {
1876 QString uu = pSigs.contains(sig) ? sig : QString();
1877 for (const QString& ps : pSigs) {
1878 if (uu.isEmpty() && ps[0] == sig[0]) uu = ps;
1879 }
1880 used << "L" + uu;
1881 }
1882 lines << QString("MW check: phase biases %1 with the code biases C%2 C%3 of the reference signals, "
1883 "wide-lane cycles (%4 m)")
1884 .arg(used.join(" ")).arg(mwSig1).arg(mwSig2)
1885 .arg(t_CST::c / (t_CST::freq(mwFrq1, 0) - t_CST::freq(mwFrq2, 0)), 0, 'f', 3);
1886 }
1887 if (_mwStat.contains(staID)) {
1888 QMapIterator<QString, QMap<char, t_mwStat> > itOther(_mwStat[staID]);
1889 while (itOther.hasNext()) {
1890 itOther.next();
1891 if (!itOther.value().contains(sys)) continue;
1892 const t_mwStat& ms = itOther.value()[sys];
1893 if (ms.numRes == 0) continue;
1894 double rms = sqrt(ms.sRes2 / ms.numRes);
1895 QString verdict = (rms < MW_OK) ? "consistent (integer wide-lane biases)" :
1896 (rms > MW_BAD) ? "NOT consistent" : "not clearly consistent";
1897 lines << QString("MW biases vs. %1 (%2 epochs, %3 satellites): fractional parts about the "
1898 "common offset %4 cycles: RMS %5 cycles, %6")
1899 .arg(itOther.key()).arg(ms.numEpo).arg(ms.satRes.size())
1900 .arg(ms.offset, 0, 'f', 2).arg(rms, 0, 'f', 3).arg(verdict);
1901 QStringList dev;
1902 QMapIterator<QString, QPair<unsigned, double> > itS(ms.satRes);
1903 while (itS.hasNext()) {
1904 itS.next();
1905 double rmsSat = sqrt(itS.value().second / itS.value().first);
1906 if (rmsSat > MW_BAD) {
1907 dev << QString("%1(%2)").arg(itS.key()).arg(rmsSat, 0, 'f', 2);
1908 }
1909 }
1910 if (!dev.isEmpty() && rms < MW_BAD) {
1911 lines << QString("MW biases vs. %1: satellites with RMS > %2 cycles: %3")
1912 .arg(itOther.key()).arg(MW_BAD, 0, 'f', 2).arg(dev.join(" "));
1913 }
1914 }
1915 }
1916 if (numPB) {
1917 if (numYaw == 0) {
1918 lines << "yaw angle: not provided";
1919 }
1920 else {
1921 lines << QString("yaw angle: provided for %1 of %2 satellites (%3 % of the phase bias records)")
1922 .arg(yawSats).arg(yawSats + noYaw.size()).arg(100.0 * numYaw / numPB, 0, 'f', 1);
1923 addSats("phase biases without yaw angle", noYaw);
1924 addSats("phase biases partly without yaw angle (records)", yawPartly);
1925 }
1926 }
1927 for (const QString& line : _attEvents.value(staID).value(sys)) {
1928 lines << line;
1929 }
1930 addSats(QString("clock jumps > %1 m").arg(MAX_CLK_JUMP), jumps);
1931 if (!maxRadialPrn.isEmpty()) {
1932 lines << QString("largest orbit corrections: radial %1 m (%2), along/cross %3 m (%4)")
1933 .arg(maxRadial, 0, 'f', 2).arg(maxRadialPrn).arg(maxAlongCross, 0, 'f', 2).arg(maxAlongCrossPrn);
1934 }
1935 // stream comparison
1936 if (_cmpStat.contains(staID)) {
1937 unsigned nSat = 0, nClk = 0, nOrb = 0, nSis = 0;
1938 double sClk = 0.0, sR = 0.0, sA = 0.0, sC = 0.0, sSis = 0.0;
1939 double vClk = 0.0, vSis = 0.0; // sums of squares about the satellite means
1940 QMap<QString, double> rmsSis, rmsClk, rmsOrb;
1941 QMap<QString, unsigned> notReferred;
1942 QMapIterator<QString, t_cmpStat> itC(_cmpStat[staID]);
1943 while (itC.hasNext()) {
1944 itC.next();
1945 if (itC.key()[0].toLatin1() != sys) continue;
1946 const t_cmpStat& st = itC.value();
1947 if (st.numClk == 0 && st.numOrb == 0) {
1948 if (st.clkNotReferred) notReferred[itC.key()] = 0;
1949 continue;
1950 }
1951 ++nSat;
1952 if (st.clkNotReferred) notReferred[itC.key()] = 0;
1953 nClk += st.numClk; sClk += st.sClk;
1954 nOrb += st.numOrb; sR += st.sR; sA += st.sA; sC += st.sC;
1955 nSis += st.numSis; sSis += st.sSis;
1956 if (st.numClk) vClk += st.sClk - st.mClk * st.mClk / st.numClk;
1957 if (st.numSis) vSis += st.sSis - st.mSis * st.mSis / st.numSis;
1958 if (st.numSis) rmsSis[itC.key()] = sqrt(st.sSis / st.numSis);
1959 else if (st.numClk) rmsClk[itC.key()] = sqrt(st.sClk / st.numClk);
1960 if (st.numOrb) rmsOrb[itC.key()] = sqrt((st.sR + st.sA + st.sC) / st.numOrb);
1961 }
1962 if (nSat) {
1963 QString refText = (_reference == "CONSENSUS") ? QString("consensus of the other ACs")
1964 : QString("stream %1").arg(_reference);
1965 QStringList parts;
1966 if (nClk) parts << QString("clock %1 (STD %2)").arg(sqrt(sClk / nClk), 0, 'f', 3)
1967 .arg(sqrt(max(0.0, vClk) / nClk), 0, 'f', 3);
1968 if (nOrb) parts << QString("radial %1, along %2, cross %3")
1969 .arg(sqrt(sR / nOrb), 0, 'f', 3).arg(sqrt(sA / nOrb), 0, 'f', 3)
1970 .arg(sqrt(sC / nOrb), 0, 'f', 3);
1971 if (nSis) parts << QString("SIS (radial - clock) %1 (STD %2)").arg(sqrt(sSis / nSis), 0, 'f', 3)
1972 .arg(sqrt(max(0.0, vSis) / nSis), 0, 'f', 3);
1973 lines << QString("comparison with %1 (%2 satellites), RMS (STD about the satellite means) [m]: %3")
1974 .arg(refText).arg(nSat).arg(parts.join(", "));
1975 if (!nOrb) {
1976 lines << "orbits not compared: no other stream with the same reference point (APC/CoM)";
1977 }
1978 addSats("clocks not compared (code biases of the reference signals missing)", notReferred);
1979 auto deviating = [&lines](const QString& what, const QMap<QString, double>& rms) {
1980 if (rms.size() < 2) return;
1981 double med = median(rms.values().toVector());
1982 QStringList dev;
1983 QMapIterator<QString, double> itR(rms);
1984 while (itR.hasNext()) {
1985 itR.next();
1986 if (itR.value() > max(DEV_MIN, DEV_FACTOR * med)) {
1987 dev << QString("%1(%2)").arg(itR.key()).arg(itR.value(), 0, 'f', 2);
1988 }
1989 }
1990 if (!dev.isEmpty()) {
1991 lines << QString("satellites deviating from the reference, RMS %1 [m]: %2").arg(what).arg(dev.join(" "));
1992 }
1993 };
1994 deviating("SIS", rmsSis);
1995 deviating("clock", rmsClk);
1996 deviating("orbit (3D)", rmsOrb);
1997 }
1998 }
1999 for (const QString& line : lines) {
2000 out << " " << sys << " " << line.toStdString() << endl;
2001 }
2002 }
2003 out.flush();
2004 }
2005
2006 emit newLogRecord(t_logRecord::message(t_logRecord::info, QString("SSR QC: report %1 %2 of %3 stream(s) written to %4")
2007 .arg(QString::fromStdString(_intervalStart.datestr()))
2008 .arg(QString::fromStdString(_intervalStart.timestr(0)))
2009 .arg(streams.size()).arg(_dirName).toLatin1()), false);
2010
2011 _cmpStat.clear();
2012 _cmpEpochs.clear();
2013 _attEvents.clear();
2014 _pbIndStat.clear();
2015 _mwStat.clear();
2016 for (QMap<QString, t_vtecStat>::iterator it = _vtecStat.begin(); it != _vtecStat.end(); ++it) {
2017 t_vtecStat fresh;
2018 fresh.model = it.value().model;
2019 it.value() = fresh;
2020 }
2021
2022 // reset, keeping the state needed across intervals
2023 for (QMap<QString, t_epoStat>::iterator it = _epoStat.begin(); it != _epoStat.end(); ++it) {
2024 t_epoStat& stat = it.value();
2025 bncTime last = stat.last;
2026 int nominal = stat.nominal;
2027 stat = t_epoStat();
2028 stat.last = last;
2029 stat.nominal = nominal;
2030 }
2031 for (QMap<QString, t_satStat>::iterator it = _satStat.begin(); it != _satStat.end(); ++it) {
2032 t_satStat& stat = it.value();
2033 t_satStat fresh;
2034 fresh.lastClkTime = stat.lastClkTime;
2035 fresh.lastIod = stat.lastIod;
2036 fresh.lastClk = stat.lastClk;
2037 fresh.missingRefSig = stat.missingRefSig;
2038 fresh.refBiasOK = stat.refBiasOK;
2039 fresh.biasIF = stat.biasIF;
2040 stat = fresh;
2041 }
2042}
Note: See TracBrowser for help on using the repository browser.