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

Last change on this file since 10127 was 10073, checked in by stuerze, 18 months ago

minor changes

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