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

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