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

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