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

Last change on this file since 7917 was 7917, checked in by stuerze, 8 years ago

rinex qc: satellite visibility is considered now if expected obs is computed

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