Changeset 11218 in ntrip for trunk/BNC/src/ssrQc.cpp
- Timestamp:
- Nov 23, 2026, 9:48:49 PM (8 hours ago)
- File:
-
- 1 edited
-
trunk/BNC/src/ssrQc.cpp (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/ssrQc.cpp
r11214 r11218 59 59 const double EPH_IOD_REUSE = 21600.0; // [s] an outdated data set this far from the epoch: IOD reused 60 60 const unsigned EPH_KEPT = 30; // data sets kept per satellite 61 const double OUTAGE_FRACTION = 0.75; // common outage: streams with a gap at the same time 62 const unsigned OUTAGE_MIN_STA = 3; // (at least this many) 63 const double OUTAGE_LAT_AFTER = 120.0; // [s] latencies left out after a common outage 64 const double MAX_EPOCH_OFFSET = 900.0; // [s] corrections with epochs further from their reception not used 61 65 const double CMP_SAMPL = 30.0; // [s] sampling of the stream comparison 62 66 const double CMP_DELAY = 60.0; // [s] epochs compared when data this much newer arrived … … 370 374 if (stat.last.valid()) { 371 375 stat.intervals.push_back(time - stat.last); 376 stat.intervalEnds.push_back(tKey(time)); 372 377 } 373 378 stat.last = time; 374 379 stat.numEpo += 1; 375 380 stat.latencies.push_back(currentTime() - time); 381 stat.latencyEpochs.push_back(tKey(time)); 376 382 } 377 383 else if (time < stat.last) { … … 450 456 } 451 457 458 // Switch of the orbit corrections to another IOD 459 //////////////////////////////////////////////////////////////////////////// 460 void t_ssrQc::checkIodSwitch(t_satStat& stat, const QString& staID, const QString& prnInt, 461 unsigned iod, const bncTime& time) { 462 bool first = !stat.orbIodSet; 463 unsigned prevIod = stat.orbIod; 464 stat.orbIodSet = true; 465 stat.orbIod = iod; 466 if (!first && iod == prevIod) { 467 return; 468 } 469 // data set of an IOD (not one with a reused IOD) 470 auto dataSet = [this, &prnInt, &time](unsigned ii) -> t_eph* { 471 t_eph* eph = _ephUser.ephWithIOD(prnInt, ii); 472 return (eph && fabs(time - eph->TOC()) <= EPH_IOD_REUSE) ? eph : 0; 473 }; 474 t_eph* eph = dataSet(iod); 475 if (!eph) { 476 return; 477 } 478 if (first || !stat.newestToc.valid()) { 479 stat.newestToc = eph->TOC(); 480 return; 481 } 482 t_eph* prev = dataSet(prevIod); 483 char sys = eph->prn().system(); 484 QString staSys = QString("%1 %2").arg(staID).arg(sys); 485 if (prev && eph->TOC() < prev->TOC()) { 486 _iodSwitch[staSys].back[QString::fromStdString(eph->prn().toString())] += 1; 487 return; 488 } 489 // first switch to this data set (not again after switching back), not 490 // before all broadcast ephemerides may have been received 491 if (!(stat.newestToc < eph->TOC())) { 492 return; 493 } 494 stat.newestToc = eph->TOC(); 495 if (!eph->receptDateTime().isValid() || time - _staStart[staID] < EPH_WARMUP) { 496 return; 497 } 498 bncTime recept(eph->receptDateTime().toString(Qt::ISODate).toStdString()); 499 t_iodSwitchStat& sw = _iodSwitch[staSys]; 500 sw.afterRecept.push_back(currentTime() - recept); 501 if (sys == 'C') { 502 sw.afterToc.push_back(time - eph->TOC()); 503 } 504 } 505 506 // Epoch time far from the reception time, e.g. a GLONASS epoch erroneously 507 // encoded 11758 s ahead (SHA1/GFZ1 22 Nov 2026): not used, as it would move 508 // the report interval (no reports for hours) and distort all statistics 509 //////////////////////////////////////////////////////////////////////////// 510 bool t_ssrQc::badEpoch(const string& staID, const bncTime& time) { 511 if (fabs(currentTime() - time) <= MAX_EPOCH_OFFSET) { 512 return false; 513 } 514 _badEpochs[QString::fromStdString(staID)] += 1; 515 return true; 516 } 517 452 518 // Orbit corrections 453 519 //////////////////////////////////////////////////////////////////////////// … … 455 521 QMutexLocker locker(&_mutex); 456 522 for (const t_orbCorr& corr : orbCorrections) { 523 if (badEpoch(corr._staID, corr._time)) continue; 457 524 if (!_excluded.contains(QString::fromStdString(corr._staID)) || corr._staID == _reference.toStdString()) { 458 525 storeHist(&corr, 0); … … 467 534 checkEph(stat, QString::fromStdString(corr._staID) + ' ' + prn, 468 535 QString::fromStdString(corr._prn.toInternalString()), corr._iod, corr._time, corr._staID); 536 checkIodSwitch(stat, QString::fromStdString(corr._staID), 537 QString::fromStdString(corr._prn.toInternalString()), corr._iod, corr._time); 469 538 double radial = fabs(corr._xr[0]); 470 539 double alongCross = max(fabs(corr._xr[1]), fabs(corr._xr[2])); … … 479 548 QMutexLocker locker(&_mutex); 480 549 for (const t_clkCorr& corr : clkCorrections) { 550 if (badEpoch(corr._staID, corr._time)) continue; 481 551 if (!_excluded.contains(QString::fromStdString(corr._staID)) || corr._staID == _reference.toStdString()) { 482 552 storeHist(0, &corr); … … 515 585 QMutexLocker locker(&_mutex); 516 586 for (const t_satCodeBias& bias : codeBiases) { 587 if (badEpoch(bias._staID, bias._time)) continue; 517 588 bool sel = selected(bias._staID); 518 589 if (_excluded.contains(QString::fromStdString(bias._staID)) && bias._staID != _reference.toStdString()) continue; … … 564 635 QMutexLocker locker(&_mutex); 565 636 for (const t_satPhaseBias& bias : phaseBiases) { 637 if (badEpoch(bias._staID, bias._time)) continue; 566 638 QString staID = QString::fromStdString(bias._staID); 567 639 QString prn = QString::fromStdString(bias._prn.toString()); … … 1516 1588 void t_ssrQc::slotNewTec(t_vTec vTec) { 1517 1589 QMutexLocker locker(&_mutex); 1518 if (vTec._layers.empty()) { 1590 if (vTec._layers.empty() || badEpoch(vTec._staID, vTec._time)) { 1519 1591 return; 1520 1592 } … … 1696 1768 } 1697 1769 1770 // common outages of the input, reported in each stream's report 1771 QVector<t_outage> outages = commonOutages(streams); 1772 auto inOutage = [&outages](double t0, double t1) { // window [t0, t1] overlaps an outage 1773 for (const t_outage& oo : outages) { 1774 if (t0 < oo.end && t1 > oo.start) return true; 1775 } 1776 return false; 1777 }; 1778 auto afterOutage = [&outages](double tt) { 1779 for (const t_outage& oo : outages) { 1780 if (tt > oo.start && tt <= oo.end + OUTAGE_LAT_AFTER) return true; 1781 } 1782 return false; 1783 }; 1784 auto tStr = [](double tt) { 1785 bncTime bt(int(tt / 604800.0), tt - 604800.0 * int(tt / 604800.0)); 1786 return QString::fromStdString(bt.datestr() + ' ' + bt.timestr(0)); 1787 }; 1788 1698 1789 QMapIterator<QString, QSet<char> > itSta(streams); 1699 1790 while (itSta.hasNext()) { … … 1727 1818 double ref = max(double(stat.nominal), medInt); 1728 1819 unsigned gaps = 0; 1729 for (double dt : stat.intervals) { 1730 if (ref > 0.0 && dt > 2.0 * ref) { 1820 for (int ii = 0; ii < stat.intervals.size(); ii++) { 1821 double dt = stat.intervals[ii]; 1822 if (ref > 0.0 && dt > 2.0 * ref && 1823 !inOutage(stat.intervalEnds[ii] - dt, stat.intervalEnds[ii])) { 1731 1824 ++gaps; 1732 1825 } 1733 1826 } 1734 double maxLat = stat.latencies.isEmpty() ? 0.0 : 1735 *std::max_element(stat.latencies.begin(), stat.latencies.end()); 1827 QVector<double> latencies; 1828 for (int ii = 0; ii < stat.latencies.size(); ii++) { 1829 if (!afterOutage(stat.latencyEpochs[ii])) { 1830 latencies.push_back(stat.latencies[ii]); 1831 } 1832 } 1833 double maxLat = latencies.isEmpty() ? 0.0 : 1834 *std::max_element(latencies.begin(), latencies.end()); 1736 1835 out << " " << sys << " " << left << setw(10) << TYPE_NAME[type] << right 1737 1836 << setw(8) << stat.numEpo … … 1739 1838 << " /" << setw(7) << maxInt 1740 1839 << setw(6) << gaps << setw(14) << stat.numOutOfOrder 1741 << setw(10) << median( stat.latencies) << " /" << setw(7) << maxLat1840 << setw(10) << median(latencies) << " /" << setw(7) << maxLat 1742 1841 << setw(7) << stat.sats.size() << endl; 1743 1842 } 1843 } 1844 1845 for (const t_outage& oo : outages) { 1846 out << " common outage of the input " << tStr(oo.start).toStdString() << " - " 1847 << tStr(oo.end).toStdString() << " (" << oo.numSta << " of " << oo.numAll 1848 << " streams): not counted as gaps, latencies until " << int(OUTAGE_LAT_AFTER) 1849 << " s after it left out" << endl; 1850 } 1851 if (_badEpochs.value(staID)) { 1852 out << " corrections with an epoch time more than " << int(MAX_EPOCH_OFFSET) 1853 << " s from their reception, not used: " << _badEpochs.value(staID) << endl; 1744 1854 } 1745 1855 … … 1901 2011 addSats("corrections for satellites without broadcast ephemeris", noEph); 1902 2012 QString staSys = QString("%1 %2").arg(staID).arg(sys); 2013 if (_iodSwitch.contains(staSys)) { 2014 const t_iodSwitchStat& sw = _iodSwitch[staSys]; 2015 // quantiles "min / 10 % / median / max" 2016 auto quant = [](QVector<double> vv) { 2017 std::sort(vv.begin(), vv.end()); 2018 return QString("%1 / %2 / %3 / %4").arg(vv.first(), 0, 'f', 0) 2019 .arg(vv[int(0.1 * (vv.size() - 1))], 0, 'f', 0) 2020 .arg(median(vv), 0, 'f', 0).arg(vv.last(), 0, 'f', 0); 2021 }; 2022 if (!sw.afterRecept.isEmpty()) { 2023 QString line = QString("IOD switch to new data sets (%1), delay after their reception by BNC " 2024 "(ephemeris streams) min / 10 % / median / max: %2 s") 2025 .arg(sw.afterRecept.size()).arg(quant(sw.afterRecept)); 2026 if (!sw.afterToc.isEmpty()) { 2027 line += QString(", after TOC: %1 s").arg(quant(sw.afterToc)); 2028 } 2029 lines << line; 2030 } 2031 addSats("orbit corrections switching back to an older data set", sw.back); 2032 } 1903 2033 if (_codeSignals.contains(staSys)) { 1904 2034 QStringList sigs = _codeSignals[staSys].values(); … … 2115 2245 _cmpStat.clear(); 2116 2246 _cmpEpochs.clear(); 2247 _iodSwitch.clear(); 2248 _badEpochs.clear(); 2117 2249 _attEvents.clear(); 2118 2250 _pbIndStat.clear(); … … 2142 2274 fresh.refBiasOK = stat.refBiasOK; 2143 2275 fresh.biasIF = stat.biasIF; 2276 fresh.orbIodSet = stat.orbIodSet; 2277 fresh.orbIod = stat.orbIod; 2278 fresh.newestToc = stat.newestToc; 2144 2279 stat = fresh; 2145 2280 } 2146 2281 } 2282 2283 // Common outages of the input in the report interval: windows in which at 2284 // least OUTAGE_FRACTION (and OUTAGE_MIN_STA) of the streams with data had a 2285 // gap (interval > 2 x max(declared, median) of any of its message types) 2286 //////////////////////////////////////////////////////////////////////////// 2287 QVector<t_ssrQc::t_outage> t_ssrQc::commonOutages(const QMap<QString, QSet<char> >& streams) const { 2288 QVector<t_outage> outages; 2289 // gap windows per stream, merged over the message types 2290 QMap<double, int> events; // time: change of the number of streams in a gap 2291 unsigned numAll = 0; 2292 QMapIterator<QString, QSet<char> > itSta(streams); 2293 while (itSta.hasNext()) { 2294 itSta.next(); 2295 QVector<QPair<double, double> > wins; 2296 bool hasData = false; 2297 for (char sys : itSta.value()) { 2298 for (int type = ORB; type <= VTEC; type++) { 2299 QString kk = QString("%1 %2 %3").arg(itSta.key()).arg(sys).arg(type); 2300 if (!_epoStat.contains(kk)) continue; 2301 const t_epoStat& stat = _epoStat[kk]; 2302 hasData = hasData || stat.numEpo > 0; 2303 double ref = max(double(stat.nominal), median(stat.intervals)); 2304 for (int ii = 0; ii < stat.intervals.size(); ii++) { 2305 if (ref > 0.0 && stat.intervals[ii] > 2.0 * ref) { 2306 wins.push_back(qMakePair(stat.intervalEnds[ii] - stat.intervals[ii], stat.intervalEnds[ii])); 2307 } 2308 } 2309 } 2310 } 2311 if (!hasData) continue; 2312 ++numAll; 2313 // gap of the stream: all its message types interrupted (intersection 2314 // would need equal epochs; the union of overlapping windows of the 2315 // types is used, a gap of a single type rarely coincides with others) 2316 std::sort(wins.begin(), wins.end()); 2317 QVector<QPair<double, double> > merged; 2318 for (const QPair<double, double>& ww : wins) { 2319 if (!merged.isEmpty() && ww.first <= merged.last().second) { 2320 merged.last().second = max(merged.last().second, ww.second); 2321 } 2322 else { 2323 merged.push_back(ww); 2324 } 2325 } 2326 for (const QPair<double, double>& ww : merged) { 2327 events[ww.first] += 1; 2328 events[ww.second] -= 1; 2329 } 2330 } 2331 unsigned need = max(OUTAGE_MIN_STA, unsigned(ceil(OUTAGE_FRACTION * numAll))); 2332 if (numAll < need) { 2333 return outages; 2334 } 2335 int level = 0; 2336 unsigned maxLevel = 0; 2337 double start = 0.0; 2338 bool open = false; 2339 QMapIterator<double, int> itE(events); 2340 while (itE.hasNext()) { 2341 itE.next(); 2342 level += itE.value(); 2343 if (!open && level >= int(need)) { 2344 open = true; 2345 start = itE.key(); 2346 maxLevel = level; 2347 } 2348 else if (open && level >= int(need)) { 2349 maxLevel = max(maxLevel, unsigned(level)); 2350 } 2351 else if (open && level < int(need)) { 2352 open = false; 2353 t_outage oo; 2354 oo.start = start; 2355 oo.end = itE.key(); 2356 oo.numSta = maxLevel; 2357 oo.numAll = numAll; 2358 outages.push_back(oo); 2359 } 2360 } 2361 return outages; 2362 }
Note:
See TracChangeset
for help on using the changeset viewer.
