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

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