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

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