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

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

small changes to allow to disable the QC plot generation on request

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