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

Last change on this file since 5143 was 5143, checked in by mervart, 11 years ago
File size: 23.9 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
[5140]243 QString prn = QString("%1%2").arg(obs.satSys)
244 .arg(obs.satNum, 2, 10, QChar('0'));
245
246 t_ephGlo* ephGlo = 0;
[4541]247 if (obs.satSys == 'R') {
[5140]248 for (int ie = 0; ie < _ephs.size(); ie++) {
249 if (_ephs[ie]->prn() == prn) {
250 ephGlo = dynamic_cast<t_ephGlo*>(_ephs[ie]);
251 break;
252 }
253 }
254 if (ephGlo) {
255 obs.slotNum = ephGlo->slotNum();
256 }
[4541]257 }
258
[4694]259 t_irc irc = _allObsMap[prn].addObs(obs);
[4675]260
[4694]261 if (irc == success) {
[5140]262 t_oneObs* newObs = _allObsMap[prn]._oneObsVec.last();
263 if (ephGlo) {
264 newObs->_slotSet = true;
265 }
[4694]266 if (newObs->_hasL1 && newObs->_hasL2) {
267 _obsStat._prnStat[prn]._numObs += 1;
268 }
[4695]269 if (newObs->_slipL1 && newObs->_slipL2) {
[4701]270 _obsStat._prnStat[prn]._numSlipsFlagged += 1;
[4695]271 }
[4694]272 }
[4262]273 }
[4541]274
[4679]275 prepareObsStat(iEpo, obsFile->interval(), xyzSta);
[4678]276 iEpo++;
277
[4541]278 } // while (_currEpo)
279 }
280 catch (QString str) {
281 if (_log) {
282 *_log << "Exception " << str << endl;
[4262]283 }
[4541]284 else {
285 qDebug() << str;
286 }
[4715]287 _mutex.unlock();
[4541]288 return;
289 }
[4262]290
[4268]291 // Analyze the Multipath
292 // ---------------------
[4718]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*>;
[4268]297
[4584]298 QMutableMapIterator<QString, t_allObs> it(_allObsMap);
[4268]299 while (it.hasNext()) {
300 it.next();
[4584]301 QString prn = it.key();
[4679]302 preparePlotData(prn, xyzSta, obsFile->interval(),
[4675]303 dataMP1, dataMP2, dataSNR1, dataSNR2);
[4268]304 }
305
[4706]306 printReport(dataMP1, dataMP2, dataSNR1, dataSNR2);
307
[4718]308 // Show the plots
309 // --------------
[5068]310 if (BNC_CORE->GUIenabled()) {
[4718]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 }
[4254]338}
[4263]339
340//
341////////////////////////////////////////////////////////////////////////////
[4694]342t_irc t_reqcAnalyze::t_allObs::addObs(const t_obs& obs) {
[4265]343
[4584]344 t_oneObs* newObs = new t_oneObs(obs.GPSWeek, obs.GPSWeeks);
[4354]345 bool okFlag = false;
[4338]346
[4608]347 // Availability and Slip Flags
348 // ---------------------------
[4424]349 double L1 = obs.measdata("L1", 3.0);
[4571]350 if (L1 != 0) {
351 newObs->_hasL1 = true;
352 }
[5136]353 double L2 = obs.satSys == 'E' ? obs.measdata("L5", 3.0) : obs.measdata("L2", 3.0);;
[4571]354 if (L2 != 0) {
355 newObs->_hasL2 = true;
356 }
[4608]357 if (obs.slipL1) {
358 newObs->_slipL1 = true;
359 }
360 if (obs.slipL2) {
361 newObs->_slipL2 = true;
362 }
363
364 // Compute the Multipath
365 // ----------------------
[4391]366 if (L1 != 0.0 && L2 != 0.0) {
[4266]367 double f1 = t_CST::f1(obs.satSys, obs.slotNum);
[5136]368 double f2 = obs.satSys == 'E' ? t_CST::freq5 : t_CST::f2(obs.satSys, obs.slotNum);
[4266]369
[4391]370 L1 = L1 * t_CST::c / f1;
371 L2 = L2 * t_CST::c / f2;
[4266]372
[4424]373 double P1 = obs.measdata("C1", 3.0);
[4391]374 if (P1 != 0.0) {
375 newObs->_MP1 = P1 - L1 - 2.0*f2*f2/(f1*f1-f2*f2) * (L1 - L2);
[4354]376 okFlag = true;
[4268]377 }
[5136]378 double P2 = obs.satSys == 'E' ? obs.measdata("C5", 3.0) : obs.measdata("C2", 3.0);
[4391]379 if (P2 != 0.0) {
380 newObs->_MP2 = P2 - L2 - 2.0*f1*f1/(f1*f1-f2*f2) * (L1 - L2);
[4354]381 okFlag = true;
[4268]382 }
[4265]383 }
[4338]384
[4559]385 // Signal-to-Noise
386 // ---------------
387 double S1 = obs.measdata("S1", 3.0);
388 if (S1 != 0.0) {
[4562]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 }
[4559]396 okFlag = true;
397 }
[4562]398 else {
399 if (obs.snrL1 > 0) {
400 newObs->_SNR1 = obs.snrL1;
401 okFlag = true;
402 }
403 }
[5136]404 double S2 = obs.satSys == 'E' ? obs.measdata("S5", 3.0) : obs.measdata("S2", 3.0);
[4559]405 if (S2 != 0.0) {
[4562]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 }
[4559]413 okFlag = true;
414 }
[4562]415 else {
416 if (obs.snrL2 > 0) {
417 newObs->_SNR2 = obs.snrL2;
418 okFlag = true;
419 }
420 }
[4559]421
[4354]422 // Remember the Observation
423 // ------------------------
424 if (okFlag) {
[4584]425 _oneObsVec << newObs;
[4694]426 return success;
[4354]427 }
428 else {
429 delete newObs;
[4694]430 return failure;
[4354]431 }
[4263]432}
[4350]433
434//
435////////////////////////////////////////////////////////////////////////////
[4679]436void t_reqcAnalyze::prepareObsStat(unsigned iEpo, double obsInterval,
437 const ColumnVector& xyzSta) {
[4677]438 const int sampl = int(30.0 / obsInterval);
439 if (iEpo % sampl == 0) {
[4676]440 double mjdX24 = _currEpo->tt.mjddec() * 24.0;
441 if (iEpo != 0) {
442 _obsStat._mjdX24 << mjdX24;
443 _obsStat._numSat << _obsStat._numSat.last();
[4680]444 _obsStat._PDOP << _obsStat._PDOP.last();
[4676]445 }
446 _obsStat._mjdX24 << mjdX24;
[4675]447 _obsStat._numSat << _currEpo->rnxSat.size();
[4680]448 _obsStat._PDOP << cmpDOP(xyzSta);
[4675]449 }
450}
451
452//
453////////////////////////////////////////////////////////////////////////////
[4679]454void t_reqcAnalyze::preparePlotData(const QString& prn,
455 const ColumnVector& xyzSta,
[4572]456 double obsInterval,
457 QVector<t_polarPoint*>* dataMP1,
458 QVector<t_polarPoint*>* dataMP2,
459 QVector<t_polarPoint*>* dataSNR1,
[4675]460 QVector<t_polarPoint*>* dataSNR2) {
[4350]461
[4544]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)
[4350]464
[4584]465 t_allObs& allObs = _allObsMap[prn];
466
[5141]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
[4591]487 // Loop over all Chunks of Data
488 // ----------------------------
[4702]489 bool slipFound = false;
[4584]490 for (int chunkStart = 0; chunkStart + numEpo < allObs._oneObsVec.size();
[4361]491 chunkStart += chunkStep) {
[4351]492
[4703]493 if (chunkStart * chunkStep == numEpo) {
[4702]494 slipFound = false;
495 }
496
[4675]497 // Chunk-Specific Variables
498 // ------------------------
[4591]499 bncTime currTime;
500 bncTime prevTime;
[4590]501 bncTime chunkStartTime;
[4675]502 double mjdX24 = 0.0;
[4607]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;
[4659]515 bool zenFlag = false;
[4353]516
[4591]517 // Loop over all Epochs within one Chunk of Data
518 // ---------------------------------------------
[5140]519 bool slotSet = false;
[4361]520 for (int ii = 0; ii < numEpo; ii++) {
[4351]521 int iEpo = chunkStart + ii;
[4584]522 const t_oneObs* oneObs = allObs._oneObsVec[iEpo];
[5140]523 if (oneObs->_slotSet) {
524 slotSet = true;
525 }
[4572]526
[4590]527 currTime.set(oneObs->_GPSWeek, oneObs->_GPSWeeks);
528
529 // Compute the Azimuth and Zenith Distance
530 // ---------------------------------------
[4572]531 if (ii == 0) {
[4590]532 chunkStartTime = currTime;
[4675]533 mjdX24 = chunkStartTime.mjddec() * 24.0;
[4590]534
[4679]535 if (xyzSta.size()) {
[4590]536 t_eph* eph = 0;
537 for (int ie = 0; ie < _ephs.size(); ie++) {
538 if (_ephs[ie]->prn() == 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;
[4679]550 topos(xyzSta(1), xyzSta(2), xyzSta(3),
551 xSat, ySat, zSat, rho, eleSat, azSat);
[4590]552
553 aziDeg = azSat * 180.0/M_PI;
554 zenDeg = 90.0 - eleSat * 180.0/M_PI;
[4659]555 zenFlag = true;
[4590]556 }
557 }
[4572]558 }
[4675]559
[4590]560 // Check Interval
561 // --------------
562 if (prevTime.valid()) {
[4591]563 double dt = currTime - prevTime;
564 if (dt != obsInterval) {
565 gapL1 = true;
566 gapL2 = true;
567 }
[4590]568 }
569 prevTime = currTime;
[4563]570
[4590]571 // Check L1 and L2 availability
572 // ----------------------------
573 if (oneObs->_hasL1) {
574 availL1 = true;
[4566]575 }
[4590]576 else {
[4591]577 gapL1 = true;
[4566]578 }
[4590]579 if (oneObs->_hasL2) {
580 availL2 = true;
581 }
582 else {
[4591]583 gapL2 = true;
[4590]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
[4607]595 // Check Slip Flags
596 // ----------------
597 if (oneObs->_slipL1) {
598 slipL1 = true;
599 }
600 if (oneObs->_slipL2) {
601 slipL2 = true;
602 }
603
[4698]604 meanMP1 += oneObs->_MP1;
605 meanMP2 += oneObs->_MP2;
606 }
607
608 // Compute the Multipath
609 // ---------------------
[5141]610 if ( (prn[0] == 'G' && plotGPS ) ||
611 (prn[0] == 'R' && plotGlo && slotSet) ||
612 (prn[0] == 'E' && plotGal ) ) {
[4700]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;
[4353]633 }
[4700]634 if (slipMP) {
635 slipL1 = true;
636 slipL2 = true;
[4702]637 if (!slipFound) {
638 slipFound = true;
639 _obsStat._prnStat[prn]._numSlipsFound += 1;
640 }
[4700]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 }
[4353]648 }
649
[4590]650 // Availability Plot Data
651 // ----------------------
652 if (availL1) {
[4607]653 if (slipL1) {
[4617]654 _availDataMap[prn]._L1slip << mjdX24;
[4591]655 }
656 else if (gapL1) {
[4617]657 _availDataMap[prn]._L1gap << mjdX24;
[4591]658 }
659 else {
[4617]660 _availDataMap[prn]._L1ok << mjdX24;
[4591]661 }
[4351]662 }
[4591]663 if (availL2) {
[4607]664 if (slipL2) {
[4617]665 _availDataMap[prn]._L2slip << mjdX24;
[4591]666 }
667 else if (gapL2) {
[4617]668 _availDataMap[prn]._L2gap << mjdX24;
[4591]669 }
670 else {
[4617]671 _availDataMap[prn]._L2ok << mjdX24;
[4591]672 }
673 }
[4659]674 if (zenFlag) {
[4662]675 _availDataMap[prn]._eleTim << mjdX24;
676 _availDataMap[prn]._eleDeg << 90.0 - zenDeg;
[4659]677 }
[4351]678
[5142]679 // Signal-to-Noise Ratio Plot Data
680 // -------------------------------
[5143]681 if ( (prn[0] == 'G' && plotGPS) ||
682 (prn[0] == 'R' && plotGlo) ||
683 (prn[0] == 'E' && plotGal) ) {
[5141]684 (*dataSNR1) << (new t_polarPoint(aziDeg, zenDeg, minSNR1));
685 (*dataSNR2) << (new t_polarPoint(aziDeg, zenDeg, minSNR2));
686 }
[4350]687 }
688}
[4572]689
690//
691////////////////////////////////////////////////////////////////////////////
692void t_reqcAnalyze::slotDspAvailPlot(const QString& fileName,
[4584]693 const QByteArray& title) {
[4572]694
[5068]695 if (BNC_CORE->GUIenabled()) {
[4659]696 t_availPlot* plotA = new t_availPlot(0, &_availDataMap);
697 plotA->setTitle(title);
[4573]698
[4662]699 t_elePlot* plotZ = new t_elePlot(0, &_availDataMap);
[4659]700
[4672]701 t_dopPlot* plotD = new t_dopPlot(0, &_obsStat);
[4671]702
[4573]703 QVector<QWidget*> plots;
[4671]704 plots << plotA << plotZ << plotD;
[4573]705 t_graphWin* graphWin = new t_graphWin(0, fileName, plots, 0, 0);
[4666]706
707 int ww = QFontMetrics(graphWin->font()).width('w');
708 graphWin->setMinimumSize(120*ww, 40*ww);
709
[4573]710 graphWin->show();
711
712 bncSettings settings;
713 QString dirName = settings.value("reqcPlotDir").toString();
714 if (!dirName.isEmpty()) {
[4606]715 QByteArray ext = "_A.png";
[4579]716 graphWin->savePNG(dirName, ext);
[4573]717 }
718 }
[4715]719 _mutex.unlock();
[4572]720}
[4679]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 (_ephs[ie]->prn() == 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;
[4681]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;
[4679]765 }
[4681]766 }
[4679]767
[4681]768 if (nSatUsed < 4) {
769 return 0.0;
[4679]770 }
771
[4681]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());
[4679]779}
[4689]780
781// Finish the report
782////////////////////////////////////////////////////////////////////////////
[4696]783void t_reqcAnalyze::printReport(QVector<t_polarPoint*>* dataMP1,
784 QVector<t_polarPoint*>* dataMP2,
785 QVector<t_polarPoint*>* dataSNR1,
786 QVector<t_polarPoint*>* dataSNR2) {
[4689]787 if (!_log) {
788 return;
789 }
790
[4701]791 *_log << "Marker name: " << _obsStat._markerName << endl
792 << "Receiver: " << _obsStat._receiverType << endl
793 << "Antenna: " << _obsStat._antennaName << endl
794 << "Start time: " << _obsStat._startTime.datestr().c_str() << ' '
795 << _obsStat._startTime.timestr().c_str() << endl
796 << "End time: " << _obsStat._endTime.datestr().c_str() << ' '
797 << _obsStat._endTime.timestr().c_str() << endl
798 << "Interval: " << _obsStat._interval << endl
799 << "# Sat.: " << _obsStat._prnStat.size() << endl;
[4689]800
[4701]801 int numObs = 0;
802 int numSlipsFlagged = 0;
803 int numSlipsFound = 0;
[4693]804 QMapIterator<QString, t_prnStat> it(_obsStat._prnStat);
805 while (it.hasNext()) {
806 it.next();
807 const t_prnStat& prnStat = it.value();
[4701]808 numObs += prnStat._numObs;
809 numSlipsFlagged += prnStat._numSlipsFlagged;
810 numSlipsFound += prnStat._numSlipsFound;
[4693]811 }
[4701]812 *_log << "# Obs.: " << numObs << endl
813 << "# Slips (file): " << numSlipsFlagged << endl
814 << "# Slips (found): " << numSlipsFound << endl;
[4693]815
[4697]816 for (int kk = 1; kk <= 4; kk++) {
817 QVector<t_polarPoint*>* data = 0;
818 QString text;
819 if (kk == 1) {
820 data = dataMP1;
[4701]821 text = "Mean MP1: ";
[4697]822 }
823 else if (kk == 2) {
824 data = dataMP2;
[4701]825 text = "Mean MP2: ";
[4697]826 }
827 else if (kk == 3) {
828 data = dataSNR1;
[4701]829 text = "Mean SNR1: ";
[4697]830 }
831 else if (kk == 4) {
832 data = dataSNR2;
[4701]833 text = "Mean SNR2: ";
[4697]834 }
835 double mean = 0.0;
836 for (int ii = 0; ii < data->size(); ii++) {
837 const t_polarPoint* point = data->at(ii);
838 mean += point->_value;
839 }
840 mean /= data->size();
841 *_log << text << mean << endl;
842 }
843
[4689]844 _log->flush();
845}
Note: See TracBrowser for help on using the repository browser.