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

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