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

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