Changeset 11228 in ntrip for trunk/BNC


Ignore:
Timestamp:
Nov 26, 2026, 8:21:15 PM (2 hours ago)
Author:
stuerze
Message:

SSP3 comparison with clock RINEX files added

Location:
trunk/BNC
Files:
12 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/CHANGELOG.md

    r11227 r11228  
    11# Changelog
    22## 2.13.9 (unreleased)
     3- ADDED: **SP3 comparison with clock RINEX files** (key `sp3CompClkFile`, optional, in the order of the SP3 files, '-' for none, one name = SP3 file 1). The clocks of a clock RINEX file replace those of its SP3 file; clocks and SIS are compared at all common clock epochs, orbits interpolated between the SP3 epochs (Lagrange, 10 consecutive epochs, no extrapolation or gaps; about 1 mm for 5 min orbits), orbit statistics at the common SP3 epochs only. Allows the daily comparison of 30 s BNC SP3 files with the 30 s clocks of a rapid product instead of its 5 min SP3 clocks (10 times more clock epochs, short clock events visible). GFZ rapid 21 Nov 2026 vs IGS03 (1 h): nClk G 372 -> 3978, orbits unchanged; a BNC clock file for the BNC SP3 gives identical results (same clocks). New test cases sp3_compare_clk, sp3_compare_clk_bnc
    34- ADDED: **SSR QC: RMS of the VTEC (IGS-SSR message 202).** The IGS-SSR decoder reads message 202 ('Proposal of New IGS-SSR Ionospheric RMS Message', CAS, Dec 2025; same layout as 201); a message shorter than its header is rejected. The RMS maps go to the SSR QC only (not to the .ssr files or PPP): evaluated on the VTEC grid and compared with the differences of the model to the consensus (stated vs actual RMS, differences normalized by the stated RMS, share within 1 and 2 RMS). Replay 20 Nov 2026 22-23 h: IONO00CAS1 stated 1.0-6.3 TECU (RMS 4.2) vs actual 4.5 TECU, normalized RMS 1.23, 67 %/91 % within 1/2 RMS (realistic); SSRC01CAS1 a constant 1.2 TECU (only C00) vs actual 10 TECU; IONO01IGS1 sends 202 with only 80 bits (header incomplete), rejected. New test case ssr_qc_vtec_rms
     5- FIXED: **Clock RINEX header: PRN LIST.** The fixed list of the header written by the upload (`*_CLK.CLK`) contained the line R16-E04 twice and lacked G24 and R04, so it did not match `# OF SOLN SATS` (177). List and number are now derived from the same satellite ranges (G01-32, R01-26, E01-36, C01-63, J01-04, I01-07, nine SBAS; 177). Data records unchanged; CLK references of combi, combi_refsig, combi_ppp, combi_bds_level, combi_multi, replay_save_sp3, replay_save_sp3_has, replay_save_sp3_midnight, upload_rtnet updated
    46- FIXED: **Combination: the orbit consistency correction dC_orb was always zero (since r10820, March 2026).** The radial difference between the orbit of an AC and the master orbit, which keeps the combined clocks consistent with the master orbit, was computed from broadcast positions without the SSR orbit corrections, i.e. identical for all ACs. Orbit differences between the ACs therefore remained in the combined product: IGS02/IGS03 R10 R20 R23 0.6-0.75 m SIS vs. the other ACs in most hours of 20-23 Nov 2026 (radial orbit corrections of the GLONASS master CHC00 0.33 m off for R23). The positions now include the orbit correction of each AC. Replay 21 Nov 2026 (IGS03 inputs, 13 min): R23 SIS vs. the ACs +0.30 -> -0.11 m; PPP with the combined product (combi_ppp) RMS N/E/U 1.1/4.2/10.2 -> 2.9/2.3/1.9 cm. References of combi, combi_refsig, combi_ppp, combi_bds_level, combi_multi updated
    57- FIXED: **SSR VTEC: a repeated VTEC message added its layers to the model of its epoch again.** The layers of a VTEC message were appended to the record of its epoch until a newer epoch arrived, so every retransmission of the same epoch added the complete model once more. IONO01IGS0 (RTCM 1264, Nov 2026) repeats each epoch 5 to 400 times, partly out of order and with non-RTCM bytes between the frames: the model reached up to 170 identical layers, i.e. VTEC up to 3900 TECU in PPP, the .ssr files and the SSR QC (14 of 57 hours), while the messages themselves are correct (hand decode: CRC-valid, coefficients up to 22 TECU, identical to IONO01IGS1). A VTEC message now replaces the record of its epoch; only the continuation of a multi-message model (Multiple Message Indicator 1) appends. New test case ssr_vtec_repeat
  • trunk/BNC/src/bncclockrinex.cpp

    r11179 r11228  
    103103
    104104  _out << "     3.00           C                                       "  << "RINEX VERSION / TYPE" << endl;
    105  ;
    106105  _out << QString("BNC v%1").arg(BNCVERSION).leftJustified(40, ' ', true).toLatin1().data()
    107106       << datTim.toString("yyyyMMdd hhmmss").leftJustified(20, ' ', true).toLatin1().data()
    … …  
    114113       << "ANALYSIS CENTER" << endl;
    115114
    116   _out << "   177                                                      "
     115  // Satellites that may be contained in the file (the header is written
     116  // before the first epoch); number and list are derived from the same ranges
     117  // -------------------------------------------------------------------------
     118  QStringList prnList;
     119  const struct { char sys; int first; int last; } ranges[] = {
     120    {'G', 1, 32}, {'R', 1, 26}, {'E', 1, 36}, {'C', 1, 63}, {'J', 1, 4}, {'I', 1, 7}
     121  };
     122  for (unsigned ir = 0; ir < sizeof(ranges) / sizeof(ranges[0]); ir++) {
     123    for (int nn = ranges[ir].first; nn <= ranges[ir].last; nn++) {
     124      prnList << QString("%1%2").arg(ranges[ir].sys).arg(nn, 2, 10, QChar('0'));
     125    }
     126  }
     127  const int sbas[] = {20, 24, 27, 28, 29, 33, 35, 37, 38};
     128  for (unsigned ii = 0; ii < sizeof(sbas) / sizeof(sbas[0]); ii++) {
     129    prnList << QString("S%1").arg(sbas[ii], 2, 10, QChar('0'));
     130  }
     131
     132  _out << QString("%1").arg(prnList.size(), 6).leftJustified(60, ' ').toLatin1().data()
    117133       << "# OF SOLN SATS" << endl;
    118134
    119   _out << "G01 G02 G03 G04 G05 G06 G07 G08 G09 G10 G11 G12 G13 G14 G15 PRN LIST" << endl;
    120   _out << "G16 G17 G18 G19 G20 G21 G22 G23 G25 G26 G27 G28 G29 G30 G31 PRN LIST" << endl;
    121   _out << "G32 R01 R02 R03 R05 R06 R07 R08 R09 R10 R11 R12 R13 R14 R15 PRN LIST" << endl;
    122   _out << "R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 E01 E02 E03 E04 PRN LIST" << endl;
    123   _out << "R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 E01 E02 E03 E04 PRN LIST" << endl;
    124   _out << "E05 E06 E07 E08 E09 E10 E11 E12 E13 E14 E15 E16 E17 E18 E19 PRN LIST" << endl;
    125   _out << "E20 E21 E22 E23 E24 E25 E26 E27 E28 E29 E30 E31 E32 E33 E34 PRN LIST" << endl;
    126   _out << "E35 E36 C01 C02 C03 C04 C05 C06 C07 C08 C09 C10 C11 C12 C13 PRN LIST" << endl;
    127   _out << "C14 C15 C16 C17 C18 C19 C20 C21 C22 C23 C24 C25 C26 C27 C28 PRN LIST" << endl;
    128   _out << "C29 C30 C31 C32 C33 C34 C35 C36 C37 C38 C39 C40 C41 C42 C43 PRN LIST" << endl;
    129   _out << "C44 C45 C46 C47 C48 C49 C50 C51 C52 C53 C54 C55 C56 C57 C58 PRN LIST" << endl;
    130   _out << "C59 C60 C61 C62 C63 J01 J02 J03 J04 I01 I02 I03 I04 I05 I06 PRN LIST" << endl;
    131   _out << "I07 S20 S24 S27 S28 S29 S33 S35 S37 S38                     PRN LIST" << endl;
     135  for (int ii = 0; ii < prnList.size(); ii += 15) {
     136    _out << QStringList(prnList.mid(ii, 15)).join(" ").leftJustified(60, ' ').toLatin1().data()
     137         << "PRN LIST" << endl;
     138  }
    132139
    133140  _out << "     0    IGS20                                             "
  • trunk/BNC/src/bnchelp.html

    r11227 r11228  
    143143    &nbsp; &nbsp; &nbsp; 2.7 <a href="#sp3comp"><b>SP3 Comparison</b></a><br>
    144144    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2.7.1 <a href="#sp3input">Input SP3 Files</a><br>
    145     &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2.7.2 <a href="#sp3exclude">Exclude Satellites</a><br>
    146     &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2.7.3 <a href="#sp3log">Logfile</a><br>
     145    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2.7.2 <a href="#sp3clk">Input Clock RINEX Files</a><br>
     146    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2.7.3 <a href="#sp3exclude">Exclude Satellites</a><br>
     147    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2.7.4 <a href="#sp3log">Logfile</a><br>
    147148    &nbsp; &nbsp; &nbsp; 2.8 <a href="#correct"><b>Broadcast Corrections</b></a><br>
    148149    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2.8.1 <a href="#corrdir">Directory, ASCII</a><br>
    … …  
    457458      <td>Graphical results from an example comparison of two SP3 files with satellite orbit and clock data using BNC
    458459      </td>
    459       <td>2.7.3</td>
     460      <td>2.7.4</td>
    460461    </tr>
    461462    <tr>
    … …  
    45324533    If so, then BNC only compares records for identical epochs. BNC accepts that a specific GNSS system
    45334534    or a specific satellite is only available from one of the SP3 files.
    4534     Note that BNC does not interpolate orbits when comparing SP3 files.
     4535    Orbits are not interpolated, unless clock RINEX files are given (see 'Input Clock RINEX Files').
    45354536  </p>
    45364537  <p>
    … …  
    45654566
    45664567  <p>
    4567   <h4 id="sp3exclude">2.7.2 Exclude Satellites - optional</h4>
     4568  <h4 id="sp3clk">2.7.2 Input Clock RINEX Files - optional</h4>
     4569  </p>
     4570  <p>
     4571    Rapid and final products often provide the satellite clocks with a higher sampling in clock RINEX files
     4572    (e.g. 30 seconds) than in their SP3 files (e.g. 5 minutes). Comparing the SP3 files only at their common epochs
     4573    then misses short clock events, e.g. jumps lasting less than the SP3 sampling interval. You may therefore
     4574    specify the full paths of clock RINEX files, separated by comma and in the order of the SP3 files. A single file
     4575    refers to the first SP3 file; enter '-' for an SP3 file without clock RINEX file. Example:
     4576  </p>
     4577  <p>
     4578    <code>GBM0MGXRAP_20263290000_01D_30S_CLK.CLK</code> (clock RINEX file of SP3 file 1)<br>
     4579    <code>-,BKG0MGXRTS_20263290000_01D_30S_CLK.CLK</code> (clock RINEX file of SP3 file 2 only)
     4580  </p>
     4581  <p>
     4582    The satellite clocks of a clock RINEX file ('AS' records) replace those of the corresponding SP3 file. The clocks
     4583    and the signal-in-space differences are then compared at all epochs common to the two clock sources. Where such
     4584    an epoch is not an SP3 epoch, the orbit is interpolated with a Lagrange polynomial through ten consecutive SP3
     4585    epochs (no extrapolation, no data gaps; interpolation error about 1 mm for 5-minute GNSS orbits). The orbit
     4586    statistics ('radialRMS' to 'nOrb') refer to the common SP3 epochs only, while 'nClk' counts the clock epochs.
     4587    A 30-second SP3 file written by BNC already contains the clocks of its clock RINEX file, so for the comparison of
     4588    BNC products with a rapid product a clock RINEX file of the rapid product is sufficient.
     4589  </p>
     4590  <p>
     4591    Default is an empty option field, meaning that the clocks of the SP3 files are compared.
     4592  </p>
     4593
     4594  <p>
     4595  <h4 id="sp3exclude">2.7.3 Exclude Satellites - optional</h4>
    45684596  </p>
    45694597  <p>
    … …  
    45844612
    45854613  <p>
    4586   <h4 id="sp3log">2.7.3 Logfile - mandatory if 'Input SP3 Files' is set</h4>
     4614  <h4 id="sp3log">2.7.4 Logfile - mandatory if 'Input SP3 Files' is set</h4>
    45874615  </p>
    45884616  <p>
    … …  
    1142411452SP3 Comparison Panel keys:
    1142511453   sp3CompFile        {SP3 input files, full path [character string, comma separated list in quotation marks]}
     11454   sp3CompClkFile     {Optional clock RINEX files for SP3 file 1 and 2, full path [character string, comma separated list in quotation marks, '-' for none]}
    1142611455   sp3CompExclude     {Satellite exclusion list [character string, comma separated list in quotation marks, example: G04,G31,R]}
    1142711456   sp3CompOutLogFile  {Output logfile, full path [character string]}
  • trunk/BNC/src/bncmain.cpp

    r11185 r11228  
    215215        "SP3 Comparison Panel keys:\n"
    216216        "   sp3CompFile        {SP3 input files, full path [character string, comma separated list in quotation marks]}\n"
     217        "   sp3CompClkFile     {Optional clock RINEX files for SP3 file 1 and 2, full path [character string, comma separated list in quotation marks, '-' for none]}\n"
    217218        "   sp3CompExclude     {Satellite exclusion list [character string, comma separated list in quotation marks, example: G04,G31,R]}\n"
    218219        "   sp3CompOutLogFile  {Output logfile, full path [character string]}\n"
  • trunk/BNC/src/bncsettings.cpp

    r11185 r11228  
    138138        // SP3
    139139        setValue_p("sp3CompFile", "");
     140        setValue_p("sp3CompClkFile", "");
    140141        setValue_p("sp3CompExclude", "");
    141142        setValue_p("sp3CompOutLogFile", "");
  • trunk/BNC/src/bncwindow.cpp

    r11189 r11228  
    14011401  _sp3CompFileChooser->setMaximumWidth(40 * ww);
    14021402
     1403  _sp3CompClkLineEdit = new QLineEdit(settings.value("sp3CompClkFile").toString());
     1404  _sp3CompClkLineEdit->setMinimumWidth(15 * ww);
     1405  _sp3CompClkLineEdit->setMaximumWidth(40 * ww);
     1406
    14031407  _sp3CompExclude = new QLineEdit(settings.value("sp3CompExclude").toString());
    14041408  _sp3CompExclude->setMinimumWidth(18 * ww);
    … …  
    14171421  sp3CompLayout->addWidget(new QLabel("Input SP3 files (full path)"), ir, 0, Qt::AlignLeft);
    14181422  sp3CompLayout->addWidget(_sp3CompFileChooser, ir, 1, 1, 20);
     1423  ++ir;
     1424  sp3CompLayout->addWidget(new QLabel("Input clock RINEX files (optional)"), ir, 0, Qt::AlignLeft);
     1425  sp3CompLayout->addWidget(_sp3CompClkLineEdit, ir, 1, 1, 20);
    14191426  ++ir;
    14201427  sp3CompLayout->addWidget(new QLabel("Exclude satellites"), ir, 0, Qt::AlignLeft);
    … …  
    16351642  // -------------------------
    16361643  _sp3CompFileChooser->setWhatsThis(tr("<p>BNC can compare two SP3 files containing GNSS satellite orbit and clock information.</p></p>Specify the full path to two files with orbits and clocks in SP3 format, separate them by comma. <i>[key: sp3CompFile]</i></p>"));
     1644  _sp3CompClkLineEdit->setWhatsThis(tr("<p>Optionally specify the full path to clock RINEX files with the satellite clocks of the SP3 files, separated by comma and in the order of the SP3 files. A single file refers to the first SP3 file; enter '-' for an SP3 file without clock RINEX file. Example:<p>GBM0MGXRAP_20263290000_01D_30S_CLK.CLK</p><p>The clocks of a clock RINEX file replace those of the corresponding SP3 file. Clocks and signal-in-space differences are then compared at all common epochs of the clocks (e.g. every 30 sec instead of every 5 min), the orbits being interpolated between the SP3 epochs where necessary. The orbit statistics refer to the common SP3 epochs only.</p><p>Default is an empty option field, meaning that the clocks of the SP3 files are compared. <i>[key: sp3CompClkFile]</i></p>"));
    16371645  _sp3CompExclude->setWhatsThis(tr("<p>Specify satellites to exclude them from orbit and clock comparison. Example:<p>G04,G31,R</p><p>This excludes GPS satellites PRN 4 and 31 as well as all GLONASS satellites from the comparison.</p><p>Default is an empty option field, meaning that no satellite is excluded from the comparison. <i>[key: sp3CompExclude]</i></p>"));
    16381646  _sp3CompLogLineEdit->setWhatsThis(tr("<p>Specify the full path to a logfile saving comparison results.</p><p>Specifying a logfile is mandatory. Comparing SP3 files and not saving comparison results on disk would be useless. <i>[key: sp3CompOutLogFile]</i></p>"));
    … …  
    20012009  delete _reqcEditOptionButton;
    20022010  delete _sp3CompFileChooser;
     2011  delete _sp3CompClkLineEdit;
    20032012  delete _sp3CompExclude;
    20042013  delete _sp3CompLogLineEdit;
    … …  
    25172526  // SP3 Comparison
    25182527  settings.setValue("sp3CompFile", _sp3CompFileChooser->fileName());
     2528  settings.setValue("sp3CompClkFile", _sp3CompClkLineEdit->text());
    25192529  settings.setValue("sp3CompExclude", _sp3CompExclude->text());
    25202530  settings.setValue("sp3CompOutLogFile", _sp3CompLogLineEdit->text());
    … …  
    31623172    enable = !_sp3CompFileChooser->fileName().isEmpty();
    31633173    enableWidget(enable, _sp3CompLogLineEdit);
     3174    enableWidget(enable, _sp3CompClkLineEdit);
    31643175    enableWidget(enable, _sp3CompExclude);
    31653176    enableWidget(enable, _sp3CompSummaryOnly);
  • trunk/BNC/src/bncwindow.h

    r11195 r11228  
    172172
    173173    qtFileChooser* _sp3CompFileChooser;
     174    QLineEdit* _sp3CompClkLineEdit;
    174175    QLineEdit* _sp3CompExclude;
    175176    QLineEdit* _sp3CompLogLineEdit;
  • trunk/BNC/src/orbComp/sp3Comp.cpp

    r11158 r11228  
    3535 * Created:    24-Nov-2014
    3636 *
    37  * Changes:
     37 * Changes:    26-Nov-2026: optional clock RINEX files (sp3CompClkFile): clocks
     38 *                           and SIS at the epochs of the clock files, orbits
     39 *                           interpolated between the SP3 epochs
    3840 *
    3941 * -----------------------------------------------------------------------*/
    … …  
    4143#include <QRegularExpression>
    4244#include <iostream>
     45#include <fstream>
    4346#include <iomanip>
     47#include <algorithm>
    4448#include "sp3Comp.h"
    4549#include "bnccore.h"
    … …  
    5862  for (int ii = 0; ii < _sp3FileNames.size(); ii++) {
    5963    expandEnvVar(_sp3FileNames[ii]);
     64  }
     65  // Clock RINEX files, in the order of the SP3 files; one name refers to
     66  // SP3 file 1, an empty entry or "-" to no clock file
     67  QString clkFiles = settings.value("sp3CompClkFile").toString().trimmed();
     68  if (!clkFiles.isEmpty()) {
     69    _clkFileNames = clkFiles.split(",", Qt::KeepEmptyParts);
     70    for (int ii = 0; ii < _clkFileNames.size(); ii++) {
     71      _clkFileNames[ii] = _clkFileNames[ii].trimmed();
     72      if (_clkFileNames[ii] == "-") {
     73        _clkFileNames[ii].clear();
     74      }
     75      expandEnvVar(_clkFileNames[ii]);
     76    }
    6077  }
    6178  _logFileName = settings.value("sp3CompOutLogFile").toString(); expandEnvVar(_logFileName);
    … …  
    94111    *_log << "! SP3 File " << ii+1 << ": " << _sp3FileNames[ii] << "\n";
    95112  }
     113  for (int ii = 0; ii < _clkFileNames.size(); ii++) {
     114    if (!_clkFileNames[ii].isEmpty()) {
     115      *_log << "! CLK File " << ii+1 << ": " << _clkFileNames[ii] << "\n";
     116    }
     117  }
    96118  if (_sp3FileNames.size() != 2) {
    97119    *_log << "ERROR: sp3Comp requires two input SP3 files" << "\n";
     120    goto end;
     121  }
     122  if (_clkFileNames.size() > 2) {
     123    *_log << "ERROR: sp3Comp accepts at most two clock RINEX files" << "\n";
    98124    goto end;
    99125  }
    … …  
    280306void t_sp3Comp::compare(ostringstream& out) const {
    281307
    282   // Synchronize reading of two sp3 files
    283   // ------------------------------------
    284   bncSP3 in1(_sp3FileNames[0]); in1.nextEpoch();
    285   bncSP3 in2(_sp3FileNames[1]); in2.nextEpoch();
     308  // Read the SP3 files (and clock RINEX files)
     309  // -------------------------------------------
     310  t_sp3Data sp3[2];
     311  map<bncTime, map<t_prn, double> > clk[2];
     312  bool withClkFiles = false;
     313  for (int ii = 0; ii < 2; ii++) {
     314    readSp3(_sp3FileNames[ii], sp3[ii]);
     315    if (ii < _clkFileNames.size() && !_clkFileNames[ii].isEmpty()) {
     316      readClk(_clkFileNames[ii], clk[ii]);
     317      withClkFiles = true;
     318      if (clk[ii].empty()) {
     319        throw "t_sp3Comp: no clocks in clock RINEX file " + string(_clkFileNames[ii].toLatin1().data());
     320      }
     321    }
     322    else {
     323      clk[ii] = sp3[ii]._clk;
     324    }
     325  }
    286326
    287327  vector<t_epoch*> epochs;
    288   while (in1.currEpoch() && in2.currEpoch()) {
    289     bncTime t1 = in1.currEpoch()->_tt;
    290     bncTime t2 = in2.currEpoch()->_tt;
    291     if      (t1 < t2) {
    292       in1.nextEpoch();
    293     }
    294     else if (t1 > t2) {
    295       in2.nextEpoch();
    296     }
    297     else if (t1 == t2) {
    298       t_epoch* epo = new t_epoch; epo->_tt = t1;
    299       bool epochOK = false;
    300       for (int i1 = 0; i1 < in1.currEpoch()->_sp3Sat.size(); i1++) {
    301         bncSP3::t_sp3Sat* sat1 = in1.currEpoch()->_sp3Sat[i1];
    302         for (int i2 = 0; i2 < in2.currEpoch()->_sp3Sat.size(); i2++) {
    303           bncSP3::t_sp3Sat* sat2 = in2.currEpoch()->_sp3Sat[i2];
    304           if (sat1->_prn == sat2->_prn &&
    305               sat1->_clkValid && sat2->_clkValid) {
    306             epochOK = true;
    307             epo->_dr[sat1->_prn]  = sat1->_xyz - sat2->_xyz;
    308             epo->_xyz[sat1->_prn] = sat1->_xyz;
    309             epo->_dc[sat1->_prn]  = sat1->_clk - sat2->_clk;
    310           }
    311         }
    312       }
    313       if (epochOK) {
     328  if (!withClkFiles) {
     329    // Common epochs of the two SP3 files, satellites with valid clocks in both
     330    // -------------------------------------------------------------------------
     331    map<bncTime, map<t_prn, ColumnVector> >::const_iterator it1;
     332    for (it1 = sp3[0]._xyz.begin(); it1 != sp3[0]._xyz.end(); it1++) {
     333      const bncTime& tt = it1->first;
     334      map<bncTime, map<t_prn, ColumnVector> >::const_iterator it2 = sp3[1]._xyz.find(tt);
     335      if (it2 == sp3[1]._xyz.end()) {
     336        continue;
     337      }
     338      const map<t_prn, double>& c1 = clk[0][tt];
     339      const map<t_prn, double>& c2 = clk[1][tt];
     340      t_epoch* epo = new t_epoch; epo->_tt = tt;
     341      for (map<t_prn, ColumnVector>::const_iterator is = it1->second.begin(); is != it1->second.end(); is++) {
     342        const t_prn& prn = is->first;
     343        map<t_prn, ColumnVector>::const_iterator jj = it2->second.find(prn);
     344        if (jj != it2->second.end() && c1.find(prn) != c1.end() && c2.find(prn) != c2.end()) {
     345          epo->_dr[prn]  = is->second - jj->second;
     346          epo->_xyz[prn] = is->second;
     347          epo->_dc[prn]  = c1.find(prn)->second - c2.find(prn)->second;
     348        }
     349      }
     350      if (epo->_dc.size() > 0) {
    314351        epochs.push_back(epo);
    315352      }
    … …  
    317354        delete epo;
    318355      }
    319       in1.nextEpoch();
    320       in2.nextEpoch();
     356    }
     357  }
     358  else {
     359    // Common epochs of the two clock sources; the orbits are interpolated
     360    // between the SP3 epochs where necessary and then used for the clock
     361    // comparison and the SIS only (orbit statistics: common SP3 epochs)
     362    // ---------------------------------------------------------------------
     363    map<bncTime, map<t_prn, double> >::const_iterator it1;
     364    for (it1 = clk[0].begin(); it1 != clk[0].end(); it1++) {
     365      const bncTime& tt = it1->first;
     366      map<bncTime, map<t_prn, double> >::const_iterator it2 = clk[1].find(tt);
     367      if (it2 == clk[1].end()) {
     368        continue;
     369      }
     370      t_epoch* epo = new t_epoch; epo->_tt = tt;
     371      for (map<t_prn, double>::const_iterator is = it1->second.begin(); is != it1->second.end(); is++) {
     372        const t_prn& prn = is->first;
     373        map<t_prn, double>::const_iterator jj = it2->second.find(prn);
     374        if (jj == it2->second.end()) {
     375          continue;
     376        }
     377        ColumnVector xyz1, xyz2;
     378        bool interp1, interp2;
     379        if (!orbit(sp3[0], prn, tt, xyz1, interp1) || !orbit(sp3[1], prn, tt, xyz2, interp2)) {
     380          continue;
     381        }
     382        epo->_dr[prn]  = xyz1 - xyz2;
     383        epo->_xyz[prn] = xyz1;
     384        epo->_dc[prn]  = is->second - jj->second;
     385        if (interp1 || interp2) {
     386          epo->_orbInterp.insert(prn);
     387        }
     388      }
     389      if (epo->_dc.size() > 0) {
     390        epochs.push_back(epo);
     391      }
     392      else {
     393        delete epo;
     394      }
    321395    }
    322396  }
    … …  
    413487              << setw(7) << setprecision(4) << rao[2] << "    ";
    414488        }
    415         stat[prn.toString()]._rao += SP(rao, rao); // Schur product
    416         stat[all.str()     ]._rao += SP(rao, rao);
    417         stat[prn.toString()]._nr  += 1;
    418         stat[all.str()     ]._nr  += 1;
     489        if (epo->_orbInterp.find(prn) == epo->_orbInterp.end()) {
     490          stat[prn.toString()]._rao += SP(rao, rao); // Schur product
     491          stat[all.str()     ]._rao += SP(rao, rao);
     492          stat[prn.toString()]._nr  += 1;
     493          stat[all.str()     ]._nr  += 1;
     494        }
    419495        if (dc.find(prn) != dc.end() && dcRed.find(prn) != dc.end()) {
    420496          double clkRes    = dc.find(prn)->second;
    … …  
    482558    char sys = prn[0];
    483559    stringstream all; all << sys << 99;
    484     if (stat._nr > 0) {
    485       stat._rao[0] = sqrt(stat._rao[0] / stat._nr);
    486       stat._rao[1] = sqrt(stat._rao[1] / stat._nr);
    487       stat._rao[2] = sqrt(stat._rao[2] / stat._nr);
    488       stat._rao3DRMS = stat._rao.NormFrobenius();
     560    if (stat._nr > 0 || stat._nc > 0) {
     561      if (stat._nr > 0) {
     562        stat._rao[0] = sqrt(stat._rao[0] / stat._nr);
     563        stat._rao[1] = sqrt(stat._rao[1] / stat._nr);
     564        stat._rao[2] = sqrt(stat._rao[2] / stat._nr);
     565        stat._rao3DRMS = stat._rao.NormFrobenius();
     566      }
    489567      // orbit values in millimeter
    490568      if (prn != all.str()) {
    … …  
    529607}
    530608
     609// Read an SP3 file (positions, valid clocks, orbit series per satellite)
     610////////////////////////////////////////////////////////////////////////////
     611void t_sp3Comp::readSp3(const QString& fileName, t_sp3Data& data) const {
     612  bncSP3 in(fileName);
     613  bncTime lastTime;
     614  while (const bncSP3::t_sp3Epoch* epo = in.nextEpoch()) {
     615    const bncTime& tt = epo->_tt;
     616    if (lastTime.valid()) {
     617      double dt = tt - lastTime;
     618      if (dt > 0.0 && (data._sampl == 0.0 || dt < data._sampl)) {
     619        data._sampl = dt;
     620      }
     621    }
     622    lastTime = tt;
     623    map<t_prn, ColumnVector>& xyz = data._xyz[tt];
     624    for (int ii = 0; ii < epo->_sp3Sat.size(); ii++) {
     625      const bncSP3::t_sp3Sat* sat = epo->_sp3Sat[ii];
     626      xyz[sat->_prn] = sat->_xyz;
     627      if (sat->_clkValid) {
     628        data._clk[tt][sat->_prn] = sat->_clk;
     629      }
     630    }
     631  }
     632  map<bncTime, map<t_prn, ColumnVector> >::const_iterator it;
     633  for (it = data._xyz.begin(); it != data._xyz.end(); it++) {
     634    map<t_prn, ColumnVector>::const_iterator is;
     635    for (is = it->second.begin(); is != it->second.end(); is++) {
     636      t_orbSeries& series = data._series[is->first];
     637      series._tt.push_back(it->first);
     638      series._xyz.push_back(is->second);
     639    }
     640  }
     641}
     642
     643// Read the satellite clocks (AS records) of a clock RINEX file [m]
     644////////////////////////////////////////////////////////////////////////////
     645void t_sp3Comp::readClk(const QString& fileName,
     646                        map<bncTime, map<t_prn, double> >& clk) const {
     647  ifstream in(fileName.toLocal8Bit().data());
     648  if (!in.good()) {
     649    throw "t_sp3Comp: cannot open clock RINEX file " + string(fileName.toLatin1().data());
     650  }
     651  string line;
     652  bool header = true;
     653  while (getline(in, line)) {
     654    if (header) {
     655      if (line.find("END OF HEADER") != string::npos) {
     656        header = false;
     657      }
     658      continue;
     659    }
     660    if (line.compare(0, 3, "AS ") != 0) {   // other records, continuation lines
     661      continue;
     662    }
     663    replace(line.begin(), line.end(), 'D', 'E');   // Fortran exponent
     664    replace(line.begin(), line.end(), 'd', 'E');
     665    istringstream inLine(line.substr(3));
     666    string prnStr;
     667    int    YY, MM, DD, hh, mm, numValues;
     668    double ss, value;
     669    inLine >> prnStr >> YY >> MM >> DD >> hh >> mm >> ss >> numValues >> value;
     670    if (inLine.fail() || numValues < 1 || prnStr.size() < 3) {
     671      continue;
     672    }
     673    t_prn prn;
     674    try {
     675      prn.set(prnStr);
     676    }
     677    catch (...) {        // satellite system not supported
     678      continue;
     679    }
     680    if (prn.number() == 0) {
     681      continue;
     682    }
     683    bncTime tt; tt.set(YY, MM, DD, hh, mm, ss);
     684    clk[tt][prn] = value * t_CST::c;
     685  }
     686}
     687
     688// Satellite position at epoch tt: the SP3 position if tt is an SP3 epoch,
     689// otherwise Lagrange interpolation with 10 consecutive SP3 epochs around tt
     690// (no extrapolation, no data gaps longer than 1.5 sampling intervals)
     691////////////////////////////////////////////////////////////////////////////
     692bool t_sp3Comp::orbit(const t_sp3Data& data, const t_prn& prn, const bncTime& tt,
     693                      ColumnVector& xyz, bool& interpolated) const {
     694  const unsigned NUMNODES = 10;
     695  interpolated = false;
     696  map<t_prn, t_orbSeries>::const_iterator itS = data._series.find(prn);
     697  if (itS == data._series.end()) {
     698    return false;
     699  }
     700  const t_orbSeries& series = itS->second;
     701  const vector<bncTime>& times = series._tt;
     702  vector<bncTime>::const_iterator it = lower_bound(times.begin(), times.end(), tt);
     703  if (it != times.end() && *it == tt) {
     704    xyz = series._xyz[it - times.begin()];
     705    return true;
     706  }
     707  if (it == times.begin() || it == times.end() || data._sampl <= 0.0) {
     708    return false;
     709  }
     710  const double maxGap = 1.5 * data._sampl;
     711  int lo = (it - times.begin()) - 1;
     712  int hi = lo + 1;
     713  if (times[hi] - times[lo] > maxGap) {
     714    return false;
     715  }
     716  // extend the window alternately to both sides
     717  while (unsigned(hi - lo + 1) < NUMNODES) {
     718    bool left  = (lo > 0 && times[lo] - times[lo-1] <= maxGap);
     719    bool right = (hi < int(times.size()) - 1 && times[hi+1] - times[hi] <= maxGap);
     720    if (!left && !right) {
     721      return false;
     722    }
     723    if (left && (!right || (tt - times[lo]) <= (times[hi] - tt))) {
     724      --lo;
     725    }
     726    else {
     727      ++hi;
     728    }
     729  }
     730  xyz.ReSize(3); xyz = 0.0;
     731  for (int ii = lo; ii <= hi; ii++) {
     732    double weight = 1.0;
     733    for (int jj = lo; jj <= hi; jj++) {
     734      if (jj != ii) {
     735        weight *= (tt - times[jj]) / (times[ii] - times[jj]);
     736      }
     737    }
     738    xyz += weight * series._xyz[ii];
     739  }
     740  interpolated = true;
     741  return true;
     742}
     743
    531744//
    532745////////////////////////////////////////////////////////////////////////////
  • trunk/BNC/src/orbComp/sp3Comp.h

    r11076 r11228  
    6262    std::map<t_prn, double>       _dcRed;
    6363    std::map<t_prn, double>       _sis;   // radial - clock, epoch-wise clock offset removed only
     64    std::set<t_prn>               _orbInterp; // orbit of at least one file interpolated
     65  };
     66
     67  // Orbit positions of one satellite (one SP3 file), sorted by time
     68  class t_orbSeries {
     69   public:
     70    std::vector<bncTime>      _tt;
     71    std::vector<ColumnVector> _xyz;
     72  };
     73
     74  // Contents of one SP3 file
     75  class t_sp3Data {
     76   public:
     77    t_sp3Data() : _sampl(0.0) {}
     78    std::map<bncTime, std::map<t_prn, ColumnVector> > _xyz;  // all positions
     79    std::map<bncTime, std::map<t_prn, double> >       _clk;  // valid clocks [m]
     80    std::map<t_prn, t_orbSeries>                      _series;
     81    double                                            _sampl; // smallest epoch interval [s]
    6482  };
    6583
    … …  
    99117  void compare(std::ostringstream& out) const;
    100118  bool excludeSat(const t_prn& prn) const;
     119  void readSp3(const QString& fileName, t_sp3Data& data) const;
     120  void readClk(const QString& fileName,
     121               std::map<bncTime, std::map<t_prn, double> >& clk) const;
     122  bool orbit(const t_sp3Data& data, const t_prn& prn, const bncTime& tt,
     123             ColumnVector& xyz, bool& interpolated) const;
    101124
    102125  QStringList  _sp3FileNames;
     126  QStringList  _clkFileNames;   // clock RINEX files for SP3 file 1 and 2 (empty: none)
    103127  QString      _logFileName;
    104128  QFile*       _logFile;
  • trunk/BNC/tests/README.md

    r11220 r11228  
    5353  `sp3_compare_exclude` (scripts 24, 23, 28). The QC cases use the 1 h BRUX
    5454  files instead of the full-day file.
     55* `sp3_compare_clk`, `sp3_compare_clk_bnc`: SP3 comparison with clock RINEX
     56  files (`sp3CompClkFile`): GFZ rapid GFZ0OPSRAP (5 min SP3, 30 s clocks) vs a
     57  30 s BNC SP3 of IGS03 (21 Nov 2026 09:55-10:25, `data/sp3clk_*`); clocks at
     58  the 30 s epochs with interpolated orbits, resp. `-` for file 1 and the BNC
     59  clock file for file 2.
    5560* `rinex_edit_minele`: Edit/Concatenate with a 10 deg elevation mask (1 h BRUX
    5661  files), covering the ephemeris selection for the elevation mask.
Note: See TracChangeset for help on using the changeset viewer.