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

Last change on this file since 6528 was 6528, checked in by mervart, 9 years ago
File size: 33.5 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>
[6527]43#include <sstream>
[4579]44#include <qwt_plot_renderer.h>
[4574]45
[3899]46#include "reqcanalyze.h"
[5070]47#include "bnccore.h"
[3899]48#include "bncsettings.h"
[4254]49#include "reqcedit.h"
[4255]50#include "bncutils.h"
[4300]51#include "graphwin.h"
[4307]52#include "polarplot.h"
[4577]53#include "availplot.h"
[4662]54#include "eleplot.h"
[4672]55#include "dopplot.h"
[6524]56#include "bncephuser.h"
[3899]57
58using namespace std;
59
60// Constructor
61////////////////////////////////////////////////////////////////////////////
62t_reqcAnalyze::t_reqcAnalyze(QObject* parent) : QThread(parent) {
63
64 bncSettings settings;
[4254]65
[4257]66 _logFileName = settings.value("reqcOutLogFile").toString(); expandEnvVar(_logFileName);
67 _logFile = 0;
68 _log = 0;
[6271]69 _currEpo = 0;
[4254]70 _obsFileNames = settings.value("reqcObsFile").toString().split(",", QString::SkipEmptyParts);
[4257]71 _navFileNames = settings.value("reqcNavFile").toString().split(",", QString::SkipEmptyParts);
[6275]72
[6322]73 connect(this, SIGNAL(dspSkyPlot(const QString&, const QString&, QVector<t_polarPoint*>*,
74 const QString&, QVector<t_polarPoint*>*,
[6275]75 const QByteArray&, double)),
[6322]76 this, SLOT(slotDspSkyPlot(const QString&, const QString&, QVector<t_polarPoint*>*,
77 const QString&, QVector<t_polarPoint*>*,
[6275]78 const QByteArray&, double)));
79
80 connect(this, SIGNAL(dspAvailPlot(const QString&, const QByteArray&)),
81 this, SLOT(slotDspAvailPlot(const QString&, const QByteArray&)));
[3899]82}
83
84// Destructor
85////////////////////////////////////////////////////////////////////////////
86t_reqcAnalyze::~t_reqcAnalyze() {
[4255]87 for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
88 delete _rnxObsFiles[ii];
89 }
90 for (int ii = 0; ii < _ephs.size(); ii++) {
91 delete _ephs[ii];
92 }
93 delete _log; _log = 0;
94 delete _logFile; _logFile = 0;
[5072]95 if (BNC_CORE->mode() != t_bncCore::interactive) {
[5066]96 qApp->exit(0);
[4452]97 }
[3899]98}
99
[6255]100//
[3899]101////////////////////////////////////////////////////////////////////////////
102void t_reqcAnalyze::run() {
103
[4255]104 // Open Log File
105 // -------------
106 _logFile = new QFile(_logFileName);
[4517]107 if (_logFile->open(QIODevice::WriteOnly | QIODevice::Text)) {
108 _log = new QTextStream();
109 _log->setDevice(_logFile);
110 }
[4255]111
[6523]112 // Check Ephemerides
113 // -----------------
114 checkEphemerides();
115
[4255]116 // Initialize RINEX Observation Files
117 // ----------------------------------
[4525]118 t_reqcEdit::initRnxObsFiles(_obsFileNames, _rnxObsFiles, _log);
[3899]119
[4257]120 // Read Ephemerides
121 // ----------------
122 t_reqcEdit::readEphemerides(_navFileNames, _ephs);
123
[6528]124 QString navFileName;
125 QStringListIterator namIt(_navFileNames);
126 bool firstName = true;
127 while (namIt.hasNext()) {
128 QFileInfo navFi(namIt.next());
129 if (firstName) {
130 firstName = false;
131 navFileName += navFi.fileName();
132 }
133 else {
134 navFileName += ", " + navFi.fileName();
135 }
136 }
137
138 static const double QC_FORMAT_VERSION = 1.0;
139
140 *_log << "QC Format Version : " << QString("%1").arg(QC_FORMAT_VERSION,3,'f',1) << endl << endl
141 << "Navigation File(s): " << navFileName << endl;
142
143 *_log << _ephMsg.c_str() << endl;
144
[4255]145 // Loop over all RINEX Files
146 // -------------------------
[4254]147 for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
148 analyzeFile(_rnxObsFiles[ii]);
149 }
150
[4255]151 // Exit
152 // ----
[4452]153 emit finished();
154 deleteLater();
[3899]155}
[4254]156
[6255]157//
[4254]158////////////////////////////////////////////////////////////////////////////
[4260]159void t_reqcAnalyze::analyzeFile(t_rnxObsFile* obsFile) {
[4259]160
[6271]161 _qcFile.clear();
[4343]162
[4342]163 // A priori Coordinates
164 // --------------------
[4679]165 ColumnVector xyzSta = obsFile->xyz();
[4342]166
[4262]167 // Loop over all Epochs
168 // --------------------
[4541]169 try {
[6296]170 QMap<QString, bncTime> lastObsTime;
[6271]171 bool firstEpo = true;
[4541]172 while ( (_currEpo = obsFile->nextEpoch()) != 0) {
[6271]173 if (firstEpo) {
174 firstEpo = false;
175 _qcFile._startTime = _currEpo->tt;
176 _qcFile._antennaName = obsFile->antennaName();
177 _qcFile._markerName = obsFile->markerName();
178 _qcFile._receiverType = obsFile->receiverType();
179 _qcFile._interval = obsFile->interval();
[4688]180 }
[6271]181 _qcFile._endTime = _currEpo->tt;
[6255]182
[6271]183 t_qcEpo qcEpo;
184 qcEpo._epoTime = _currEpo->tt;
185 qcEpo._PDOP = cmpDOP(xyzSta);
186
[4541]187 // Loop over all satellites
188 // ------------------------
189 for (unsigned iObs = 0; iObs < _currEpo->rnxSat.size(); iObs++) {
190 const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iObs];
[6271]191 t_satObs satObs;
192 t_rnxObsFile::setObsFromRnx(obsFile, _currEpo, rnxSat, satObs);
[6288]193 t_qcSat& qcSat = qcEpo._qcSat[satObs._prn];
[6296]194 setQcObs(qcEpo._epoTime, xyzSta, satObs, lastObsTime, qcSat);
[6288]195 updateQcSat(qcSat, _qcFile._qcSatSum[satObs._prn]);
[4262]196 }
[6271]197 _qcFile._qcEpo.push_back(qcEpo);
198 }
[6255]199
[6281]200 analyzeMultipath();
201
[6271]202 preparePlotData(obsFile);
[4678]203
[6284]204 printReport(obsFile);
[4541]205 }
206 catch (QString str) {
207 if (_log) {
208 *_log << "Exception " << str << endl;
[4262]209 }
[4541]210 else {
[6255]211 qDebug() << str;
[4541]212 }
213 }
[6271]214}
[4262]215
[6271]216// Compute Dilution of Precision
217////////////////////////////////////////////////////////////////////////////
218double t_reqcAnalyze::cmpDOP(const ColumnVector& xyzSta) const {
[4268]219
[6398]220 if ( xyzSta.size() != 3 || (xyzSta[0] == 0.0 && xyzSta[1] == 0.0 && xyzSta[2] == 0.0) ) {
[6271]221 return 0.0;
[4268]222 }
223
[6271]224 unsigned nSat = _currEpo->rnxSat.size();
[4706]225
[6271]226 if (nSat < 4) {
227 return 0.0;
[4718]228 }
[6271]229
230 Matrix AA(nSat, 4);
231
232 unsigned nSatUsed = 0;
233 for (unsigned iSat = 0; iSat < nSat; iSat++) {
234
235 const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iSat];
236 const t_prn& prn = rnxSat.prn;
237
238 t_eph* eph = 0;
239 for (int ie = 0; ie < _ephs.size(); ie++) {
240 if (_ephs[ie]->prn() == prn) {
241 eph = _ephs[ie];
242 break;
243 }
[4718]244 }
[6271]245 if (eph) {
246 ColumnVector xSat(4);
247 ColumnVector vv(3);
248 if (eph->getCrd(_currEpo->tt, xSat, vv, false) == success) {
249 ++nSatUsed;
250 ColumnVector dx = xSat.Rows(1,3) - xyzSta;
251 double rho = dx.norm_Frobenius();
252 AA(nSatUsed,1) = dx(1) / rho;
253 AA(nSatUsed,2) = dx(2) / rho;
254 AA(nSatUsed,3) = dx(3) / rho;
255 AA(nSatUsed,4) = 1.0;
256 }
[4718]257 }
258 }
[6271]259
260 if (nSatUsed < 4) {
261 return 0.0;
262 }
263
264 AA = AA.Rows(1, nSatUsed);
265
266 SymmetricMatrix QQ;
267 QQ << AA.t() * AA;
268 QQ = QQ.i();
269
270 return sqrt(QQ.trace());
[4254]271}
[4263]272
[6255]273//
[4263]274////////////////////////////////////////////////////////////////////////////
[6288]275void t_reqcAnalyze::updateQcSat(const t_qcSat& qcSat, t_qcSatSum& qcSatSum) {
[6285]276
[6288]277 for (int ii = 0; ii < qcSat._qcFrq.size(); ii++) {
278 const t_qcFrq& qcFrq = qcSat._qcFrq[ii];
[6285]279 t_qcFrqSum& qcFrqSum = qcSatSum._qcFrqSum[qcFrq._rnxType2ch];
280 qcFrqSum._numObs += 1;
281 if (qcFrq._slip) {
282 qcFrqSum._numSlipsFlagged += 1;
283 }
284 if (qcFrq._gap) {
285 qcFrqSum._numGaps += 1;
286 }
[6312]287 if (qcFrq._SNR > 0.0) {
288 qcFrqSum._numSNR += 1;
289 qcFrqSum._sumSNR += qcFrq._SNR;
290 }
[6271]291 }
292}
[4265]293
[6271]294//
295////////////////////////////////////////////////////////////////////////////
[6281]296void t_reqcAnalyze::setQcObs(const bncTime& epoTime, const ColumnVector& xyzSta,
[6296]297 const t_satObs& satObs, QMap<QString, bncTime>& lastObsTime,
298 t_qcSat& qcSat) {
[4338]299
[6281]300 t_eph* eph = 0;
301 for (int ie = 0; ie < _ephs.size(); ie++) {
302 if (_ephs[ie]->prn() == satObs._prn) {
303 eph = _ephs[ie];
304 break;
[6271]305 }
[6281]306 }
307 if (eph) {
308 ColumnVector xc(4);
309 ColumnVector vv(3);
[6398]310 if ( xyzSta.size() == 3 && (xyzSta[0] != 0.0 || xyzSta[1] != 0.0 || xyzSta[2] != 0.0) &&
311 eph->getCrd(epoTime, xc, vv, false) == success) {
[6281]312 double rho, eleSat, azSat;
313 topos(xyzSta(1), xyzSta(2), xyzSta(3), xc(1), xc(2), xc(3), rho, eleSat, azSat);
[6288]314 qcSat._eleSet = true;
315 qcSat._azDeg = azSat * 180.0/M_PI;
316 qcSat._eleDeg = eleSat * 180.0/M_PI;
[6281]317 }
318 if (satObs._prn.system() == 'R') {
[6288]319 qcSat._slotSet = true;
320 qcSat._slotNum = eph->slotNum();
[6271]321 }
322 }
323
[4608]324 // Availability and Slip Flags
325 // ---------------------------
[6285]326 for (unsigned ii = 0; ii < satObs._obs.size(); ii++) {
327 const t_frqObs* frqObs = satObs._obs[ii];
328
[6288]329 qcSat._qcFrq.push_back(t_qcFrq());
330 t_qcFrq& qcFrq = qcSat._qcFrq.back();
[6285]331
332 qcFrq._rnxType2ch = QString(frqObs->_rnxType2ch.c_str());
333 qcFrq._SNR = frqObs->_snr;
334 qcFrq._slip = frqObs->_slip;
[6293]335 qcFrq._phaseValid = frqObs->_phaseValid;
336 qcFrq._codeValid = frqObs->_codeValid;
[6285]337 // Check Gaps
338 // ----------
[6296]339 QString key = QString(satObs._prn.toString().c_str()) + qcFrq._rnxType2ch;
340 if (lastObsTime[key].valid()) {
341 double dt = epoTime - lastObsTime[key];
[6285]342 if (dt > 1.5 * _qcFile._interval) {
343 qcFrq._gap = true;
[6137]344 }
345 }
[6296]346 lastObsTime[key] = epoTime;
[6285]347
348 // Compute the Multipath Linear Combination
349 // ----------------------------------------
[6292]350 if (frqObs->_codeValid) {
[6285]351 t_frequency::type fA;
352 t_frequency::type fB;
353 if (satObs._prn.system() == 'G') {
354 if (frqObs->_rnxType2ch[0] == '1') {
355 fA = t_frequency::G1;
356 fB = t_frequency::G2;
357 }
358 else if (frqObs->_rnxType2ch[0] == '2') {
359 fA = t_frequency::G2;
360 fB = t_frequency::G1;
361 }
[6137]362 }
[6285]363 else if (satObs._prn.system() == 'R') {
364 if (frqObs->_rnxType2ch[0] == '1') {
365 fA = t_frequency::R1;
366 fB = t_frequency::R2;
367 }
368 else if (frqObs->_rnxType2ch[0] == '2') {
369 fA = t_frequency::R2;
370 fB = t_frequency::R1;
371 }
[6137]372 }
[6285]373 else if (satObs._prn.system() == 'E') {
374 if (frqObs->_rnxType2ch[0] == '1') {
375 fA = t_frequency::E1;
376 fB = t_frequency::E5;
377 }
378 else if (frqObs->_rnxType2ch[0] == '5') {
379 fA = t_frequency::E5;
380 fB = t_frequency::E1;
381 }
[6137]382 }
[6322]383 else if (satObs._prn.system() == 'J') {
384 if (frqObs->_rnxType2ch[0] == '1') {
385 fA = t_frequency::J1;
386 fB = t_frequency::J2;
387 }
388 else if (frqObs->_rnxType2ch[0] == '2') {
389 fA = t_frequency::J2;
390 fB = t_frequency::J1;
391 }
392 }
393 else if (satObs._prn.system() == 'S') {
394 if (frqObs->_rnxType2ch[0] == '1') {
395 fA = t_frequency::S1;
396 fB = t_frequency::S5;
397 }
398 else if (frqObs->_rnxType2ch[0] == '5') {
399 fA = t_frequency::S5;
400 fB = t_frequency::S1;
401 }
402 }
403 else if (satObs._prn.system() == 'C') {
404 if (frqObs->_rnxType2ch[0] == '1') {
405 fA = t_frequency::C1;
406 fB = t_frequency::C7;
407 }
408 else if (frqObs->_rnxType2ch[0] == '7') {
409 fA = t_frequency::C7;
410 fB = t_frequency::C1;
411 }
412 }
[6285]413 if (fA != t_frequency::dummy && fB != t_frequency::dummy) {
[6292]414 double f_a = t_CST::freq(fA, qcSat._slotNum);
415 double f_b = t_CST::freq(fB, qcSat._slotNum);
416 double C_a = frqObs->_code;
417
418 bool foundA = false;
419 double L_a = 0.0;
420 bool foundB = false;
421 double L_b = 0.0;
[6285]422 for (unsigned jj = 0; jj < satObs._obs.size(); jj++) {
[6292]423 const t_frqObs* frqObsHlp = satObs._obs[jj];
424 if (frqObsHlp->_rnxType2ch[0] == t_frequency::toString(fA)[1] &&
425 frqObsHlp->_phaseValid) {
426 foundA = true;
427 L_a = frqObsHlp->_phase * t_CST::c / f_a;
[6285]428 }
[6292]429 else if (frqObsHlp->_rnxType2ch[0] == t_frequency::toString(fB)[1] &&
430 frqObsHlp->_phaseValid) {
431 foundB = true;
432 L_b = frqObsHlp->_phase * t_CST::c / f_b;
433 }
[6285]434 }
[6292]435 if (foundA && foundB) {
436 qcFrq._setMP = true;
437 qcFrq._rawMP = C_a - L_a - 2.0*f_b*f_b/(f_a*f_a-f_b*f_b) * (L_a - L_b);
438 }
[6285]439 }
440 }
[6291]441 } // satObs loop
[4263]442}
[4350]443
[6255]444//
[4350]445////////////////////////////////////////////////////////////////////////////
[6281]446void t_reqcAnalyze::analyzeMultipath() {
[4675]447
[6271]448 const double SLIPTRESH = 10.0; // cycle-slip threshold (meters)
449 const double chunkStep = 600.0; // 10 minutes
[4584]450
[6271]451 // Loop over all satellites available
452 // ----------------------------------
[6285]453 QMutableMapIterator<t_prn, t_qcSatSum> itSat(_qcFile._qcSatSum);
454 while (itSat.hasNext()) {
455 itSat.next();
456 const t_prn& prn = itSat.key();
457 t_qcSatSum& qcSatSum = itSat.value();
[4351]458
[6285]459 // Loop over all frequencies available
460 // -----------------------------------
461 QMutableMapIterator<QString, t_qcFrqSum> itFrq(qcSatSum._qcFrqSum);
462 while (itFrq.hasNext()) {
463 itFrq.next();
464 const QString& frqType = itFrq.key();
465 t_qcFrqSum& qcFrqSum = itFrq.value();
[4702]466
[6285]467 // Loop over all Chunks of Data
468 // ----------------------------
469 for (bncTime chunkStart = _qcFile._startTime;
470 chunkStart < _qcFile._endTime; chunkStart += chunkStep) {
471
472 bncTime chunkEnd = chunkStart + chunkStep;
473
474 QVector<t_qcFrq*> frqVec;
475 QVector<double> MP;
[6271]476
[6285]477 // Loop over all Epochs within one Chunk of Data
478 // ---------------------------------------------
479 for (int iEpo = 0; iEpo < _qcFile._qcEpo.size(); iEpo++) {
480 t_qcEpo& qcEpo = _qcFile._qcEpo[iEpo];
481 if (chunkStart <= qcEpo._epoTime && qcEpo._epoTime < chunkEnd) {
[6288]482 if (qcEpo._qcSat.contains(prn)) {
483 t_qcSat& qcSat = qcEpo._qcSat[prn];
484 for (int iFrq = 0; iFrq < qcSat._qcFrq.size(); iFrq++) {
485 t_qcFrq& qcFrq = qcSat._qcFrq[iFrq];
[6285]486 if (qcFrq._rnxType2ch == frqType) {
487 frqVec << &qcFrq;
488 if (qcFrq._setMP) {
489 MP << qcFrq._rawMP;
490 }
491 }
492 }
[6213]493 }
[4590]494 }
495 }
[4563]496
[6285]497 // Compute the multipath mean and standard deviation
498 // -------------------------------------------------
499 if (MP.size() > 1) {
500 double meanMP = 0.0;
501 for (int ii = 0; ii < MP.size(); ii++) {
502 meanMP += MP[ii];
[6271]503 }
[6285]504 meanMP /= MP.size();
505
506 bool slipMP = false;
507
508 double stdMP = 0.0;
509 for (int ii = 0; ii < MP.size(); ii++) {
510 double diff = MP[ii] - meanMP;
511 if (fabs(diff) > SLIPTRESH) {
512 slipMP = true;
513 break;
514 }
515 stdMP += diff * diff;
516 }
517
[6281]518 if (slipMP) {
[6285]519 stdMP = 0.0;
520 stdMP = 0.0;
521 qcFrqSum._numSlipsFound += 1;
[6281]522 }
523 else {
[6285]524 stdMP = sqrt(stdMP / (MP.size()-1));
[6312]525 qcFrqSum._numMP += 1;
526 qcFrqSum._sumMP += stdMP;
[6281]527 }
[6285]528
529 for (int ii = 0; ii < frqVec.size(); ii++) {
530 t_qcFrq* qcFrq = frqVec[ii];
531 if (slipMP) {
532 qcFrq->_slip = true;
533 }
534 else {
535 qcFrq->_stdMP = stdMP;
536 }
537 }
[6281]538 }
[6285]539 } // chunk loop
540 } // frq loop
541 } // sat loop
[6281]542}
543
544//
545////////////////////////////////////////////////////////////////////////////
546void t_reqcAnalyze::preparePlotData(const t_rnxObsFile* obsFile) {
547
[6424]548 QString mp1Title = "Multipath\n";
549 QString mp2Title = "Multipath\n";
550 QString sn1Title = "Signal-to-Noise Ratio\n";
551 QString sn2Title = "Signal-to-Noise Ratio\n";
[6422]552
[6281]553 bncSettings settings;
[6436]554
555 QString reqcSkyPlotSignals = settings.value("reqcSkyPlotSignals").toString();
556 if (reqcSkyPlotSignals.isEmpty()) {
557 reqcSkyPlotSignals = "G:1&2 R:1&2 J:1&2 E:1&7 C:1&6";
558 }
559
560 QStringList signalsOpt = reqcSkyPlotSignals.split(" ", QString::SkipEmptyParts);
[6424]561 QMap<char, QString> signalTypes1;
562 QMap<char, QString> signalTypes2;
[6413]563 for (int ii = 0; ii < signalsOpt.size(); ii++) {
564 QStringList hlp = signalsOpt.at(ii).split(QRegExp("[:&]"), QString::SkipEmptyParts);
[6415]565 if (hlp.size() > 1 && hlp[0].length() == 1) {
[6424]566 char system = hlp[0].toAscii().constData()[0];
567 signalTypes1[system] = hlp[1];
568 mp1Title += hlp[0] + ":" + hlp[1] + " ";
569 sn1Title += hlp[0] + ":" + hlp[1] + " ";
570 if (hlp.size() > 2) {
571 signalTypes2[system] = hlp[2];
572 mp2Title += hlp[0] + ":" + hlp[2] + " ";
573 sn2Title += hlp[0] + ":" + hlp[2] + " ";
[6415]574 }
575 }
[6413]576 }
577
[6318]578 QVector<t_polarPoint*>* dataMP1 = new QVector<t_polarPoint*>;
579 QVector<t_polarPoint*>* dataMP2 = new QVector<t_polarPoint*>;
580 QVector<t_polarPoint*>* dataSNR1 = new QVector<t_polarPoint*>;
581 QVector<t_polarPoint*>* dataSNR2 = new QVector<t_polarPoint*>;
582
[6281]583 // Loop over all observations
584 // --------------------------
585 for (int iEpo = 0; iEpo < _qcFile._qcEpo.size(); iEpo++) {
586 t_qcEpo& qcEpo = _qcFile._qcEpo[iEpo];
[6288]587 QMapIterator<t_prn, t_qcSat> it(qcEpo._qcSat);
[6281]588 while (it.hasNext()) {
589 it.next();
590 const t_prn& prn = it.key();
[6288]591 const t_qcSat& qcSat = it.value();
[6424]592 if (qcSat._eleSet) {
[6281]593
[6424]594 QString frqType[2];
595
596 for (int iFrq = 0; iFrq < qcSat._qcFrq.size(); iFrq++) {
597 const t_qcFrq& qcFrq = qcSat._qcFrq[iFrq];
598
599 for (int ii = 0; ii < 2; ii++) {
600 const QMap<char, QString>& signalTypes = (ii == 0 ? signalTypes1 : signalTypes2);
601 if (frqType[ii].isEmpty()) {
602 QMapIterator<char, QString> it(signalTypes);
603 while (it.hasNext()) {
604 it.next();
605 if (it.key() == prn.system()) {
606 if (it.value() == qcFrq._rnxType2ch || it.value() == qcFrq._rnxType2ch.left(1)) {
607 frqType[ii] = qcFrq._rnxType2ch;
608 break;
609 }
610 }
611 }
[6286]612 }
613 }
[6424]614 if (qcFrq._rnxType2ch == frqType[0]) {
615 (*dataSNR1) << (new t_polarPoint(qcSat._azDeg, 90.0 - qcSat._eleDeg, qcFrq._SNR));
616 (*dataMP1) << (new t_polarPoint(qcSat._azDeg, 90.0 - qcSat._eleDeg, qcFrq._stdMP));
617 }
618 else if (qcFrq._rnxType2ch == frqType[1]) {
619 (*dataSNR2) << (new t_polarPoint(qcSat._azDeg, 90.0 - qcSat._eleDeg, qcFrq._SNR));
620 (*dataMP2) << (new t_polarPoint(qcSat._azDeg, 90.0 - qcSat._eleDeg, qcFrq._stdMP));
621 }
[6284]622 }
[4700]623 }
[4353]624 }
[6271]625 }
[4353]626
[6271]627 // Show the plots
628 // --------------
629 if (BNC_CORE->GUIenabled()) {
630 QFileInfo fileInfo(obsFile->fileName());
631 QByteArray title = fileInfo.fileName().toAscii();
[6322]632 emit dspSkyPlot(obsFile->fileName(), mp1Title, dataMP1, mp2Title, dataMP2, "Meters", 2.0);
[6424]633 emit dspSkyPlot(obsFile->fileName(), sn1Title, dataSNR1, sn2Title, dataSNR2, "dbHz", 54.0);
[6275]634 emit dspAvailPlot(obsFile->fileName(), title);
[6271]635 }
636 else {
637 for (int ii = 0; ii < dataMP1->size(); ii++) {
638 delete dataMP1->at(ii);
[4351]639 }
[6271]640 delete dataMP1;
641 for (int ii = 0; ii < dataMP2->size(); ii++) {
642 delete dataMP2->at(ii);
[4591]643 }
[6271]644 delete dataMP2;
645 for (int ii = 0; ii < dataSNR1->size(); ii++) {
646 delete dataSNR1->at(ii);
[4659]647 }
[6271]648 delete dataSNR1;
649 for (int ii = 0; ii < dataSNR2->size(); ii++) {
650 delete dataSNR2->at(ii);
[5141]651 }
[6271]652 delete dataSNR2;
[4350]653 }
654}
[4572]655
[6255]656//
[4572]657////////////////////////////////////////////////////////////////////////////
[6322]658void t_reqcAnalyze::slotDspSkyPlot(const QString& fileName, const QString& title1,
659 QVector<t_polarPoint*>* data1, const QString& title2,
[6275]660 QVector<t_polarPoint*>* data2, const QByteArray& scaleTitle,
661 double maxValue) {
[4572]662
[5068]663 if (BNC_CORE->GUIenabled()) {
[4573]664
[6271]665 if (maxValue == 0.0) {
666 if (data1) {
667 for (int ii = 0; ii < data1->size(); ii++) {
668 double val = data1->at(ii)->_value;
669 if (maxValue < val) {
670 maxValue = val;
671 }
672 }
673 }
674 if (data2) {
675 for (int ii = 0; ii < data2->size(); ii++) {
676 double val = data2->at(ii)->_value;
677 if (maxValue < val) {
678 maxValue = val;
679 }
680 }
681 }
682 }
[4659]683
[6271]684 QwtInterval scaleInterval(0.0, maxValue);
[4671]685
[4573]686 QVector<QWidget*> plots;
[6271]687 if (data1) {
[6422]688 QwtText title(title1);
[6423]689 QFont font = title.font(); font.setPointSize(font.pointSize()-1); title.setFont(font);
[6422]690 t_polarPlot* plot1 = new t_polarPlot(title, scaleInterval, BNC_CORE->mainWindow());
[6271]691 plot1->addCurve(data1);
692 plots << plot1;
693 }
694 if (data2) {
[6422]695 QwtText title(title2);
[6423]696 QFont font = title.font(); font.setPointSize(font.pointSize()-1); title.setFont(font);
[6422]697 t_polarPlot* plot2 = new t_polarPlot(title, scaleInterval, BNC_CORE->mainWindow());
[6271]698 plot2->addCurve(data2);
699 plots << plot2;
700 }
[4666]701
[6271]702 t_graphWin* graphWin = new t_graphWin(0, fileName, plots,
703 &scaleTitle, &scaleInterval);
[4666]704
[4573]705 graphWin->show();
706
707 bncSettings settings;
708 QString dirName = settings.value("reqcPlotDir").toString();
709 if (!dirName.isEmpty()) {
[6271]710 QByteArray ext = (scaleTitle == "Meters") ? "_M.png" : "_S.png";
[4579]711 graphWin->savePNG(dirName, ext);
[4573]712 }
713 }
[4572]714}
[4679]715
[6271]716//
[4679]717////////////////////////////////////////////////////////////////////////////
[6275]718void t_reqcAnalyze::slotDspAvailPlot(const QString& fileName, const QByteArray& title) {
[4679]719
[6280]720 t_plotData plotData;
[6278]721 QMap<t_prn, t_plotData> plotDataMap;
[6272]722
[6278]723 for (int ii = 0; ii < _qcFile._qcEpo.size(); ii++) {
724 const t_qcEpo& qcEpo = _qcFile._qcEpo[ii];
[6280]725 double mjdX24 = qcEpo._epoTime.mjddec() * 24.0;
726
727 plotData._mjdX24 << mjdX24;
728 plotData._PDOP << qcEpo._PDOP;
[6288]729 plotData._numSat << qcEpo._qcSat.size();
[6280]730
[6288]731 QMapIterator<t_prn, t_qcSat> it(qcEpo._qcSat);
[6278]732 while (it.hasNext()) {
733 it.next();
734 const t_prn& prn = it.key();
[6288]735 const t_qcSat& qcSat = it.value();
[6280]736 t_plotData& data = plotDataMap[prn];
[6286]737
[6297]738 if (qcSat._eleSet) {
739 data._mjdX24 << mjdX24;
740 data._eleDeg << qcSat._eleDeg;
741 }
[6286]742
[6404]743 char frqChar1 = '1';
744 char frqChar2 = '2';
745 if (prn.system() == 'E' || prn.system() == 'S') {
746 frqChar2 = '5';
747 }
748 else if (prn.system() == 'C') {
749 frqChar2 = '7';
750 }
[6286]751 QString frqType1;
752 QString frqType2;
[6288]753 for (int iFrq = 0; iFrq < qcSat._qcFrq.size(); iFrq++) {
754 const t_qcFrq& qcFrq = qcSat._qcFrq[iFrq];
[6404]755 if (qcFrq._rnxType2ch[0] == frqChar1 && frqType1.isEmpty()) {
[6286]756 frqType1 = qcFrq._rnxType2ch;
[6284]757 }
[6404]758 if (qcFrq._rnxType2ch[0] == frqChar2 && frqType2.isEmpty()) {
[6286]759 frqType2 = qcFrq._rnxType2ch;
[6284]760 }
[6286]761 if (qcFrq._rnxType2ch == frqType1) {
762 if (qcFrq._slip) {
763 data._L1slip << mjdX24;
764 }
765 else if (qcFrq._gap) {
766 data._L1gap << mjdX24;
767 }
768 else {
769 data._L1ok << mjdX24;
770 }
[6284]771 }
[6286]772 else if (qcFrq._rnxType2ch == frqType2) {
773 if (qcFrq._slip) {
774 data._L2slip << mjdX24;
775 }
776 else if (qcFrq._gap) {
777 data._L2gap << mjdX24;
778 }
779 else {
780 data._L2ok << mjdX24;
781 }
[6284]782 }
783 }
[6278]784 }
785 }
786
[6271]787 if (BNC_CORE->GUIenabled()) {
[6278]788 t_availPlot* plotA = new t_availPlot(0, plotDataMap);
[6271]789 plotA->setTitle(title);
[4679]790
[6278]791 t_elePlot* plotZ = new t_elePlot(0, plotDataMap);
[4679]792
[6279]793 t_dopPlot* plotD = new t_dopPlot(0, plotData);
[4679]794
[6271]795 QVector<QWidget*> plots;
796 plots << plotA << plotZ << plotD;
797 t_graphWin* graphWin = new t_graphWin(0, fileName, plots, 0, 0);
[4679]798
[6271]799 int ww = QFontMetrics(graphWin->font()).width('w');
800 graphWin->setMinimumSize(120*ww, 40*ww);
[4679]801
[6271]802 graphWin->show();
[4679]803
[6271]804 bncSettings settings;
805 QString dirName = settings.value("reqcPlotDir").toString();
806 if (!dirName.isEmpty()) {
807 QByteArray ext = "_A.png";
808 graphWin->savePNG(dirName, ext);
[4679]809 }
[4681]810 }
[4679]811}
[4689]812
813// Finish the report
814////////////////////////////////////////////////////////////////////////////
[6284]815void t_reqcAnalyze::printReport(const t_rnxObsFile* obsFile) {
[5368]816
[4689]817 if (!_log) {
818 return;
819 }
820
[6317]821 QFileInfo obsFi(obsFile->fileName());
822 QString obsFileName = obsFi.fileName();
823
[6300]824 // Summary
825 // -------
[6527]826 *_log << "Observation File : " << obsFileName << endl
[6301]827 << "RINEX Version : " << QString("%1").arg(obsFile->version(),4,'f',2) << endl
[6317]828 << "Marker Name : " << _qcFile._markerName << endl
829 << "Marker Number : " << obsFile->markerNumber() << endl
830 << "Receiver : " << _qcFile._receiverType << endl
831 << "Antenna : " << _qcFile._antennaName << endl
[6316]832 << "Position XYZ : " << QString("%1 %2 %3").arg(obsFile->xyz()(1), 14, 'f', 4)
[6303]833 .arg(obsFile->xyz()(2), 14, 'f', 4)
834 .arg(obsFile->xyz()(3), 14, 'f', 4) << endl
835 << "Antenna dH/dE/dN : " << QString("%1 %2 %3").arg(obsFile->antNEU()(3), 8, 'f', 4)
836 .arg(obsFile->antNEU()(2), 8, 'f', 4)
837 .arg(obsFile->antNEU()(1), 8, 'f', 4) << endl
[6317]838 << "Start Time : " << _qcFile._startTime.datestr().c_str() << ' '
839 << _qcFile._startTime.timestr(1,'.').c_str() << endl
840 << "End Time : " << _qcFile._endTime.datestr().c_str() << ' '
841 << _qcFile._endTime.timestr(1,'.').c_str() << endl
842 << "Interval : " << _qcFile._interval << endl;
[4689]843
[6303]844 // Number of systems
845 // -----------------
846 QMap<QChar, QVector<const t_qcSatSum*> > systemMap;
[6286]847 QMapIterator<t_prn, t_qcSatSum> itSat(_qcFile._qcSatSum);
848 while (itSat.hasNext()) {
849 itSat.next();
[6303]850 const t_prn& prn = itSat.key();
[6286]851 const t_qcSatSum& qcSatSum = itSat.value();
[6303]852 systemMap[prn.system()].push_back(&qcSatSum);
853 }
[6286]854
[6309]855 *_log << "Navigation Systems: " << systemMap.size() << " ";
[6303]856 QMapIterator<QChar, QVector<const t_qcSatSum*> > itSys(systemMap);
857 while (itSys.hasNext()) {
858 itSys.next();
859 *_log << ' ' << itSys.key();
[4693]860 }
[6303]861 *_log << endl;
[4693]862
[6304]863 itSys.toFront();
864 while (itSys.hasNext()) {
865 itSys.next();
866 const QChar& sys = itSys.key();
867 const QVector<const t_qcSatSum*>& qcSatVec = itSys.value();
868 QString prefixSys = QString(" ") + sys + QString(": ");
[6306]869 QMap<QString, QVector<const t_qcFrqSum*> > frqMap;
[6305]870 for (int ii = 0; ii < qcSatVec.size(); ii++) {
871 const t_qcSatSum* qcSatSum = qcSatVec[ii];
872 QMapIterator<QString, t_qcFrqSum> itFrq(qcSatSum->_qcFrqSum);
873 while (itFrq.hasNext()) {
874 itFrq.next();
[6315]875 QString frqType = itFrq.key(); if (frqType.length() < 2) frqType += '?';
[6305]876 const t_qcFrqSum& qcFrqSum = itFrq.value();
[6306]877 frqMap[frqType].push_back(&qcFrqSum);
[6305]878 }
879 }
[6309]880 *_log << endl
[6310]881 << prefixSys << "Satellites: " << qcSatVec.size() << endl
882 << prefixSys << "Signals : " << frqMap.size() << " ";
[6307]883 QMapIterator<QString, QVector<const t_qcFrqSum*> > itFrq(frqMap);
884 while (itFrq.hasNext()) {
885 itFrq.next();
[6315]886 QString frqType = itFrq.key(); if (frqType.length() < 2) frqType += '?';
[6308]887 *_log << ' ' << frqType;
888 }
889 *_log << endl;
[6316]890 QString prefixSys2 = " " + prefixSys;
[6308]891 itFrq.toFront();
892 while (itFrq.hasNext()) {
893 itFrq.next();
[6315]894 QString frqType = itFrq.key(); if (frqType.length() < 2) frqType += '?';
[6307]895 const QVector<const t_qcFrqSum*> qcFrqVec = itFrq.value();
896 QString prefixFrq = QString(" ") + frqType + QString(": ");
[6308]897
[6313]898 int numObs = 0;
899 int numSlipsFlagged = 0;
900 int numSlipsFound = 0;
901 int numGaps = 0;
902 int numSNR = 0;
903 int numMP = 0;
904 double sumSNR = 0.0;
905 double sumMP = 0.0;
[6308]906 for (int ii = 0; ii < qcFrqVec.size(); ii++) {
907 const t_qcFrqSum* qcFrqSum = qcFrqVec[ii];
908 numObs += qcFrqSum->_numObs ;
909 numSlipsFlagged += qcFrqSum->_numSlipsFlagged;
910 numSlipsFound += qcFrqSum->_numSlipsFound ;
911 numGaps += qcFrqSum->_numGaps ;
[6313]912 numSNR += qcFrqSum->_numSNR;
913 numMP += qcFrqSum->_numMP;
[6314]914 sumSNR += qcFrqSum->_sumSNR;
915 sumMP += qcFrqSum->_sumMP;
[6308]916 }
[6313]917 if (numSNR > 0) {
918 sumSNR /= numSNR;
919 }
920 if (numMP > 0) {
921 sumMP /= numMP;
922 }
[6309]923 *_log << endl
[6316]924 << prefixSys2 << prefixFrq << "Observations : " << QString("%1\n").arg(numObs, 6)
925 << prefixSys2 << prefixFrq << "Slips (file+found): " << QString("%1 +").arg(numSlipsFlagged, 6)
926 << QString("%1\n").arg(numSlipsFound, 6)
927 << prefixSys2 << prefixFrq << "Gaps : " << QString("%1\n").arg(numGaps, 6)
928 << prefixSys2 << prefixFrq << "Mean SNR : " << QString("%1\n").arg(sumSNR, 6, 'f', 1)
929 << prefixSys2 << prefixFrq << "Mean Multipath : " << QString("%1\n").arg(sumMP, 6, 'f', 2);
[6307]930 }
[6304]931 }
932
[6300]933 // Epoch-Specific Output
934 // ---------------------
935 bncSettings settings;
936 if (Qt::CheckState(settings.value("reqcLogSummaryOnly").toInt()) == Qt::Checked) {
937 return;
938 }
[6309]939 *_log << endl;
[6289]940 for (int iEpo = 0; iEpo < _qcFile._qcEpo.size(); iEpo++) {
941 const t_qcEpo& qcEpo = _qcFile._qcEpo[iEpo];
942
943 unsigned year, month, day, hour, min;
944 double sec;
945 qcEpo._epoTime.civil_date(year, month, day);
946 qcEpo._epoTime.civil_time(hour, min, sec);
947
948 QString dateStr;
949 QTextStream(&dateStr) << QString("> %1 %2 %3 %4 %5%6")
950 .arg(year, 4)
951 .arg(month, 2, 10, QChar('0'))
952 .arg(day, 2, 10, QChar('0'))
953 .arg(hour, 2, 10, QChar('0'))
954 .arg(min, 2, 10, QChar('0'))
955 .arg(sec, 11, 'f', 7);
956
[6290]957 *_log << dateStr << QString(" %1").arg(qcEpo._qcSat.size(), 2)
958 << QString(" %1").arg(qcEpo._PDOP, 4, 'f', 1)
959 << endl;
[6289]960
961 QMapIterator<t_prn, t_qcSat> itSat(qcEpo._qcSat);
962 while (itSat.hasNext()) {
963 itSat.next();
964 const t_prn& prn = itSat.key();
965 const t_qcSat& qcSat = itSat.value();
966
[6290]967 *_log << prn.toString().c_str()
[6295]968 << QString(" %1 %2").arg(qcSat._eleDeg, 6, 'f', 2).arg(qcSat._azDeg, 7, 'f', 2);
969
970 int numObsTypes = 0;
[6290]971 for (int iFrq = 0; iFrq < qcSat._qcFrq.size(); iFrq++) {
972 const t_qcFrq& qcFrq = qcSat._qcFrq[iFrq];
[6294]973 if (qcFrq._phaseValid) {
[6295]974 numObsTypes += 1;
[6294]975 }
976 if (qcFrq._codeValid) {
[6295]977 numObsTypes += 1;
[6294]978 }
[6295]979 }
[6298]980 *_log << QString(" %1").arg(numObsTypes, 2);
[6295]981
982 for (int iFrq = 0; iFrq < qcSat._qcFrq.size(); iFrq++) {
983 const t_qcFrq& qcFrq = qcSat._qcFrq[iFrq];
984 if (qcFrq._phaseValid) {
985 *_log << " L" << qcFrq._rnxType2ch << ' ';
986 if (qcFrq._slip) {
987 *_log << 's';
988 }
989 else {
990 *_log << '.';
991 }
992 if (qcFrq._gap) {
993 *_log << 'g';
994 }
995 else {
996 *_log << '.';
997 }
998 *_log << QString(" %1").arg(qcFrq._SNR, 4, 'f', 1);
[6294]999 }
[6295]1000 if (qcFrq._codeValid) {
1001 *_log << " C" << qcFrq._rnxType2ch << ' ';
1002 if (qcFrq._gap) {
[6298]1003 *_log << " g";
[6295]1004 }
1005 else {
[6298]1006 *_log << " .";
[6295]1007 }
1008 *_log << QString(" %1").arg(qcFrq._stdMP, 3, 'f', 2);
[6290]1009 }
1010 }
1011 *_log << endl;
[6289]1012 }
1013 }
[4689]1014 _log->flush();
1015}
[6523]1016
1017//
1018////////////////////////////////////////////////////////////////////////////
1019void t_reqcAnalyze::checkEphemerides() {
[6527]1020
1021 ostringstream out;
1022
[6523]1023 QStringListIterator it(_navFileNames);
1024 while (it.hasNext()) {
[6524]1025 const QString& fileName = it.next();
1026 unsigned numOK = 0;
1027 unsigned numBad = 0;
1028 bncEphUser ephUser(false);
1029 t_rnxNavFile rnxNavFile(fileName, t_rnxNavFile::input);
1030 for (unsigned ii = 0; ii < rnxNavFile.ephs().size(); ii++) {
1031 t_eph* eph = rnxNavFile.ephs()[ii];
1032 ephUser.putNewEph(eph, true);
1033 if (eph->checkState() == t_eph::bad) {
1034 ++numBad;
1035 }
1036 else {
1037 ++numOK;
1038 }
1039 }
[6528]1040 out << "Ephemeris : " << numOK << " OK " << numBad << " BAD" << endl;
[6524]1041 if (numBad > 0) {
1042 for (unsigned ii = 0; ii < rnxNavFile.ephs().size(); ii++) {
1043 t_eph* eph = rnxNavFile.ephs()[ii];
1044 if (eph->checkState() == t_eph::bad) {
[6528]1045 out << " Bad Ephemeris : " << fileName.toAscii().data() << ' '
[6527]1046 << eph->prn().toString() << ' '
1047 << eph->TOC().datestr(' ') << ' '
1048 << eph->TOC().timestr(1, ' ') << endl;
[6524]1049 }
1050 }
1051 }
[6523]1052 }
[6527]1053
1054 _ephMsg = out.str();
[6523]1055}
Note: See TracBrowser for help on using the repository browser.