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

Last change on this file since 10945 was 10945, checked in by stuerze, 2 months ago

Added a Minimum Elevation parameter to BNC's RINEX Editing & QC feature

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