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

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