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

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

minor changes to get more realistic results for gap investigation

File size: 24.2 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
58const double SLIPTRESH = 10.0; // cycle-slip threshold (meters)
59
60// Constructor
61////////////////////////////////////////////////////////////////////////////
62t_reqcAnalyze::t_reqcAnalyze(QObject* parent) : QThread(parent) {
63
64 bncSettings settings;
65
66 _logFileName = settings.value("reqcOutLogFile").toString(); expandEnvVar(_logFileName);
67 _logFile = 0;
68 _log = 0;
69 _obsFileNames = settings.value("reqcObsFile").toString().split(",", QString::SkipEmptyParts);
70 _navFileNames = settings.value("reqcNavFile").toString().split(",", QString::SkipEmptyParts);
71
72 _currEpo = 0;
73
74 connect(this, SIGNAL(dspSkyPlot(const QString&,
75 const QByteArray&,
76 QVector<t_polarPoint*>*,
77 const QByteArray&,
78 QVector<t_polarPoint*>*,
79 const QByteArray&, double)),
80 this, SLOT(slotDspSkyPlot(const QString&,
81 const QByteArray&,
82 QVector<t_polarPoint*>*,
83 const QByteArray&,
84 QVector<t_polarPoint*>*,
85 const QByteArray&, double)));
86
87 connect(this, SIGNAL(dspAvailPlot(const QString&, const QByteArray&)),
88 this, SLOT(slotDspAvailPlot(const QString&, const QByteArray&)));
89}
90
91// Destructor
92////////////////////////////////////////////////////////////////////////////
93t_reqcAnalyze::~t_reqcAnalyze() {
94 for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
95 delete _rnxObsFiles[ii];
96 }
97 for (int ii = 0; ii < _ephs.size(); ii++) {
98 delete _ephs[ii];
99 }
100 delete _log; _log = 0;
101 delete _logFile; _logFile = 0;
102 if (BNC_CORE->mode() != t_bncCore::interactive) {
103 qApp->exit(0);
104 }
105}
106
107//
108////////////////////////////////////////////////////////////////////////////
109void t_reqcAnalyze::slotDspSkyPlot(const QString& fileName,
110 const QByteArray& title1,
111 QVector<t_polarPoint*>* data1,
112 const QByteArray& title2,
113 QVector<t_polarPoint*>* data2,
114 const QByteArray& scaleTitle,
115 double maxValue) {
116
117 if (BNC_CORE->GUIenabled()) {
118
119 if (maxValue == 0.0) {
120 if (data1) {
121 for (int ii = 0; ii < data1->size(); ii++) {
122 double val = data1->at(ii)->_value;
123 if (maxValue < val) {
124 maxValue = val;
125 }
126 }
127 }
128 if (data2) {
129 for (int ii = 0; ii < data2->size(); ii++) {
130 double val = data2->at(ii)->_value;
131 if (maxValue < val) {
132 maxValue = val;
133 }
134 }
135 }
136 }
137
138 QwtInterval scaleInterval(0.0, maxValue);
139
140 QVector<QWidget*> plots;
141 if (data1) {
142 t_polarPlot* plot1 = new t_polarPlot(QwtText(title1), scaleInterval,
143 BNC_CORE->mainWindow());
144 plot1->addCurve(data1);
145 plots << plot1;
146 }
147 if (data2) {
148 t_polarPlot* plot2 = new t_polarPlot(QwtText(title2), scaleInterval,
149 BNC_CORE->mainWindow());
150 plot2->addCurve(data2);
151 plots << plot2;
152 }
153
154 t_graphWin* graphWin = new t_graphWin(0, fileName, plots,
155 &scaleTitle, &scaleInterval);
156
157 graphWin->show();
158
159 bncSettings settings;
160 QString dirName = settings.value("reqcPlotDir").toString();
161 if (!dirName.isEmpty()) {
162 QByteArray ext = (scaleTitle == "Meters") ? "_M.png" : "_S.png";
163 graphWin->savePNG(dirName, ext);
164 }
165 }
166}
167
168//
169////////////////////////////////////////////////////////////////////////////
170void t_reqcAnalyze::run() {
171
172 // Open Log File
173 // -------------
174 _logFile = new QFile(_logFileName);
175 if (_logFile->open(QIODevice::WriteOnly | QIODevice::Text)) {
176 _log = new QTextStream();
177 _log->setDevice(_logFile);
178 }
179
180 // Initialize RINEX Observation Files
181 // ----------------------------------
182 t_reqcEdit::initRnxObsFiles(_obsFileNames, _rnxObsFiles, _log);
183
184 // Read Ephemerides
185 // ----------------
186 t_reqcEdit::readEphemerides(_navFileNames, _ephs);
187
188 // Loop over all RINEX Files
189 // -------------------------
190 for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
191 analyzeFile(_rnxObsFiles[ii]);
192 }
193
194 // Exit
195 // ----
196 emit finished();
197 deleteLater();
198}
199
200//
201////////////////////////////////////////////////////////////////////////////
202void t_reqcAnalyze::analyzeFile(t_rnxObsFile* obsFile) {
203
204 _mutex.lock();
205
206 if (_log) {
207 *_log << "\nAnalyze File\n"
208 << "------------\n"
209 << "File: " << obsFile->fileName().toAscii().data() << endl;
210 }
211
212 _allObsMap.clear();
213 _availDataMap.clear();
214 _obsStat.reset();
215
216 // A priori Coordinates
217 // --------------------
218 ColumnVector xyzSta = obsFile->xyz();
219
220 // Loop over all Epochs
221 // --------------------
222 try {
223 unsigned iEpo = 0;
224 while ( (_currEpo = obsFile->nextEpoch()) != 0) {
225
226 if (iEpo == 0) {
227 _obsStat._startTime = _currEpo->tt;
228 _obsStat._antennaName = obsFile->antennaName();
229 _obsStat._markerName = obsFile->markerName();
230 _obsStat._receiverType = obsFile->receiverType();
231 _obsStat._interval = obsFile->interval();
232 }
233 _obsStat._endTime = _currEpo->tt;
234
235 // Loop over all satellites
236 // ------------------------
237 for (unsigned iObs = 0; iObs < _currEpo->rnxSat.size(); iObs++) {
238 const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iObs];
239 t_satObs obs;
240 t_rnxObsFile::setObsFromRnx(obsFile, _currEpo, rnxSat, obs);
241
242 QString prn(obs._prn.toString().c_str());
243
244 t_ephGlo* ephGlo = 0;
245 int slotNum = 0;
246 if (obs._prn.system() == 'R') {
247 for (int ie = 0; ie < _ephs.size(); ie++) {
248 if (QString(_ephs[ie]->prn().toString().c_str()) == prn) {
249 ephGlo = dynamic_cast<t_ephGlo*>(_ephs[ie]);
250 break;
251 }
252 }
253 if (ephGlo) {
254 slotNum = ephGlo->slotNum();
255 }
256 }
257
258 t_irc irc = _allObsMap[prn].addObs(obs, slotNum);
259
260 if (irc == success) {
261 t_oneObs* newObs = _allObsMap[prn]._oneObsVec.last();
262 if (ephGlo) {
263 newObs->_slotSet = true;
264 }
265 if (newObs->_hasL1 && newObs->_hasL2) {
266 _obsStat._prnStat[prn]._numObs += 1;
267 }
268 if (newObs->_slipL1 && newObs->_slipL2) {
269 _obsStat._prnStat[prn]._numSlipsFlagged += 1;
270 }
271 }
272 }
273
274 prepareObsStat(iEpo, obsFile->interval(), xyzSta);
275 iEpo++;
276
277 } // while (_currEpo)
278 }
279 catch (QString str) {
280 if (_log) {
281 *_log << "Exception " << str << endl;
282 }
283 else {
284 qDebug() << str;
285 }
286 _mutex.unlock();
287 return;
288 }
289
290 // Analyze the Multipath
291 // ---------------------
292 QVector<t_polarPoint*>* dataMP1 = new QVector<t_polarPoint*>;
293 QVector<t_polarPoint*>* dataMP2 = new QVector<t_polarPoint*>;
294 QVector<t_polarPoint*>* dataSNR1 = new QVector<t_polarPoint*>;
295 QVector<t_polarPoint*>* dataSNR2 = new QVector<t_polarPoint*>;
296
297 QMutableMapIterator<QString, t_allObs> it(_allObsMap);
298 while (it.hasNext()) {
299 it.next();
300 QString prn = it.key();
301 preparePlotData(prn, xyzSta, obsFile->interval(),
302 dataMP1, dataMP2, dataSNR1, dataSNR2);
303 }
304
305 printReport(dataMP1, dataMP2, dataSNR1, dataSNR2);
306
307 // Show the plots
308 // --------------
309 if (BNC_CORE->GUIenabled()) {
310 QFileInfo fileInfo(obsFile->fileName());
311 QByteArray title = fileInfo.fileName().toAscii();
312 emit dspSkyPlot(obsFile->fileName(), "MP1", dataMP1, "MP2", dataMP2,
313 "Meters", 2.0);
314 double mean = 0.0;
315 for (int ii = 0; ii < dataSNR1->size(); ii++) {
316 const t_polarPoint* point = dataSNR1->at(ii);
317 mean += point->_value;
318 }
319 if (dataSNR1->size() > 0) {
320 mean /= dataSNR1->size();
321 }
322 double max = (mean > 9.0) ? 54.0 : 9.0;
323 QByteArray str = (mean > 9.0) ? "dbHz" : "";
324 emit dspSkyPlot(obsFile->fileName(), "SNR1", dataSNR1, "SNR2", dataSNR2,
325 str, max);
326 emit dspAvailPlot(obsFile->fileName(), title);
327 }
328 else {
329 for (int ii = 0; ii < dataMP1->size(); ii++) {
330 delete dataMP1->at(ii);
331 }
332 delete dataMP1;
333 for (int ii = 0; ii < dataMP2->size(); ii++) {
334 delete dataMP2->at(ii);
335 }
336 delete dataMP2;
337 for (int ii = 0; ii < dataSNR1->size(); ii++) {
338 delete dataSNR1->at(ii);
339 }
340 delete dataSNR1;
341 for (int ii = 0; ii < dataSNR2->size(); ii++) {
342 delete dataSNR2->at(ii);
343 }
344 delete dataSNR2;
345 _mutex.unlock();
346 }
347}
348
349//
350////////////////////////////////////////////////////////////////////////////
351t_irc t_reqcAnalyze::t_allObs::addObs(const t_satObs& obs, int slotNum) {
352
353 t_oneObs* newObs = new t_oneObs(obs._time.gpsw(), obs._time.gpssec());
354 bool okFlag = false;
355
356 // Availability and Slip Flags
357 // ---------------------------
358 double L1 = 0.0;
359 double L2 = 0.0;
360 double P1 = 0.0;
361 double P2 = 0.0;
362
363 for (unsigned iFrq = 0; iFrq < obs._obs.size(); iFrq++) {
364 const t_frqObs* frqObs = obs._obs[iFrq];
365 if (frqObs->_rnxType2ch[0] == '1') {
366 if (frqObs->_phaseValid) {
367 L1 = frqObs->_phase;
368 newObs->_hasL1 = true;
369 newObs->_slipL1 = frqObs->_slip;
370 }
371 if (frqObs->_codeValid) {
372 P1 = frqObs->_code;
373 }
374 if (frqObs->_snrValid) {
375 newObs->_SNR1 = frqObs->_snr;
376 }
377 }
378 else if ( (obs._prn.system() != 'E' && frqObs->_rnxType2ch[0] == '2') ||
379 (obs._prn.system() == 'E' && frqObs->_rnxType2ch[0] == '5') ) {
380 if (frqObs->_phaseValid) {
381 L2 = frqObs->_phase;
382 newObs->_hasL2 = true;
383 newObs->_slipL2 = frqObs->_slip;
384 }
385 if (frqObs->_codeValid) {
386 P2 = frqObs->_code;
387 }
388 if (frqObs->_snrValid) {
389 newObs->_SNR2 = frqObs->_snr;
390 }
391 }
392 }
393
394 // Compute the Multipath
395 // ----------------------
396 if (L1 != 0.0 && L2 != 0.0) {
397 double f1 = 0.0;
398 double f2 = 0.0;
399 if (obs._prn.system() == 'G') {
400 f1 = t_CST::freq(t_frequency::G1, 0);
401 f2 = t_CST::freq(t_frequency::G2, 0);
402 }
403 else if (obs._prn.system() == 'R') {
404 f1 = t_CST::freq(t_frequency::R1, slotNum);
405 f2 = t_CST::freq(t_frequency::R2, slotNum);
406 }
407 else if (obs._prn.system() == 'E') {
408 f1 = t_CST::freq(t_frequency::E1, 0);
409 f2 = t_CST::freq(t_frequency::E5, 0);
410 }
411
412 L1 = L1 * t_CST::c / f1;
413 L2 = L2 * t_CST::c / f2;
414
415 if (P1 != 0.0) {
416 newObs->_MP1 = P1 - L1 - 2.0*f2*f2/(f1*f1-f2*f2) * (L1 - L2);
417 okFlag = true;
418 }
419 if (P2 != 0.0) {
420 newObs->_MP2 = P2 - L2 - 2.0*f1*f1/(f1*f1-f2*f2) * (L1 - L2);
421 okFlag = true;
422 }
423 }
424
425 // Remember the Observation
426 // ------------------------
427 if (okFlag) {
428 _oneObsVec << newObs;
429 return success;
430 }
431 else {
432 delete newObs;
433 return failure;
434 }
435}
436
437//
438////////////////////////////////////////////////////////////////////////////
439void t_reqcAnalyze::prepareObsStat(unsigned iEpo, double obsInterval,
440 const ColumnVector& xyzSta) {
441 const int sampl = int(30.0 / obsInterval);
442 if (iEpo % sampl == 0) {
443 double mjdX24 = _currEpo->tt.mjddec() * 24.0;
444 if (iEpo != 0) {
445 _obsStat._mjdX24 << mjdX24;
446 _obsStat._numSat << _obsStat._numSat.last();
447 _obsStat._PDOP << _obsStat._PDOP.last();
448 }
449 _obsStat._mjdX24 << mjdX24;
450 _obsStat._numSat << _currEpo->rnxSat.size();
451 _obsStat._PDOP << cmpDOP(xyzSta);
452 }
453}
454
455//
456////////////////////////////////////////////////////////////////////////////
457void t_reqcAnalyze::preparePlotData(const QString& prn,
458 const ColumnVector& xyzSta,
459 double obsInterval,
460 QVector<t_polarPoint*>* dataMP1,
461 QVector<t_polarPoint*>* dataMP2,
462 QVector<t_polarPoint*>* dataSNR1,
463 QVector<t_polarPoint*>* dataSNR2) {
464
465 const int chunkStep = int( 30.0 / obsInterval); // chunk step (30 sec)
466 const int numEpo = int(600.0 / obsInterval); // # epochs in one chunk (10 min)
467
468 t_allObs& allObs = _allObsMap[prn];
469
470 bncSettings settings;
471 QString reqSkyPlotSystems = settings.value("reqcSkyPlotSystems").toString();
472 bool plotGPS = false;
473 bool plotGlo = false;
474 bool plotGal = false;
475 if (reqSkyPlotSystems == "GPS") {
476 plotGPS = true;
477 }
478 else if (reqSkyPlotSystems == "GLONASS") {
479 plotGlo = true;
480 }
481 else if (reqSkyPlotSystems == "Galileo") {
482 plotGal = true;
483 }
484 else {
485 plotGPS = true;
486 plotGlo = true;
487 plotGal = true;
488 }
489
490 // Loop over all Chunks of Data
491 // ----------------------------
492 bool slipFound = false;
493 for (int chunkStart = 0; chunkStart + numEpo < allObs._oneObsVec.size();
494 chunkStart += chunkStep) {
495
496 if (chunkStart * chunkStep == numEpo) {
497 slipFound = false;
498 }
499
500 // Chunk-Specific Variables
501 // ------------------------
502 bncTime currTime;
503 bncTime prevTime;
504 bncTime chunkStartTime;
505 double mjdX24 = 0.0;
506 bool availL1 = false;
507 bool availL2 = false;
508 bool gapL1 = false;
509 bool gapL2 = false;
510 bool slipL1 = false;
511 bool slipL2 = false;
512 double meanMP1 = 0.0;
513 double meanMP2 = 0.0;
514 double minSNR1 = 0.0;
515 double minSNR2 = 0.0;
516 double aziDeg = 0.0;
517 double zenDeg = 0.0;
518 bool zenFlag = false;
519
520 // Loop over all Epochs within one Chunk of Data
521 // ---------------------------------------------
522 bool slotSet = false;
523 for (int ii = 0; ii < numEpo; ii++) {
524 int iEpo = chunkStart + ii;
525 const t_oneObs* oneObs = allObs._oneObsVec[iEpo];
526 if (oneObs->_slotSet) {
527 slotSet = true;
528 }
529
530 currTime.set(oneObs->_GPSWeek, oneObs->_GPSWeeks);
531
532 // Compute the Azimuth and Zenith Distance
533 // ---------------------------------------
534 if (ii == 0) {
535 chunkStartTime = currTime;
536 mjdX24 = chunkStartTime.mjddec() * 24.0;
537
538 if (xyzSta.size()) {
539 t_eph* eph = 0;
540 for (int ie = 0; ie < _ephs.size(); ie++) {
541 if (QString(_ephs[ie]->prn().toString().c_str()) == prn) {
542 eph = _ephs[ie];
543 break;
544 }
545 }
546
547 if (eph) {
548 ColumnVector xc(4);
549 ColumnVector vv(3);
550 if (eph->getCrd(bncTime(oneObs->_GPSWeek, oneObs->_GPSWeeks), xc, vv, false) == success) {
551 double rho, eleSat, azSat;
552 topos(xyzSta(1), xyzSta(2), xyzSta(3), xc(1), xc(2), xc(3), rho, eleSat, azSat);
553 aziDeg = azSat * 180.0/M_PI;
554 zenDeg = 90.0 - eleSat * 180.0/M_PI;
555 zenFlag = true;
556 }
557 }
558 }
559 }
560
561 // Check Interval
562 // --------------
563 if (prevTime.valid()) {
564 double dt = currTime - prevTime;
565 double intpart, fractpart;
566 fractpart = modf(dt, &intpart);
567 if (fractpart > obsInterval || intpart > obsInterval) {
568 gapL1 = true;
569 gapL2 = true;
570 }
571 }
572 prevTime = currTime;
573
574 // Check L1 and L2 availability
575 // ----------------------------
576 if (oneObs->_hasL1) {
577 availL1 = true;
578 }
579 else {
580 gapL1 = true;
581 }
582 if (oneObs->_hasL2) {
583 availL2 = true;
584 }
585 else {
586 gapL2 = true;
587 }
588
589 // Check Minimal Signal-to-Noise Ratio
590 // -----------------------------------
591 if ( oneObs->_SNR1 > 0 && (minSNR1 == 0 || minSNR1 > oneObs->_SNR1) ) {
592 minSNR1 = oneObs->_SNR1;
593 }
594 if ( oneObs->_SNR2 > 0 && (minSNR2 == 0 || minSNR2 > oneObs->_SNR2) ) {
595 minSNR2 = oneObs->_SNR2;
596 }
597
598 // Check Slip Flags
599 // ----------------
600 if (oneObs->_slipL1) {
601 slipL1 = true;
602 }
603 if (oneObs->_slipL2) {
604 slipL2 = true;
605 }
606
607 meanMP1 += oneObs->_MP1;
608 meanMP2 += oneObs->_MP2;
609 }
610
611 // Compute the Multipath
612 // ---------------------
613 if ( (prn[0] == 'G' && plotGPS ) ||
614 (prn[0] == 'R' && plotGlo && slotSet) ||
615 (prn[0] == 'E' && plotGal ) ) {
616 bool slipMP = false;
617 meanMP1 /= numEpo;
618 meanMP2 /= numEpo;
619 double MP1 = 0.0;
620 double MP2 = 0.0;
621 for (int ii = 0; ii < numEpo; ii++) {
622 int iEpo = chunkStart + ii;
623 const t_oneObs* oneObs = allObs._oneObsVec[iEpo];
624 double diff1 = oneObs->_MP1 - meanMP1;
625 double diff2 = oneObs->_MP2 - meanMP2;
626
627 // Check Slip Threshold
628 // --------------------
629 if (fabs(diff1) > SLIPTRESH || fabs(diff2) > SLIPTRESH) {
630 slipMP = true;
631 break;
632 }
633
634 MP1 += diff1 * diff1;
635 MP2 += diff2 * diff2;
636 }
637 if (slipMP) {
638 slipL1 = true;
639 slipL2 = true;
640 if (!slipFound) {
641 slipFound = true;
642 _obsStat._prnStat[prn]._numSlipsFound += 1;
643 }
644 }
645 else {
646 MP1 = sqrt(MP1 / (numEpo-1));
647 MP2 = sqrt(MP2 / (numEpo-1));
648 (*dataMP1) << (new t_polarPoint(aziDeg, zenDeg, MP1));
649 (*dataMP2) << (new t_polarPoint(aziDeg, zenDeg, MP2));
650 }
651 }
652
653 // Availability Plot Data
654 // ----------------------
655 if (availL1) {
656 if (slipL1) {
657 _availDataMap[prn]._L1slip << mjdX24;
658 }
659 else if (gapL1) {
660 _availDataMap[prn]._L1gap << mjdX24;
661 }
662 else {
663 _availDataMap[prn]._L1ok << mjdX24;
664 }
665 }
666 if (availL2) {
667 if (slipL2) {
668 _availDataMap[prn]._L2slip << mjdX24;
669 }
670 else if (gapL2) {
671 _availDataMap[prn]._L2gap << mjdX24;
672 }
673 else {
674 _availDataMap[prn]._L2ok << mjdX24;
675 }
676 }
677 if (zenFlag) {
678 _availDataMap[prn]._eleTim << mjdX24;
679 _availDataMap[prn]._eleDeg << 90.0 - zenDeg;
680 }
681
682 // Signal-to-Noise Ratio Plot Data
683 // -------------------------------
684 if ( (prn[0] == 'G' && plotGPS) ||
685 (prn[0] == 'R' && plotGlo) ||
686 (prn[0] == 'E' && plotGal) ) {
687 (*dataSNR1) << (new t_polarPoint(aziDeg, zenDeg, minSNR1));
688 (*dataSNR2) << (new t_polarPoint(aziDeg, zenDeg, minSNR2));
689 }
690 }
691}
692
693//
694////////////////////////////////////////////////////////////////////////////
695void t_reqcAnalyze::slotDspAvailPlot(const QString& fileName,
696 const QByteArray& title) {
697
698 if (BNC_CORE->GUIenabled()) {
699 t_availPlot* plotA = new t_availPlot(0, &_availDataMap);
700 plotA->setTitle(title);
701
702 t_elePlot* plotZ = new t_elePlot(0, &_availDataMap);
703
704 t_dopPlot* plotD = new t_dopPlot(0, &_obsStat);
705
706 QVector<QWidget*> plots;
707 plots << plotA << plotZ << plotD;
708 t_graphWin* graphWin = new t_graphWin(0, fileName, plots, 0, 0);
709
710 int ww = QFontMetrics(graphWin->font()).width('w');
711 graphWin->setMinimumSize(120*ww, 40*ww);
712
713 graphWin->show();
714
715 bncSettings settings;
716 QString dirName = settings.value("reqcPlotDir").toString();
717 if (!dirName.isEmpty()) {
718 QByteArray ext = "_A.png";
719 graphWin->savePNG(dirName, ext);
720 }
721 }
722 _mutex.unlock();
723}
724
725// Compute Dilution of Precision
726////////////////////////////////////////////////////////////////////////////
727double t_reqcAnalyze::cmpDOP(const ColumnVector& xyzSta) const {
728
729 if (xyzSta.size() != 3) {
730 return 0.0;
731 }
732
733 unsigned nSat = _currEpo->rnxSat.size();
734
735 if (nSat < 4) {
736 return 0.0;
737 }
738
739 Matrix AA(nSat, 4);
740
741 unsigned nSatUsed = 0;
742 for (unsigned iSat = 0; iSat < nSat; iSat++) {
743
744 const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iSat];
745 const t_prn& prn = rnxSat.prn;
746
747 t_eph* eph = 0;
748 for (int ie = 0; ie < _ephs.size(); ie++) {
749 if (_ephs[ie]->prn() == prn) {
750 eph = _ephs[ie];
751 break;
752 }
753 }
754 if (eph) {
755 ColumnVector xSat(4);
756 ColumnVector vv(3);
757 if (eph->getCrd(_currEpo->tt, xSat, vv, false) == success) {
758 ++nSatUsed;
759 ColumnVector dx = xSat.Rows(1,3) - xyzSta;
760 double rho = dx.norm_Frobenius();
761 AA(nSatUsed,1) = dx(1) / rho;
762 AA(nSatUsed,2) = dx(2) / rho;
763 AA(nSatUsed,3) = dx(3) / rho;
764 AA(nSatUsed,4) = 1.0;
765 }
766 }
767 }
768
769 if (nSatUsed < 4) {
770 return 0.0;
771 }
772
773 AA = AA.Rows(1, nSatUsed);
774
775 SymmetricMatrix QQ;
776 QQ << AA.t() * AA;
777 QQ = QQ.i();
778
779 return sqrt(QQ.trace());
780}
781
782// Finish the report
783////////////////////////////////////////////////////////////////////////////
784void t_reqcAnalyze::printReport(QVector<t_polarPoint*>* dataMP1,
785 QVector<t_polarPoint*>* dataMP2,
786 QVector<t_polarPoint*>* dataSNR1,
787 QVector<t_polarPoint*>* dataSNR2) {
788
789 if (!_log) {
790 return;
791 }
792
793 *_log << "Marker name: " << _obsStat._markerName << endl
794 << "Receiver: " << _obsStat._receiverType << endl
795 << "Antenna: " << _obsStat._antennaName << endl
796 << "Start time: " << _obsStat._startTime.datestr().c_str() << ' '
797 << _obsStat._startTime.timestr().c_str() << endl
798 << "End time: " << _obsStat._endTime.datestr().c_str() << ' '
799 << _obsStat._endTime.timestr().c_str() << endl
800 << "Interval: " << _obsStat._interval << endl
801 << "# Sat.: " << _obsStat._prnStat.size() << endl;
802
803 int numObs = 0;
804 int numSlipsFlagged = 0;
805 int numSlipsFound = 0;
806 QMapIterator<QString, t_prnStat> it(_obsStat._prnStat);
807 while (it.hasNext()) {
808 it.next();
809 const t_prnStat& prnStat = it.value();
810 numObs += prnStat._numObs;
811 numSlipsFlagged += prnStat._numSlipsFlagged;
812 numSlipsFound += prnStat._numSlipsFound;
813 }
814 *_log << "# Obs.: " << numObs << endl
815 << "# Slips (file): " << numSlipsFlagged << endl
816 << "# Slips (found): " << numSlipsFound << endl;
817
818 for (int kk = 1; kk <= 4; kk++) {
819 QVector<t_polarPoint*>* data = 0;
820 QString text;
821 if (kk == 1) {
822 data = dataMP1;
823 text = "Mean MP1: ";
824 }
825 else if (kk == 2) {
826 data = dataMP2;
827 text = "Mean MP2: ";
828 }
829 else if (kk == 3) {
830 data = dataSNR1;
831 text = "Mean SNR1: ";
832 }
833 else if (kk == 4) {
834 data = dataSNR2;
835 text = "Mean SNR2: ";
836 }
837 double mean = 0.0;
838 for (int ii = 0; ii < data->size(); ii++) {
839 const t_polarPoint* point = data->at(ii);
840 mean += point->_value;
841 }
842 if (data->size() > 0) {
843 mean /= data->size();
844 }
845 *_log << text << mean << endl;
846 }
847
848 _log->flush();
849}
Note: See TracBrowser for help on using the repository browser.