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

Last change on this file since 10617 was 10614, checked in by stuerze, 10 days ago

bug fixes egarding RINEX Editing and QC

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