[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 | QMutexLocker lock(&_mutex);
|
---|
[4704] | 135 |
|
---|
[4517] | 136 | if (_log) {
|
---|
| 137 | *_log << "\nAnalyze File\n"
|
---|
| 138 | << "------------\n"
|
---|
[4701] | 139 | << "File: " << obsFile->fileName().toAscii().data() << endl;
|
---|
[4517] | 140 | }
|
---|
[4260] | 141 |
|
---|
[6271] | 142 | _qcFile.clear();
|
---|
[4343] | 143 |
|
---|
[4342] | 144 | // A priori Coordinates
|
---|
| 145 | // --------------------
|
---|
[4679] | 146 | ColumnVector xyzSta = obsFile->xyz();
|
---|
[4342] | 147 |
|
---|
[4262] | 148 | // Loop over all Epochs
|
---|
| 149 | // --------------------
|
---|
[4541] | 150 | try {
|
---|
[6271] | 151 | bool firstEpo = true;
|
---|
[4541] | 152 | while ( (_currEpo = obsFile->nextEpoch()) != 0) {
|
---|
[6271] | 153 | if (firstEpo) {
|
---|
| 154 | firstEpo = false;
|
---|
| 155 | _qcFile._startTime = _currEpo->tt;
|
---|
| 156 | _qcFile._antennaName = obsFile->antennaName();
|
---|
| 157 | _qcFile._markerName = obsFile->markerName();
|
---|
| 158 | _qcFile._receiverType = obsFile->receiverType();
|
---|
| 159 | _qcFile._interval = obsFile->interval();
|
---|
[4688] | 160 | }
|
---|
[6271] | 161 | _qcFile._endTime = _currEpo->tt;
|
---|
[6255] | 162 |
|
---|
[6271] | 163 | t_qcEpo qcEpo;
|
---|
| 164 | qcEpo._epoTime = _currEpo->tt;
|
---|
| 165 | qcEpo._PDOP = cmpDOP(xyzSta);
|
---|
| 166 |
|
---|
[4541] | 167 | // Loop over all satellites
|
---|
| 168 | // ------------------------
|
---|
| 169 | for (unsigned iObs = 0; iObs < _currEpo->rnxSat.size(); iObs++) {
|
---|
| 170 | const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iObs];
|
---|
[6271] | 171 | t_satObs satObs;
|
---|
| 172 | t_rnxObsFile::setObsFromRnx(obsFile, _currEpo, rnxSat, satObs);
|
---|
[6281] | 173 | t_qcObs& qcObs = qcEpo._qcObs[satObs._prn];
|
---|
| 174 | setQcObs(qcEpo._epoTime, xyzSta, satObs, qcObs);
|
---|
| 175 | updateQcSat(qcObs, _qcFile._qcSat[satObs._prn]);
|
---|
[4262] | 176 | }
|
---|
[6271] | 177 | _qcFile._qcEpo.push_back(qcEpo);
|
---|
| 178 | }
|
---|
[6255] | 179 |
|
---|
[6281] | 180 | analyzeMultipath();
|
---|
| 181 |
|
---|
[6271] | 182 | preparePlotData(obsFile);
|
---|
[4678] | 183 |
|
---|
[6271] | 184 | printReport();
|
---|
[4541] | 185 | }
|
---|
| 186 | catch (QString str) {
|
---|
| 187 | if (_log) {
|
---|
| 188 | *_log << "Exception " << str << endl;
|
---|
[4262] | 189 | }
|
---|
[4541] | 190 | else {
|
---|
[6255] | 191 | qDebug() << str;
|
---|
[4541] | 192 | }
|
---|
| 193 | }
|
---|
[6271] | 194 | }
|
---|
[4262] | 195 |
|
---|
[6271] | 196 | // Compute Dilution of Precision
|
---|
| 197 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 198 | double t_reqcAnalyze::cmpDOP(const ColumnVector& xyzSta) const {
|
---|
[4268] | 199 |
|
---|
[6271] | 200 | if (xyzSta.size() != 3) {
|
---|
| 201 | return 0.0;
|
---|
[4268] | 202 | }
|
---|
| 203 |
|
---|
[6271] | 204 | unsigned nSat = _currEpo->rnxSat.size();
|
---|
[4706] | 205 |
|
---|
[6271] | 206 | if (nSat < 4) {
|
---|
| 207 | return 0.0;
|
---|
[4718] | 208 | }
|
---|
[6271] | 209 |
|
---|
| 210 | Matrix AA(nSat, 4);
|
---|
| 211 |
|
---|
| 212 | unsigned nSatUsed = 0;
|
---|
| 213 | for (unsigned iSat = 0; iSat < nSat; iSat++) {
|
---|
| 214 |
|
---|
| 215 | const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iSat];
|
---|
| 216 | const t_prn& prn = rnxSat.prn;
|
---|
| 217 |
|
---|
| 218 | t_eph* eph = 0;
|
---|
| 219 | for (int ie = 0; ie < _ephs.size(); ie++) {
|
---|
| 220 | if (_ephs[ie]->prn() == prn) {
|
---|
| 221 | eph = _ephs[ie];
|
---|
| 222 | break;
|
---|
| 223 | }
|
---|
[4718] | 224 | }
|
---|
[6271] | 225 | if (eph) {
|
---|
| 226 | ColumnVector xSat(4);
|
---|
| 227 | ColumnVector vv(3);
|
---|
| 228 | if (eph->getCrd(_currEpo->tt, xSat, vv, false) == success) {
|
---|
| 229 | ++nSatUsed;
|
---|
| 230 | ColumnVector dx = xSat.Rows(1,3) - xyzSta;
|
---|
| 231 | double rho = dx.norm_Frobenius();
|
---|
| 232 | AA(nSatUsed,1) = dx(1) / rho;
|
---|
| 233 | AA(nSatUsed,2) = dx(2) / rho;
|
---|
| 234 | AA(nSatUsed,3) = dx(3) / rho;
|
---|
| 235 | AA(nSatUsed,4) = 1.0;
|
---|
| 236 | }
|
---|
[4718] | 237 | }
|
---|
| 238 | }
|
---|
[6271] | 239 |
|
---|
| 240 | if (nSatUsed < 4) {
|
---|
| 241 | return 0.0;
|
---|
| 242 | }
|
---|
| 243 |
|
---|
| 244 | AA = AA.Rows(1, nSatUsed);
|
---|
| 245 |
|
---|
| 246 | SymmetricMatrix QQ;
|
---|
| 247 | QQ << AA.t() * AA;
|
---|
| 248 | QQ = QQ.i();
|
---|
| 249 |
|
---|
| 250 | return sqrt(QQ.trace());
|
---|
[4254] | 251 | }
|
---|
[4263] | 252 |
|
---|
[6255] | 253 | //
|
---|
[4263] | 254 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6271] | 255 | void t_reqcAnalyze::updateQcSat(const t_qcObs& qcObs, t_qcSat& qcSat) {
|
---|
| 256 | if (qcObs._hasL1 && qcObs._hasL2) {
|
---|
| 257 | qcSat._numObs += 1;
|
---|
| 258 | }
|
---|
| 259 | if (qcObs._slipL1 && qcObs._slipL2) {
|
---|
| 260 | qcSat._numSlipsFlagged += 1;
|
---|
| 261 | }
|
---|
| 262 | }
|
---|
[4265] | 263 |
|
---|
[6271] | 264 | //
|
---|
| 265 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6281] | 266 | void t_reqcAnalyze::setQcObs(const bncTime& epoTime, const ColumnVector& xyzSta,
|
---|
| 267 | const t_satObs& satObs, t_qcObs& qcObs) {
|
---|
[4338] | 268 |
|
---|
[6281] | 269 | t_eph* eph = 0;
|
---|
| 270 | for (int ie = 0; ie < _ephs.size(); ie++) {
|
---|
| 271 | if (_ephs[ie]->prn() == satObs._prn) {
|
---|
| 272 | eph = _ephs[ie];
|
---|
| 273 | break;
|
---|
[6271] | 274 | }
|
---|
[6281] | 275 | }
|
---|
| 276 | if (eph) {
|
---|
| 277 | ColumnVector xc(4);
|
---|
| 278 | ColumnVector vv(3);
|
---|
| 279 | if (xyzSta.size() && eph->getCrd(epoTime, xc, vv, false) == success) {
|
---|
| 280 | double rho, eleSat, azSat;
|
---|
| 281 | topos(xyzSta(1), xyzSta(2), xyzSta(3), xc(1), xc(2), xc(3), rho, eleSat, azSat);
|
---|
| 282 | qcObs._eleSet = true;
|
---|
| 283 | qcObs._azDeg = azSat * 180.0/M_PI;
|
---|
| 284 | qcObs._eleDeg = eleSat * 180.0/M_PI;
|
---|
| 285 | }
|
---|
| 286 | if (satObs._prn.system() == 'R') {
|
---|
[6271] | 287 | qcObs._slotSet = true;
|
---|
[6281] | 288 | qcObs._slotNum = eph->slotNum();
|
---|
[6271] | 289 | }
|
---|
| 290 | }
|
---|
| 291 |
|
---|
[6281] | 292 | // Check Gaps
|
---|
| 293 | // ----------
|
---|
| 294 | if (qcObs._lastObsTime.valid()) {
|
---|
| 295 | double dt = epoTime - qcObs._lastObsTime;
|
---|
| 296 | if (dt > 1.5 * _qcFile._interval) {
|
---|
| 297 | qcObs._gapL1 = true;
|
---|
| 298 | qcObs._gapL2 = true;
|
---|
| 299 | }
|
---|
| 300 | }
|
---|
| 301 | qcObs._lastObsTime = epoTime;
|
---|
[6271] | 302 |
|
---|
[4608] | 303 | // Availability and Slip Flags
|
---|
| 304 | // ---------------------------
|
---|
[6137] | 305 | double L1 = 0.0;
|
---|
| 306 | double L2 = 0.0;
|
---|
| 307 | double P1 = 0.0;
|
---|
| 308 | double P2 = 0.0;
|
---|
[6271] | 309 | for (unsigned iFrq = 0; iFrq < satObs._obs.size(); iFrq++) {
|
---|
| 310 | const t_frqObs* frqObs = satObs._obs[iFrq];
|
---|
[6137] | 311 | if (frqObs->_rnxType2ch[0] == '1') {
|
---|
| 312 | if (frqObs->_phaseValid) {
|
---|
[6281] | 313 | L1 = frqObs->_phase;
|
---|
[6271] | 314 | qcObs._hasL1 = true;
|
---|
| 315 | qcObs._slipL1 = frqObs->_slip;
|
---|
[6137] | 316 | }
|
---|
| 317 | if (frqObs->_codeValid) {
|
---|
[6255] | 318 | P1 = frqObs->_code;
|
---|
[6137] | 319 | }
|
---|
| 320 | if (frqObs->_snrValid) {
|
---|
[6271] | 321 | qcObs._SNR1 = frqObs->_snr;
|
---|
[6137] | 322 | }
|
---|
| 323 | }
|
---|
[6271] | 324 | else if ( (satObs._prn.system() != 'E' && frqObs->_rnxType2ch[0] == '2') ||
|
---|
| 325 | (satObs._prn.system() == 'E' && frqObs->_rnxType2ch[0] == '5') ) {
|
---|
[6137] | 326 | if (frqObs->_phaseValid) {
|
---|
[6281] | 327 | L2 = frqObs->_phase;
|
---|
| 328 | qcObs._hasL2 = true;
|
---|
[6271] | 329 | qcObs._slipL2 = frqObs->_slip;
|
---|
[6137] | 330 | }
|
---|
| 331 | if (frqObs->_codeValid) {
|
---|
[6255] | 332 | P2 = frqObs->_code;
|
---|
[6137] | 333 | }
|
---|
| 334 | if (frqObs->_snrValid) {
|
---|
[6271] | 335 | qcObs._SNR2 = frqObs->_snr;
|
---|
[6137] | 336 | }
|
---|
| 337 | }
|
---|
[4571] | 338 | }
|
---|
[4608] | 339 |
|
---|
[6281] | 340 | // Compute the Multipath Linear Combination
|
---|
| 341 | // ----------------------------------------
|
---|
| 342 | if (L1 != 0.0 && L2 != 0.0 && P1 != 0.0 && P2 != 0.0) {
|
---|
[6017] | 343 | double f1 = 0.0;
|
---|
| 344 | double f2 = 0.0;
|
---|
[6271] | 345 | if (satObs._prn.system() == 'G') {
|
---|
[6017] | 346 | f1 = t_CST::freq(t_frequency::G1, 0);
|
---|
| 347 | f2 = t_CST::freq(t_frequency::G2, 0);
|
---|
| 348 | }
|
---|
[6271] | 349 | else if (satObs._prn.system() == 'R') {
|
---|
| 350 | f1 = t_CST::freq(t_frequency::R1, qcObs._slotNum);
|
---|
| 351 | f2 = t_CST::freq(t_frequency::R2, qcObs._slotNum);
|
---|
[6017] | 352 | }
|
---|
[6271] | 353 | else if (satObs._prn.system() == 'E') {
|
---|
[6017] | 354 | f1 = t_CST::freq(t_frequency::E1, 0);
|
---|
| 355 | f2 = t_CST::freq(t_frequency::E5, 0);
|
---|
| 356 | }
|
---|
[4266] | 357 |
|
---|
[4391] | 358 | L1 = L1 * t_CST::c / f1;
|
---|
| 359 | L2 = L2 * t_CST::c / f2;
|
---|
[4266] | 360 |
|
---|
[6281] | 361 | qcObs._rawMP1 = P1 - L1 - 2.0*f2*f2/(f1*f1-f2*f2) * (L1 - L2);
|
---|
| 362 | qcObs._rawMP2 = P2 - L2 - 2.0*f1*f1/(f1*f1-f2*f2) * (L1 - L2);
|
---|
| 363 | qcObs._mpSet = true;
|
---|
[4265] | 364 | }
|
---|
[4263] | 365 | }
|
---|
[4350] | 366 |
|
---|
[6255] | 367 | //
|
---|
[4350] | 368 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6281] | 369 | void t_reqcAnalyze::analyzeMultipath() {
|
---|
[4675] | 370 |
|
---|
[6271] | 371 | const double SLIPTRESH = 10.0; // cycle-slip threshold (meters)
|
---|
| 372 | const double chunkStep = 600.0; // 10 minutes
|
---|
[4584] | 373 |
|
---|
[6271] | 374 | // Loop over all satellites available
|
---|
| 375 | // ----------------------------------
|
---|
| 376 | QMutableMapIterator<t_prn, t_qcSat> it(_qcFile._qcSat);
|
---|
| 377 | while (it.hasNext()) {
|
---|
| 378 | it.next();
|
---|
| 379 | const t_prn& prn = it.key();
|
---|
| 380 | t_qcSat& qcSat = it.value();
|
---|
[4351] | 381 |
|
---|
[6271] | 382 | // Loop over all Chunks of Data
|
---|
| 383 | // ----------------------------
|
---|
| 384 | for (bncTime chunkStart = _qcFile._startTime;
|
---|
| 385 | chunkStart < _qcFile._endTime; chunkStart += chunkStep) {
|
---|
[4702] | 386 |
|
---|
[6281] | 387 | bncTime chunkEnd = chunkStart + chunkStep;
|
---|
[4353] | 388 |
|
---|
[6281] | 389 | QVector<t_qcObs*> obsVec;
|
---|
| 390 | QVector<double> MP1;
|
---|
| 391 | QVector<double> MP2;
|
---|
[6271] | 392 |
|
---|
| 393 | // Loop over all Epochs within one Chunk of Data
|
---|
| 394 | // ---------------------------------------------
|
---|
| 395 | for (int iEpo = 0; iEpo < _qcFile._qcEpo.size(); iEpo++) {
|
---|
[6280] | 396 | t_qcEpo& qcEpo = _qcFile._qcEpo[iEpo];
|
---|
[6281] | 397 | if (chunkStart <= qcEpo._epoTime && qcEpo._epoTime < chunkEnd) {
|
---|
| 398 | if (qcEpo._qcObs.contains(prn)) {
|
---|
| 399 | t_qcObs& qcObs = qcEpo._qcObs[prn];
|
---|
| 400 | obsVec << &qcObs;
|
---|
| 401 | if (qcObs._mpSet) {
|
---|
| 402 | MP1 << qcObs._rawMP1;
|
---|
| 403 | MP2 << qcObs._rawMP2;
|
---|
[6213] | 404 | }
|
---|
[4590] | 405 | }
|
---|
| 406 | }
|
---|
| 407 | }
|
---|
[4563] | 408 |
|
---|
[6281] | 409 | // Compute the multipath mean and standard deviation
|
---|
| 410 | // -------------------------------------------------
|
---|
| 411 | if (MP1.size() > 1) {
|
---|
[6271] | 412 | double meanMP1 = 0.0;
|
---|
| 413 | double meanMP2 = 0.0;
|
---|
| 414 | for (int ii = 0; ii < MP1.size(); ii++) {
|
---|
| 415 | meanMP1 += MP1[ii];
|
---|
| 416 | meanMP2 += MP2[ii];
|
---|
| 417 | }
|
---|
| 418 | meanMP1 /= MP1.size();
|
---|
| 419 | meanMP2 /= MP2.size();
|
---|
[4590] | 420 |
|
---|
[6271] | 421 | bool slipMP = false;
|
---|
[6281] | 422 |
|
---|
[6271] | 423 | double stdMP1 = 0.0;
|
---|
| 424 | double stdMP2 = 0.0;
|
---|
| 425 | for (int ii = 0; ii < MP1.size(); ii++) {
|
---|
| 426 | double diff1 = MP1[ii] - meanMP1;
|
---|
| 427 | double diff2 = MP2[ii] - meanMP2;
|
---|
| 428 | if (fabs(diff1) > SLIPTRESH || fabs(diff2) > SLIPTRESH) {
|
---|
| 429 | slipMP = true;
|
---|
| 430 | break;
|
---|
| 431 | }
|
---|
| 432 | stdMP1 += diff1 * diff1;
|
---|
[6276] | 433 | stdMP2 += diff2 * diff2;
|
---|
[4700] | 434 | }
|
---|
[6255] | 435 |
|
---|
[6271] | 436 | if (slipMP) {
|
---|
[6281] | 437 | stdMP1 = 0.0;
|
---|
| 438 | stdMP2 = 0.0;
|
---|
[6271] | 439 | qcSat._numSlipsFound += 1;
|
---|
[4702] | 440 | }
|
---|
[6271] | 441 | else {
|
---|
[6281] | 442 | stdMP1 = sqrt(stdMP1 / (MP1.size()-1));
|
---|
| 443 | stdMP2 = sqrt(stdMP2 / (MP2.size()-1));
|
---|
[6271] | 444 | }
|
---|
[6281] | 445 |
|
---|
| 446 | for (int ii = 0; ii < obsVec.size(); ii++) {
|
---|
| 447 | t_qcObs* qcObs = obsVec[ii];
|
---|
| 448 | if (slipMP) {
|
---|
| 449 | qcObs->_slipL1 = true;
|
---|
| 450 | qcObs->_slipL2 = true;
|
---|
| 451 | }
|
---|
| 452 | else {
|
---|
| 453 | qcObs->_stdMP1 = stdMP1;
|
---|
| 454 | qcObs->_stdMP2 = stdMP2;
|
---|
| 455 | }
|
---|
| 456 | }
|
---|
[6255] | 457 | }
|
---|
[6281] | 458 | }
|
---|
| 459 | }
|
---|
| 460 | }
|
---|
| 461 |
|
---|
| 462 | //
|
---|
| 463 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 464 | void t_reqcAnalyze::preparePlotData(const t_rnxObsFile* obsFile) {
|
---|
| 465 |
|
---|
| 466 | QVector<t_polarPoint*>* dataMP1 = new QVector<t_polarPoint*>;
|
---|
| 467 | QVector<t_polarPoint*>* dataMP2 = new QVector<t_polarPoint*>;
|
---|
| 468 | QVector<t_polarPoint*>* dataSNR1 = new QVector<t_polarPoint*>;
|
---|
| 469 | QVector<t_polarPoint*>* dataSNR2 = new QVector<t_polarPoint*>;
|
---|
| 470 |
|
---|
| 471 | bncSettings settings;
|
---|
| 472 | QString reqSkyPlotSystems = settings.value("reqcSkyPlotSystems").toString();
|
---|
| 473 | bool plotGPS = false;
|
---|
| 474 | bool plotGlo = false;
|
---|
| 475 | bool plotGal = false;
|
---|
| 476 | if (reqSkyPlotSystems == "GPS") {
|
---|
| 477 | plotGPS = true;
|
---|
| 478 | }
|
---|
| 479 | else if (reqSkyPlotSystems == "GLONASS") {
|
---|
| 480 | plotGlo = true;
|
---|
| 481 | }
|
---|
| 482 | else if (reqSkyPlotSystems == "Galileo") {
|
---|
| 483 | plotGal = true;
|
---|
| 484 | }
|
---|
| 485 | else {
|
---|
| 486 | plotGPS = true;
|
---|
| 487 | plotGlo = true;
|
---|
| 488 | plotGal = true;
|
---|
| 489 | }
|
---|
| 490 |
|
---|
| 491 | // Loop over all observations
|
---|
| 492 | // --------------------------
|
---|
| 493 | for (int iEpo = 0; iEpo < _qcFile._qcEpo.size(); iEpo++) {
|
---|
| 494 | t_qcEpo& qcEpo = _qcFile._qcEpo[iEpo];
|
---|
| 495 | QMapIterator<t_prn, t_qcObs> it(qcEpo._qcObs);
|
---|
| 496 | while (it.hasNext()) {
|
---|
| 497 | it.next();
|
---|
| 498 | const t_prn& prn = it.key();
|
---|
| 499 | const t_qcObs& qcObs = it.value();
|
---|
[6271] | 500 | if ( (prn.system() == 'G' && plotGPS) ||
|
---|
| 501 | (prn.system() == 'R' && plotGlo) ||
|
---|
| 502 | (prn.system() == 'E' && plotGal) ) {
|
---|
[6281] | 503 |
|
---|
| 504 | (*dataSNR1) << (new t_polarPoint(qcObs._azDeg, 90.0 - qcObs._eleDeg, qcObs._SNR1));
|
---|
| 505 | (*dataSNR2) << (new t_polarPoint(qcObs._azDeg, 90.0 - qcObs._eleDeg, qcObs._SNR2));
|
---|
| 506 |
|
---|
| 507 | (*dataMP1) << (new t_polarPoint(qcObs._azDeg, 90.0 - qcObs._eleDeg, qcObs._stdMP1));
|
---|
| 508 | (*dataMP2) << (new t_polarPoint(qcObs._azDeg, 90.0 - qcObs._eleDeg, qcObs._stdMP2));
|
---|
[4700] | 509 | }
|
---|
[4353] | 510 | }
|
---|
[6271] | 511 | }
|
---|
[4353] | 512 |
|
---|
[6271] | 513 | // Show the plots
|
---|
| 514 | // --------------
|
---|
| 515 | if (BNC_CORE->GUIenabled()) {
|
---|
| 516 | QFileInfo fileInfo(obsFile->fileName());
|
---|
| 517 | QByteArray title = fileInfo.fileName().toAscii();
|
---|
[6275] | 518 | emit dspSkyPlot(obsFile->fileName(), "MP1", dataMP1, "MP2", dataMP2, "Meters", 2.0);
|
---|
| 519 | emit dspSkyPlot(obsFile->fileName(), "SNR1", dataSNR1, "SNR2", dataSNR2, "dbHz", 54.0);
|
---|
| 520 | emit dspAvailPlot(obsFile->fileName(), title);
|
---|
[6271] | 521 | }
|
---|
| 522 | else {
|
---|
| 523 | for (int ii = 0; ii < dataMP1->size(); ii++) {
|
---|
| 524 | delete dataMP1->at(ii);
|
---|
[4351] | 525 | }
|
---|
[6271] | 526 | delete dataMP1;
|
---|
| 527 | for (int ii = 0; ii < dataMP2->size(); ii++) {
|
---|
| 528 | delete dataMP2->at(ii);
|
---|
[4591] | 529 | }
|
---|
[6271] | 530 | delete dataMP2;
|
---|
| 531 | for (int ii = 0; ii < dataSNR1->size(); ii++) {
|
---|
| 532 | delete dataSNR1->at(ii);
|
---|
[4659] | 533 | }
|
---|
[6271] | 534 | delete dataSNR1;
|
---|
| 535 | for (int ii = 0; ii < dataSNR2->size(); ii++) {
|
---|
| 536 | delete dataSNR2->at(ii);
|
---|
[5141] | 537 | }
|
---|
[6271] | 538 | delete dataSNR2;
|
---|
[4350] | 539 | }
|
---|
| 540 | }
|
---|
[4572] | 541 |
|
---|
[6255] | 542 | //
|
---|
[4572] | 543 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6275] | 544 | void t_reqcAnalyze::slotDspSkyPlot(const QString& fileName, const QByteArray& title1,
|
---|
| 545 | QVector<t_polarPoint*>* data1, const QByteArray& title2,
|
---|
| 546 | QVector<t_polarPoint*>* data2, const QByteArray& scaleTitle,
|
---|
| 547 | double maxValue) {
|
---|
[4572] | 548 |
|
---|
[5068] | 549 | if (BNC_CORE->GUIenabled()) {
|
---|
[4573] | 550 |
|
---|
[6271] | 551 | if (maxValue == 0.0) {
|
---|
| 552 | if (data1) {
|
---|
| 553 | for (int ii = 0; ii < data1->size(); ii++) {
|
---|
| 554 | double val = data1->at(ii)->_value;
|
---|
| 555 | if (maxValue < val) {
|
---|
| 556 | maxValue = val;
|
---|
| 557 | }
|
---|
| 558 | }
|
---|
| 559 | }
|
---|
| 560 | if (data2) {
|
---|
| 561 | for (int ii = 0; ii < data2->size(); ii++) {
|
---|
| 562 | double val = data2->at(ii)->_value;
|
---|
| 563 | if (maxValue < val) {
|
---|
| 564 | maxValue = val;
|
---|
| 565 | }
|
---|
| 566 | }
|
---|
| 567 | }
|
---|
| 568 | }
|
---|
[4659] | 569 |
|
---|
[6271] | 570 | QwtInterval scaleInterval(0.0, maxValue);
|
---|
[4671] | 571 |
|
---|
[4573] | 572 | QVector<QWidget*> plots;
|
---|
[6271] | 573 | if (data1) {
|
---|
| 574 | t_polarPlot* plot1 = new t_polarPlot(QwtText(title1), scaleInterval,
|
---|
| 575 | BNC_CORE->mainWindow());
|
---|
| 576 | plot1->addCurve(data1);
|
---|
| 577 | plots << plot1;
|
---|
| 578 | }
|
---|
| 579 | if (data2) {
|
---|
| 580 | t_polarPlot* plot2 = new t_polarPlot(QwtText(title2), scaleInterval,
|
---|
| 581 | BNC_CORE->mainWindow());
|
---|
| 582 | plot2->addCurve(data2);
|
---|
| 583 | plots << plot2;
|
---|
| 584 | }
|
---|
[4666] | 585 |
|
---|
[6271] | 586 | t_graphWin* graphWin = new t_graphWin(0, fileName, plots,
|
---|
| 587 | &scaleTitle, &scaleInterval);
|
---|
[4666] | 588 |
|
---|
[4573] | 589 | graphWin->show();
|
---|
| 590 |
|
---|
| 591 | bncSettings settings;
|
---|
| 592 | QString dirName = settings.value("reqcPlotDir").toString();
|
---|
| 593 | if (!dirName.isEmpty()) {
|
---|
[6271] | 594 | QByteArray ext = (scaleTitle == "Meters") ? "_M.png" : "_S.png";
|
---|
[4579] | 595 | graphWin->savePNG(dirName, ext);
|
---|
[4573] | 596 | }
|
---|
| 597 | }
|
---|
[4572] | 598 | }
|
---|
[4679] | 599 |
|
---|
[6271] | 600 | //
|
---|
[4679] | 601 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6275] | 602 | void t_reqcAnalyze::slotDspAvailPlot(const QString& fileName, const QByteArray& title) {
|
---|
[4679] | 603 |
|
---|
[6280] | 604 | t_plotData plotData;
|
---|
[6278] | 605 | QMap<t_prn, t_plotData> plotDataMap;
|
---|
[6272] | 606 |
|
---|
[6278] | 607 | for (int ii = 0; ii < _qcFile._qcEpo.size(); ii++) {
|
---|
| 608 | const t_qcEpo& qcEpo = _qcFile._qcEpo[ii];
|
---|
[6280] | 609 | double mjdX24 = qcEpo._epoTime.mjddec() * 24.0;
|
---|
| 610 |
|
---|
| 611 | plotData._mjdX24 << mjdX24;
|
---|
| 612 | plotData._PDOP << qcEpo._PDOP;
|
---|
| 613 | plotData._numSat << qcEpo._qcObs.size();
|
---|
| 614 |
|
---|
[6278] | 615 | QMapIterator<t_prn, t_qcObs> it(qcEpo._qcObs);
|
---|
| 616 | while (it.hasNext()) {
|
---|
| 617 | it.next();
|
---|
| 618 | const t_prn& prn = it.key();
|
---|
| 619 | const t_qcObs& qcObs = it.value();
|
---|
[6280] | 620 | t_plotData& data = plotDataMap[prn];
|
---|
| 621 | if (qcObs._hasL1) data._L1ok << mjdX24;
|
---|
| 622 | if (qcObs._hasL2) data._L2ok << mjdX24;
|
---|
| 623 | if (qcObs._slipL1) data._L1slip << mjdX24;
|
---|
| 624 | if (qcObs._slipL2) data._L2slip << mjdX24;
|
---|
| 625 | if (qcObs._gapL1) data._L1gap << mjdX24;
|
---|
| 626 | if (qcObs._gapL2) data._L2gap << mjdX24;
|
---|
| 627 | data._eleDeg << qcObs._eleDeg;
|
---|
[6278] | 628 | }
|
---|
| 629 | }
|
---|
| 630 |
|
---|
[6279] | 631 |
|
---|
[6271] | 632 | if (BNC_CORE->GUIenabled()) {
|
---|
[6278] | 633 | t_availPlot* plotA = new t_availPlot(0, plotDataMap);
|
---|
[6271] | 634 | plotA->setTitle(title);
|
---|
[4679] | 635 |
|
---|
[6278] | 636 | t_elePlot* plotZ = new t_elePlot(0, plotDataMap);
|
---|
[4679] | 637 |
|
---|
[6279] | 638 | t_dopPlot* plotD = new t_dopPlot(0, plotData);
|
---|
[4679] | 639 |
|
---|
[6271] | 640 | QVector<QWidget*> plots;
|
---|
| 641 | plots << plotA << plotZ << plotD;
|
---|
| 642 | t_graphWin* graphWin = new t_graphWin(0, fileName, plots, 0, 0);
|
---|
[4679] | 643 |
|
---|
[6271] | 644 | int ww = QFontMetrics(graphWin->font()).width('w');
|
---|
| 645 | graphWin->setMinimumSize(120*ww, 40*ww);
|
---|
[4679] | 646 |
|
---|
[6271] | 647 | graphWin->show();
|
---|
[4679] | 648 |
|
---|
[6271] | 649 | bncSettings settings;
|
---|
| 650 | QString dirName = settings.value("reqcPlotDir").toString();
|
---|
| 651 | if (!dirName.isEmpty()) {
|
---|
| 652 | QByteArray ext = "_A.png";
|
---|
| 653 | graphWin->savePNG(dirName, ext);
|
---|
[4679] | 654 | }
|
---|
[4681] | 655 | }
|
---|
[4679] | 656 | }
|
---|
[4689] | 657 |
|
---|
| 658 | // Finish the report
|
---|
| 659 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6271] | 660 | void t_reqcAnalyze::printReport() {
|
---|
[5368] | 661 |
|
---|
[4689] | 662 | if (!_log) {
|
---|
| 663 | return;
|
---|
| 664 | }
|
---|
| 665 |
|
---|
[6271] | 666 | *_log << "Marker name: " << _qcFile._markerName << endl
|
---|
| 667 | << "Receiver: " << _qcFile._receiverType << endl
|
---|
| 668 | << "Antenna: " << _qcFile._antennaName << endl
|
---|
| 669 | << "Start time: " << _qcFile._startTime.datestr().c_str() << ' '
|
---|
| 670 | << _qcFile._startTime.timestr().c_str() << endl
|
---|
| 671 | << "End time: " << _qcFile._endTime.datestr().c_str() << ' '
|
---|
| 672 | << _qcFile._endTime.timestr().c_str() << endl
|
---|
| 673 | << "Interval: " << _qcFile._interval << endl
|
---|
| 674 | << "# Sat.: " << _qcFile._qcSat.size() << endl;
|
---|
[4689] | 675 |
|
---|
[4701] | 676 | int numObs = 0;
|
---|
| 677 | int numSlipsFlagged = 0;
|
---|
| 678 | int numSlipsFound = 0;
|
---|
[6271] | 679 | QMapIterator<t_prn, t_qcSat> it(_qcFile._qcSat);
|
---|
[4693] | 680 | while (it.hasNext()) {
|
---|
| 681 | it.next();
|
---|
[6271] | 682 | const t_qcSat& qcSat = it.value();
|
---|
| 683 | numObs += qcSat._numObs;
|
---|
| 684 | numSlipsFlagged += qcSat._numSlipsFlagged;
|
---|
| 685 | numSlipsFound += qcSat._numSlipsFound;
|
---|
[4693] | 686 | }
|
---|
[4701] | 687 | *_log << "# Obs.: " << numObs << endl
|
---|
| 688 | << "# Slips (file): " << numSlipsFlagged << endl
|
---|
| 689 | << "# Slips (found): " << numSlipsFound << endl;
|
---|
[4693] | 690 |
|
---|
[4689] | 691 | _log->flush();
|
---|
| 692 | }
|
---|