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

Last change on this file since 6560 was 6560, checked in by stuerze, 9 years ago

minor changes regarding qc

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