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

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