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

Last change on this file since 6269 was 6269, checked in by mervart, 9 years ago
File size: 24.1 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 *
[6255]37 * Changes:
[3899]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
[6255]74 connect(this, SIGNAL(dspSkyPlot(const QString&,
[4572]75 const QByteArray&,
[6255]76 QVector<t_polarPoint*>*,
[4572]77 const QByteArray&,
78 QVector<t_polarPoint*>*,
[6255]79 const QByteArray&, double)),
80 this, SLOT(slotDspSkyPlot(const QString&,
[4556]81 const QByteArray&,
[6255]82 QVector<t_polarPoint*>*,
[4556]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
[6255]107//
[3899]108////////////////////////////////////////////////////////////////////////////
[6255]109void t_reqcAnalyze::slotDspSkyPlot(const QString& fileName,
[4572]110 const QByteArray& title1,
[6255]111 QVector<t_polarPoint*>* data1,
[4572]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 }
[6255]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
[6255]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()) {
[6256]162 QByteArray ext = (scaleTitle == "Meters") ? "_M.png" : "_S.png";
[4579]163 graphWin->savePNG(dirName, ext);
[4451]164 }
[4308]165 }
[4300]166}
167
[6255]168//
[4300]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
[6255]200//
[4254]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;
[6255]234
[4541]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);
[6255]241
[6269]242 const t_prn& prn = obs._prn;
[6255]243
[6137]244 t_ephGlo* ephGlo = 0;
245 int slotNum = 0;
[6269]246 if (prn.system() == 'R') {
[5140]247 for (int ie = 0; ie < _ephs.size(); ie++) {
[6269]248 if (_ephs[ie]->prn() == 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 }
[6255]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 }
[6255]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 {
[6255]284 qDebug() << str;
[4541]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
[6269]297 QMutableMapIterator<t_prn, t_allObs> it(_allObsMap);
[4268]298 while (it.hasNext()) {
299 it.next();
[6269]300 const t_prn& prn = it.key();
[6255]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();
[6255]312 emit dspSkyPlot(obsFile->fileName(), "MP1", dataMP1, "MP2", dataMP2,
[4718]313 "Meters", 2.0);
[6255]314 double mean = 0.0;
315 for (int ii = 0; ii < dataSNR1->size(); ii++) {
316 const t_polarPoint* point = dataSNR1->at(ii);
317 mean += point->_value;
318 }
[6257]319 if (dataSNR1->size() > 0) {
320 mean /= dataSNR1->size();
321 }
[6255]322 double max = (mean > 9.0) ? 54.0 : 9.0;
323 QByteArray str = (mean > 9.0) ? "dbHz" : "";
324 emit dspSkyPlot(obsFile->fileName(), "SNR1", dataSNR1, "SNR2", dataSNR2,
325 str, max);
[4718]326 emit dspAvailPlot(obsFile->fileName(), title);
327 }
328 else {
329 for (int ii = 0; ii < dataMP1->size(); ii++) {
330 delete dataMP1->at(ii);
331 }
332 delete dataMP1;
333 for (int ii = 0; ii < dataMP2->size(); ii++) {
334 delete dataMP2->at(ii);
335 }
336 delete dataMP2;
337 for (int ii = 0; ii < dataSNR1->size(); ii++) {
338 delete dataSNR1->at(ii);
339 }
340 delete dataSNR1;
341 for (int ii = 0; ii < dataSNR2->size(); ii++) {
342 delete dataSNR2->at(ii);
343 }
344 delete dataSNR2;
345 _mutex.unlock();
346 }
[4254]347}
[4263]348
[6255]349//
[4263]350////////////////////////////////////////////////////////////////////////////
[6255]351t_irc t_reqcAnalyze::t_allObs::addObs(const t_satObs& obs, int slotNum) {
[4265]352
[6137]353 t_oneObs* newObs = new t_oneObs(obs._time.gpsw(), obs._time.gpssec());
[4354]354 bool okFlag = false;
[4338]355
[4608]356 // Availability and Slip Flags
357 // ---------------------------
[6137]358 double L1 = 0.0;
359 double L2 = 0.0;
360 double P1 = 0.0;
361 double P2 = 0.0;
362
363 for (unsigned iFrq = 0; iFrq < obs._obs.size(); iFrq++) {
364 const t_frqObs* frqObs = obs._obs[iFrq];
365 if (frqObs->_rnxType2ch[0] == '1') {
366 if (frqObs->_phaseValid) {
367 L1 = frqObs->_phase;
368 newObs->_hasL1 = true;
369 newObs->_slipL1 = frqObs->_slip;
370 }
371 if (frqObs->_codeValid) {
[6255]372 P1 = frqObs->_code;
[6137]373 }
374 if (frqObs->_snrValid) {
[6255]375 newObs->_SNR1 = frqObs->_snr;
[6137]376 }
377 }
378 else if ( (obs._prn.system() != 'E' && frqObs->_rnxType2ch[0] == '2') ||
379 (obs._prn.system() == 'E' && frqObs->_rnxType2ch[0] == '5') ) {
380 if (frqObs->_phaseValid) {
381 L2 = frqObs->_phase;
382 newObs->_hasL2 = true;
383 newObs->_slipL2 = frqObs->_slip;
384 }
385 if (frqObs->_codeValid) {
[6255]386 P2 = frqObs->_code;
[6137]387 }
388 if (frqObs->_snrValid) {
[6255]389 newObs->_SNR2 = frqObs->_snr;
[6137]390 }
391 }
[4571]392 }
[4608]393
394 // Compute the Multipath
395 // ----------------------
[4391]396 if (L1 != 0.0 && L2 != 0.0) {
[6017]397 double f1 = 0.0;
398 double f2 = 0.0;
[6137]399 if (obs._prn.system() == 'G') {
[6017]400 f1 = t_CST::freq(t_frequency::G1, 0);
401 f2 = t_CST::freq(t_frequency::G2, 0);
402 }
[6137]403 else if (obs._prn.system() == 'R') {
404 f1 = t_CST::freq(t_frequency::R1, slotNum);
405 f2 = t_CST::freq(t_frequency::R2, slotNum);
[6017]406 }
[6137]407 else if (obs._prn.system() == 'E') {
[6017]408 f1 = t_CST::freq(t_frequency::E1, 0);
409 f2 = t_CST::freq(t_frequency::E5, 0);
410 }
[4266]411
[4391]412 L1 = L1 * t_CST::c / f1;
413 L2 = L2 * t_CST::c / f2;
[4266]414
[4391]415 if (P1 != 0.0) {
416 newObs->_MP1 = P1 - L1 - 2.0*f2*f2/(f1*f1-f2*f2) * (L1 - L2);
[4354]417 okFlag = true;
[4268]418 }
[4391]419 if (P2 != 0.0) {
420 newObs->_MP2 = P2 - L2 - 2.0*f1*f1/(f1*f1-f2*f2) * (L1 - L2);
[4354]421 okFlag = true;
[4268]422 }
[4265]423 }
[4338]424
[4354]425 // Remember the Observation
426 // ------------------------
427 if (okFlag) {
[4584]428 _oneObsVec << newObs;
[4694]429 return success;
[4354]430 }
431 else {
432 delete newObs;
[4694]433 return failure;
[4354]434 }
[4263]435}
[4350]436
[6255]437//
[4350]438////////////////////////////////////////////////////////////////////////////
[4679]439void t_reqcAnalyze::prepareObsStat(unsigned iEpo, double obsInterval,
440 const ColumnVector& xyzSta) {
[4677]441 const int sampl = int(30.0 / obsInterval);
442 if (iEpo % sampl == 0) {
[4676]443 double mjdX24 = _currEpo->tt.mjddec() * 24.0;
444 if (iEpo != 0) {
445 _obsStat._mjdX24 << mjdX24;
446 _obsStat._numSat << _obsStat._numSat.last();
[4680]447 _obsStat._PDOP << _obsStat._PDOP.last();
[4676]448 }
449 _obsStat._mjdX24 << mjdX24;
[4675]450 _obsStat._numSat << _currEpo->rnxSat.size();
[4680]451 _obsStat._PDOP << cmpDOP(xyzSta);
[4675]452 }
453}
454
[6255]455//
[4675]456////////////////////////////////////////////////////////////////////////////
[6269]457void t_reqcAnalyze::preparePlotData(const t_prn& prn,
[4679]458 const ColumnVector& xyzSta,
[4572]459 double obsInterval,
[6255]460 QVector<t_polarPoint*>* dataMP1,
[4572]461 QVector<t_polarPoint*>* dataMP2,
[6255]462 QVector<t_polarPoint*>* dataSNR1,
[4675]463 QVector<t_polarPoint*>* dataSNR2) {
[4350]464
[6255]465 const int chunkStep = int( 30.0 / obsInterval); // chunk step (30 sec)
[4544]466 const int numEpo = int(600.0 / obsInterval); // # epochs in one chunk (10 min)
[4350]467
[4584]468 t_allObs& allObs = _allObsMap[prn];
469
[5141]470 bncSettings settings;
471 QString reqSkyPlotSystems = settings.value("reqcSkyPlotSystems").toString();
472 bool plotGPS = false;
473 bool plotGlo = false;
474 bool plotGal = false;
475 if (reqSkyPlotSystems == "GPS") {
476 plotGPS = true;
477 }
478 else if (reqSkyPlotSystems == "GLONASS") {
479 plotGlo = true;
480 }
481 else if (reqSkyPlotSystems == "Galileo") {
482 plotGal = true;
483 }
484 else {
485 plotGPS = true;
486 plotGlo = true;
487 plotGal = true;
488 }
489
[4591]490 // Loop over all Chunks of Data
491 // ----------------------------
[4702]492 bool slipFound = false;
[4584]493 for (int chunkStart = 0; chunkStart + numEpo < allObs._oneObsVec.size();
[4361]494 chunkStart += chunkStep) {
[4351]495
[4703]496 if (chunkStart * chunkStep == numEpo) {
[4702]497 slipFound = false;
498 }
499
[6255]500 // Chunk-Specific Variables
[4675]501 // ------------------------
[4591]502 bncTime currTime;
503 bncTime prevTime;
[4590]504 bncTime chunkStartTime;
[4675]505 double mjdX24 = 0.0;
[4607]506 bool availL1 = false;
507 bool availL2 = false;
508 bool gapL1 = false;
509 bool gapL2 = false;
510 bool slipL1 = false;
511 bool slipL2 = false;
512 double meanMP1 = 0.0;
513 double meanMP2 = 0.0;
514 double minSNR1 = 0.0;
515 double minSNR2 = 0.0;
516 double aziDeg = 0.0;
517 double zenDeg = 0.0;
[4659]518 bool zenFlag = false;
[4353]519
[4591]520 // Loop over all Epochs within one Chunk of Data
521 // ---------------------------------------------
[5140]522 bool slotSet = false;
[4361]523 for (int ii = 0; ii < numEpo; ii++) {
[4351]524 int iEpo = chunkStart + ii;
[4584]525 const t_oneObs* oneObs = allObs._oneObsVec[iEpo];
[5140]526 if (oneObs->_slotSet) {
527 slotSet = true;
528 }
[4572]529
[4590]530 currTime.set(oneObs->_GPSWeek, oneObs->_GPSWeeks);
531
532 // Compute the Azimuth and Zenith Distance
533 // ---------------------------------------
[4572]534 if (ii == 0) {
[4590]535 chunkStartTime = currTime;
[4675]536 mjdX24 = chunkStartTime.mjddec() * 24.0;
[4590]537
[4679]538 if (xyzSta.size()) {
[4590]539 t_eph* eph = 0;
540 for (int ie = 0; ie < _ephs.size(); ie++) {
[6269]541 if (_ephs[ie]->prn() == prn) {
[4590]542 eph = _ephs[ie];
543 break;
544 }
545 }
[6255]546
[4590]547 if (eph) {
[6109]548 ColumnVector xc(4);
549 ColumnVector vv(3);
[6213]550 if (eph->getCrd(bncTime(oneObs->_GPSWeek, oneObs->_GPSWeeks), xc, vv, false) == success) {
551 double rho, eleSat, azSat;
552 topos(xyzSta(1), xyzSta(2), xyzSta(3), xc(1), xc(2), xc(3), rho, eleSat, azSat);
553 aziDeg = azSat * 180.0/M_PI;
554 zenDeg = 90.0 - eleSat * 180.0/M_PI;
555 zenFlag = true;
556 }
[4590]557 }
558 }
[4572]559 }
[6255]560
[4590]561 // Check Interval
562 // --------------
563 if (prevTime.valid()) {
[4591]564 double dt = currTime - prevTime;
[6267]565 if (dt > 1.5 * obsInterval) {
[4591]566 gapL1 = true;
567 gapL2 = true;
568 }
[4590]569 }
570 prevTime = currTime;
[4563]571
[4590]572 // Check L1 and L2 availability
573 // ----------------------------
574 if (oneObs->_hasL1) {
575 availL1 = true;
[4566]576 }
[4590]577 else {
[4591]578 gapL1 = true;
[4566]579 }
[4590]580 if (oneObs->_hasL2) {
581 availL2 = true;
582 }
583 else {
[4591]584 gapL2 = true;
[4590]585 }
586
587 // Check Minimal Signal-to-Noise Ratio
588 // -----------------------------------
589 if ( oneObs->_SNR1 > 0 && (minSNR1 == 0 || minSNR1 > oneObs->_SNR1) ) {
590 minSNR1 = oneObs->_SNR1;
591 }
592 if ( oneObs->_SNR2 > 0 && (minSNR2 == 0 || minSNR2 > oneObs->_SNR2) ) {
593 minSNR2 = oneObs->_SNR2;
594 }
595
[4607]596 // Check Slip Flags
597 // ----------------
598 if (oneObs->_slipL1) {
599 slipL1 = true;
600 }
601 if (oneObs->_slipL2) {
602 slipL2 = true;
603 }
604
[4698]605 meanMP1 += oneObs->_MP1;
606 meanMP2 += oneObs->_MP2;
607 }
608
609 // Compute the Multipath
610 // ---------------------
[6269]611 if ( (prn.system() == 'G' && plotGPS ) ||
612 (prn.system() == 'R' && plotGlo && slotSet) ||
613 (prn.system() == 'E' && plotGal ) ) {
[4700]614 bool slipMP = false;
615 meanMP1 /= numEpo;
616 meanMP2 /= numEpo;
617 double MP1 = 0.0;
618 double MP2 = 0.0;
619 for (int ii = 0; ii < numEpo; ii++) {
620 int iEpo = chunkStart + ii;
621 const t_oneObs* oneObs = allObs._oneObsVec[iEpo];
622 double diff1 = oneObs->_MP1 - meanMP1;
623 double diff2 = oneObs->_MP2 - meanMP2;
[6255]624
[4700]625 // Check Slip Threshold
626 // --------------------
627 if (fabs(diff1) > SLIPTRESH || fabs(diff2) > SLIPTRESH) {
628 slipMP = true;
629 break;
630 }
[6255]631
[4700]632 MP1 += diff1 * diff1;
633 MP2 += diff2 * diff2;
[4353]634 }
[4700]635 if (slipMP) {
636 slipL1 = true;
637 slipL2 = true;
[4702]638 if (!slipFound) {
639 slipFound = true;
640 _obsStat._prnStat[prn]._numSlipsFound += 1;
641 }
[6255]642 }
[4700]643 else {
644 MP1 = sqrt(MP1 / (numEpo-1));
645 MP2 = sqrt(MP2 / (numEpo-1));
646 (*dataMP1) << (new t_polarPoint(aziDeg, zenDeg, MP1));
647 (*dataMP2) << (new t_polarPoint(aziDeg, zenDeg, MP2));
648 }
[4353]649 }
650
[4590]651 // Availability Plot Data
652 // ----------------------
653 if (availL1) {
[4607]654 if (slipL1) {
[4617]655 _availDataMap[prn]._L1slip << mjdX24;
[4591]656 }
657 else if (gapL1) {
[4617]658 _availDataMap[prn]._L1gap << mjdX24;
[4591]659 }
660 else {
[4617]661 _availDataMap[prn]._L1ok << mjdX24;
[4591]662 }
[4351]663 }
[4591]664 if (availL2) {
[4607]665 if (slipL2) {
[4617]666 _availDataMap[prn]._L2slip << mjdX24;
[4591]667 }
668 else if (gapL2) {
[4617]669 _availDataMap[prn]._L2gap << mjdX24;
[4591]670 }
671 else {
[4617]672 _availDataMap[prn]._L2ok << mjdX24;
[4591]673 }
674 }
[4659]675 if (zenFlag) {
[4662]676 _availDataMap[prn]._eleTim << mjdX24;
677 _availDataMap[prn]._eleDeg << 90.0 - zenDeg;
[4659]678 }
[4351]679
[5142]680 // Signal-to-Noise Ratio Plot Data
681 // -------------------------------
[6269]682 if ( (prn.system() == 'G' && plotGPS) ||
683 (prn.system() == 'R' && plotGlo) ||
684 (prn.system() == 'E' && plotGal) ) {
[5141]685 (*dataSNR1) << (new t_polarPoint(aziDeg, zenDeg, minSNR1));
686 (*dataSNR2) << (new t_polarPoint(aziDeg, zenDeg, minSNR2));
687 }
[4350]688 }
689}
[4572]690
[6255]691//
[4572]692////////////////////////////////////////////////////////////////////////////
[6255]693void t_reqcAnalyze::slotDspAvailPlot(const QString& fileName,
[4584]694 const QByteArray& title) {
[4572]695
[5068]696 if (BNC_CORE->GUIenabled()) {
[4659]697 t_availPlot* plotA = new t_availPlot(0, &_availDataMap);
698 plotA->setTitle(title);
[4573]699
[4662]700 t_elePlot* plotZ = new t_elePlot(0, &_availDataMap);
[4659]701
[4672]702 t_dopPlot* plotD = new t_dopPlot(0, &_obsStat);
[4671]703
[4573]704 QVector<QWidget*> plots;
[4671]705 plots << plotA << plotZ << plotD;
[4573]706 t_graphWin* graphWin = new t_graphWin(0, fileName, plots, 0, 0);
[4666]707
708 int ww = QFontMetrics(graphWin->font()).width('w');
709 graphWin->setMinimumSize(120*ww, 40*ww);
710
[4573]711 graphWin->show();
712
713 bncSettings settings;
714 QString dirName = settings.value("reqcPlotDir").toString();
715 if (!dirName.isEmpty()) {
[4606]716 QByteArray ext = "_A.png";
[4579]717 graphWin->savePNG(dirName, ext);
[4573]718 }
719 }
[4715]720 _mutex.unlock();
[4572]721}
[4679]722
723// Compute Dilution of Precision
724////////////////////////////////////////////////////////////////////////////
725double t_reqcAnalyze::cmpDOP(const ColumnVector& xyzSta) const {
726
727 if (xyzSta.size() != 3) {
728 return 0.0;
729 }
730
731 unsigned nSat = _currEpo->rnxSat.size();
732
733 if (nSat < 4) {
734 return 0.0;
735 }
736
737 Matrix AA(nSat, 4);
738
739 unsigned nSatUsed = 0;
740 for (unsigned iSat = 0; iSat < nSat; iSat++) {
741
742 const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iSat];
[6122]743 const t_prn& prn = rnxSat.prn;
[4679]744
745 t_eph* eph = 0;
746 for (int ie = 0; ie < _ephs.size(); ie++) {
[6122]747 if (_ephs[ie]->prn() == prn) {
[4679]748 eph = _ephs[ie];
749 break;
750 }
751 }
752 if (eph) {
[6109]753 ColumnVector xSat(4);
754 ColumnVector vv(3);
[6213]755 if (eph->getCrd(_currEpo->tt, xSat, vv, false) == success) {
756 ++nSatUsed;
757 ColumnVector dx = xSat.Rows(1,3) - xyzSta;
758 double rho = dx.norm_Frobenius();
759 AA(nSatUsed,1) = dx(1) / rho;
760 AA(nSatUsed,2) = dx(2) / rho;
761 AA(nSatUsed,3) = dx(3) / rho;
762 AA(nSatUsed,4) = 1.0;
763 }
[4679]764 }
[4681]765 }
[4679]766
[4681]767 if (nSatUsed < 4) {
768 return 0.0;
[4679]769 }
770
[4681]771 AA = AA.Rows(1, nSatUsed);
772
[6255]773 SymmetricMatrix QQ;
[4681]774 QQ << AA.t() * AA;
775 QQ = QQ.i();
776
777 return sqrt(QQ.trace());
[4679]778}
[4689]779
780// Finish the report
781////////////////////////////////////////////////////////////////////////////
[4696]782void t_reqcAnalyze::printReport(QVector<t_polarPoint*>* dataMP1,
783 QVector<t_polarPoint*>* dataMP2,
784 QVector<t_polarPoint*>* dataSNR1,
785 QVector<t_polarPoint*>* dataSNR2) {
[5368]786
[4689]787 if (!_log) {
788 return;
789 }
790
[6255]791 *_log << "Marker name: " << _obsStat._markerName << endl
[4701]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;
[6269]804 QMapIterator<t_prn, t_prnStat> it(_obsStat._prnStat);
[4693]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 }
[6257]840 if (data->size() > 0) {
841 mean /= data->size();
842 }
[4697]843 *_log << text << mean << endl;
844 }
845
[4689]846 _log->flush();
847}
Note: See TracBrowser for help on using the repository browser.