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

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