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

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