source: ntrip/trunk/BNC/src/rinex/reqcanalyze.cpp@ 6312

Last change on this file since 6312 was 6312, checked in by mervart, 9 years ago
File size: 28.9 KB
RevLine 
[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
56using namespace std;
57
58// Constructor
59////////////////////////////////////////////////////////////////////////////
60t_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////////////////////////////////////////////////////////////////////////////
84t_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////////////////////////////////////////////////////////////////////////////
100void 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]132void 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 {
[6296]143 QMap<QString, bncTime> lastObsTime;
[6271]144 bool firstEpo = true;
[4541]145 while ( (_currEpo = obsFile->nextEpoch()) != 0) {
[6271]146 if (firstEpo) {
147 firstEpo = false;
148 _qcFile._startTime = _currEpo->tt;
149 _qcFile._antennaName = obsFile->antennaName();
150 _qcFile._markerName = obsFile->markerName();
151 _qcFile._receiverType = obsFile->receiverType();
152 _qcFile._interval = obsFile->interval();
[4688]153 }
[6271]154 _qcFile._endTime = _currEpo->tt;
[6255]155
[6271]156 t_qcEpo qcEpo;
157 qcEpo._epoTime = _currEpo->tt;
158 qcEpo._PDOP = cmpDOP(xyzSta);
159
[4541]160 // Loop over all satellites
161 // ------------------------
162 for (unsigned iObs = 0; iObs < _currEpo->rnxSat.size(); iObs++) {
163 const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iObs];
[6271]164 t_satObs satObs;
165 t_rnxObsFile::setObsFromRnx(obsFile, _currEpo, rnxSat, satObs);
[6288]166 t_qcSat& qcSat = qcEpo._qcSat[satObs._prn];
[6296]167 setQcObs(qcEpo._epoTime, xyzSta, satObs, lastObsTime, qcSat);
[6288]168 updateQcSat(qcSat, _qcFile._qcSatSum[satObs._prn]);
[4262]169 }
[6271]170 _qcFile._qcEpo.push_back(qcEpo);
171 }
[6255]172
[6281]173 analyzeMultipath();
174
[6271]175 preparePlotData(obsFile);
[4678]176
[6284]177 printReport(obsFile);
[4541]178 }
179 catch (QString str) {
180 if (_log) {
181 *_log << "Exception " << str << endl;
[4262]182 }
[4541]183 else {
[6255]184 qDebug() << str;
[4541]185 }
186 }
[6271]187}
[4262]188
[6271]189// Compute Dilution of Precision
190////////////////////////////////////////////////////////////////////////////
191double t_reqcAnalyze::cmpDOP(const ColumnVector& xyzSta) const {
[4268]192
[6271]193 if (xyzSta.size() != 3) {
194 return 0.0;
[4268]195 }
196
[6271]197 unsigned nSat = _currEpo->rnxSat.size();
[4706]198
[6271]199 if (nSat < 4) {
200 return 0.0;
[4718]201 }
[6271]202
203 Matrix AA(nSat, 4);
204
205 unsigned nSatUsed = 0;
206 for (unsigned iSat = 0; iSat < nSat; iSat++) {
207
208 const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iSat];
209 const t_prn& prn = rnxSat.prn;
210
211 t_eph* eph = 0;
212 for (int ie = 0; ie < _ephs.size(); ie++) {
213 if (_ephs[ie]->prn() == prn) {
214 eph = _ephs[ie];
215 break;
216 }
[4718]217 }
[6271]218 if (eph) {
219 ColumnVector xSat(4);
220 ColumnVector vv(3);
221 if (eph->getCrd(_currEpo->tt, xSat, vv, false) == success) {
222 ++nSatUsed;
223 ColumnVector dx = xSat.Rows(1,3) - xyzSta;
224 double rho = dx.norm_Frobenius();
225 AA(nSatUsed,1) = dx(1) / rho;
226 AA(nSatUsed,2) = dx(2) / rho;
227 AA(nSatUsed,3) = dx(3) / rho;
228 AA(nSatUsed,4) = 1.0;
229 }
[4718]230 }
231 }
[6271]232
233 if (nSatUsed < 4) {
234 return 0.0;
235 }
236
237 AA = AA.Rows(1, nSatUsed);
238
239 SymmetricMatrix QQ;
240 QQ << AA.t() * AA;
241 QQ = QQ.i();
242
243 return sqrt(QQ.trace());
[4254]244}
[4263]245
[6255]246//
[4263]247////////////////////////////////////////////////////////////////////////////
[6288]248void t_reqcAnalyze::updateQcSat(const t_qcSat& qcSat, t_qcSatSum& qcSatSum) {
[6285]249
[6288]250 for (int ii = 0; ii < qcSat._qcFrq.size(); ii++) {
251 const t_qcFrq& qcFrq = qcSat._qcFrq[ii];
[6285]252 t_qcFrqSum& qcFrqSum = qcSatSum._qcFrqSum[qcFrq._rnxType2ch];
253 qcFrqSum._numObs += 1;
254 if (qcFrq._slip) {
255 qcFrqSum._numSlipsFlagged += 1;
256 }
257 if (qcFrq._gap) {
258 qcFrqSum._numGaps += 1;
259 }
[6312]260 if (qcFrq._SNR > 0.0) {
261 qcFrqSum._numSNR += 1;
262 qcFrqSum._sumSNR += qcFrq._SNR;
263 }
[6271]264 }
265}
[4265]266
[6271]267//
268////////////////////////////////////////////////////////////////////////////
[6281]269void t_reqcAnalyze::setQcObs(const bncTime& epoTime, const ColumnVector& xyzSta,
[6296]270 const t_satObs& satObs, QMap<QString, bncTime>& lastObsTime,
271 t_qcSat& qcSat) {
[4338]272
[6281]273 t_eph* eph = 0;
274 for (int ie = 0; ie < _ephs.size(); ie++) {
275 if (_ephs[ie]->prn() == satObs._prn) {
276 eph = _ephs[ie];
277 break;
[6271]278 }
[6281]279 }
280 if (eph) {
281 ColumnVector xc(4);
282 ColumnVector vv(3);
283 if (xyzSta.size() && eph->getCrd(epoTime, xc, vv, false) == success) {
284 double rho, eleSat, azSat;
285 topos(xyzSta(1), xyzSta(2), xyzSta(3), xc(1), xc(2), xc(3), rho, eleSat, azSat);
[6288]286 qcSat._eleSet = true;
287 qcSat._azDeg = azSat * 180.0/M_PI;
288 qcSat._eleDeg = eleSat * 180.0/M_PI;
[6281]289 }
290 if (satObs._prn.system() == 'R') {
[6288]291 qcSat._slotSet = true;
292 qcSat._slotNum = eph->slotNum();
[6271]293 }
294 }
295
[4608]296 // Availability and Slip Flags
297 // ---------------------------
[6285]298 for (unsigned ii = 0; ii < satObs._obs.size(); ii++) {
299
300 const t_frqObs* frqObs = satObs._obs[ii];
301
[6288]302 qcSat._qcFrq.push_back(t_qcFrq());
303 t_qcFrq& qcFrq = qcSat._qcFrq.back();
[6285]304
305 qcFrq._rnxType2ch = QString(frqObs->_rnxType2ch.c_str());
306 qcFrq._SNR = frqObs->_snr;
307 qcFrq._slip = frqObs->_slip;
[6293]308 qcFrq._phaseValid = frqObs->_phaseValid;
309 qcFrq._codeValid = frqObs->_codeValid;
[6285]310
311 // Check Gaps
312 // ----------
[6296]313 QString key = QString(satObs._prn.toString().c_str()) + qcFrq._rnxType2ch;
314 if (lastObsTime[key].valid()) {
315 double dt = epoTime - lastObsTime[key];
[6285]316 if (dt > 1.5 * _qcFile._interval) {
317 qcFrq._gap = true;
[6137]318 }
319 }
[6296]320 lastObsTime[key] = epoTime;
[6285]321
322 // Compute the Multipath Linear Combination
323 // ----------------------------------------
[6292]324 if (frqObs->_codeValid) {
[6285]325 t_frequency::type fA;
326 t_frequency::type fB;
327 if (satObs._prn.system() == 'G') {
328 if (frqObs->_rnxType2ch[0] == '1') {
329 fA = t_frequency::G1;
330 fB = t_frequency::G2;
331 }
332 else if (frqObs->_rnxType2ch[0] == '2') {
333 fA = t_frequency::G2;
334 fB = t_frequency::G1;
335 }
[6137]336 }
[6285]337 else if (satObs._prn.system() == 'R') {
338 if (frqObs->_rnxType2ch[0] == '1') {
339 fA = t_frequency::R1;
340 fB = t_frequency::R2;
341 }
342 else if (frqObs->_rnxType2ch[0] == '2') {
343 fA = t_frequency::R2;
344 fB = t_frequency::R1;
345 }
[6137]346 }
[6285]347 else if (satObs._prn.system() == 'E') {
348 if (frqObs->_rnxType2ch[0] == '1') {
349 fA = t_frequency::E1;
350 fB = t_frequency::E5;
351 }
352 else if (frqObs->_rnxType2ch[0] == '5') {
353 fA = t_frequency::E5;
354 fB = t_frequency::E1;
355 }
[6137]356 }
[4608]357
[6285]358 if (fA != t_frequency::dummy && fB != t_frequency::dummy) {
[6292]359 double f_a = t_CST::freq(fA, qcSat._slotNum);
360 double f_b = t_CST::freq(fB, qcSat._slotNum);
361 double C_a = frqObs->_code;
362
363 bool foundA = false;
364 double L_a = 0.0;
365 bool foundB = false;
366 double L_b = 0.0;
[6285]367 for (unsigned jj = 0; jj < satObs._obs.size(); jj++) {
[6292]368 const t_frqObs* frqObsHlp = satObs._obs[jj];
369 if (frqObsHlp->_rnxType2ch[0] == t_frequency::toString(fA)[1] &&
370 frqObsHlp->_phaseValid) {
371 foundA = true;
372 L_a = frqObsHlp->_phase * t_CST::c / f_a;
[6285]373 }
[6292]374 else if (frqObsHlp->_rnxType2ch[0] == t_frequency::toString(fB)[1] &&
375 frqObsHlp->_phaseValid) {
376 foundB = true;
377 L_b = frqObsHlp->_phase * t_CST::c / f_b;
378 }
[6285]379 }
[6292]380 if (foundA && foundB) {
381 qcFrq._setMP = true;
382 qcFrq._rawMP = C_a - L_a - 2.0*f_b*f_b/(f_a*f_a-f_b*f_b) * (L_a - L_b);
383 }
[6285]384 }
385 }
[6291]386 } // satObs loop
[4263]387}
[4350]388
[6255]389//
[4350]390////////////////////////////////////////////////////////////////////////////
[6281]391void t_reqcAnalyze::analyzeMultipath() {
[4675]392
[6271]393 const double SLIPTRESH = 10.0; // cycle-slip threshold (meters)
394 const double chunkStep = 600.0; // 10 minutes
[4584]395
[6271]396 // Loop over all satellites available
397 // ----------------------------------
[6285]398 QMutableMapIterator<t_prn, t_qcSatSum> itSat(_qcFile._qcSatSum);
399 while (itSat.hasNext()) {
400 itSat.next();
401 const t_prn& prn = itSat.key();
402 t_qcSatSum& qcSatSum = itSat.value();
[4351]403
[6285]404 // Loop over all frequencies available
405 // -----------------------------------
406 QMutableMapIterator<QString, t_qcFrqSum> itFrq(qcSatSum._qcFrqSum);
407 while (itFrq.hasNext()) {
408 itFrq.next();
409 const QString& frqType = itFrq.key();
410 t_qcFrqSum& qcFrqSum = itFrq.value();
[4702]411
[4353]412
[6285]413 // Loop over all Chunks of Data
414 // ----------------------------
415 for (bncTime chunkStart = _qcFile._startTime;
416 chunkStart < _qcFile._endTime; chunkStart += chunkStep) {
417
418 bncTime chunkEnd = chunkStart + chunkStep;
419
420 QVector<t_qcFrq*> frqVec;
421 QVector<double> MP;
[6271]422
[6285]423 // Loop over all Epochs within one Chunk of Data
424 // ---------------------------------------------
425 for (int iEpo = 0; iEpo < _qcFile._qcEpo.size(); iEpo++) {
426 t_qcEpo& qcEpo = _qcFile._qcEpo[iEpo];
427 if (chunkStart <= qcEpo._epoTime && qcEpo._epoTime < chunkEnd) {
[6288]428 if (qcEpo._qcSat.contains(prn)) {
429 t_qcSat& qcSat = qcEpo._qcSat[prn];
430 for (int iFrq = 0; iFrq < qcSat._qcFrq.size(); iFrq++) {
431 t_qcFrq& qcFrq = qcSat._qcFrq[iFrq];
[6285]432 if (qcFrq._rnxType2ch == frqType) {
433 frqVec << &qcFrq;
434 if (qcFrq._setMP) {
435 MP << qcFrq._rawMP;
436 }
437 }
438 }
[6213]439 }
[4590]440 }
441 }
[4563]442
[6285]443 // Compute the multipath mean and standard deviation
444 // -------------------------------------------------
445 if (MP.size() > 1) {
446 double meanMP = 0.0;
447 for (int ii = 0; ii < MP.size(); ii++) {
448 meanMP += MP[ii];
[6271]449 }
[6285]450 meanMP /= MP.size();
451
452 bool slipMP = false;
453
454 double stdMP = 0.0;
455 for (int ii = 0; ii < MP.size(); ii++) {
456 double diff = MP[ii] - meanMP;
457 if (fabs(diff) > SLIPTRESH) {
458 slipMP = true;
459 break;
460 }
461 stdMP += diff * diff;
462 }
463
[6281]464 if (slipMP) {
[6285]465 stdMP = 0.0;
466 stdMP = 0.0;
467 qcFrqSum._numSlipsFound += 1;
[6281]468 }
469 else {
[6285]470 stdMP = sqrt(stdMP / (MP.size()-1));
[6312]471 qcFrqSum._numMP += 1;
472 qcFrqSum._sumMP += stdMP;
[6281]473 }
[6285]474
475 for (int ii = 0; ii < frqVec.size(); ii++) {
476 t_qcFrq* qcFrq = frqVec[ii];
477 if (slipMP) {
478 qcFrq->_slip = true;
479 }
480 else {
481 qcFrq->_stdMP = stdMP;
482 }
483 }
[6281]484 }
[6285]485 } // chunk loop
486 } // frq loop
487 } // sat loop
[6281]488}
489
490//
491////////////////////////////////////////////////////////////////////////////
492void t_reqcAnalyze::preparePlotData(const t_rnxObsFile* obsFile) {
493
494 QVector<t_polarPoint*>* dataMP1 = new QVector<t_polarPoint*>;
495 QVector<t_polarPoint*>* dataMP2 = new QVector<t_polarPoint*>;
496 QVector<t_polarPoint*>* dataSNR1 = new QVector<t_polarPoint*>;
497 QVector<t_polarPoint*>* dataSNR2 = new QVector<t_polarPoint*>;
498
499 bncSettings settings;
500 QString reqSkyPlotSystems = settings.value("reqcSkyPlotSystems").toString();
501 bool plotGPS = false;
502 bool plotGlo = false;
503 bool plotGal = false;
504 if (reqSkyPlotSystems == "GPS") {
505 plotGPS = true;
506 }
507 else if (reqSkyPlotSystems == "GLONASS") {
508 plotGlo = true;
509 }
510 else if (reqSkyPlotSystems == "Galileo") {
511 plotGal = true;
512 }
513 else {
514 plotGPS = true;
515 plotGlo = true;
516 plotGal = true;
517 }
518
519 // Loop over all observations
520 // --------------------------
521 for (int iEpo = 0; iEpo < _qcFile._qcEpo.size(); iEpo++) {
522 t_qcEpo& qcEpo = _qcFile._qcEpo[iEpo];
[6288]523 QMapIterator<t_prn, t_qcSat> it(qcEpo._qcSat);
[6281]524 while (it.hasNext()) {
525 it.next();
526 const t_prn& prn = it.key();
[6288]527 const t_qcSat& qcSat = it.value();
[6271]528 if ( (prn.system() == 'G' && plotGPS) ||
529 (prn.system() == 'R' && plotGlo) ||
530 (prn.system() == 'E' && plotGal) ) {
[6281]531
[6288]532 if (qcSat._eleSet) {
[6286]533 QString frqType1;
534 QString frqType2;
[6288]535 for (int iFrq = 0; iFrq < qcSat._qcFrq.size(); iFrq++) {
536 const t_qcFrq& qcFrq = qcSat._qcFrq[iFrq];
[6287]537 if (qcFrq._rnxType2ch[0] == '1' && frqType1.isEmpty()) {
[6286]538 frqType1 = qcFrq._rnxType2ch;
539 }
[6287]540 if (qcFrq._rnxType2ch[0] == '2' && frqType2.isEmpty()) {
[6286]541 frqType2 = qcFrq._rnxType2ch;
542 }
543 if (qcFrq._rnxType2ch == frqType1) {
[6288]544 (*dataSNR1) << (new t_polarPoint(qcSat._azDeg, 90.0 - qcSat._eleDeg, qcFrq._SNR));
545 (*dataMP1) << (new t_polarPoint(qcSat._azDeg, 90.0 - qcSat._eleDeg, qcFrq._stdMP));
[6286]546 }
547 else if (qcFrq._rnxType2ch == frqType2) {
[6288]548 (*dataSNR2) << (new t_polarPoint(qcSat._azDeg, 90.0 - qcSat._eleDeg, qcFrq._SNR));
549 (*dataMP2) << (new t_polarPoint(qcSat._azDeg, 90.0 - qcSat._eleDeg, qcFrq._stdMP));
[6286]550 }
551 }
[6284]552 }
[4700]553 }
[4353]554 }
[6271]555 }
[4353]556
[6271]557 // Show the plots
558 // --------------
559 if (BNC_CORE->GUIenabled()) {
560 QFileInfo fileInfo(obsFile->fileName());
561 QByteArray title = fileInfo.fileName().toAscii();
[6286]562 emit dspSkyPlot(obsFile->fileName(), "MP1", dataMP1, "MP2", dataMP2, "Meters", 2.0);
563 emit dspSkyPlot(obsFile->fileName(), "SNR1", dataSNR1, "SNR2", dataSNR2, "dbHz", 54.0);
[6275]564 emit dspAvailPlot(obsFile->fileName(), title);
[6271]565 }
566 else {
567 for (int ii = 0; ii < dataMP1->size(); ii++) {
568 delete dataMP1->at(ii);
[4351]569 }
[6271]570 delete dataMP1;
571 for (int ii = 0; ii < dataMP2->size(); ii++) {
572 delete dataMP2->at(ii);
[4591]573 }
[6271]574 delete dataMP2;
575 for (int ii = 0; ii < dataSNR1->size(); ii++) {
576 delete dataSNR1->at(ii);
[4659]577 }
[6271]578 delete dataSNR1;
579 for (int ii = 0; ii < dataSNR2->size(); ii++) {
580 delete dataSNR2->at(ii);
[5141]581 }
[6271]582 delete dataSNR2;
[4350]583 }
584}
[4572]585
[6255]586//
[4572]587////////////////////////////////////////////////////////////////////////////
[6275]588void t_reqcAnalyze::slotDspSkyPlot(const QString& fileName, const QByteArray& title1,
589 QVector<t_polarPoint*>* data1, const QByteArray& title2,
590 QVector<t_polarPoint*>* data2, const QByteArray& scaleTitle,
591 double maxValue) {
[4572]592
[5068]593 if (BNC_CORE->GUIenabled()) {
[4573]594
[6271]595 if (maxValue == 0.0) {
596 if (data1) {
597 for (int ii = 0; ii < data1->size(); ii++) {
598 double val = data1->at(ii)->_value;
599 if (maxValue < val) {
600 maxValue = val;
601 }
602 }
603 }
604 if (data2) {
605 for (int ii = 0; ii < data2->size(); ii++) {
606 double val = data2->at(ii)->_value;
607 if (maxValue < val) {
608 maxValue = val;
609 }
610 }
611 }
612 }
[4659]613
[6271]614 QwtInterval scaleInterval(0.0, maxValue);
[4671]615
[4573]616 QVector<QWidget*> plots;
[6271]617 if (data1) {
618 t_polarPlot* plot1 = new t_polarPlot(QwtText(title1), scaleInterval,
619 BNC_CORE->mainWindow());
620 plot1->addCurve(data1);
621 plots << plot1;
622 }
623 if (data2) {
624 t_polarPlot* plot2 = new t_polarPlot(QwtText(title2), scaleInterval,
625 BNC_CORE->mainWindow());
626 plot2->addCurve(data2);
627 plots << plot2;
628 }
[4666]629
[6271]630 t_graphWin* graphWin = new t_graphWin(0, fileName, plots,
631 &scaleTitle, &scaleInterval);
[4666]632
[4573]633 graphWin->show();
634
635 bncSettings settings;
636 QString dirName = settings.value("reqcPlotDir").toString();
637 if (!dirName.isEmpty()) {
[6271]638 QByteArray ext = (scaleTitle == "Meters") ? "_M.png" : "_S.png";
[4579]639 graphWin->savePNG(dirName, ext);
[4573]640 }
641 }
[4572]642}
[4679]643
[6271]644//
[4679]645////////////////////////////////////////////////////////////////////////////
[6275]646void t_reqcAnalyze::slotDspAvailPlot(const QString& fileName, const QByteArray& title) {
[4679]647
[6280]648 t_plotData plotData;
[6278]649 QMap<t_prn, t_plotData> plotDataMap;
[6272]650
[6278]651 for (int ii = 0; ii < _qcFile._qcEpo.size(); ii++) {
652 const t_qcEpo& qcEpo = _qcFile._qcEpo[ii];
[6280]653 double mjdX24 = qcEpo._epoTime.mjddec() * 24.0;
654
655 plotData._mjdX24 << mjdX24;
656 plotData._PDOP << qcEpo._PDOP;
[6288]657 plotData._numSat << qcEpo._qcSat.size();
[6280]658
[6288]659 QMapIterator<t_prn, t_qcSat> it(qcEpo._qcSat);
[6278]660 while (it.hasNext()) {
661 it.next();
662 const t_prn& prn = it.key();
[6288]663 const t_qcSat& qcSat = it.value();
[6280]664 t_plotData& data = plotDataMap[prn];
[6286]665
[6297]666 if (qcSat._eleSet) {
667 data._mjdX24 << mjdX24;
668 data._eleDeg << qcSat._eleDeg;
669 }
[6286]670
671 QString frqType1;
672 QString frqType2;
[6288]673 for (int iFrq = 0; iFrq < qcSat._qcFrq.size(); iFrq++) {
674 const t_qcFrq& qcFrq = qcSat._qcFrq[iFrq];
[6287]675 if (qcFrq._rnxType2ch[0] == '1' && frqType1.isEmpty()) {
[6286]676 frqType1 = qcFrq._rnxType2ch;
[6284]677 }
[6287]678 if (qcFrq._rnxType2ch[0] == '2' && frqType2.isEmpty()) {
[6286]679 frqType2 = qcFrq._rnxType2ch;
[6284]680 }
[6286]681 if (qcFrq._rnxType2ch == frqType1) {
682 if (qcFrq._slip) {
683 data._L1slip << mjdX24;
684 }
685 else if (qcFrq._gap) {
686 data._L1gap << mjdX24;
687 }
688 else {
689 data._L1ok << mjdX24;
690 }
[6284]691 }
[6286]692 else if (qcFrq._rnxType2ch == frqType2) {
693 if (qcFrq._slip) {
694 data._L2slip << mjdX24;
695 }
696 else if (qcFrq._gap) {
697 data._L2gap << mjdX24;
698 }
699 else {
700 data._L2ok << mjdX24;
701 }
[6284]702 }
703 }
[6278]704 }
705 }
706
[6271]707 if (BNC_CORE->GUIenabled()) {
[6278]708 t_availPlot* plotA = new t_availPlot(0, plotDataMap);
[6271]709 plotA->setTitle(title);
[4679]710
[6278]711 t_elePlot* plotZ = new t_elePlot(0, plotDataMap);
[4679]712
[6279]713 t_dopPlot* plotD = new t_dopPlot(0, plotData);
[4679]714
[6271]715 QVector<QWidget*> plots;
716 plots << plotA << plotZ << plotD;
717 t_graphWin* graphWin = new t_graphWin(0, fileName, plots, 0, 0);
[4679]718
[6271]719 int ww = QFontMetrics(graphWin->font()).width('w');
720 graphWin->setMinimumSize(120*ww, 40*ww);
[4679]721
[6271]722 graphWin->show();
[4679]723
[6271]724 bncSettings settings;
725 QString dirName = settings.value("reqcPlotDir").toString();
726 if (!dirName.isEmpty()) {
727 QByteArray ext = "_A.png";
728 graphWin->savePNG(dirName, ext);
[4679]729 }
[4681]730 }
[4679]731}
[4689]732
733// Finish the report
734////////////////////////////////////////////////////////////////////////////
[6284]735void t_reqcAnalyze::printReport(const t_rnxObsFile* obsFile) {
[5368]736
[6301]737 static const double QC_FORMAT_VERSION = 1.0;
738
[4689]739 if (!_log) {
740 return;
741 }
742
[6300]743 // Summary
744 // -------
[6309]745 *_log << "QC Format Version : " << QString("%1").arg(QC_FORMAT_VERSION,3,'f',1) << endl << endl
[6301]746 << "Observation File : " << obsFile->fileName().toAscii().data() << endl
747 << "Navigation File(s): " << _navFileNames.join(", ") << endl
748 << "RINEX Version : " << QString("%1").arg(obsFile->version(),4,'f',2) << endl
749 << "Marker name : " << _qcFile._markerName << endl
[6302]750 << "Marker number : " << obsFile->markerNumber() << endl
[6301]751 << "Receiver : " << _qcFile._receiverType << endl
752 << "Antenna : " << _qcFile._antennaName << endl
[6303]753 << "Approx pos XYZ : " << QString("%1 %2 %3").arg(obsFile->xyz()(1), 14, 'f', 4)
754 .arg(obsFile->xyz()(2), 14, 'f', 4)
755 .arg(obsFile->xyz()(3), 14, 'f', 4) << endl
756 << "Antenna dH/dE/dN : " << QString("%1 %2 %3").arg(obsFile->antNEU()(3), 8, 'f', 4)
757 .arg(obsFile->antNEU()(2), 8, 'f', 4)
758 .arg(obsFile->antNEU()(1), 8, 'f', 4) << endl
[6301]759 << "Start time : " << _qcFile._startTime.datestr().c_str() << ' '
[6304]760 << _qcFile._startTime.timestr(1,'.').c_str() << endl
[6301]761 << "End time : " << _qcFile._endTime.datestr().c_str() << ' '
[6304]762 << _qcFile._endTime.timestr(1,'.').c_str() << endl
[6303]763 << "Interval : " << _qcFile._interval << endl;
[4689]764
[6303]765 // Number of systems
766 // -----------------
767 QMap<QChar, QVector<const t_qcSatSum*> > systemMap;
[6286]768 QMapIterator<t_prn, t_qcSatSum> itSat(_qcFile._qcSatSum);
769 while (itSat.hasNext()) {
770 itSat.next();
[6303]771 const t_prn& prn = itSat.key();
[6286]772 const t_qcSatSum& qcSatSum = itSat.value();
[6303]773 systemMap[prn.system()].push_back(&qcSatSum);
774 }
[6286]775
[6309]776 *_log << "Navigation Systems: " << systemMap.size() << " ";
[6303]777 QMapIterator<QChar, QVector<const t_qcSatSum*> > itSys(systemMap);
778 while (itSys.hasNext()) {
779 itSys.next();
780 *_log << ' ' << itSys.key();
[4693]781 }
[6303]782 *_log << endl;
[4693]783
[6304]784 itSys.toFront();
785 while (itSys.hasNext()) {
786 itSys.next();
787 const QChar& sys = itSys.key();
788 const QVector<const t_qcSatSum*>& qcSatVec = itSys.value();
789 QString prefixSys = QString(" ") + sys + QString(": ");
[6306]790 QMap<QString, QVector<const t_qcFrqSum*> > frqMap;
[6305]791 for (int ii = 0; ii < qcSatVec.size(); ii++) {
792 const t_qcSatSum* qcSatSum = qcSatVec[ii];
793 QMapIterator<QString, t_qcFrqSum> itFrq(qcSatSum->_qcFrqSum);
794 while (itFrq.hasNext()) {
795 itFrq.next();
[6309]796 QString frqType = itFrq.key(); if (frqType.length() < 2) frqType += ' ';
[6305]797 const t_qcFrqSum& qcFrqSum = itFrq.value();
[6306]798 frqMap[frqType].push_back(&qcFrqSum);
[6305]799 }
800 }
[6309]801 *_log << endl
[6310]802 << prefixSys << "Satellites: " << qcSatVec.size() << endl
803 << prefixSys << "Signals : " << frqMap.size() << " ";
[6307]804 QMapIterator<QString, QVector<const t_qcFrqSum*> > itFrq(frqMap);
805 while (itFrq.hasNext()) {
806 itFrq.next();
[6309]807 QString frqType = itFrq.key(); if (frqType.length() < 2) frqType += ' ';
[6308]808 *_log << ' ' << frqType;
809 }
810 *_log << endl;
811 itFrq.toFront();
812 while (itFrq.hasNext()) {
813 itFrq.next();
[6309]814 QString frqType = itFrq.key(); if (frqType.length() < 2) frqType += ' ';
[6307]815 const QVector<const t_qcFrqSum*> qcFrqVec = itFrq.value();
816 QString prefixFrq = QString(" ") + frqType + QString(": ");
[6308]817
818 int numObs = 0;
819 int numSlipsFlagged = 0;
820 int numSlipsFound = 0;
821 int numGaps = 0;
822 for (int ii = 0; ii < qcFrqVec.size(); ii++) {
823 const t_qcFrqSum* qcFrqSum = qcFrqVec[ii];
824 numObs += qcFrqSum->_numObs ;
825 numSlipsFlagged += qcFrqSum->_numSlipsFlagged;
826 numSlipsFound += qcFrqSum->_numSlipsFound ;
827 numGaps += qcFrqSum->_numGaps ;
828 }
[6309]829 *_log << endl
[6311]830 << prefixSys << prefixFrq << "Observations : " << numObs << endl
831 << prefixSys << prefixFrq << "Slips (file+found): " << numSlipsFlagged << " + " << numSlipsFound << endl
832 << prefixSys << prefixFrq << "Gaps : " << numGaps << endl
833 << prefixSys << prefixFrq << "Mean SNR : " << 0.0 << endl
834 << prefixSys << prefixFrq << "Mean Multipath : " << 0.0 << endl;
[6307]835 }
[6304]836 }
837
[6300]838 // Epoch-Specific Output
839 // ---------------------
840 bncSettings settings;
841 if (Qt::CheckState(settings.value("reqcLogSummaryOnly").toInt()) == Qt::Checked) {
842 return;
843 }
[6309]844 *_log << endl;
[6289]845 for (int iEpo = 0; iEpo < _qcFile._qcEpo.size(); iEpo++) {
846 const t_qcEpo& qcEpo = _qcFile._qcEpo[iEpo];
847
848 unsigned year, month, day, hour, min;
849 double sec;
850 qcEpo._epoTime.civil_date(year, month, day);
851 qcEpo._epoTime.civil_time(hour, min, sec);
852
853 QString dateStr;
854 QTextStream(&dateStr) << QString("> %1 %2 %3 %4 %5%6")
855 .arg(year, 4)
856 .arg(month, 2, 10, QChar('0'))
857 .arg(day, 2, 10, QChar('0'))
858 .arg(hour, 2, 10, QChar('0'))
859 .arg(min, 2, 10, QChar('0'))
860 .arg(sec, 11, 'f', 7);
861
[6290]862 *_log << dateStr << QString(" %1").arg(qcEpo._qcSat.size(), 2)
863 << QString(" %1").arg(qcEpo._PDOP, 4, 'f', 1)
864 << endl;
[6289]865
866 QMapIterator<t_prn, t_qcSat> itSat(qcEpo._qcSat);
867 while (itSat.hasNext()) {
868 itSat.next();
869 const t_prn& prn = itSat.key();
870 const t_qcSat& qcSat = itSat.value();
871
[6290]872 *_log << prn.toString().c_str()
[6295]873 << QString(" %1 %2").arg(qcSat._eleDeg, 6, 'f', 2).arg(qcSat._azDeg, 7, 'f', 2);
874
875 int numObsTypes = 0;
[6290]876 for (int iFrq = 0; iFrq < qcSat._qcFrq.size(); iFrq++) {
877 const t_qcFrq& qcFrq = qcSat._qcFrq[iFrq];
[6294]878 if (qcFrq._phaseValid) {
[6295]879 numObsTypes += 1;
[6294]880 }
881 if (qcFrq._codeValid) {
[6295]882 numObsTypes += 1;
[6294]883 }
[6295]884 }
[6298]885 *_log << QString(" %1").arg(numObsTypes, 2);
[6295]886
887 for (int iFrq = 0; iFrq < qcSat._qcFrq.size(); iFrq++) {
888 const t_qcFrq& qcFrq = qcSat._qcFrq[iFrq];
889 if (qcFrq._phaseValid) {
890 *_log << " L" << qcFrq._rnxType2ch << ' ';
891 if (qcFrq._slip) {
892 *_log << 's';
893 }
894 else {
895 *_log << '.';
896 }
897 if (qcFrq._gap) {
898 *_log << 'g';
899 }
900 else {
901 *_log << '.';
902 }
903 *_log << QString(" %1").arg(qcFrq._SNR, 4, 'f', 1);
[6294]904 }
[6295]905 if (qcFrq._codeValid) {
906 *_log << " C" << qcFrq._rnxType2ch << ' ';
907 if (qcFrq._gap) {
[6298]908 *_log << " g";
[6295]909 }
910 else {
[6298]911 *_log << " .";
[6295]912 }
913 *_log << QString(" %1").arg(qcFrq._stdMP, 3, 'f', 2);
[6290]914 }
915 }
916 *_log << endl;
[6289]917 }
918 }
[4689]919 _log->flush();
920}
Note: See TracBrowser for help on using the repository browser.