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

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