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

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