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

Last change on this file since 6812 was 6563, checked in by stuerze, 10 years ago

try to catch incorrect user input

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