Changeset 11218 in ntrip for trunk


Ignore:
Timestamp:
Nov 23, 2026, 9:48:49 PM (8 hours ago)
Author:
stuerze
Message:

improvements regarding ssrqc ephemerides upload and combination

Location:
trunk/BNC
Files:
24 added
56 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/CHANGELOG.md

    r11217 r11218  
    11# Changelog
    22## 2.13.9 (unreleased)
     3- CHANGED: **Upload Ephemeris vote: no replacement of an uploaded data set for receiver-dependent fields.** Once a data set is uploaded, a copy differing only in fields which differ legitimately between receivers (URA/URAI/SISA, GPS/QZSS L2 code, L2 P and fit flags, GLONASS Cn/A/P/P1/P3/FT/NA/N4, BDS AODE/AODC) no longer replaces it; receivers keep the first copy anyway, so these replacements only changed the uploaded content back and forth. Before the upload the majority still decides on all fields. Replay 20 Nov 2026 (8 h, 96 input streams): 447 instead of 751 replacements, GPS 43 instead of 329 (up to 8 per data set before, L2code/fit), all 46 health corrections (Bn, ln) unchanged
     4- ADDED: **SSR QC: IOD switch delay.** Per stream and system the number of switches of the orbit corrections to a new data set and the delay of the first correction after the reception of the data set by BNC (min / 10 % / median / max), for BDS also after the TOC (full-hour issue); switches back to an older data set are listed per satellite. Shows e.g. Analysis Centers using a new IOD earlier than 60 s after its broadcast (CAS01 BDS, Nov 2026, found by hand before)
     5- FIXED: **SSR QC: corrections with an epoch time far from their reception moved the report interval.** A GLONASS epoch of SSRA01SHA1/SSRC01GFZ1 encoded 11758 s ahead (22 Nov 2026 00:10, "differs by 11758 s ... erroneously encoded?") moved the interval to 03:00: no reports for 01 and 02 h, the 03 h report covered 00:10-04:00 with latency maxima of ~650 s, which looked like a caster outage. Corrections more than 900 s from their reception are no longer used and counted per stream in the report
     6- ADDED: **SSR QC: common outages of the input.** Periods in which at least 75 % (and 3) of the streams have a gap at the same time (caster or network outage) are listed once in each report and no longer counted as gaps of the single streams; the latencies during and up to 120 s after them are left out. New test case ssr_qc_outage
     7- FIXED: **Combination (Kalman filter): jumps of the clock level of a system when a satellite is missing in one epoch.** The sum of the combined clocks was fixed to zero over the satellites of each epoch; a satellite not combined in an epoch (master AC without its correction, e.g. its correction referred to an ephemeris not yet received at the hourly BDS ephemeris change) shifted all other clocks of the system by its clock divided by the number of satellites and back at the next epoch. IGS03 20-23 Nov 2026: BDS jumps of 0.7-1.4 m in 22 of 57 hours, mostly at hh:01, once -4.9 m (15 satellites missing). Now the sum over the satellites also combined in the previous epoch keeps its value (previous clocks converted to the current ephemeris), relaxing to zero with a time constant of 1 h; after a gap > 60 s it is zero. Clocks relative to each other and orbits unchanged; replay 21 Nov 18:30-22:00: no common jumps, levels G/R/E within 0.15 m of before. New test case combi_bds_level, tool tests/tools/clkjumps.py
    38- CHANGED: **Ephemerides of satellites outside the range supported by BNC** (e.g. G39, test signal of NTS-3 since 30 Sep 2026, not IS-GPS compliant, seen 19 Nov 2026 by many stations in Australia and the Pacific) are no longer written to RINEX navigation files or the ephemeris port, uploaded, or used in PPP, combination and SSR QC; each data set is logged once with its complete RINEX navigation record. Before, they were passed on unchanged (e.g. into an uploaded Broadcast Ephemeris stream), only the warning 'outside the range supported by BNC' was logged. RINEX Edit/Concatenate keeps such records of input files. New test case eph_out_of_range, test tool bncraw.py ephsats
    49- ADDED: **Upload Ephemeris: majority vote over the copies of a data set.** A new data set (TOC and IOD) is uploaded as soon as three streams deliver the same content, at the latest 40 s after its first copy (before: the first copy immediately; SSR providers use a new IOD after 60 s, the 20 s left cover the upload interval and latency); meanwhile the previous data set stays in the upload (checked with each ephemeris and every second). Receivers and applications, BNC too, keep the first copy of a data set, so only this delay protects them; immediately uploaded if the previous data set came from less than three streams or for the first data set of a satellite. Replay 18 Nov 2026 (89 streams, 20 min): three agreeing streams after 14 s in the median, 87 % of 94 data sets within 40 s. Every further stream counts as a vote for its copy, and a copy with different content (the RTCM3 message without the GLONASS frame time tk and the system time offsets tau_c/tau_GPS, which receivers take from the string 5 of any satellite) replaces the uploaded one as soon as more streams deliver it than the current one, i.e. with at least three streams (only the latest copy per stream counts, so the only stream of a data set may replace its own copy). Each replacement is logged with the streams per copy and the differing fields. Before, the fastest stream decided all fields of a data set, e.g. BCEP00BKG0 18 Nov 2026 R19/R20 with Bn = 1 (unhealthy) from RIO200ARG0/ENAO00PRT0 while all other streams sent Bn = 0, and ln3 = 1 from CUT000AUS0; replay of 89 input streams (2 h): GLONASS health different from the majority of the streams in 1 of 156 data sets (a 2:2 tie in Cn of the unhealthy R27) instead of 63. New test case upload_eph_vote
  • trunk/BNC/src/bncephuser.cpp

    r11216 r11218  
    293293  return val;
    294294}
    295 }
    296 
    297 QString bncEphUser::differingFields(const QByteArray& c1, const QByteArray& c2) {
     295
     296// Fields differing legitimately between the copies of the same data set
     297// (receiver-dependent or informational): accuracy indices, GPS/QZSS L2 code
     298// and fit flags, GLONASS almanac flags and day numbers, BDS AODE/AODC
     299const char* minorFields1019[] = {"URA", "L2code", "L2P", "fit", 0};
     300const char* minorFields1020[] = {"Cn", "A", "P", "P1", "P3", "FT", "NA", "N4", 0};
     301const char* minorFields1042[] = {"URAI", "AODE", "AODC", 0};
     302const char* minorFields1045[] = {"SISA", 0};
     303
     304// Names of the differing fields; empty: not decodable or no difference
     305QStringList fieldDifferences(const QByteArray& c1, const QByteArray& c2, const char* const** minor) {
     306  QStringList names;
     307  if (minor) {
     308    *minor = 0;
     309  }
    298310  if (c1.size() != c2.size() || c1.size() < 5) {
    299     return "content";
     311    return names;
    300312  }
    301313  const t_field* fields = 0;
     314  const char* const* minorFields = 0;
    302315  switch (getBits(c1, 24, 12)) {
    303     case 1019: fields = fields1019; break;
    304     case 1020: fields = fields1020; break;
    305     case 1042: fields = fields1042; break;
    306     case 1044: fields = fields1044; break;
    307     case 1045: fields = fields1045; break;
    308     case 1046: fields = fields1046; break;
     316    case 1019: fields = fields1019; minorFields = minorFields1019; break;
     317    case 1020: fields = fields1020; minorFields = minorFields1020; break;
     318    case 1042: fields = fields1042; minorFields = minorFields1042; break;
     319    case 1044: fields = fields1044; minorFields = minorFields1019; break;
     320    case 1045: fields = fields1045; minorFields = minorFields1045; break;
     321    case 1046: fields = fields1046; minorFields = minorFields1045; break;
    309322  }
    310323  if (!fields) {
    311     return "content";
    312   }
    313   QStringList names;
     324    return names;
     325  }
     326  if (minor) {
     327    *minor = minorFields;
     328  }
    314329  int pos = 24;
    315330  for (int ii = 0; fields[ii].name; ii++) {
    … …  
    322337    pos += fields[ii].nbits;
    323338  }
     339  return names;
     340}
     341}
     342
     343// Two vote contents differ only in fields differing legitimately between
     344// receivers (see minorFields...)
     345////////////////////////////////////////////////////////////////////////////
     346bool bncEphUser::minorDifference(const QByteArray& c1, const QByteArray& c2) {
     347  const char* const* minor = 0;
     348  QStringList names = fieldDifferences(c1, c2, &minor);
     349  if (names.isEmpty() || !minor) {
     350    return false;
     351  }
     352  for (const QString& name : names) {
     353    bool found = false;
     354    for (int ii = 0; minor[ii]; ii++) {
     355      found = found || name == minor[ii];
     356    }
     357    if (!found) {
     358      return false;
     359    }
     360  }
     361  return true;
     362}
     363
     364QString bncEphUser::differingFields(const QByteArray& c1, const QByteArray& c2) {
     365  QStringList names = fieldDifferences(c1, c2, 0);
    324366  return names.isEmpty() ? QString("content") : names.join(" ");
    325367}
    … …  
    447489    }
    448490  }
     491  bool wasReleased = votes->_released;
    449492  bool released = false;
    450493  if (!votes->_released && count[iBest] >= VOTE_AGREE) {
    … …  
    452495    released = true;
    453496  }
    454   if (iBest == votes->_current) {
     497  // after the upload, a copy differing only in receiver-dependent fields
     498  // replaces it no more: receivers keep the first copy of a data set anyway
     499  if (iBest == votes->_current ||
     500      (wasReleased && minorDifference(votes->_content[votes->_current], votes->_content[iBest]))) {
    455501    if (released) {
    456502      ephBufferChanged();
  • trunk/BNC/src/bncephuser.h

    r11217 r11218  
    6060  // than the current one, i.e. with at least three streams (only the latest
    6161  // copy of each stream counts: a single stream may replace its own copy).
     62  // Once uploaded, a data set is no more replaced by a copy differing only in
     63  // receiver-dependent fields (accuracy indices, GPS/QZSS L2 code and fit
     64  // flags, GLONASS almanac flags and day numbers, BDS AODE/AODC).
    6265  // A new data set is held back from the upload (ephUpload() returns the
    6366  // previous one) until three streams deliver the same content or VOTE_HOLD
    … …  
    134137  static QByteArray votingContent(const t_eph* eph);
    135138  static QString    differingFields(const QByteArray& content1, const QByteArray& content2);
     139  static bool       minorDifference(const QByteArray& content1, const QByteArray& content2);
    136140  void   vote(const QString& prn, unsigned index, const t_eph* eph);
    137141  void   checkEphemeris(t_eph* eph, bool realTime);
  • trunk/BNC/src/bnchelp.html

    r11217 r11218  
    53325332    <li>the update interval as declared in the messages (SSR Update Interval), the median and the maximum of the
    53335333      actual intervals,</li>
    5334     <li>the number of gaps, i.e. intervals longer than twice the larger of declared and median interval,</li>
     5334    <li>the number of gaps, i.e. intervals longer than twice the larger of declared and median interval,
     5335      without those overlapping a common outage of the input (see below),</li>
    53355336    <li>the number of epochs older than the previous one (out of order),</li>
    53365337    <li>the latency, median and maximum, i.e. the time of the decoded output minus the epoch time. BNC passes on
    … …  
    53395340    <li>the number of satellites.</li>
    53405341  </ul>
     5342  <p>
     5343    A common outage of the input, i.e. a period in which at least 75 % (and at least 3) of the streams with data in
     5344    the interval had a gap at the same time, e.g. an outage of the caster or of the network connection of BNC, is
     5345    listed once below the table of each stream ('common outage of the input &lt;from&gt; - &lt;to&gt; (&lt;n&gt; of
     5346    &lt;m&gt; streams)'). It is not an Analysis Center problem: its gaps are not counted, and the latencies of the
     5347    epochs during it and up to 120 s after it, which reflect the delivery of buffered data, are left out of the
     5348    latency median and maximum. The maximum interval still contains it.
     5349  </p>
     5350  <p>
     5351    Corrections with an epoch time more than 900 seconds from their reception, e.g. an erroneously encoded GLONASS
     5352    epoch (see the decoder message 'SSR epoch time ... differs by ... s from the GPS SSR epoch time of the stream'),
     5353    are not used and their number is given below the table; they would otherwise move the report interval.
     5354  </p>
    53415355  <p>
    53425356    It is followed by the findings per system, only lines with findings are listed:
    … …  
    53555369      as Galileo e.g. broadcasts a new data set every 10 minutes and Analysis Centers keep one for up to an
    53565370      hour,</li>
     5371    <li>the IOD switch: number of switches of the orbit corrections to a new data set and the delay of the first
     5372      correction referring to it after the reception of this data set by BNC (ephemeris streams), minimum, 10 %
     5373      quantile, median and maximum in seconds; for BDS, where all satellites get a new data set at the full hour
     5374      (TOC = issue time), also the delay after the TOC. Analysis Centers should not use a new data set before
     5375      60 seconds after its first broadcast, as receivers need this time to collect it; note that the reception by
     5376      BNC is itself delayed (ephemeris upload, majority vote, see section 2.16), so a value below 60 s is not
     5377      necessarily a violation, while the BDS delay after TOC is independent of BNC. A switch back to an older data
     5378      set is listed per satellite ('orbit corrections switching back to an older data set'); switching forward
     5379      again to the same new data set is not counted twice,</li>
    53575380    <li>the code bias signals provided, satellites without code biases of the reference signals (default GPS C1W/C2W,
    53585381      GLONASS C1P/C2P, Galileo C1C/C5Q, BDS C2I/C6I, QZSS C1C/C2L, SBAS C1C/C5Q; as in the combination, see option
    … …  
    86058628</pre>
    86068629  <p>
     8630    <b>Level of the combined clocks:</b>
     8631    The common level of the combined clocks of a system (with respect to the AC specific offsets) is defined by the
     8632    sum of the combined clocks over the satellites. A satellite is combined only if the AC providing the orbits
     8633    (master AC) delivers it; if it is missing in an epoch, e.g. because the master AC refers its correction to a new
     8634    ephemeris not yet received (BDS updates the ephemerides of all satellites at the full hour), a sum fixed to zero
     8635    over the satellites of each epoch would shift all other clocks of the system by the clock of the missing satellite
     8636    divided by the number of satellites (BDS: up to 1 m, at the next epoch back). Therefore the sum over the satellites
     8637    also combined in the previous epoch keeps its value; clocks of the previous epoch referring to another ephemeris
     8638    are converted to the current one. To keep the combined clocks referred to the broadcast clocks in the long run, this
     8639    sum relaxes to zero with a time constant of one hour, so that a permanent change of the combined satellites shifts
     8640    the clocks only slowly. After a gap of more than 60 seconds (and at the start) the sum is set to zero.
     8641  </p>
     8642  <p>
    86078643    Corrections can still be rejected persistently, e.g. for satellites provided by fewer than three ACs or for noisy
    86088644    clocks. This protects the combined clock, but it is worth to be reported to the AC. Therefore, once per hour and
    … …  
    1008210118    the latency before SSR providers may use the new IOD, 60 seconds after its broadcast; three streams agreed in the
    1008310119    median after 14 seconds and in 87 percent of the data sets within 40 seconds with 89 input streams
    10084     (18 Nov 2026). A replacement after the upload is still possible. The content compared is the RTCM Version 3 message as uploaded, for GLONASS
     10120    (18 Nov 2026). A replacement after the upload is still possible, but only for differences beyond the fields
     10121    which differ legitimately between receivers (accuracy indices URA/URAI/SISA, GPS/QZSS L2 code, L2 P data and fit
     10122    flags, GLONASS almanac flags Cn/A, P, P1, P3, FT, day numbers NA/N4, BDS AODE/AODC): as receivers keep the first
     10123    copy anyway, such replacements would only change the content of the uploaded stream back and forth (751
     10124    replacements in 8 hours of 20 Nov 2026, nearly all of this kind); before the upload the majority decides on all
     10125    fields. The content compared is the RTCM Version 3 message as uploaded, for GLONASS
    1008510126    without the frame time tk and the system time offsets tau_c and tau_GPS, which differ legitimately between
    1008610127    receivers. This protects the uploaded stream against single receivers sending e.g. wrong health flags. Each
  • trunk/BNC/src/combination/bnccomb.cpp

    r11212 r11218  
    4343
    4444const double sigObs        =   0.05;
     45
     46// level of the combined clocks (regularization condition, see createAmat)
     47const double CLK_LEVEL_TAU    = 3600.0; // [s] relaxation of the sum to zero
     48const double CLK_LEVEL_MAXGAP =   60.0; // [s] longer gap: sum set to zero again
    4549
    4650using namespace std;
    … …  
    11771181  // --------------------------------------
    11781182  if (irc == success) {
     1183    if (_method == filter) {
     1184      _prevClk[sys].clear();
     1185      _prevClkTime[sys] = epoTime;
     1186    }
    11791187    for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
    11801188      cmbParam* pp = _params[sys][iPar-1];
    … …  
    11841192          // set clock result
    11851193          masterCorr[pp->prn]->_dClkResult = pp->xx / t_CST::c;
     1194          if (_method == filter && masterCorr[pp->prn]->_eph) {
     1195            t_prevClk& prev = _prevClk[sys][pp->prn];
     1196            prev.clk = pp->xx;
     1197            prev.iod = masterCorr[pp->prn]->_eph->IOD();
     1198          }
    11861199          // Add Code Biases from SINEX File
    11871200          if (_bsx) {
    … …  
    21702183  }
    21712184
    2172   // Regularization
    2173   // --------------
     2185  // Regularization: level of the combined clocks
     2186  // ---------------------------------------------
     2187  // The sum of the combined clocks over the satellites of the epoch is not
     2188  // fixed to zero in each epoch: a satellite missing in one epoch (e.g. its
     2189  // correction of the master AC refers to an ephemeris not yet received, at
     2190  // the BDS ephemeris change every hour) shifted all other clocks of the
     2191  // system by its clock divided by the number of satellites (BDS: up to 1 m).
     2192  // Instead, the sum over the satellites also combined in the previous epoch
     2193  // keeps its value (continuity), relaxing to zero with CLK_LEVEL_TAU, so
     2194  // that the clocks stay referred to the broadcast clocks in the long run
     2195  // and a permanent change of the satellites shifts them only slowly. A
     2196  // previous clock of another ephemeris is converted to the current one
     2197  // (as in switchToLastEph). Without a previous epoch (start, gap longer
     2198  // than CLK_LEVEL_MAXGAP) the sum is zero.
     2199  QSet<int> presetRows;  // conditions with their value set here
    21742200  if (_method == filter) {
    21752201    const double Ph = 1.e6;
    21762202    PP(nObs+1) = Ph;
     2203    const bncTime epoTime = corrs(sys)[0]->_time;
     2204    const double  dtPrev  = _prevClkTime[sys].valid() ? epoTime - _prevClkTime[sys] : -1.0;
     2205    const bool    cont    = dtPrev > 0.0 && dtPrev <= CLK_LEVEL_MAXGAP;
     2206    double target  = 0.0;
     2207    int    nCommon = 0;
     2208    QList<int> allClk;
    21772209    for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
    21782210      cmbParam* pp = _params[sys][iPar-1];
    21792211      if ( AA.Column(iPar).maximum_absolute_value() > 0.0 &&
    21802212           pp->type == cmbParam::clkSat ) {
     2213        allClk << iPar;
     2214        if (!cont || !_prevClk[sys].contains(pp->prn) || !masterCorr.contains(pp->prn)) {
     2215          continue;
     2216        }
     2217        const t_prevClk& prev = _prevClk[sys][pp->prn];
     2218        const t_eph*     eph  = masterCorr[pp->prn]->_eph;
     2219        double prevClk = prev.clk;
     2220        if (eph->IOD() != prev.iod) {
     2221          const t_eph* ephOld = 0;
     2222          for (const t_eph* ee : {(const t_eph*)_ephUser.ephLast(pp->prn), (const t_eph*)_ephUser.ephPrev(pp->prn)}) {
     2223            if (ee && ee != eph && ee->IOD() == prev.iod) {
     2224              ephOld = ee;
     2225            }
     2226          }
     2227          ColumnVector xcNew(6), xcOld(6), vv(3);
     2228          if (!ephOld ||
     2229              eph->getCrd(epoTime, xcNew, vv, false) != success ||
     2230              ephOld->getCrd(epoTime, xcOld, vv, false) != success) {
     2231            continue;
     2232          }
     2233          prevClk -= (xcNew(4) - xcOld(4)) * t_CST::c;
     2234        }
     2235        AA(nObs+1, iPar) = 1.0;
     2236        target += prevClk;
     2237        ++nCommon;
     2238      }
     2239    }
     2240    if (nCommon > 0) {
     2241      ll(nObs+1) = (1.0 - min(1.0, dtPrev / CLK_LEVEL_TAU)) * target - DotProduct(AA.Row(nObs+1), x0);
     2242      presetRows.insert(1);
     2243    }
     2244    else {
     2245      for (int iPar : allClk) {
    21812246        AA(nObs+1, iPar) = 1.0;
    21822247      }
    … …  
    22902355    // filter. Exception: incomplete nominal datum of a satellite (see above).
    22912356    for (int iCon = 1; iCon <= nCon; iCon++) {
    2292       if (!incrementRows.contains(iCon)) {
     2357      if (!incrementRows.contains(iCon) && !presetRows.contains(iCon)) {
    22932358        ll(nObs+iCon) = -DotProduct(AA.Row(nObs+iCon), x0);
    22942359      }
  • trunk/BNC/src/combination/bnccomb.h

    r11212 r11218  
    266266  QMap<QString, int>                         _biasExclusions; // AC+system: number of exclusions (hysteresis)
    267267  QMap<char, bncTime>                        _lastFilterEpoch;      // per system: last epoch of the filter prediction
     268  // Combined clock of each satellite in the last epoch, for the continuity
     269  // of the clock level (regularization condition, see createAmat)
     270  struct t_prevClk {
     271    double   clk = 0.0;   // [m], referred to the ephemeris with IOD iod
     272    unsigned iod = 0;
     273  };
     274  QMap<char, QMap<QString, t_prevClk> >      _prevClk;       // per system, key full PRN
     275  QMap<char, bncTime>                        _prevClkTime;   // per system: epoch of _prevClk
    268276  void checkBiasConsistency(bncTime epoTime, char sys, QTextStream& out);
    269277  void checkPersistentOutliers(bncTime epoTime, char sys, QTextStream& out);
  • trunk/BNC/src/ssrQc.cpp

    r11214 r11218  
    5959  const double EPH_IOD_REUSE  = 21600.0; // [s] an outdated data set this far from the epoch: IOD reused
    6060  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
    6165  const double CMP_SAMPL      = 30.0;  // [s] sampling of the stream comparison
    6266  const double CMP_DELAY      = 60.0;  // [s] epochs compared when data this much newer arrived
    … …  
    370374    if (stat.last.valid()) {
    371375      stat.intervals.push_back(time - stat.last);
     376      stat.intervalEnds.push_back(tKey(time));
    372377    }
    373378    stat.last = time;
    374379    stat.numEpo += 1;
    375380    stat.latencies.push_back(currentTime() - time);
     381    stat.latencyEpochs.push_back(tKey(time));
    376382  }
    377383  else if (time < stat.last) {
    … …  
    450456}
    451457
     458// Switch of the orbit corrections to another IOD
     459////////////////////////////////////////////////////////////////////////////
     460void 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////////////////////////////////////////////////////////////////////////////
     510bool 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
    452518// Orbit corrections
    453519////////////////////////////////////////////////////////////////////////////
    … …  
    455521  QMutexLocker locker(&_mutex);
    456522  for (const t_orbCorr& corr : orbCorrections) {
     523    if (badEpoch(corr._staID, corr._time)) continue;
    457524    if (!_excluded.contains(QString::fromStdString(corr._staID)) || corr._staID == _reference.toStdString()) {
    458525      storeHist(&corr, 0);
    … …  
    467534    checkEph(stat, QString::fromStdString(corr._staID) + ' ' + prn,
    468535             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);
    469538    double radial = fabs(corr._xr[0]);
    470539    double alongCross = max(fabs(corr._xr[1]), fabs(corr._xr[2]));
    … …  
    479548  QMutexLocker locker(&_mutex);
    480549  for (const t_clkCorr& corr : clkCorrections) {
     550    if (badEpoch(corr._staID, corr._time)) continue;
    481551    if (!_excluded.contains(QString::fromStdString(corr._staID)) || corr._staID == _reference.toStdString()) {
    482552      storeHist(0, &corr);
    … …  
    515585  QMutexLocker locker(&_mutex);
    516586  for (const t_satCodeBias& bias : codeBiases) {
     587    if (badEpoch(bias._staID, bias._time)) continue;
    517588    bool sel = selected(bias._staID);
    518589    if (_excluded.contains(QString::fromStdString(bias._staID)) && bias._staID != _reference.toStdString()) continue;
    … …  
    564635  QMutexLocker locker(&_mutex);
    565636  for (const t_satPhaseBias& bias : phaseBiases) {
     637    if (badEpoch(bias._staID, bias._time)) continue;
    566638    QString staID = QString::fromStdString(bias._staID);
    567639    QString prn   = QString::fromStdString(bias._prn.toString());
    … …  
    15161588void t_ssrQc::slotNewTec(t_vTec vTec) {
    15171589  QMutexLocker locker(&_mutex);
    1518   if (vTec._layers.empty()) {
     1590  if (vTec._layers.empty() || badEpoch(vTec._staID, vTec._time)) {
    15191591    return;
    15201592  }
    … …  
    16961768  }
    16971769
     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
    16981789  QMapIterator<QString, QSet<char> > itSta(streams);
    16991790  while (itSta.hasNext()) {
    … …  
    17271818        double ref = max(double(stat.nominal), medInt);
    17281819        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])) {
    17311824            ++gaps;
    17321825          }
    17331826        }
    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());
    17361835        out << "  " << sys << "   " << left << setw(10) << TYPE_NAME[type] << right
    17371836              << setw(8) << stat.numEpo
    … …  
    17391838              << " /" << setw(7) << maxInt
    17401839              << setw(6) << gaps << setw(14) << stat.numOutOfOrder
    1741               << setw(10) << median(stat.latencies) << " /" << setw(7) << maxLat
     1840              << setw(10) << median(latencies) << " /" << setw(7) << maxLat
    17421841              << setw(7) << stat.sats.size() << endl;
    17431842      }
     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;
    17441854    }
    17451855
    … …  
    19012011      addSats("corrections for satellites without broadcast ephemeris", noEph);
    19022012      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      }
    19032033      if (_codeSignals.contains(staSys)) {
    19042034        QStringList sigs = _codeSignals[staSys].values();
    … …  
    21152245  _cmpStat.clear();
    21162246  _cmpEpochs.clear();
     2247  _iodSwitch.clear();
     2248  _badEpochs.clear();
    21172249  _attEvents.clear();
    21182250  _pbIndStat.clear();
    … …  
    21422274    fresh.refBiasOK     = stat.refBiasOK;
    21432275    fresh.biasIF        = stat.biasIF;
     2276    fresh.orbIodSet     = stat.orbIodSet;
     2277    fresh.orbIod        = stat.orbIod;
     2278    fresh.newestToc     = stat.newestToc;
    21442279    stat = fresh;
    21452280  }
    21462281}
     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////////////////////////////////////////////////////////////////////////////
     2287QVector<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}
  • trunk/BNC/src/ssrQc.h

    r11214 r11218  
    4949    bncTime         last;
    5050    QVector<double> intervals;
     51    QVector<double> intervalEnds;  // [s] (tKey) epoch ending each interval
    5152    QVector<double> latencies;
     53    QVector<double> latencyEpochs; // [s] (tKey) epoch of each latency
    5254    QSet<QString>   sats;
    5355  };
    … …  
    7981    unsigned      numYaw = 0;    // phase bias records with yaw angle
    8082    unsigned      pbJumps = 0;   // changes of the phase bias discontinuity counter
    81   };
     83    bool          orbIodSet = false; // IOD of the orbit corrections (kept across intervals)
     84    unsigned      orbIod    = 0;
     85    bncTime       newestToc;     // TOC of the newest data set referred to so far
     86  };
     87
     88  // IOD switch: delay of the first orbit correction referring to a new data
     89  // set after its reception by BNC (ephemeris streams) and, for BDS (all
     90  // satellites updated at the full hour, TOC = issue time), after its TOC;
     91  // switches back to an older data set
     92  class t_iodSwitchStat {    // per stream and system
     93   public:
     94    QVector<double>         afterRecept;  // [s]
     95    QVector<double>         afterToc;     // [s]
     96    QMap<QString, unsigned> back;         // PRN: switches back
     97  };
     98  void   checkIodSwitch(t_satStat& stat, const QString& staID, const QString& prnInt,
     99                        unsigned iod, const bncTime& time);
     100  QMap<QString, t_iodSwitchStat> _iodSwitch;  // key "STA SYS"
     101
     102  // Common outages of the input: gaps of at least OUTAGE_FRACTION of the
     103  // streams at the same time (e.g. caster, network); reported once, not
     104  // counted as gaps of the single streams and their latencies left out
     105  class t_outage {
     106   public:
     107    double   start;          // [s] (tKey)
     108    double   end;
     109    unsigned numSta;         // streams with a gap
     110    unsigned numAll;         // streams with data in the interval
     111  };
     112  QVector<t_outage> commonOutages(const QMap<QString, QSet<char> >& streams) const;
     113
     114  // Corrections with an epoch time far from the reception time (erroneously
     115  // encoded): not used, counted per stream
     116  bool   badEpoch(const std::string& staID, const bncTime& time);
     117  QMap<QString, unsigned> _badEpochs;
    82118
    83119  void   newEpoch(const std::string& staID, char sys, e_type type, const bncTime& time,
  • trunk/BNC/tests/README.md

    r11215 r11218  
    117117  encodings, missing reference-signal biases, inconsistent biases and
    118118  persistent outliers. The longest case (about 4 min).
     119* `combi_bds_level`: 17 with the six inputs of the IGS03 combination (CAS01,
     120  CHC00, GMV00, CNE00, BKG00, SHA01 without BDS; 10 s) from
     121  `data/combi_bds_level_261121_13min.raw` (21 Nov 2026 18:50-19:03, cut from
     122  the SSR QC recording). At 19:01:00 the master AC CAS01 refers C14 to an IOD
     123  not yet received from BCEP00BKG0, C14 is missing in one epoch; the level of
     124  the combined clocks must not jump (before: all BDS clocks -0.92 m and back).
     125  `tools/clkjumps.py` lists common clock jumps > 0.1 m of the CLK file.
    119126* `combi_refsig`: `combi` with non-default reference signals (`ssrRefSignals
    120127  C:1P&5P`): BDS clock referral and code biases from the Bias SINEX file on
    … …  
    157164  later (WHU1), never received (GMV1 G16, upload not in BCEP00BKG0), ephemeris outside its
    158165  validity (CNE1 GLONASS).
     166* `ssr_qc_outage`: common outage of the input on `data/ssr_qc_outage_261002_5min.raw`
     167  (`data/combi_multi_261002_5min.raw` without the chunks of all 7 AC streams 11:43:00-11:44:00,
     168  BCEP00BKG0 kept, and without those of SSRA00CNE1 11:44:30-11:45:10): the outage is listed in
     169  each report and not counted as gap, the own gap of CNE1 is. The IOD switch delays (after the
     170  reception by BNC, BDS also after TOC) appear in all SSR QC cases.
     171* `ssr_qc_bad_epoch`: `data/ssr_qc_bad_epoch_261122_10min.raw` (22 Nov 2026 00:10:30-00:21, cut
     172  from the QC capture: BCEP00BKG0, SSRA00SHA1, SSRA00CNE1, SSRA00GMV0): SSRA00SHA1 sends a GLONASS
     173  epoch 11758 s ahead; its 159 corrections are not used (counted in the report), the 5 min reports
     174  continue normally.
    159175* `ssr_qc_glo_ln`: GLONASS health flag ln on `data/glo_ln_261015_1h.raw` (BCEP00BKG0 GLONASS
    160176  ephemerides 09:40-10:40 and SSRA00GMV0 GLONASS corrections 09:55-10:40 of 15 Oct 2026, merged
  • trunk/BNC/tests/cases/upload_eph_vote/case.json

    r11216 r11218  
    11{
    2   "description": "19_UploadEph replay with the majority vote over the copies of a data set: GPS, GLONASS and BDS ephemerides of 89 uploader input streams (BCEP00BKG0 removed), 18 Nov 2026 17:43-18:03; the log lists each replaced copy, e.g. R06/R19/R20 of 18:15:18 GPS time with Bn=1 from RIO200ARG0 replaced as soon as two other streams agree; new data sets are uploaded after three agreeing streams or at the latest after 40 s (timeouts logged). The uploaded content depends on the wall-clock timing and is not compared",
     2  "description": "19_UploadEph replay with the majority vote over the copies of a data set: GPS, GLONASS and BDS ephemerides of 89 uploader input streams (BCEP00BKG0 removed), 18 Nov 2026 17:43-18:03; the log lists each replaced copy, e.g. R06/R19/R20 of 18:15:18 GPS time with Bn=1 from RIO200ARG0 replaced as soon as two other streams agree; new data sets are uploaded after three agreeing streams or at the latest after 40 s (timeouts logged). Once uploaded, a data set is replaced only for differences beyond receiver-dependent fields (e.g. GPS L2code/fit, GLONASS Cn/A/P3/NA/N4, BDS AODE/AODC); the R06/R19/R20 Bn corrections remain. The uploaded content depends on the wall-clock timing and is not compared",
    33  "config": "Example_Configs/19_UploadEph.bnc",
    44  "raw": "data/eph_vote_261118_20min.raw",
Note: See TracChangeset for help on using the changeset viewer.