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