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

Last change on this file since 5883 was 5883, checked in by mervart, 10 years ago
File size: 23.9 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.isEmpty() ? "_S.png" : "_M.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_obs obs;
240 setObsFromRnx(obsFile, _currEpo, rnxSat, obs);
241
242 QString prn = QString("%1%2").arg(obs.satSys)
243 .arg(obs.satNum, 2, 10, QChar('0'));
244
245 t_ephGlo* ephGlo = 0;
246 if (obs.satSys == '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 obs.slotNum = ephGlo->slotNum();
255 }
256 }
257
258 t_irc irc = _allObsMap[prn].addObs(obs);
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 emit dspSkyPlot(obsFile->fileName(), "SNR1", dataSNR1, "SNR2", dataSNR2,
315 "", 9.0);
316 emit dspAvailPlot(obsFile->fileName(), title);
317 }
318 else {
319 for (int ii = 0; ii < dataMP1->size(); ii++) {
320 delete dataMP1->at(ii);
321 }
322 delete dataMP1;
323 for (int ii = 0; ii < dataMP2->size(); ii++) {
324 delete dataMP2->at(ii);
325 }
326 delete dataMP2;
327 for (int ii = 0; ii < dataSNR1->size(); ii++) {
328 delete dataSNR1->at(ii);
329 }
330 delete dataSNR1;
331 for (int ii = 0; ii < dataSNR2->size(); ii++) {
332 delete dataSNR2->at(ii);
333 }
334 delete dataSNR2;
335 _mutex.unlock();
336 }
337}
338
339//
340////////////////////////////////////////////////////////////////////////////
341t_irc t_reqcAnalyze::t_allObs::addObs(const t_obs& obs) {
342
343 t_oneObs* newObs = new t_oneObs(obs.GPSWeek, obs.GPSWeeks);
344 bool okFlag = false;
345
346 // Availability and Slip Flags
347 // ---------------------------
348 double L1 = obs.measdata("L1", 3.0);
349 if (L1 != 0) {
350 newObs->_hasL1 = true;
351 }
352 double L2 = obs.satSys == 'E' ? obs.measdata("L5", 3.0) : obs.measdata("L2", 3.0);;
353 if (L2 != 0) {
354 newObs->_hasL2 = true;
355 }
356 if (obs.slipL1) {
357 newObs->_slipL1 = true;
358 }
359 if (obs.slipL2) {
360 newObs->_slipL2 = true;
361 }
362
363 // Compute the Multipath
364 // ----------------------
365 if (L1 != 0.0 && L2 != 0.0) {
366 double f1 = t_CST::f1(obs.satSys, obs.slotNum);
367 double f2 = obs.satSys == 'E' ? t_CST::freq5 : t_CST::f2(obs.satSys, obs.slotNum);
368
369 L1 = L1 * t_CST::c / f1;
370 L2 = L2 * t_CST::c / f2;
371
372 double P1 = obs.measdata("C1", 3.0);
373 if (P1 != 0.0) {
374 newObs->_MP1 = P1 - L1 - 2.0*f2*f2/(f1*f1-f2*f2) * (L1 - L2);
375 okFlag = true;
376 }
377 double P2 = obs.satSys == 'E' ? obs.measdata("C5", 3.0) : obs.measdata("C2", 3.0);
378 if (P2 != 0.0) {
379 newObs->_MP2 = P2 - L2 - 2.0*f1*f1/(f1*f1-f2*f2) * (L1 - L2);
380 okFlag = true;
381 }
382 }
383
384 // Signal-to-Noise
385 // ---------------
386 double S1 = obs.measdata("S1", 3.0);
387 if (S1 != 0.0) {
388 newObs->_SNR1 = floor(S1/6);
389 if (newObs->_SNR1 > 9.0) {
390 newObs->_SNR1 = 9.0;
391 }
392 if (newObs->_SNR1 < 1.0) {
393 newObs->_SNR1 = 1.0;
394 }
395 okFlag = true;
396 }
397 else {
398 if (obs.snrL1 > 0) {
399 newObs->_SNR1 = obs.snrL1;
400 okFlag = true;
401 }
402 }
403 double S2 = obs.satSys == 'E' ? obs.measdata("S5", 3.0) : obs.measdata("S2", 3.0);
404 if (S2 != 0.0) {
405 newObs->_SNR2 = floor(S2/6);
406 if (newObs->_SNR2 > 9.0) {
407 newObs->_SNR2 = 9.0;
408 }
409 if (newObs->_SNR2 < 1.0) {
410 newObs->_SNR2 = 1.0;
411 }
412 okFlag = true;
413 }
414 else {
415 if (obs.snrL2 > 0) {
416 newObs->_SNR2 = obs.snrL2;
417 okFlag = true;
418 }
419 }
420
421 // Remember the Observation
422 // ------------------------
423 if (okFlag) {
424 _oneObsVec << newObs;
425 return success;
426 }
427 else {
428 delete newObs;
429 return failure;
430 }
431}
432
433//
434////////////////////////////////////////////////////////////////////////////
435void t_reqcAnalyze::prepareObsStat(unsigned iEpo, double obsInterval,
436 const ColumnVector& xyzSta) {
437 const int sampl = int(30.0 / obsInterval);
438 if (iEpo % sampl == 0) {
439 double mjdX24 = _currEpo->tt.mjddec() * 24.0;
440 if (iEpo != 0) {
441 _obsStat._mjdX24 << mjdX24;
442 _obsStat._numSat << _obsStat._numSat.last();
443 _obsStat._PDOP << _obsStat._PDOP.last();
444 }
445 _obsStat._mjdX24 << mjdX24;
446 _obsStat._numSat << _currEpo->rnxSat.size();
447 _obsStat._PDOP << cmpDOP(xyzSta);
448 }
449}
450
451//
452////////////////////////////////////////////////////////////////////////////
453void t_reqcAnalyze::preparePlotData(const QString& prn,
454 const ColumnVector& xyzSta,
455 double obsInterval,
456 QVector<t_polarPoint*>* dataMP1,
457 QVector<t_polarPoint*>* dataMP2,
458 QVector<t_polarPoint*>* dataSNR1,
459 QVector<t_polarPoint*>* dataSNR2) {
460
461 const int chunkStep = int( 30.0 / obsInterval); // chunk step (30 sec)
462 const int numEpo = int(600.0 / obsInterval); // # epochs in one chunk (10 min)
463
464 t_allObs& allObs = _allObsMap[prn];
465
466 bncSettings settings;
467 QString reqSkyPlotSystems = settings.value("reqcSkyPlotSystems").toString();
468 bool plotGPS = false;
469 bool plotGlo = false;
470 bool plotGal = false;
471 if (reqSkyPlotSystems == "GPS") {
472 plotGPS = true;
473 }
474 else if (reqSkyPlotSystems == "GLONASS") {
475 plotGlo = true;
476 }
477 else if (reqSkyPlotSystems == "Galileo") {
478 plotGal = true;
479 }
480 else {
481 plotGPS = true;
482 plotGlo = true;
483 plotGal = true;
484 }
485
486 // Loop over all Chunks of Data
487 // ----------------------------
488 bool slipFound = false;
489 for (int chunkStart = 0; chunkStart + numEpo < allObs._oneObsVec.size();
490 chunkStart += chunkStep) {
491
492 if (chunkStart * chunkStep == numEpo) {
493 slipFound = false;
494 }
495
496 // Chunk-Specific Variables
497 // ------------------------
498 bncTime currTime;
499 bncTime prevTime;
500 bncTime chunkStartTime;
501 double mjdX24 = 0.0;
502 bool availL1 = false;
503 bool availL2 = false;
504 bool gapL1 = false;
505 bool gapL2 = false;
506 bool slipL1 = false;
507 bool slipL2 = false;
508 double meanMP1 = 0.0;
509 double meanMP2 = 0.0;
510 double minSNR1 = 0.0;
511 double minSNR2 = 0.0;
512 double aziDeg = 0.0;
513 double zenDeg = 0.0;
514 bool zenFlag = false;
515
516 // Loop over all Epochs within one Chunk of Data
517 // ---------------------------------------------
518 bool slotSet = false;
519 for (int ii = 0; ii < numEpo; ii++) {
520 int iEpo = chunkStart + ii;
521 const t_oneObs* oneObs = allObs._oneObsVec[iEpo];
522 if (oneObs->_slotSet) {
523 slotSet = true;
524 }
525
526 currTime.set(oneObs->_GPSWeek, oneObs->_GPSWeeks);
527
528 // Compute the Azimuth and Zenith Distance
529 // ---------------------------------------
530 if (ii == 0) {
531 chunkStartTime = currTime;
532 mjdX24 = chunkStartTime.mjddec() * 24.0;
533
534 if (xyzSta.size()) {
535 t_eph* eph = 0;
536 for (int ie = 0; ie < _ephs.size(); ie++) {
537 if (QString(_ephs[ie]->prn().toString().c_str()) == prn) {
538 eph = _ephs[ie];
539 break;
540 }
541 }
542
543 if (eph) {
544 double xSat, ySat, zSat, clkSat;
545 eph->position(oneObs->_GPSWeek, oneObs->_GPSWeeks,
546 xSat, ySat, zSat, clkSat);
547
548 double rho, eleSat, azSat;
549 topos(xyzSta(1), xyzSta(2), xyzSta(3),
550 xSat, ySat, zSat, rho, eleSat, azSat);
551
552 aziDeg = azSat * 180.0/M_PI;
553 zenDeg = 90.0 - eleSat * 180.0/M_PI;
554 zenFlag = true;
555 }
556 }
557 }
558
559 // Check Interval
560 // --------------
561 if (prevTime.valid()) {
562 double dt = currTime - prevTime;
563 if (dt != obsInterval) {
564 gapL1 = true;
565 gapL2 = true;
566 }
567 }
568 prevTime = currTime;
569
570 // Check L1 and L2 availability
571 // ----------------------------
572 if (oneObs->_hasL1) {
573 availL1 = true;
574 }
575 else {
576 gapL1 = true;
577 }
578 if (oneObs->_hasL2) {
579 availL2 = true;
580 }
581 else {
582 gapL2 = true;
583 }
584
585 // Check Minimal Signal-to-Noise Ratio
586 // -----------------------------------
587 if ( oneObs->_SNR1 > 0 && (minSNR1 == 0 || minSNR1 > oneObs->_SNR1) ) {
588 minSNR1 = oneObs->_SNR1;
589 }
590 if ( oneObs->_SNR2 > 0 && (minSNR2 == 0 || minSNR2 > oneObs->_SNR2) ) {
591 minSNR2 = oneObs->_SNR2;
592 }
593
594 // Check Slip Flags
595 // ----------------
596 if (oneObs->_slipL1) {
597 slipL1 = true;
598 }
599 if (oneObs->_slipL2) {
600 slipL2 = true;
601 }
602
603 meanMP1 += oneObs->_MP1;
604 meanMP2 += oneObs->_MP2;
605 }
606
607 // Compute the Multipath
608 // ---------------------
609 if ( (prn[0] == 'G' && plotGPS ) ||
610 (prn[0] == 'R' && plotGlo && slotSet) ||
611 (prn[0] == 'E' && plotGal ) ) {
612 bool slipMP = false;
613 meanMP1 /= numEpo;
614 meanMP2 /= numEpo;
615 double MP1 = 0.0;
616 double MP2 = 0.0;
617 for (int ii = 0; ii < numEpo; ii++) {
618 int iEpo = chunkStart + ii;
619 const t_oneObs* oneObs = allObs._oneObsVec[iEpo];
620 double diff1 = oneObs->_MP1 - meanMP1;
621 double diff2 = oneObs->_MP2 - meanMP2;
622
623 // Check Slip Threshold
624 // --------------------
625 if (fabs(diff1) > SLIPTRESH || fabs(diff2) > SLIPTRESH) {
626 slipMP = true;
627 break;
628 }
629
630 MP1 += diff1 * diff1;
631 MP2 += diff2 * diff2;
632 }
633 if (slipMP) {
634 slipL1 = true;
635 slipL2 = true;
636 if (!slipFound) {
637 slipFound = true;
638 _obsStat._prnStat[prn]._numSlipsFound += 1;
639 }
640 }
641 else {
642 MP1 = sqrt(MP1 / (numEpo-1));
643 MP2 = sqrt(MP2 / (numEpo-1));
644 (*dataMP1) << (new t_polarPoint(aziDeg, zenDeg, MP1));
645 (*dataMP2) << (new t_polarPoint(aziDeg, zenDeg, MP2));
646 }
647 }
648
649 // Availability Plot Data
650 // ----------------------
651 if (availL1) {
652 if (slipL1) {
653 _availDataMap[prn]._L1slip << mjdX24;
654 }
655 else if (gapL1) {
656 _availDataMap[prn]._L1gap << mjdX24;
657 }
658 else {
659 _availDataMap[prn]._L1ok << mjdX24;
660 }
661 }
662 if (availL2) {
663 if (slipL2) {
664 _availDataMap[prn]._L2slip << mjdX24;
665 }
666 else if (gapL2) {
667 _availDataMap[prn]._L2gap << mjdX24;
668 }
669 else {
670 _availDataMap[prn]._L2ok << mjdX24;
671 }
672 }
673 if (zenFlag) {
674 _availDataMap[prn]._eleTim << mjdX24;
675 _availDataMap[prn]._eleDeg << 90.0 - zenDeg;
676 }
677
678 // Signal-to-Noise Ratio Plot Data
679 // -------------------------------
680 if ( (prn[0] == 'G' && plotGPS) ||
681 (prn[0] == 'R' && plotGlo) ||
682 (prn[0] == 'E' && plotGal) ) {
683 (*dataSNR1) << (new t_polarPoint(aziDeg, zenDeg, minSNR1));
684 (*dataSNR2) << (new t_polarPoint(aziDeg, zenDeg, minSNR2));
685 }
686 }
687}
688
689//
690////////////////////////////////////////////////////////////////////////////
691void t_reqcAnalyze::slotDspAvailPlot(const QString& fileName,
692 const QByteArray& title) {
693
694 if (BNC_CORE->GUIenabled()) {
695 t_availPlot* plotA = new t_availPlot(0, &_availDataMap);
696 plotA->setTitle(title);
697
698 t_elePlot* plotZ = new t_elePlot(0, &_availDataMap);
699
700 t_dopPlot* plotD = new t_dopPlot(0, &_obsStat);
701
702 QVector<QWidget*> plots;
703 plots << plotA << plotZ << plotD;
704 t_graphWin* graphWin = new t_graphWin(0, fileName, plots, 0, 0);
705
706 int ww = QFontMetrics(graphWin->font()).width('w');
707 graphWin->setMinimumSize(120*ww, 40*ww);
708
709 graphWin->show();
710
711 bncSettings settings;
712 QString dirName = settings.value("reqcPlotDir").toString();
713 if (!dirName.isEmpty()) {
714 QByteArray ext = "_A.png";
715 graphWin->savePNG(dirName, ext);
716 }
717 }
718 _mutex.unlock();
719}
720
721// Compute Dilution of Precision
722////////////////////////////////////////////////////////////////////////////
723double t_reqcAnalyze::cmpDOP(const ColumnVector& xyzSta) const {
724
725 if (xyzSta.size() != 3) {
726 return 0.0;
727 }
728
729 unsigned nSat = _currEpo->rnxSat.size();
730
731 if (nSat < 4) {
732 return 0.0;
733 }
734
735 Matrix AA(nSat, 4);
736
737 unsigned nSatUsed = 0;
738 for (unsigned iSat = 0; iSat < nSat; iSat++) {
739
740 const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iSat];
741
742 QString prn = QString("%1%2").arg(rnxSat.satSys)
743 .arg(rnxSat.satNum, 2, 10, QChar('0'));
744
745 t_eph* eph = 0;
746 for (int ie = 0; ie < _ephs.size(); ie++) {
747 if (QString(_ephs[ie]->prn().toString().c_str()) == prn) {
748 eph = _ephs[ie];
749 break;
750 }
751 }
752 if (eph) {
753 ++nSatUsed;
754 ColumnVector xSat(3);
755 double clkSat;
756 eph->position(_currEpo->tt.gpsw(), _currEpo->tt.gpssec(),
757 xSat(1), xSat(2), xSat(3), clkSat);
758 ColumnVector dx = xSat - xyzSta;
759 double rho = dx.norm_Frobenius();
760 AA(nSatUsed,1) = dx(1) / rho;
761 AA(nSatUsed,2) = dx(2) / rho;
762 AA(nSatUsed,3) = dx(3) / rho;
763 AA(nSatUsed,4) = 1.0;
764 }
765 }
766
767 if (nSatUsed < 4) {
768 return 0.0;
769 }
770
771 AA = AA.Rows(1, nSatUsed);
772
773 SymmetricMatrix QQ;
774 QQ << AA.t() * AA;
775 QQ = QQ.i();
776
777 return sqrt(QQ.trace());
778}
779
780// Finish the report
781////////////////////////////////////////////////////////////////////////////
782void t_reqcAnalyze::printReport(QVector<t_polarPoint*>* dataMP1,
783 QVector<t_polarPoint*>* dataMP2,
784 QVector<t_polarPoint*>* dataSNR1,
785 QVector<t_polarPoint*>* dataSNR2) {
786
787 if (!_log) {
788 return;
789 }
790
791 *_log << "Marker name: " << _obsStat._markerName << endl
792 << "Receiver: " << _obsStat._receiverType << endl
793 << "Antenna: " << _obsStat._antennaName << endl
794 << "Start time: " << _obsStat._startTime.datestr().c_str() << ' '
795 << _obsStat._startTime.timestr().c_str() << endl
796 << "End time: " << _obsStat._endTime.datestr().c_str() << ' '
797 << _obsStat._endTime.timestr().c_str() << endl
798 << "Interval: " << _obsStat._interval << endl
799 << "# Sat.: " << _obsStat._prnStat.size() << endl;
800
801 int numObs = 0;
802 int numSlipsFlagged = 0;
803 int numSlipsFound = 0;
804 QMapIterator<QString, t_prnStat> it(_obsStat._prnStat);
805 while (it.hasNext()) {
806 it.next();
807 const t_prnStat& prnStat = it.value();
808 numObs += prnStat._numObs;
809 numSlipsFlagged += prnStat._numSlipsFlagged;
810 numSlipsFound += prnStat._numSlipsFound;
811 }
812 *_log << "# Obs.: " << numObs << endl
813 << "# Slips (file): " << numSlipsFlagged << endl
814 << "# Slips (found): " << numSlipsFound << endl;
815
816 for (int kk = 1; kk <= 4; kk++) {
817 QVector<t_polarPoint*>* data = 0;
818 QString text;
819 if (kk == 1) {
820 data = dataMP1;
821 text = "Mean MP1: ";
822 }
823 else if (kk == 2) {
824 data = dataMP2;
825 text = "Mean MP2: ";
826 }
827 else if (kk == 3) {
828 data = dataSNR1;
829 text = "Mean SNR1: ";
830 }
831 else if (kk == 4) {
832 data = dataSNR2;
833 text = "Mean SNR2: ";
834 }
835 double mean = 0.0;
836 for (int ii = 0; ii < data->size(); ii++) {
837 const t_polarPoint* point = data->at(ii);
838 mean += point->_value;
839 }
840 mean /= data->size();
841 *_log << text << mean << endl;
842 }
843
844 _log->flush();
845}
Note: See TracBrowser for help on using the repository browser.