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

Last change on this file since 6017 was 6017, checked in by mervart, 10 years ago
File size: 24.2 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];
239 t_obs obs;
[5884]240 t_rnxObsFile::setObsFromRnx(obsFile, _currEpo, rnxSat, obs);
[4541]241
[5140]242 QString prn = QString("%1%2").arg(obs.satSys)
243 .arg(obs.satNum, 2, 10, QChar('0'));
244
245 t_ephGlo* ephGlo = 0;
[4541]246 if (obs.satSys == '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) {
254 obs.slotNum = ephGlo->slotNum();
255 }
[4541]256 }
257
[4694]258 t_irc irc = _allObsMap[prn].addObs(obs);
[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////////////////////////////////////////////////////////////////////////////
[4694]341t_irc t_reqcAnalyze::t_allObs::addObs(const t_obs& obs) {
[4265]342
[4584]343 t_oneObs* newObs = new t_oneObs(obs.GPSWeek, obs.GPSWeeks);
[4354]344 bool okFlag = false;
[4338]345
[4608]346 // Availability and Slip Flags
347 // ---------------------------
[4424]348 double L1 = obs.measdata("L1", 3.0);
[4571]349 if (L1 != 0) {
350 newObs->_hasL1 = true;
351 }
[5136]352 double L2 = obs.satSys == 'E' ? obs.measdata("L5", 3.0) : obs.measdata("L2", 3.0);;
[4571]353 if (L2 != 0) {
354 newObs->_hasL2 = true;
355 }
[4608]356 if (obs.slipL1) {
357 newObs->_slipL1 = true;
358 }
359 if (obs.slipL2) {
360 newObs->_slipL2 = true;
361 }
362
363 // Compute the Multipath
364 // ----------------------
[4391]365 if (L1 != 0.0 && L2 != 0.0) {
[6017]366 double f1 = 0.0;
367 double f2 = 0.0;
368 if (obs.satSys == 'G') {
369 f1 = t_CST::freq(t_frequency::G1, 0);
370 f2 = t_CST::freq(t_frequency::G2, 0);
371 }
372 else if (obs.satSys == 'R') {
373 f1 = t_CST::freq(t_frequency::R1, obs.slotNum);
374 f2 = t_CST::freq(t_frequency::R2, obs.slotNum);
375 }
376 else if (obs.satSys == 'E') {
377 f1 = t_CST::freq(t_frequency::E1, 0);
378 f2 = t_CST::freq(t_frequency::E5, 0);
379 }
[4266]380
[4391]381 L1 = L1 * t_CST::c / f1;
382 L2 = L2 * t_CST::c / f2;
[4266]383
[4424]384 double P1 = obs.measdata("C1", 3.0);
[4391]385 if (P1 != 0.0) {
386 newObs->_MP1 = P1 - L1 - 2.0*f2*f2/(f1*f1-f2*f2) * (L1 - L2);
[4354]387 okFlag = true;
[4268]388 }
[5136]389 double P2 = obs.satSys == 'E' ? obs.measdata("C5", 3.0) : obs.measdata("C2", 3.0);
[4391]390 if (P2 != 0.0) {
391 newObs->_MP2 = P2 - L2 - 2.0*f1*f1/(f1*f1-f2*f2) * (L1 - L2);
[4354]392 okFlag = true;
[4268]393 }
[4265]394 }
[4338]395
[4559]396 // Signal-to-Noise
397 // ---------------
398 double S1 = obs.measdata("S1", 3.0);
399 if (S1 != 0.0) {
[4562]400 newObs->_SNR1 = floor(S1/6);
401 if (newObs->_SNR1 > 9.0) {
402 newObs->_SNR1 = 9.0;
403 }
404 if (newObs->_SNR1 < 1.0) {
405 newObs->_SNR1 = 1.0;
406 }
[4559]407 okFlag = true;
408 }
[4562]409 else {
410 if (obs.snrL1 > 0) {
411 newObs->_SNR1 = obs.snrL1;
412 okFlag = true;
413 }
414 }
[5136]415 double S2 = obs.satSys == 'E' ? obs.measdata("S5", 3.0) : obs.measdata("S2", 3.0);
[4559]416 if (S2 != 0.0) {
[4562]417 newObs->_SNR2 = floor(S2/6);
418 if (newObs->_SNR2 > 9.0) {
419 newObs->_SNR2 = 9.0;
420 }
421 if (newObs->_SNR2 < 1.0) {
422 newObs->_SNR2 = 1.0;
423 }
[4559]424 okFlag = true;
425 }
[4562]426 else {
427 if (obs.snrL2 > 0) {
428 newObs->_SNR2 = obs.snrL2;
429 okFlag = true;
430 }
431 }
[4559]432
[4354]433 // Remember the Observation
434 // ------------------------
435 if (okFlag) {
[4584]436 _oneObsVec << newObs;
[4694]437 return success;
[4354]438 }
439 else {
440 delete newObs;
[4694]441 return failure;
[4354]442 }
[4263]443}
[4350]444
445//
446////////////////////////////////////////////////////////////////////////////
[4679]447void t_reqcAnalyze::prepareObsStat(unsigned iEpo, double obsInterval,
448 const ColumnVector& xyzSta) {
[4677]449 const int sampl = int(30.0 / obsInterval);
450 if (iEpo % sampl == 0) {
[4676]451 double mjdX24 = _currEpo->tt.mjddec() * 24.0;
452 if (iEpo != 0) {
453 _obsStat._mjdX24 << mjdX24;
454 _obsStat._numSat << _obsStat._numSat.last();
[4680]455 _obsStat._PDOP << _obsStat._PDOP.last();
[4676]456 }
457 _obsStat._mjdX24 << mjdX24;
[4675]458 _obsStat._numSat << _currEpo->rnxSat.size();
[4680]459 _obsStat._PDOP << cmpDOP(xyzSta);
[4675]460 }
461}
462
463//
464////////////////////////////////////////////////////////////////////////////
[4679]465void t_reqcAnalyze::preparePlotData(const QString& prn,
466 const ColumnVector& xyzSta,
[4572]467 double obsInterval,
468 QVector<t_polarPoint*>* dataMP1,
469 QVector<t_polarPoint*>* dataMP2,
470 QVector<t_polarPoint*>* dataSNR1,
[4675]471 QVector<t_polarPoint*>* dataSNR2) {
[4350]472
[4544]473 const int chunkStep = int( 30.0 / obsInterval); // chunk step (30 sec)
474 const int numEpo = int(600.0 / obsInterval); // # epochs in one chunk (10 min)
[4350]475
[4584]476 t_allObs& allObs = _allObsMap[prn];
477
[5141]478 bncSettings settings;
479 QString reqSkyPlotSystems = settings.value("reqcSkyPlotSystems").toString();
480 bool plotGPS = false;
481 bool plotGlo = false;
482 bool plotGal = false;
483 if (reqSkyPlotSystems == "GPS") {
484 plotGPS = true;
485 }
486 else if (reqSkyPlotSystems == "GLONASS") {
487 plotGlo = true;
488 }
489 else if (reqSkyPlotSystems == "Galileo") {
490 plotGal = true;
491 }
492 else {
493 plotGPS = true;
494 plotGlo = true;
495 plotGal = true;
496 }
497
[4591]498 // Loop over all Chunks of Data
499 // ----------------------------
[4702]500 bool slipFound = false;
[4584]501 for (int chunkStart = 0; chunkStart + numEpo < allObs._oneObsVec.size();
[4361]502 chunkStart += chunkStep) {
[4351]503
[4703]504 if (chunkStart * chunkStep == numEpo) {
[4702]505 slipFound = false;
506 }
507
[4675]508 // Chunk-Specific Variables
509 // ------------------------
[4591]510 bncTime currTime;
511 bncTime prevTime;
[4590]512 bncTime chunkStartTime;
[4675]513 double mjdX24 = 0.0;
[4607]514 bool availL1 = false;
515 bool availL2 = false;
516 bool gapL1 = false;
517 bool gapL2 = false;
518 bool slipL1 = false;
519 bool slipL2 = false;
520 double meanMP1 = 0.0;
521 double meanMP2 = 0.0;
522 double minSNR1 = 0.0;
523 double minSNR2 = 0.0;
524 double aziDeg = 0.0;
525 double zenDeg = 0.0;
[4659]526 bool zenFlag = false;
[4353]527
[4591]528 // Loop over all Epochs within one Chunk of Data
529 // ---------------------------------------------
[5140]530 bool slotSet = false;
[4361]531 for (int ii = 0; ii < numEpo; ii++) {
[4351]532 int iEpo = chunkStart + ii;
[4584]533 const t_oneObs* oneObs = allObs._oneObsVec[iEpo];
[5140]534 if (oneObs->_slotSet) {
535 slotSet = true;
536 }
[4572]537
[4590]538 currTime.set(oneObs->_GPSWeek, oneObs->_GPSWeeks);
539
540 // Compute the Azimuth and Zenith Distance
541 // ---------------------------------------
[4572]542 if (ii == 0) {
[4590]543 chunkStartTime = currTime;
[4675]544 mjdX24 = chunkStartTime.mjddec() * 24.0;
[4590]545
[4679]546 if (xyzSta.size()) {
[4590]547 t_eph* eph = 0;
548 for (int ie = 0; ie < _ephs.size(); ie++) {
[5776]549 if (QString(_ephs[ie]->prn().toString().c_str()) == prn) {
[4590]550 eph = _ephs[ie];
551 break;
552 }
553 }
554
555 if (eph) {
556 double xSat, ySat, zSat, clkSat;
557 eph->position(oneObs->_GPSWeek, oneObs->_GPSWeeks,
558 xSat, ySat, zSat, clkSat);
559
560 double rho, eleSat, azSat;
[4679]561 topos(xyzSta(1), xyzSta(2), xyzSta(3),
562 xSat, ySat, zSat, rho, eleSat, azSat);
[4590]563
564 aziDeg = azSat * 180.0/M_PI;
565 zenDeg = 90.0 - eleSat * 180.0/M_PI;
[4659]566 zenFlag = true;
[4590]567 }
568 }
[4572]569 }
[4675]570
[4590]571 // Check Interval
572 // --------------
573 if (prevTime.valid()) {
[4591]574 double dt = currTime - prevTime;
575 if (dt != obsInterval) {
576 gapL1 = true;
577 gapL2 = true;
578 }
[4590]579 }
580 prevTime = currTime;
[4563]581
[4590]582 // Check L1 and L2 availability
583 // ----------------------------
584 if (oneObs->_hasL1) {
585 availL1 = true;
[4566]586 }
[4590]587 else {
[4591]588 gapL1 = true;
[4566]589 }
[4590]590 if (oneObs->_hasL2) {
591 availL2 = true;
592 }
593 else {
[4591]594 gapL2 = true;
[4590]595 }
596
597 // Check Minimal Signal-to-Noise Ratio
598 // -----------------------------------
599 if ( oneObs->_SNR1 > 0 && (minSNR1 == 0 || minSNR1 > oneObs->_SNR1) ) {
600 minSNR1 = oneObs->_SNR1;
601 }
602 if ( oneObs->_SNR2 > 0 && (minSNR2 == 0 || minSNR2 > oneObs->_SNR2) ) {
603 minSNR2 = oneObs->_SNR2;
604 }
605
[4607]606 // Check Slip Flags
607 // ----------------
608 if (oneObs->_slipL1) {
609 slipL1 = true;
610 }
611 if (oneObs->_slipL2) {
612 slipL2 = true;
613 }
614
[4698]615 meanMP1 += oneObs->_MP1;
616 meanMP2 += oneObs->_MP2;
617 }
618
619 // Compute the Multipath
620 // ---------------------
[5141]621 if ( (prn[0] == 'G' && plotGPS ) ||
622 (prn[0] == 'R' && plotGlo && slotSet) ||
623 (prn[0] == 'E' && plotGal ) ) {
[4700]624 bool slipMP = false;
625 meanMP1 /= numEpo;
626 meanMP2 /= numEpo;
627 double MP1 = 0.0;
628 double MP2 = 0.0;
629 for (int ii = 0; ii < numEpo; ii++) {
630 int iEpo = chunkStart + ii;
631 const t_oneObs* oneObs = allObs._oneObsVec[iEpo];
632 double diff1 = oneObs->_MP1 - meanMP1;
633 double diff2 = oneObs->_MP2 - meanMP2;
634
635 // Check Slip Threshold
636 // --------------------
637 if (fabs(diff1) > SLIPTRESH || fabs(diff2) > SLIPTRESH) {
638 slipMP = true;
639 break;
640 }
641
642 MP1 += diff1 * diff1;
643 MP2 += diff2 * diff2;
[4353]644 }
[4700]645 if (slipMP) {
646 slipL1 = true;
647 slipL2 = true;
[4702]648 if (!slipFound) {
649 slipFound = true;
650 _obsStat._prnStat[prn]._numSlipsFound += 1;
651 }
[4700]652 }
653 else {
654 MP1 = sqrt(MP1 / (numEpo-1));
655 MP2 = sqrt(MP2 / (numEpo-1));
656 (*dataMP1) << (new t_polarPoint(aziDeg, zenDeg, MP1));
657 (*dataMP2) << (new t_polarPoint(aziDeg, zenDeg, MP2));
658 }
[4353]659 }
660
[4590]661 // Availability Plot Data
662 // ----------------------
663 if (availL1) {
[4607]664 if (slipL1) {
[4617]665 _availDataMap[prn]._L1slip << mjdX24;
[4591]666 }
667 else if (gapL1) {
[4617]668 _availDataMap[prn]._L1gap << mjdX24;
[4591]669 }
670 else {
[4617]671 _availDataMap[prn]._L1ok << mjdX24;
[4591]672 }
[4351]673 }
[4591]674 if (availL2) {
[4607]675 if (slipL2) {
[4617]676 _availDataMap[prn]._L2slip << mjdX24;
[4591]677 }
678 else if (gapL2) {
[4617]679 _availDataMap[prn]._L2gap << mjdX24;
[4591]680 }
681 else {
[4617]682 _availDataMap[prn]._L2ok << mjdX24;
[4591]683 }
684 }
[4659]685 if (zenFlag) {
[4662]686 _availDataMap[prn]._eleTim << mjdX24;
687 _availDataMap[prn]._eleDeg << 90.0 - zenDeg;
[4659]688 }
[4351]689
[5142]690 // Signal-to-Noise Ratio Plot Data
691 // -------------------------------
[5143]692 if ( (prn[0] == 'G' && plotGPS) ||
693 (prn[0] == 'R' && plotGlo) ||
694 (prn[0] == 'E' && plotGal) ) {
[5141]695 (*dataSNR1) << (new t_polarPoint(aziDeg, zenDeg, minSNR1));
696 (*dataSNR2) << (new t_polarPoint(aziDeg, zenDeg, minSNR2));
697 }
[4350]698 }
699}
[4572]700
701//
702////////////////////////////////////////////////////////////////////////////
703void t_reqcAnalyze::slotDspAvailPlot(const QString& fileName,
[4584]704 const QByteArray& title) {
[4572]705
[5068]706 if (BNC_CORE->GUIenabled()) {
[4659]707 t_availPlot* plotA = new t_availPlot(0, &_availDataMap);
708 plotA->setTitle(title);
[4573]709
[4662]710 t_elePlot* plotZ = new t_elePlot(0, &_availDataMap);
[4659]711
[4672]712 t_dopPlot* plotD = new t_dopPlot(0, &_obsStat);
[4671]713
[4573]714 QVector<QWidget*> plots;
[4671]715 plots << plotA << plotZ << plotD;
[4573]716 t_graphWin* graphWin = new t_graphWin(0, fileName, plots, 0, 0);
[4666]717
718 int ww = QFontMetrics(graphWin->font()).width('w');
719 graphWin->setMinimumSize(120*ww, 40*ww);
720
[4573]721 graphWin->show();
722
723 bncSettings settings;
724 QString dirName = settings.value("reqcPlotDir").toString();
725 if (!dirName.isEmpty()) {
[4606]726 QByteArray ext = "_A.png";
[4579]727 graphWin->savePNG(dirName, ext);
[4573]728 }
729 }
[4715]730 _mutex.unlock();
[4572]731}
[4679]732
733// Compute Dilution of Precision
734////////////////////////////////////////////////////////////////////////////
735double t_reqcAnalyze::cmpDOP(const ColumnVector& xyzSta) const {
736
737 if (xyzSta.size() != 3) {
738 return 0.0;
739 }
740
741 unsigned nSat = _currEpo->rnxSat.size();
742
743 if (nSat < 4) {
744 return 0.0;
745 }
746
747 Matrix AA(nSat, 4);
748
749 unsigned nSatUsed = 0;
750 for (unsigned iSat = 0; iSat < nSat; iSat++) {
751
752 const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iSat];
753
754 QString prn = QString("%1%2").arg(rnxSat.satSys)
755 .arg(rnxSat.satNum, 2, 10, QChar('0'));
756
757 t_eph* eph = 0;
758 for (int ie = 0; ie < _ephs.size(); ie++) {
[5776]759 if (QString(_ephs[ie]->prn().toString().c_str()) == prn) {
[4679]760 eph = _ephs[ie];
761 break;
762 }
763 }
764 if (eph) {
765 ++nSatUsed;
766 ColumnVector xSat(3);
767 double clkSat;
768 eph->position(_currEpo->tt.gpsw(), _currEpo->tt.gpssec(),
769 xSat(1), xSat(2), xSat(3), clkSat);
770 ColumnVector dx = xSat - xyzSta;
[4681]771 double rho = dx.norm_Frobenius();
772 AA(nSatUsed,1) = dx(1) / rho;
773 AA(nSatUsed,2) = dx(2) / rho;
774 AA(nSatUsed,3) = dx(3) / rho;
775 AA(nSatUsed,4) = 1.0;
[4679]776 }
[4681]777 }
[4679]778
[4681]779 if (nSatUsed < 4) {
780 return 0.0;
[4679]781 }
782
[4681]783 AA = AA.Rows(1, nSatUsed);
784
785 SymmetricMatrix QQ;
786 QQ << AA.t() * AA;
787 QQ = QQ.i();
788
789 return sqrt(QQ.trace());
[4679]790}
[4689]791
792// Finish the report
793////////////////////////////////////////////////////////////////////////////
[4696]794void t_reqcAnalyze::printReport(QVector<t_polarPoint*>* dataMP1,
795 QVector<t_polarPoint*>* dataMP2,
796 QVector<t_polarPoint*>* dataSNR1,
797 QVector<t_polarPoint*>* dataSNR2) {
[5368]798
[4689]799 if (!_log) {
800 return;
801 }
802
[4701]803 *_log << "Marker name: " << _obsStat._markerName << endl
804 << "Receiver: " << _obsStat._receiverType << endl
805 << "Antenna: " << _obsStat._antennaName << endl
806 << "Start time: " << _obsStat._startTime.datestr().c_str() << ' '
807 << _obsStat._startTime.timestr().c_str() << endl
808 << "End time: " << _obsStat._endTime.datestr().c_str() << ' '
809 << _obsStat._endTime.timestr().c_str() << endl
810 << "Interval: " << _obsStat._interval << endl
811 << "# Sat.: " << _obsStat._prnStat.size() << endl;
[4689]812
[4701]813 int numObs = 0;
814 int numSlipsFlagged = 0;
815 int numSlipsFound = 0;
[4693]816 QMapIterator<QString, t_prnStat> it(_obsStat._prnStat);
817 while (it.hasNext()) {
818 it.next();
819 const t_prnStat& prnStat = it.value();
[4701]820 numObs += prnStat._numObs;
821 numSlipsFlagged += prnStat._numSlipsFlagged;
822 numSlipsFound += prnStat._numSlipsFound;
[4693]823 }
[4701]824 *_log << "# Obs.: " << numObs << endl
825 << "# Slips (file): " << numSlipsFlagged << endl
826 << "# Slips (found): " << numSlipsFound << endl;
[4693]827
[4697]828 for (int kk = 1; kk <= 4; kk++) {
829 QVector<t_polarPoint*>* data = 0;
830 QString text;
831 if (kk == 1) {
832 data = dataMP1;
[4701]833 text = "Mean MP1: ";
[4697]834 }
835 else if (kk == 2) {
836 data = dataMP2;
[4701]837 text = "Mean MP2: ";
[4697]838 }
839 else if (kk == 3) {
840 data = dataSNR1;
[4701]841 text = "Mean SNR1: ";
[4697]842 }
843 else if (kk == 4) {
844 data = dataSNR2;
[4701]845 text = "Mean SNR2: ";
[4697]846 }
847 double mean = 0.0;
848 for (int ii = 0; ii < data->size(); ii++) {
849 const t_polarPoint* point = data->at(ii);
850 mean += point->_value;
851 }
852 mean /= data->size();
853 *_log << text << mean << endl;
854 }
855
[4689]856 _log->flush();
857}
Note: See TracBrowser for help on using the repository browser.