[3899] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
| 3 | //
|
---|
| 4 | // Copyright (C) 2007
|
---|
| 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
| 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
| 8 | // http://www.fsv.cvut.cz
|
---|
| 9 | //
|
---|
| 10 | // Email: euref-ip@bkg.bund.de
|
---|
| 11 | //
|
---|
| 12 | // This program is free software; you can redistribute it and/or
|
---|
| 13 | // modify it under the terms of the GNU General Public License
|
---|
| 14 | // as published by the Free Software Foundation, version 2.
|
---|
| 15 | //
|
---|
| 16 | // This program is distributed in the hope that it will be useful,
|
---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | // GNU General Public License for more details.
|
---|
| 20 | //
|
---|
| 21 | // You should have received a copy of the GNU General Public License
|
---|
| 22 | // along with this program; if not, write to the Free Software
|
---|
| 23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
| 26 | * BKG NTRIP Client
|
---|
| 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: t_reqcAnalyze
|
---|
| 30 | *
|
---|
| 31 | * Purpose: Analyze RINEX Files
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 11-Apr-2012
|
---|
| 36 | *
|
---|
[6255] | 37 | * Changes:
|
---|
[3899] | 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
| 41 | #include <iostream>
|
---|
[4361] | 42 | #include <iomanip>
|
---|
[4579] | 43 | #include <qwt_plot_renderer.h>
|
---|
[4574] | 44 |
|
---|
[3899] | 45 | #include "reqcanalyze.h"
|
---|
[5070] | 46 | #include "bnccore.h"
|
---|
[3899] | 47 | #include "bncsettings.h"
|
---|
[4254] | 48 | #include "reqcedit.h"
|
---|
[4255] | 49 | #include "bncutils.h"
|
---|
[4300] | 50 | #include "graphwin.h"
|
---|
[4307] | 51 | #include "polarplot.h"
|
---|
[4577] | 52 | #include "availplot.h"
|
---|
[4662] | 53 | #include "eleplot.h"
|
---|
[4672] | 54 | #include "dopplot.h"
|
---|
[3899] | 55 |
|
---|
| 56 | using namespace std;
|
---|
| 57 |
|
---|
| 58 | // Constructor
|
---|
| 59 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 60 | t_reqcAnalyze::t_reqcAnalyze(QObject* parent) : QThread(parent) {
|
---|
| 61 |
|
---|
| 62 | bncSettings settings;
|
---|
[4254] | 63 |
|
---|
[4257] | 64 | _logFileName = settings.value("reqcOutLogFile").toString(); expandEnvVar(_logFileName);
|
---|
| 65 | _logFile = 0;
|
---|
| 66 | _log = 0;
|
---|
[6271] | 67 | _currEpo = 0;
|
---|
[4254] | 68 | _obsFileNames = settings.value("reqcObsFile").toString().split(",", QString::SkipEmptyParts);
|
---|
[4257] | 69 | _navFileNames = settings.value("reqcNavFile").toString().split(",", QString::SkipEmptyParts);
|
---|
[6275] | 70 |
|
---|
| 71 | connect(this, SIGNAL(dspSkyPlot(const QString&, const QByteArray&, QVector<t_polarPoint*>*,
|
---|
| 72 | const QByteArray&, QVector<t_polarPoint*>*,
|
---|
| 73 | const QByteArray&, double)),
|
---|
| 74 | this, SLOT(slotDspSkyPlot(const QString&, const QByteArray&, QVector<t_polarPoint*>*,
|
---|
| 75 | const QByteArray&, QVector<t_polarPoint*>*,
|
---|
| 76 | const QByteArray&, double)));
|
---|
| 77 |
|
---|
| 78 | connect(this, SIGNAL(dspAvailPlot(const QString&, const QByteArray&)),
|
---|
| 79 | this, SLOT(slotDspAvailPlot(const QString&, const QByteArray&)));
|
---|
[3899] | 80 | }
|
---|
| 81 |
|
---|
| 82 | // Destructor
|
---|
| 83 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 84 | t_reqcAnalyze::~t_reqcAnalyze() {
|
---|
[4255] | 85 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 86 | delete _rnxObsFiles[ii];
|
---|
| 87 | }
|
---|
| 88 | for (int ii = 0; ii < _ephs.size(); ii++) {
|
---|
| 89 | delete _ephs[ii];
|
---|
| 90 | }
|
---|
| 91 | delete _log; _log = 0;
|
---|
| 92 | delete _logFile; _logFile = 0;
|
---|
[5072] | 93 | if (BNC_CORE->mode() != t_bncCore::interactive) {
|
---|
[5066] | 94 | qApp->exit(0);
|
---|
[4452] | 95 | }
|
---|
[3899] | 96 | }
|
---|
| 97 |
|
---|
[6255] | 98 | //
|
---|
[3899] | 99 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 100 | void t_reqcAnalyze::run() {
|
---|
| 101 |
|
---|
[4255] | 102 | // Open Log File
|
---|
| 103 | // -------------
|
---|
| 104 | _logFile = new QFile(_logFileName);
|
---|
[4517] | 105 | if (_logFile->open(QIODevice::WriteOnly | QIODevice::Text)) {
|
---|
| 106 | _log = new QTextStream();
|
---|
| 107 | _log->setDevice(_logFile);
|
---|
| 108 | }
|
---|
[4255] | 109 |
|
---|
| 110 | // Initialize RINEX Observation Files
|
---|
| 111 | // ----------------------------------
|
---|
[4525] | 112 | t_reqcEdit::initRnxObsFiles(_obsFileNames, _rnxObsFiles, _log);
|
---|
[3899] | 113 |
|
---|
[4257] | 114 | // Read Ephemerides
|
---|
| 115 | // ----------------
|
---|
| 116 | t_reqcEdit::readEphemerides(_navFileNames, _ephs);
|
---|
| 117 |
|
---|
[4255] | 118 | // Loop over all RINEX Files
|
---|
| 119 | // -------------------------
|
---|
[4254] | 120 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 121 | analyzeFile(_rnxObsFiles[ii]);
|
---|
| 122 | }
|
---|
| 123 |
|
---|
[4255] | 124 | // Exit
|
---|
| 125 | // ----
|
---|
[4452] | 126 | emit finished();
|
---|
| 127 | deleteLater();
|
---|
[3899] | 128 | }
|
---|
[4254] | 129 |
|
---|
[6255] | 130 | //
|
---|
[4254] | 131 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4260] | 132 | void t_reqcAnalyze::analyzeFile(t_rnxObsFile* obsFile) {
|
---|
[4259] | 133 |
|
---|
[6271] | 134 | _qcFile.clear();
|
---|
[4343] | 135 |
|
---|
[4342] | 136 | // A priori Coordinates
|
---|
| 137 | // --------------------
|
---|
[4679] | 138 | ColumnVector xyzSta = obsFile->xyz();
|
---|
[4342] | 139 |
|
---|
[4262] | 140 | // Loop over all Epochs
|
---|
| 141 | // --------------------
|
---|
[4541] | 142 | try {
|
---|
[6271] | 143 | bool firstEpo = true;
|
---|
[4541] | 144 | while ( (_currEpo = obsFile->nextEpoch()) != 0) {
|
---|
[6271] | 145 | if (firstEpo) {
|
---|
| 146 | firstEpo = false;
|
---|
| 147 | _qcFile._startTime = _currEpo->tt;
|
---|
| 148 | _qcFile._antennaName = obsFile->antennaName();
|
---|
| 149 | _qcFile._markerName = obsFile->markerName();
|
---|
| 150 | _qcFile._receiverType = obsFile->receiverType();
|
---|
| 151 | _qcFile._interval = obsFile->interval();
|
---|
[4688] | 152 | }
|
---|
[6271] | 153 | _qcFile._endTime = _currEpo->tt;
|
---|
[6255] | 154 |
|
---|
[6271] | 155 | t_qcEpo qcEpo;
|
---|
| 156 | qcEpo._epoTime = _currEpo->tt;
|
---|
| 157 | qcEpo._PDOP = cmpDOP(xyzSta);
|
---|
| 158 |
|
---|
[4541] | 159 | // Loop over all satellites
|
---|
| 160 | // ------------------------
|
---|
| 161 | for (unsigned iObs = 0; iObs < _currEpo->rnxSat.size(); iObs++) {
|
---|
| 162 | const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iObs];
|
---|
[6271] | 163 | t_satObs satObs;
|
---|
| 164 | t_rnxObsFile::setObsFromRnx(obsFile, _currEpo, rnxSat, satObs);
|
---|
[6288] | 165 | t_qcSat& qcSat = qcEpo._qcSat[satObs._prn];
|
---|
| 166 | setQcObs(qcEpo._epoTime, xyzSta, satObs, qcSat);
|
---|
| 167 | updateQcSat(qcSat, _qcFile._qcSatSum[satObs._prn]);
|
---|
[4262] | 168 | }
|
---|
[6271] | 169 | _qcFile._qcEpo.push_back(qcEpo);
|
---|
| 170 | }
|
---|
[6255] | 171 |
|
---|
[6281] | 172 | analyzeMultipath();
|
---|
| 173 |
|
---|
[6271] | 174 | preparePlotData(obsFile);
|
---|
[4678] | 175 |
|
---|
[6284] | 176 | printReport(obsFile);
|
---|
[4541] | 177 | }
|
---|
| 178 | catch (QString str) {
|
---|
| 179 | if (_log) {
|
---|
| 180 | *_log << "Exception " << str << endl;
|
---|
[4262] | 181 | }
|
---|
[4541] | 182 | else {
|
---|
[6255] | 183 | qDebug() << str;
|
---|
[4541] | 184 | }
|
---|
| 185 | }
|
---|
[6271] | 186 | }
|
---|
[4262] | 187 |
|
---|
[6271] | 188 | // Compute Dilution of Precision
|
---|
| 189 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 190 | double t_reqcAnalyze::cmpDOP(const ColumnVector& xyzSta) const {
|
---|
[4268] | 191 |
|
---|
[6271] | 192 | if (xyzSta.size() != 3) {
|
---|
| 193 | return 0.0;
|
---|
[4268] | 194 | }
|
---|
| 195 |
|
---|
[6271] | 196 | unsigned nSat = _currEpo->rnxSat.size();
|
---|
[4706] | 197 |
|
---|
[6271] | 198 | if (nSat < 4) {
|
---|
| 199 | return 0.0;
|
---|
[4718] | 200 | }
|
---|
[6271] | 201 |
|
---|
| 202 | Matrix AA(nSat, 4);
|
---|
| 203 |
|
---|
| 204 | unsigned nSatUsed = 0;
|
---|
| 205 | for (unsigned iSat = 0; iSat < nSat; iSat++) {
|
---|
| 206 |
|
---|
| 207 | const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iSat];
|
---|
| 208 | const t_prn& prn = rnxSat.prn;
|
---|
| 209 |
|
---|
| 210 | t_eph* eph = 0;
|
---|
| 211 | for (int ie = 0; ie < _ephs.size(); ie++) {
|
---|
| 212 | if (_ephs[ie]->prn() == prn) {
|
---|
| 213 | eph = _ephs[ie];
|
---|
| 214 | break;
|
---|
| 215 | }
|
---|
[4718] | 216 | }
|
---|
[6271] | 217 | if (eph) {
|
---|
| 218 | ColumnVector xSat(4);
|
---|
| 219 | ColumnVector vv(3);
|
---|
| 220 | if (eph->getCrd(_currEpo->tt, xSat, vv, false) == success) {
|
---|
| 221 | ++nSatUsed;
|
---|
| 222 | ColumnVector dx = xSat.Rows(1,3) - xyzSta;
|
---|
| 223 | double rho = dx.norm_Frobenius();
|
---|
| 224 | AA(nSatUsed,1) = dx(1) / rho;
|
---|
| 225 | AA(nSatUsed,2) = dx(2) / rho;
|
---|
| 226 | AA(nSatUsed,3) = dx(3) / rho;
|
---|
| 227 | AA(nSatUsed,4) = 1.0;
|
---|
| 228 | }
|
---|
[4718] | 229 | }
|
---|
| 230 | }
|
---|
[6271] | 231 |
|
---|
| 232 | if (nSatUsed < 4) {
|
---|
| 233 | return 0.0;
|
---|
| 234 | }
|
---|
| 235 |
|
---|
| 236 | AA = AA.Rows(1, nSatUsed);
|
---|
| 237 |
|
---|
| 238 | SymmetricMatrix QQ;
|
---|
| 239 | QQ << AA.t() * AA;
|
---|
| 240 | QQ = QQ.i();
|
---|
| 241 |
|
---|
| 242 | return sqrt(QQ.trace());
|
---|
[4254] | 243 | }
|
---|
[4263] | 244 |
|
---|
[6255] | 245 | //
|
---|
[4263] | 246 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6288] | 247 | void t_reqcAnalyze::updateQcSat(const t_qcSat& qcSat, t_qcSatSum& qcSatSum) {
|
---|
[6285] | 248 |
|
---|
[6288] | 249 | for (int ii = 0; ii < qcSat._qcFrq.size(); ii++) {
|
---|
| 250 | const t_qcFrq& qcFrq = qcSat._qcFrq[ii];
|
---|
[6285] | 251 | t_qcFrqSum& qcFrqSum = qcSatSum._qcFrqSum[qcFrq._rnxType2ch];
|
---|
| 252 | qcFrqSum._numObs += 1;
|
---|
| 253 | if (qcFrq._slip) {
|
---|
| 254 | qcFrqSum._numSlipsFlagged += 1;
|
---|
| 255 | }
|
---|
| 256 | if (qcFrq._gap) {
|
---|
| 257 | qcFrqSum._numGaps += 1;
|
---|
| 258 | }
|
---|
[6271] | 259 | }
|
---|
| 260 | }
|
---|
[4265] | 261 |
|
---|
[6271] | 262 | //
|
---|
| 263 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6281] | 264 | void t_reqcAnalyze::setQcObs(const bncTime& epoTime, const ColumnVector& xyzSta,
|
---|
[6288] | 265 | const t_satObs& satObs, t_qcSat& qcSat) {
|
---|
[4338] | 266 |
|
---|
[6281] | 267 | t_eph* eph = 0;
|
---|
| 268 | for (int ie = 0; ie < _ephs.size(); ie++) {
|
---|
| 269 | if (_ephs[ie]->prn() == satObs._prn) {
|
---|
| 270 | eph = _ephs[ie];
|
---|
| 271 | break;
|
---|
[6271] | 272 | }
|
---|
[6281] | 273 | }
|
---|
| 274 | if (eph) {
|
---|
| 275 | ColumnVector xc(4);
|
---|
| 276 | ColumnVector vv(3);
|
---|
| 277 | if (xyzSta.size() && eph->getCrd(epoTime, xc, vv, false) == success) {
|
---|
| 278 | double rho, eleSat, azSat;
|
---|
| 279 | topos(xyzSta(1), xyzSta(2), xyzSta(3), xc(1), xc(2), xc(3), rho, eleSat, azSat);
|
---|
[6288] | 280 | qcSat._eleSet = true;
|
---|
| 281 | qcSat._azDeg = azSat * 180.0/M_PI;
|
---|
| 282 | qcSat._eleDeg = eleSat * 180.0/M_PI;
|
---|
[6281] | 283 | }
|
---|
| 284 | if (satObs._prn.system() == 'R') {
|
---|
[6288] | 285 | qcSat._slotSet = true;
|
---|
| 286 | qcSat._slotNum = eph->slotNum();
|
---|
[6271] | 287 | }
|
---|
| 288 | }
|
---|
| 289 |
|
---|
[4608] | 290 | // Availability and Slip Flags
|
---|
| 291 | // ---------------------------
|
---|
[6285] | 292 | for (unsigned ii = 0; ii < satObs._obs.size(); ii++) {
|
---|
| 293 |
|
---|
| 294 | const t_frqObs* frqObs = satObs._obs[ii];
|
---|
| 295 |
|
---|
[6288] | 296 | qcSat._qcFrq.push_back(t_qcFrq());
|
---|
| 297 | t_qcFrq& qcFrq = qcSat._qcFrq.back();
|
---|
[6285] | 298 |
|
---|
| 299 | qcFrq._rnxType2ch = QString(frqObs->_rnxType2ch.c_str());
|
---|
| 300 | qcFrq._SNR = frqObs->_snr;
|
---|
| 301 | qcFrq._slip = frqObs->_slip;
|
---|
| 302 |
|
---|
| 303 | // Check Gaps
|
---|
| 304 | // ----------
|
---|
| 305 | if (qcFrq._lastObsTime.valid()) {
|
---|
| 306 | double dt = epoTime - qcFrq._lastObsTime;
|
---|
| 307 | if (dt > 1.5 * _qcFile._interval) {
|
---|
| 308 | qcFrq._gap = true;
|
---|
[6137] | 309 | }
|
---|
| 310 | }
|
---|
[6285] | 311 | qcFrq._lastObsTime = epoTime;
|
---|
| 312 |
|
---|
| 313 | // Compute the Multipath Linear Combination
|
---|
| 314 | // ----------------------------------------
|
---|
| 315 | if (frqObs->_phaseValid && frqObs->_codeValid) {
|
---|
| 316 | t_frequency::type fA;
|
---|
| 317 | t_frequency::type fB;
|
---|
| 318 | if (satObs._prn.system() == 'G') {
|
---|
| 319 | if (frqObs->_rnxType2ch[0] == '1') {
|
---|
| 320 | fA = t_frequency::G1;
|
---|
| 321 | fB = t_frequency::G2;
|
---|
| 322 | }
|
---|
| 323 | else if (frqObs->_rnxType2ch[0] == '2') {
|
---|
| 324 | fA = t_frequency::G2;
|
---|
| 325 | fB = t_frequency::G1;
|
---|
| 326 | }
|
---|
[6137] | 327 | }
|
---|
[6285] | 328 | else if (satObs._prn.system() == 'R') {
|
---|
| 329 | if (frqObs->_rnxType2ch[0] == '1') {
|
---|
| 330 | fA = t_frequency::R1;
|
---|
| 331 | fB = t_frequency::R2;
|
---|
| 332 | }
|
---|
| 333 | else if (frqObs->_rnxType2ch[0] == '2') {
|
---|
| 334 | fA = t_frequency::R2;
|
---|
| 335 | fB = t_frequency::R1;
|
---|
| 336 | }
|
---|
[6137] | 337 | }
|
---|
[6285] | 338 | else if (satObs._prn.system() == 'E') {
|
---|
| 339 | if (frqObs->_rnxType2ch[0] == '1') {
|
---|
| 340 | fA = t_frequency::E1;
|
---|
| 341 | fB = t_frequency::E5;
|
---|
| 342 | }
|
---|
| 343 | else if (frqObs->_rnxType2ch[0] == '5') {
|
---|
| 344 | fA = t_frequency::E5;
|
---|
| 345 | fB = t_frequency::E1;
|
---|
| 346 | }
|
---|
[6137] | 347 | }
|
---|
[4608] | 348 |
|
---|
[6285] | 349 | if (fA != t_frequency::dummy && fB != t_frequency::dummy) {
|
---|
| 350 | for (unsigned jj = 0; jj < satObs._obs.size(); jj++) {
|
---|
| 351 | const t_frqObs* frqObsB = satObs._obs[jj];
|
---|
| 352 | if (frqObsB->_rnxType2ch[0] == t_frequency::toString(fB)[1] &&
|
---|
| 353 | frqObsB->_phaseValid && frqObsB->_codeValid) {
|
---|
[4266] | 354 |
|
---|
[6288] | 355 | double f_a = t_CST::freq(fA, qcSat._slotNum);
|
---|
| 356 | double f_b = t_CST::freq(fB, qcSat._slotNum);
|
---|
[4266] | 357 |
|
---|
[6285] | 358 | double L_a = frqObs->_phase * t_CST::c / f_a;
|
---|
| 359 | double C_a = frqObs->_code;
|
---|
| 360 | double L_b = frqObsB->_phase * t_CST::c / f_b;
|
---|
| 361 |
|
---|
| 362 | qcFrq._setMP = true;
|
---|
| 363 | qcFrq._rawMP = C_a - L_a - 2.0*f_b*f_b/(f_a*f_a-f_b*f_b) * (L_a - L_b);
|
---|
| 364 | break;
|
---|
| 365 | }
|
---|
| 366 | }
|
---|
| 367 | }
|
---|
| 368 |
|
---|
| 369 | }
|
---|
[4265] | 370 | }
|
---|
[4263] | 371 | }
|
---|
[4350] | 372 |
|
---|
[6255] | 373 | //
|
---|
[4350] | 374 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6281] | 375 | void t_reqcAnalyze::analyzeMultipath() {
|
---|
[4675] | 376 |
|
---|
[6271] | 377 | const double SLIPTRESH = 10.0; // cycle-slip threshold (meters)
|
---|
| 378 | const double chunkStep = 600.0; // 10 minutes
|
---|
[4584] | 379 |
|
---|
[6271] | 380 | // Loop over all satellites available
|
---|
| 381 | // ----------------------------------
|
---|
[6285] | 382 | QMutableMapIterator<t_prn, t_qcSatSum> itSat(_qcFile._qcSatSum);
|
---|
| 383 | while (itSat.hasNext()) {
|
---|
| 384 | itSat.next();
|
---|
| 385 | const t_prn& prn = itSat.key();
|
---|
| 386 | t_qcSatSum& qcSatSum = itSat.value();
|
---|
[4351] | 387 |
|
---|
[6285] | 388 | // Loop over all frequencies available
|
---|
| 389 | // -----------------------------------
|
---|
| 390 | QMutableMapIterator<QString, t_qcFrqSum> itFrq(qcSatSum._qcFrqSum);
|
---|
| 391 | while (itFrq.hasNext()) {
|
---|
| 392 | itFrq.next();
|
---|
| 393 | const QString& frqType = itFrq.key();
|
---|
| 394 | t_qcFrqSum& qcFrqSum = itFrq.value();
|
---|
[4702] | 395 |
|
---|
[4353] | 396 |
|
---|
[6285] | 397 | // Loop over all Chunks of Data
|
---|
| 398 | // ----------------------------
|
---|
| 399 | for (bncTime chunkStart = _qcFile._startTime;
|
---|
| 400 | chunkStart < _qcFile._endTime; chunkStart += chunkStep) {
|
---|
| 401 |
|
---|
| 402 | bncTime chunkEnd = chunkStart + chunkStep;
|
---|
| 403 |
|
---|
| 404 | QVector<t_qcFrq*> frqVec;
|
---|
| 405 | QVector<double> MP;
|
---|
[6271] | 406 |
|
---|
[6285] | 407 | // Loop over all Epochs within one Chunk of Data
|
---|
| 408 | // ---------------------------------------------
|
---|
| 409 | for (int iEpo = 0; iEpo < _qcFile._qcEpo.size(); iEpo++) {
|
---|
| 410 | t_qcEpo& qcEpo = _qcFile._qcEpo[iEpo];
|
---|
| 411 | if (chunkStart <= qcEpo._epoTime && qcEpo._epoTime < chunkEnd) {
|
---|
[6288] | 412 | if (qcEpo._qcSat.contains(prn)) {
|
---|
| 413 | t_qcSat& qcSat = qcEpo._qcSat[prn];
|
---|
| 414 | for (int iFrq = 0; iFrq < qcSat._qcFrq.size(); iFrq++) {
|
---|
| 415 | t_qcFrq& qcFrq = qcSat._qcFrq[iFrq];
|
---|
[6285] | 416 | if (qcFrq._rnxType2ch == frqType) {
|
---|
| 417 | frqVec << &qcFrq;
|
---|
| 418 | if (qcFrq._setMP) {
|
---|
| 419 | MP << qcFrq._rawMP;
|
---|
| 420 | }
|
---|
| 421 | }
|
---|
| 422 | }
|
---|
[6213] | 423 | }
|
---|
[4590] | 424 | }
|
---|
| 425 | }
|
---|
[4563] | 426 |
|
---|
[6285] | 427 | // Compute the multipath mean and standard deviation
|
---|
| 428 | // -------------------------------------------------
|
---|
| 429 | if (MP.size() > 1) {
|
---|
| 430 | double meanMP = 0.0;
|
---|
| 431 | for (int ii = 0; ii < MP.size(); ii++) {
|
---|
| 432 | meanMP += MP[ii];
|
---|
[6271] | 433 | }
|
---|
[6285] | 434 | meanMP /= MP.size();
|
---|
| 435 |
|
---|
| 436 | bool slipMP = false;
|
---|
| 437 |
|
---|
| 438 | double stdMP = 0.0;
|
---|
| 439 | for (int ii = 0; ii < MP.size(); ii++) {
|
---|
| 440 | double diff = MP[ii] - meanMP;
|
---|
| 441 | if (fabs(diff) > SLIPTRESH) {
|
---|
| 442 | slipMP = true;
|
---|
| 443 | break;
|
---|
| 444 | }
|
---|
| 445 | stdMP += diff * diff;
|
---|
| 446 | }
|
---|
| 447 |
|
---|
[6281] | 448 | if (slipMP) {
|
---|
[6285] | 449 | stdMP = 0.0;
|
---|
| 450 | stdMP = 0.0;
|
---|
| 451 | qcFrqSum._numSlipsFound += 1;
|
---|
[6281] | 452 | }
|
---|
| 453 | else {
|
---|
[6285] | 454 | stdMP = sqrt(stdMP / (MP.size()-1));
|
---|
[6281] | 455 | }
|
---|
[6285] | 456 |
|
---|
| 457 | for (int ii = 0; ii < frqVec.size(); ii++) {
|
---|
| 458 | t_qcFrq* qcFrq = frqVec[ii];
|
---|
| 459 | if (slipMP) {
|
---|
| 460 | qcFrq->_slip = true;
|
---|
| 461 | }
|
---|
| 462 | else {
|
---|
| 463 | qcFrq->_stdMP = stdMP;
|
---|
| 464 | }
|
---|
| 465 | }
|
---|
[6281] | 466 | }
|
---|
[6285] | 467 | } // chunk loop
|
---|
| 468 | } // frq loop
|
---|
| 469 | } // sat loop
|
---|
[6281] | 470 | }
|
---|
| 471 |
|
---|
| 472 | //
|
---|
| 473 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 474 | void t_reqcAnalyze::preparePlotData(const t_rnxObsFile* obsFile) {
|
---|
| 475 |
|
---|
| 476 | QVector<t_polarPoint*>* dataMP1 = new QVector<t_polarPoint*>;
|
---|
| 477 | QVector<t_polarPoint*>* dataMP2 = new QVector<t_polarPoint*>;
|
---|
| 478 | QVector<t_polarPoint*>* dataSNR1 = new QVector<t_polarPoint*>;
|
---|
| 479 | QVector<t_polarPoint*>* dataSNR2 = new QVector<t_polarPoint*>;
|
---|
| 480 |
|
---|
| 481 | bncSettings settings;
|
---|
| 482 | QString reqSkyPlotSystems = settings.value("reqcSkyPlotSystems").toString();
|
---|
| 483 | bool plotGPS = false;
|
---|
| 484 | bool plotGlo = false;
|
---|
| 485 | bool plotGal = false;
|
---|
| 486 | if (reqSkyPlotSystems == "GPS") {
|
---|
| 487 | plotGPS = true;
|
---|
| 488 | }
|
---|
| 489 | else if (reqSkyPlotSystems == "GLONASS") {
|
---|
| 490 | plotGlo = true;
|
---|
| 491 | }
|
---|
| 492 | else if (reqSkyPlotSystems == "Galileo") {
|
---|
| 493 | plotGal = true;
|
---|
| 494 | }
|
---|
| 495 | else {
|
---|
| 496 | plotGPS = true;
|
---|
| 497 | plotGlo = true;
|
---|
| 498 | plotGal = true;
|
---|
| 499 | }
|
---|
| 500 |
|
---|
| 501 | // Loop over all observations
|
---|
| 502 | // --------------------------
|
---|
| 503 | for (int iEpo = 0; iEpo < _qcFile._qcEpo.size(); iEpo++) {
|
---|
| 504 | t_qcEpo& qcEpo = _qcFile._qcEpo[iEpo];
|
---|
[6288] | 505 | QMapIterator<t_prn, t_qcSat> it(qcEpo._qcSat);
|
---|
[6281] | 506 | while (it.hasNext()) {
|
---|
| 507 | it.next();
|
---|
| 508 | const t_prn& prn = it.key();
|
---|
[6288] | 509 | const t_qcSat& qcSat = it.value();
|
---|
[6271] | 510 | if ( (prn.system() == 'G' && plotGPS) ||
|
---|
| 511 | (prn.system() == 'R' && plotGlo) ||
|
---|
| 512 | (prn.system() == 'E' && plotGal) ) {
|
---|
[6281] | 513 |
|
---|
[6288] | 514 | if (qcSat._eleSet) {
|
---|
[6286] | 515 | QString frqType1;
|
---|
| 516 | QString frqType2;
|
---|
[6288] | 517 | for (int iFrq = 0; iFrq < qcSat._qcFrq.size(); iFrq++) {
|
---|
| 518 | const t_qcFrq& qcFrq = qcSat._qcFrq[iFrq];
|
---|
[6287] | 519 | if (qcFrq._rnxType2ch[0] == '1' && frqType1.isEmpty()) {
|
---|
[6286] | 520 | frqType1 = qcFrq._rnxType2ch;
|
---|
| 521 | }
|
---|
[6287] | 522 | if (qcFrq._rnxType2ch[0] == '2' && frqType2.isEmpty()) {
|
---|
[6286] | 523 | frqType2 = qcFrq._rnxType2ch;
|
---|
| 524 | }
|
---|
| 525 | if (qcFrq._rnxType2ch == frqType1) {
|
---|
[6288] | 526 | (*dataSNR1) << (new t_polarPoint(qcSat._azDeg, 90.0 - qcSat._eleDeg, qcFrq._SNR));
|
---|
| 527 | (*dataMP1) << (new t_polarPoint(qcSat._azDeg, 90.0 - qcSat._eleDeg, qcFrq._stdMP));
|
---|
[6286] | 528 | }
|
---|
| 529 | else if (qcFrq._rnxType2ch == frqType2) {
|
---|
[6288] | 530 | (*dataSNR2) << (new t_polarPoint(qcSat._azDeg, 90.0 - qcSat._eleDeg, qcFrq._SNR));
|
---|
| 531 | (*dataMP2) << (new t_polarPoint(qcSat._azDeg, 90.0 - qcSat._eleDeg, qcFrq._stdMP));
|
---|
[6286] | 532 | }
|
---|
| 533 | }
|
---|
[6284] | 534 | }
|
---|
[4700] | 535 | }
|
---|
[4353] | 536 | }
|
---|
[6271] | 537 | }
|
---|
[4353] | 538 |
|
---|
[6271] | 539 | // Show the plots
|
---|
| 540 | // --------------
|
---|
| 541 | if (BNC_CORE->GUIenabled()) {
|
---|
| 542 | QFileInfo fileInfo(obsFile->fileName());
|
---|
| 543 | QByteArray title = fileInfo.fileName().toAscii();
|
---|
[6286] | 544 | emit dspSkyPlot(obsFile->fileName(), "MP1", dataMP1, "MP2", dataMP2, "Meters", 2.0);
|
---|
| 545 | emit dspSkyPlot(obsFile->fileName(), "SNR1", dataSNR1, "SNR2", dataSNR2, "dbHz", 54.0);
|
---|
[6275] | 546 | emit dspAvailPlot(obsFile->fileName(), title);
|
---|
[6271] | 547 | }
|
---|
| 548 | else {
|
---|
| 549 | for (int ii = 0; ii < dataMP1->size(); ii++) {
|
---|
| 550 | delete dataMP1->at(ii);
|
---|
[4351] | 551 | }
|
---|
[6271] | 552 | delete dataMP1;
|
---|
| 553 | for (int ii = 0; ii < dataMP2->size(); ii++) {
|
---|
| 554 | delete dataMP2->at(ii);
|
---|
[4591] | 555 | }
|
---|
[6271] | 556 | delete dataMP2;
|
---|
| 557 | for (int ii = 0; ii < dataSNR1->size(); ii++) {
|
---|
| 558 | delete dataSNR1->at(ii);
|
---|
[4659] | 559 | }
|
---|
[6271] | 560 | delete dataSNR1;
|
---|
| 561 | for (int ii = 0; ii < dataSNR2->size(); ii++) {
|
---|
| 562 | delete dataSNR2->at(ii);
|
---|
[5141] | 563 | }
|
---|
[6271] | 564 | delete dataSNR2;
|
---|
[4350] | 565 | }
|
---|
| 566 | }
|
---|
[4572] | 567 |
|
---|
[6255] | 568 | //
|
---|
[4572] | 569 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6275] | 570 | void t_reqcAnalyze::slotDspSkyPlot(const QString& fileName, const QByteArray& title1,
|
---|
| 571 | QVector<t_polarPoint*>* data1, const QByteArray& title2,
|
---|
| 572 | QVector<t_polarPoint*>* data2, const QByteArray& scaleTitle,
|
---|
| 573 | double maxValue) {
|
---|
[4572] | 574 |
|
---|
[5068] | 575 | if (BNC_CORE->GUIenabled()) {
|
---|
[4573] | 576 |
|
---|
[6271] | 577 | if (maxValue == 0.0) {
|
---|
| 578 | if (data1) {
|
---|
| 579 | for (int ii = 0; ii < data1->size(); ii++) {
|
---|
| 580 | double val = data1->at(ii)->_value;
|
---|
| 581 | if (maxValue < val) {
|
---|
| 582 | maxValue = val;
|
---|
| 583 | }
|
---|
| 584 | }
|
---|
| 585 | }
|
---|
| 586 | if (data2) {
|
---|
| 587 | for (int ii = 0; ii < data2->size(); ii++) {
|
---|
| 588 | double val = data2->at(ii)->_value;
|
---|
| 589 | if (maxValue < val) {
|
---|
| 590 | maxValue = val;
|
---|
| 591 | }
|
---|
| 592 | }
|
---|
| 593 | }
|
---|
| 594 | }
|
---|
[4659] | 595 |
|
---|
[6271] | 596 | QwtInterval scaleInterval(0.0, maxValue);
|
---|
[4671] | 597 |
|
---|
[4573] | 598 | QVector<QWidget*> plots;
|
---|
[6271] | 599 | if (data1) {
|
---|
| 600 | t_polarPlot* plot1 = new t_polarPlot(QwtText(title1), scaleInterval,
|
---|
| 601 | BNC_CORE->mainWindow());
|
---|
| 602 | plot1->addCurve(data1);
|
---|
| 603 | plots << plot1;
|
---|
| 604 | }
|
---|
| 605 | if (data2) {
|
---|
| 606 | t_polarPlot* plot2 = new t_polarPlot(QwtText(title2), scaleInterval,
|
---|
| 607 | BNC_CORE->mainWindow());
|
---|
| 608 | plot2->addCurve(data2);
|
---|
| 609 | plots << plot2;
|
---|
| 610 | }
|
---|
[4666] | 611 |
|
---|
[6271] | 612 | t_graphWin* graphWin = new t_graphWin(0, fileName, plots,
|
---|
| 613 | &scaleTitle, &scaleInterval);
|
---|
[4666] | 614 |
|
---|
[4573] | 615 | graphWin->show();
|
---|
| 616 |
|
---|
| 617 | bncSettings settings;
|
---|
| 618 | QString dirName = settings.value("reqcPlotDir").toString();
|
---|
| 619 | if (!dirName.isEmpty()) {
|
---|
[6271] | 620 | QByteArray ext = (scaleTitle == "Meters") ? "_M.png" : "_S.png";
|
---|
[4579] | 621 | graphWin->savePNG(dirName, ext);
|
---|
[4573] | 622 | }
|
---|
| 623 | }
|
---|
[4572] | 624 | }
|
---|
[4679] | 625 |
|
---|
[6271] | 626 | //
|
---|
[4679] | 627 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6275] | 628 | void t_reqcAnalyze::slotDspAvailPlot(const QString& fileName, const QByteArray& title) {
|
---|
[4679] | 629 |
|
---|
[6280] | 630 | t_plotData plotData;
|
---|
[6278] | 631 | QMap<t_prn, t_plotData> plotDataMap;
|
---|
[6272] | 632 |
|
---|
[6278] | 633 | for (int ii = 0; ii < _qcFile._qcEpo.size(); ii++) {
|
---|
| 634 | const t_qcEpo& qcEpo = _qcFile._qcEpo[ii];
|
---|
[6280] | 635 | double mjdX24 = qcEpo._epoTime.mjddec() * 24.0;
|
---|
| 636 |
|
---|
| 637 | plotData._mjdX24 << mjdX24;
|
---|
| 638 | plotData._PDOP << qcEpo._PDOP;
|
---|
[6288] | 639 | plotData._numSat << qcEpo._qcSat.size();
|
---|
[6280] | 640 |
|
---|
[6288] | 641 | QMapIterator<t_prn, t_qcSat> it(qcEpo._qcSat);
|
---|
[6278] | 642 | while (it.hasNext()) {
|
---|
| 643 | it.next();
|
---|
| 644 | const t_prn& prn = it.key();
|
---|
[6288] | 645 | const t_qcSat& qcSat = it.value();
|
---|
[6280] | 646 | t_plotData& data = plotDataMap[prn];
|
---|
[6286] | 647 |
|
---|
[6283] | 648 | data._mjdX24 << mjdX24;
|
---|
[6288] | 649 | data._eleDeg << qcSat._eleDeg;
|
---|
[6286] | 650 |
|
---|
| 651 | QString frqType1;
|
---|
| 652 | QString frqType2;
|
---|
[6288] | 653 | for (int iFrq = 0; iFrq < qcSat._qcFrq.size(); iFrq++) {
|
---|
| 654 | const t_qcFrq& qcFrq = qcSat._qcFrq[iFrq];
|
---|
[6287] | 655 | if (qcFrq._rnxType2ch[0] == '1' && frqType1.isEmpty()) {
|
---|
[6286] | 656 | frqType1 = qcFrq._rnxType2ch;
|
---|
[6284] | 657 | }
|
---|
[6287] | 658 | if (qcFrq._rnxType2ch[0] == '2' && frqType2.isEmpty()) {
|
---|
[6286] | 659 | frqType2 = qcFrq._rnxType2ch;
|
---|
[6284] | 660 | }
|
---|
[6286] | 661 | if (qcFrq._rnxType2ch == frqType1) {
|
---|
| 662 | if (qcFrq._slip) {
|
---|
| 663 | data._L1slip << mjdX24;
|
---|
| 664 | }
|
---|
| 665 | else if (qcFrq._gap) {
|
---|
| 666 | data._L1gap << mjdX24;
|
---|
| 667 | }
|
---|
| 668 | else {
|
---|
| 669 | data._L1ok << mjdX24;
|
---|
| 670 | }
|
---|
[6284] | 671 | }
|
---|
[6286] | 672 | else if (qcFrq._rnxType2ch == frqType2) {
|
---|
| 673 | if (qcFrq._slip) {
|
---|
| 674 | data._L2slip << mjdX24;
|
---|
| 675 | }
|
---|
| 676 | else if (qcFrq._gap) {
|
---|
| 677 | data._L2gap << mjdX24;
|
---|
| 678 | }
|
---|
| 679 | else {
|
---|
| 680 | data._L2ok << mjdX24;
|
---|
| 681 | }
|
---|
[6284] | 682 | }
|
---|
| 683 | }
|
---|
[6278] | 684 | }
|
---|
| 685 | }
|
---|
| 686 |
|
---|
[6271] | 687 | if (BNC_CORE->GUIenabled()) {
|
---|
[6278] | 688 | t_availPlot* plotA = new t_availPlot(0, plotDataMap);
|
---|
[6271] | 689 | plotA->setTitle(title);
|
---|
[4679] | 690 |
|
---|
[6278] | 691 | t_elePlot* plotZ = new t_elePlot(0, plotDataMap);
|
---|
[4679] | 692 |
|
---|
[6279] | 693 | t_dopPlot* plotD = new t_dopPlot(0, plotData);
|
---|
[4679] | 694 |
|
---|
[6271] | 695 | QVector<QWidget*> plots;
|
---|
| 696 | plots << plotA << plotZ << plotD;
|
---|
| 697 | t_graphWin* graphWin = new t_graphWin(0, fileName, plots, 0, 0);
|
---|
[4679] | 698 |
|
---|
[6271] | 699 | int ww = QFontMetrics(graphWin->font()).width('w');
|
---|
| 700 | graphWin->setMinimumSize(120*ww, 40*ww);
|
---|
[4679] | 701 |
|
---|
[6271] | 702 | graphWin->show();
|
---|
[4679] | 703 |
|
---|
[6271] | 704 | bncSettings settings;
|
---|
| 705 | QString dirName = settings.value("reqcPlotDir").toString();
|
---|
| 706 | if (!dirName.isEmpty()) {
|
---|
| 707 | QByteArray ext = "_A.png";
|
---|
| 708 | graphWin->savePNG(dirName, ext);
|
---|
[4679] | 709 | }
|
---|
[4681] | 710 | }
|
---|
[4679] | 711 | }
|
---|
[4689] | 712 |
|
---|
| 713 | // Finish the report
|
---|
| 714 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6284] | 715 | void t_reqcAnalyze::printReport(const t_rnxObsFile* obsFile) {
|
---|
[5368] | 716 |
|
---|
[4689] | 717 | if (!_log) {
|
---|
| 718 | return;
|
---|
| 719 | }
|
---|
| 720 |
|
---|
[6284] | 721 | *_log << "File: " << obsFile->fileName().toAscii().data() << endl
|
---|
| 722 | << "Marker name: " << _qcFile._markerName << endl
|
---|
| 723 | << "Receiver: " << _qcFile._receiverType << endl
|
---|
| 724 | << "Antenna: " << _qcFile._antennaName << endl
|
---|
[6271] | 725 | << "Start time: " << _qcFile._startTime.datestr().c_str() << ' '
|
---|
| 726 | << _qcFile._startTime.timestr().c_str() << endl
|
---|
[6284] | 727 | << "End time: " << _qcFile._endTime.datestr().c_str() << ' '
|
---|
| 728 | << _qcFile._endTime.timestr().c_str() << endl
|
---|
| 729 | << "Interval: " << _qcFile._interval << endl
|
---|
[6286] | 730 | << "# Sat.: " << _qcFile._qcSatSum.size() << endl;
|
---|
[4689] | 731 |
|
---|
[4701] | 732 | int numObs = 0;
|
---|
| 733 | int numSlipsFlagged = 0;
|
---|
| 734 | int numSlipsFound = 0;
|
---|
[6286] | 735 | QMapIterator<t_prn, t_qcSatSum> itSat(_qcFile._qcSatSum);
|
---|
| 736 | while (itSat.hasNext()) {
|
---|
| 737 | itSat.next();
|
---|
| 738 | const t_qcSatSum& qcSatSum = itSat.value();
|
---|
| 739 |
|
---|
| 740 | QMapIterator<QString, t_qcFrqSum> itFrq(qcSatSum._qcFrqSum);
|
---|
| 741 | while (itFrq.hasNext()) {
|
---|
| 742 | itFrq.next();
|
---|
| 743 | const t_qcFrqSum& qcFrqSum = itFrq.value();
|
---|
| 744 | numObs += qcFrqSum._numObs;
|
---|
| 745 | numSlipsFlagged += qcFrqSum._numSlipsFlagged;
|
---|
| 746 | numSlipsFound += qcFrqSum._numSlipsFound;
|
---|
| 747 | }
|
---|
[4693] | 748 | }
|
---|
[4701] | 749 | *_log << "# Obs.: " << numObs << endl
|
---|
| 750 | << "# Slips (file): " << numSlipsFlagged << endl
|
---|
| 751 | << "# Slips (found): " << numSlipsFound << endl;
|
---|
[4693] | 752 |
|
---|
[6289] | 753 | for (int iEpo = 0; iEpo < _qcFile._qcEpo.size(); iEpo++) {
|
---|
| 754 | const t_qcEpo& qcEpo = _qcFile._qcEpo[iEpo];
|
---|
| 755 |
|
---|
| 756 | unsigned year, month, day, hour, min;
|
---|
| 757 | double sec;
|
---|
| 758 | qcEpo._epoTime.civil_date(year, month, day);
|
---|
| 759 | qcEpo._epoTime.civil_time(hour, min, sec);
|
---|
| 760 |
|
---|
| 761 | QString dateStr;
|
---|
| 762 | QTextStream(&dateStr) << QString("> %1 %2 %3 %4 %5%6")
|
---|
| 763 | .arg(year, 4)
|
---|
| 764 | .arg(month, 2, 10, QChar('0'))
|
---|
| 765 | .arg(day, 2, 10, QChar('0'))
|
---|
| 766 | .arg(hour, 2, 10, QChar('0'))
|
---|
| 767 | .arg(min, 2, 10, QChar('0'))
|
---|
| 768 | .arg(sec, 11, 'f', 7);
|
---|
| 769 |
|
---|
| 770 | *_log << dateStr << QString("%1\n").arg(qcEpo._qcSat.size(), 3);
|
---|
| 771 |
|
---|
| 772 | QMapIterator<t_prn, t_qcSat> itSat(qcEpo._qcSat);
|
---|
| 773 | while (itSat.hasNext()) {
|
---|
| 774 | itSat.next();
|
---|
| 775 | const t_prn& prn = itSat.key();
|
---|
| 776 | const t_qcSat& qcSat = itSat.value();
|
---|
| 777 |
|
---|
| 778 | *_log << prn.toString().c_str() << endl;
|
---|
| 779 | }
|
---|
| 780 | }
|
---|
[4689] | 781 | _log->flush();
|
---|
| 782 | }
|
---|