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

Last change on this file since 4705 was 4705, 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 }
[4705]279 _mutex.unlock();
[4541]280 return;
281 }
[4262]282
[4268]283 // Analyze the Multipath
284 // ---------------------
[4572]285 QVector<t_polarPoint*>* dataMP1 = new QVector<t_polarPoint*>;
286 QVector<t_polarPoint*>* dataMP2 = new QVector<t_polarPoint*>;
287 QVector<t_polarPoint*>* dataSNR1 = new QVector<t_polarPoint*>;
288 QVector<t_polarPoint*>* dataSNR2 = new QVector<t_polarPoint*>;
[4268]289
[4584]290 QMutableMapIterator<QString, t_allObs> it(_allObsMap);
[4268]291 while (it.hasNext()) {
292 it.next();
[4584]293 QString prn = it.key();
[4679]294 preparePlotData(prn, xyzSta, obsFile->interval(),
[4675]295 dataMP1, dataMP2, dataSNR1, dataSNR2);
[4268]296 }
297
[4572]298 emit dspSkyPlot(obsFile->fileName(), "MP1", dataMP1, "MP2", dataMP2,
299 "Meters", 2.0);
[4300]300
[4572]301 emit dspSkyPlot(obsFile->fileName(), "SNR1", dataSNR1, "SNR2", dataSNR2,
302 "", 9.0);
303
[4605]304 QFileInfo fileInfo(obsFile->fileName());
305 QByteArray title = fileInfo.fileName().toAscii();
[4572]306
[4605]307 emit dspAvailPlot(obsFile->fileName(), title);
308
[4696]309 printReport(dataMP1, dataMP2, dataSNR1, dataSNR2);
[4254]310}
[4263]311
312//
313////////////////////////////////////////////////////////////////////////////
[4694]314t_irc t_reqcAnalyze::t_allObs::addObs(const t_obs& obs) {
[4265]315
[4584]316 t_oneObs* newObs = new t_oneObs(obs.GPSWeek, obs.GPSWeeks);
[4354]317 bool okFlag = false;
[4338]318
[4608]319 // Availability and Slip Flags
320 // ---------------------------
[4424]321 double L1 = obs.measdata("L1", 3.0);
[4571]322 if (L1 != 0) {
323 newObs->_hasL1 = true;
324 }
[4424]325 double L2 = obs.measdata("L2", 3.0);
[4571]326 if (L2 != 0) {
327 newObs->_hasL2 = true;
328 }
[4608]329 if (obs.slipL1) {
330 newObs->_slipL1 = true;
331 }
332 if (obs.slipL2) {
333 newObs->_slipL2 = true;
334 }
335
336 // Compute the Multipath
337 // ----------------------
[4391]338 if (L1 != 0.0 && L2 != 0.0) {
[4266]339 double f1 = t_CST::f1(obs.satSys, obs.slotNum);
340 double f2 = t_CST::f2(obs.satSys, obs.slotNum);
341
[4391]342 L1 = L1 * t_CST::c / f1;
343 L2 = L2 * t_CST::c / f2;
[4266]344
[4424]345 double P1 = obs.measdata("C1", 3.0);
[4391]346 if (P1 != 0.0) {
347 newObs->_MP1 = P1 - L1 - 2.0*f2*f2/(f1*f1-f2*f2) * (L1 - L2);
[4354]348 okFlag = true;
[4268]349 }
[4424]350 double P2 = obs.measdata("C2", 3.0);
[4391]351 if (P2 != 0.0) {
352 newObs->_MP2 = P2 - L2 - 2.0*f1*f1/(f1*f1-f2*f2) * (L1 - L2);
[4354]353 okFlag = true;
[4268]354 }
[4265]355 }
[4338]356
[4559]357 // Signal-to-Noise
358 // ---------------
359 double S1 = obs.measdata("S1", 3.0);
360 if (S1 != 0.0) {
[4562]361 newObs->_SNR1 = floor(S1/6);
362 if (newObs->_SNR1 > 9.0) {
363 newObs->_SNR1 = 9.0;
364 }
365 if (newObs->_SNR1 < 1.0) {
366 newObs->_SNR1 = 1.0;
367 }
[4559]368 okFlag = true;
369 }
[4562]370 else {
371 if (obs.snrL1 > 0) {
372 newObs->_SNR1 = obs.snrL1;
373 okFlag = true;
374 }
375 }
[4559]376 double S2 = obs.measdata("S2", 3.0);
377 if (S2 != 0.0) {
[4562]378 newObs->_SNR2 = floor(S2/6);
379 if (newObs->_SNR2 > 9.0) {
380 newObs->_SNR2 = 9.0;
381 }
382 if (newObs->_SNR2 < 1.0) {
383 newObs->_SNR2 = 1.0;
384 }
[4559]385 okFlag = true;
386 }
[4562]387 else {
388 if (obs.snrL2 > 0) {
389 newObs->_SNR2 = obs.snrL2;
390 okFlag = true;
391 }
392 }
[4559]393
[4354]394 // Remember the Observation
395 // ------------------------
396 if (okFlag) {
[4584]397 _oneObsVec << newObs;
[4694]398 return success;
[4354]399 }
400 else {
401 delete newObs;
[4694]402 return failure;
[4354]403 }
[4263]404}
[4350]405
406//
407////////////////////////////////////////////////////////////////////////////
[4679]408void t_reqcAnalyze::prepareObsStat(unsigned iEpo, double obsInterval,
409 const ColumnVector& xyzSta) {
[4677]410 const int sampl = int(30.0 / obsInterval);
411 if (iEpo % sampl == 0) {
[4676]412 double mjdX24 = _currEpo->tt.mjddec() * 24.0;
413 if (iEpo != 0) {
414 _obsStat._mjdX24 << mjdX24;
415 _obsStat._numSat << _obsStat._numSat.last();
[4680]416 _obsStat._PDOP << _obsStat._PDOP.last();
[4676]417 }
418 _obsStat._mjdX24 << mjdX24;
[4675]419 _obsStat._numSat << _currEpo->rnxSat.size();
[4680]420 _obsStat._PDOP << cmpDOP(xyzSta);
[4675]421 }
422}
423
424//
425////////////////////////////////////////////////////////////////////////////
[4679]426void t_reqcAnalyze::preparePlotData(const QString& prn,
427 const ColumnVector& xyzSta,
[4572]428 double obsInterval,
429 QVector<t_polarPoint*>* dataMP1,
430 QVector<t_polarPoint*>* dataMP2,
431 QVector<t_polarPoint*>* dataSNR1,
[4675]432 QVector<t_polarPoint*>* dataSNR2) {
[4350]433
[4544]434 const int chunkStep = int( 30.0 / obsInterval); // chunk step (30 sec)
435 const int numEpo = int(600.0 / obsInterval); // # epochs in one chunk (10 min)
[4350]436
[4584]437 t_allObs& allObs = _allObsMap[prn];
438
[4591]439 // Loop over all Chunks of Data
440 // ----------------------------
[4702]441 bool slipFound = false;
[4584]442 for (int chunkStart = 0; chunkStart + numEpo < allObs._oneObsVec.size();
[4361]443 chunkStart += chunkStep) {
[4351]444
[4703]445 if (chunkStart * chunkStep == numEpo) {
[4702]446 slipFound = false;
447 }
448
[4675]449 // Chunk-Specific Variables
450 // ------------------------
[4591]451 bncTime currTime;
452 bncTime prevTime;
[4590]453 bncTime chunkStartTime;
[4675]454 double mjdX24 = 0.0;
[4607]455 bool availL1 = false;
456 bool availL2 = false;
457 bool gapL1 = false;
458 bool gapL2 = false;
459 bool slipL1 = false;
460 bool slipL2 = false;
461 double meanMP1 = 0.0;
462 double meanMP2 = 0.0;
463 double minSNR1 = 0.0;
464 double minSNR2 = 0.0;
465 double aziDeg = 0.0;
466 double zenDeg = 0.0;
[4659]467 bool zenFlag = false;
[4353]468
[4591]469 // Loop over all Epochs within one Chunk of Data
470 // ---------------------------------------------
[4361]471 for (int ii = 0; ii < numEpo; ii++) {
[4351]472 int iEpo = chunkStart + ii;
[4584]473 const t_oneObs* oneObs = allObs._oneObsVec[iEpo];
[4572]474
[4590]475 currTime.set(oneObs->_GPSWeek, oneObs->_GPSWeeks);
476
477 // Compute the Azimuth and Zenith Distance
478 // ---------------------------------------
[4572]479 if (ii == 0) {
[4590]480 chunkStartTime = currTime;
[4675]481 mjdX24 = chunkStartTime.mjddec() * 24.0;
[4590]482
[4679]483 if (xyzSta.size()) {
[4590]484 t_eph* eph = 0;
485 for (int ie = 0; ie < _ephs.size(); ie++) {
486 if (_ephs[ie]->prn() == prn) {
487 eph = _ephs[ie];
488 break;
489 }
490 }
491
492 if (eph) {
493 double xSat, ySat, zSat, clkSat;
494 eph->position(oneObs->_GPSWeek, oneObs->_GPSWeeks,
495 xSat, ySat, zSat, clkSat);
496
497 double rho, eleSat, azSat;
[4679]498 topos(xyzSta(1), xyzSta(2), xyzSta(3),
499 xSat, ySat, zSat, rho, eleSat, azSat);
[4590]500
501 aziDeg = azSat * 180.0/M_PI;
502 zenDeg = 90.0 - eleSat * 180.0/M_PI;
[4659]503 zenFlag = true;
[4590]504 }
505 }
[4572]506 }
[4675]507
[4590]508 // Check Interval
509 // --------------
510 if (prevTime.valid()) {
[4591]511 double dt = currTime - prevTime;
512 if (dt != obsInterval) {
513 gapL1 = true;
514 gapL2 = true;
515 }
[4590]516 }
517 prevTime = currTime;
[4563]518
[4590]519 // Check L1 and L2 availability
520 // ----------------------------
521 if (oneObs->_hasL1) {
522 availL1 = true;
[4566]523 }
[4590]524 else {
[4591]525 gapL1 = true;
[4566]526 }
[4590]527 if (oneObs->_hasL2) {
528 availL2 = true;
529 }
530 else {
[4591]531 gapL2 = true;
[4590]532 }
533
534 // Check Minimal Signal-to-Noise Ratio
535 // -----------------------------------
536 if ( oneObs->_SNR1 > 0 && (minSNR1 == 0 || minSNR1 > oneObs->_SNR1) ) {
537 minSNR1 = oneObs->_SNR1;
538 }
539 if ( oneObs->_SNR2 > 0 && (minSNR2 == 0 || minSNR2 > oneObs->_SNR2) ) {
540 minSNR2 = oneObs->_SNR2;
541 }
542
[4607]543 // Check Slip Flags
544 // ----------------
545 if (oneObs->_slipL1) {
546 slipL1 = true;
547 }
548 if (oneObs->_slipL2) {
549 slipL2 = true;
550 }
551
[4698]552 meanMP1 += oneObs->_MP1;
553 meanMP2 += oneObs->_MP2;
554 }
555
556 // Compute the Multipath
557 // ---------------------
[4700]558 if (prn[0] != 'R') { // TODO
559 bool slipMP = false;
560 meanMP1 /= numEpo;
561 meanMP2 /= numEpo;
562 double MP1 = 0.0;
563 double MP2 = 0.0;
564 for (int ii = 0; ii < numEpo; ii++) {
565 int iEpo = chunkStart + ii;
566 const t_oneObs* oneObs = allObs._oneObsVec[iEpo];
567 double diff1 = oneObs->_MP1 - meanMP1;
568 double diff2 = oneObs->_MP2 - meanMP2;
569
570 // Check Slip Threshold
571 // --------------------
572 if (fabs(diff1) > SLIPTRESH || fabs(diff2) > SLIPTRESH) {
573 slipMP = true;
574 break;
575 }
576
577 MP1 += diff1 * diff1;
578 MP2 += diff2 * diff2;
[4353]579 }
[4700]580 if (slipMP) {
581 slipL1 = true;
582 slipL2 = true;
[4702]583 if (!slipFound) {
584 slipFound = true;
585 _obsStat._prnStat[prn]._numSlipsFound += 1;
586 }
[4700]587 }
588 else {
589 MP1 = sqrt(MP1 / (numEpo-1));
590 MP2 = sqrt(MP2 / (numEpo-1));
591 (*dataMP1) << (new t_polarPoint(aziDeg, zenDeg, MP1));
592 (*dataMP2) << (new t_polarPoint(aziDeg, zenDeg, MP2));
593 }
[4353]594 }
595
[4590]596 // Availability Plot Data
597 // ----------------------
598 if (availL1) {
[4607]599 if (slipL1) {
[4617]600 _availDataMap[prn]._L1slip << mjdX24;
[4591]601 }
602 else if (gapL1) {
[4617]603 _availDataMap[prn]._L1gap << mjdX24;
[4591]604 }
605 else {
[4617]606 _availDataMap[prn]._L1ok << mjdX24;
[4591]607 }
[4351]608 }
[4591]609 if (availL2) {
[4607]610 if (slipL2) {
[4617]611 _availDataMap[prn]._L2slip << mjdX24;
[4591]612 }
613 else if (gapL2) {
[4617]614 _availDataMap[prn]._L2gap << mjdX24;
[4591]615 }
616 else {
[4617]617 _availDataMap[prn]._L2ok << mjdX24;
[4591]618 }
619 }
[4659]620 if (zenFlag) {
[4662]621 _availDataMap[prn]._eleTim << mjdX24;
622 _availDataMap[prn]._eleDeg << 90.0 - zenDeg;
[4659]623 }
[4351]624
[4590]625 // Signal-to-Noise Ration Plot Data
626 // --------------------------------
627 (*dataSNR1) << (new t_polarPoint(aziDeg, zenDeg, minSNR1));
628 (*dataSNR2) << (new t_polarPoint(aziDeg, zenDeg, minSNR2));
[4350]629 }
630}
[4572]631
632//
633////////////////////////////////////////////////////////////////////////////
634void t_reqcAnalyze::slotDspAvailPlot(const QString& fileName,
[4584]635 const QByteArray& title) {
[4572]636
[4704]637 _mutex.unlock();
638 QMutexLocker locker(&_mutex);
639
[4574]640 if (dynamic_cast<bncApp*>(qApp)->GUIenabled()) {
[4573]641
[4659]642 t_availPlot* plotA = new t_availPlot(0, &_availDataMap);
643 plotA->setTitle(title);
[4573]644
[4662]645 t_elePlot* plotZ = new t_elePlot(0, &_availDataMap);
[4659]646
[4672]647 t_dopPlot* plotD = new t_dopPlot(0, &_obsStat);
[4671]648
[4573]649 QVector<QWidget*> plots;
[4671]650 plots << plotA << plotZ << plotD;
[4573]651 t_graphWin* graphWin = new t_graphWin(0, fileName, plots, 0, 0);
[4666]652
653 int ww = QFontMetrics(graphWin->font()).width('w');
654 graphWin->setMinimumSize(120*ww, 40*ww);
655
[4573]656 graphWin->show();
657
658 bncSettings settings;
659 QString dirName = settings.value("reqcPlotDir").toString();
660 if (!dirName.isEmpty()) {
[4606]661 QByteArray ext = "_A.png";
[4579]662 graphWin->savePNG(dirName, ext);
[4573]663 }
664 }
[4572]665}
[4679]666
667// Compute Dilution of Precision
668////////////////////////////////////////////////////////////////////////////
669double t_reqcAnalyze::cmpDOP(const ColumnVector& xyzSta) const {
670
671 if (xyzSta.size() != 3) {
672 return 0.0;
673 }
674
675 unsigned nSat = _currEpo->rnxSat.size();
676
677 if (nSat < 4) {
678 return 0.0;
679 }
680
681 Matrix AA(nSat, 4);
682
683 unsigned nSatUsed = 0;
684 for (unsigned iSat = 0; iSat < nSat; iSat++) {
685
686 const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iSat];
687
688 QString prn = QString("%1%2").arg(rnxSat.satSys)
689 .arg(rnxSat.satNum, 2, 10, QChar('0'));
690
691 t_eph* eph = 0;
692 for (int ie = 0; ie < _ephs.size(); ie++) {
693 if (_ephs[ie]->prn() == prn) {
694 eph = _ephs[ie];
695 break;
696 }
697 }
698 if (eph) {
699 ++nSatUsed;
700 ColumnVector xSat(3);
701 double clkSat;
702 eph->position(_currEpo->tt.gpsw(), _currEpo->tt.gpssec(),
703 xSat(1), xSat(2), xSat(3), clkSat);
704 ColumnVector dx = xSat - xyzSta;
[4681]705 double rho = dx.norm_Frobenius();
706 AA(nSatUsed,1) = dx(1) / rho;
707 AA(nSatUsed,2) = dx(2) / rho;
708 AA(nSatUsed,3) = dx(3) / rho;
709 AA(nSatUsed,4) = 1.0;
[4679]710 }
[4681]711 }
[4679]712
[4681]713 if (nSatUsed < 4) {
714 return 0.0;
[4679]715 }
716
[4681]717 AA = AA.Rows(1, nSatUsed);
718
719 SymmetricMatrix QQ;
720 QQ << AA.t() * AA;
721 QQ = QQ.i();
722
723 return sqrt(QQ.trace());
[4679]724}
[4689]725
726// Finish the report
727////////////////////////////////////////////////////////////////////////////
[4696]728void t_reqcAnalyze::printReport(QVector<t_polarPoint*>* dataMP1,
729 QVector<t_polarPoint*>* dataMP2,
730 QVector<t_polarPoint*>* dataSNR1,
731 QVector<t_polarPoint*>* dataSNR2) {
[4689]732 if (!_log) {
733 return;
734 }
735
[4701]736 *_log << "Marker name: " << _obsStat._markerName << endl
737 << "Receiver: " << _obsStat._receiverType << endl
738 << "Antenna: " << _obsStat._antennaName << endl
739 << "Start time: " << _obsStat._startTime.datestr().c_str() << ' '
740 << _obsStat._startTime.timestr().c_str() << endl
741 << "End time: " << _obsStat._endTime.datestr().c_str() << ' '
742 << _obsStat._endTime.timestr().c_str() << endl
743 << "Interval: " << _obsStat._interval << endl
744 << "# Sat.: " << _obsStat._prnStat.size() << endl;
[4689]745
[4701]746 int numObs = 0;
747 int numSlipsFlagged = 0;
748 int numSlipsFound = 0;
[4693]749 QMapIterator<QString, t_prnStat> it(_obsStat._prnStat);
750 while (it.hasNext()) {
751 it.next();
752 const t_prnStat& prnStat = it.value();
[4701]753 numObs += prnStat._numObs;
754 numSlipsFlagged += prnStat._numSlipsFlagged;
755 numSlipsFound += prnStat._numSlipsFound;
[4693]756 }
[4701]757 *_log << "# Obs.: " << numObs << endl
758 << "# Slips (file): " << numSlipsFlagged << endl
759 << "# Slips (found): " << numSlipsFound << endl;
[4693]760
[4697]761 for (int kk = 1; kk <= 4; kk++) {
762 QVector<t_polarPoint*>* data = 0;
763 QString text;
764 if (kk == 1) {
765 data = dataMP1;
[4701]766 text = "Mean MP1: ";
[4697]767 }
768 else if (kk == 2) {
769 data = dataMP2;
[4701]770 text = "Mean MP2: ";
[4697]771 }
772 else if (kk == 3) {
773 data = dataSNR1;
[4701]774 text = "Mean SNR1: ";
[4697]775 }
776 else if (kk == 4) {
777 data = dataSNR2;
[4701]778 text = "Mean SNR2: ";
[4697]779 }
780 double mean = 0.0;
781 for (int ii = 0; ii < data->size(); ii++) {
782 const t_polarPoint* point = data->at(ii);
783 mean += point->_value;
784 }
785 mean /= data->size();
786 *_log << text << mean << endl;
787 }
788
[4689]789 _log->flush();
790}
Note: See TracBrowser for help on using the repository browser.