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

Last change on this file since 10971 was 10966, checked in by stuerze, 5 weeks ago

minor changes

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