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 |
|
---|
56 | using namespace std;
|
---|
57 |
|
---|
58 | // Constructor
|
---|
59 | ////////////////////////////////////////////////////////////////////////////
|
---|
60 | t_reqcAnalyze::t_reqcAnalyze(QObject* parent) : QThread(parent) {
|
---|
61 |
|
---|
62 | bncSettings settings;
|
---|
63 |
|
---|
64 | _logFileName = settings.value("reqcOutLogFile").toString(); expandEnvVar(_logFileName);
|
---|
65 | _logFile = 0;
|
---|
66 | _log = 0;
|
---|
67 | _currEpo = 0;
|
---|
68 | _obsFileNames = settings.value("reqcObsFile").toString().split(",", QString::SkipEmptyParts);
|
---|
69 | _navFileNames = settings.value("reqcNavFile").toString().split(",", QString::SkipEmptyParts);
|
---|
70 |
|
---|
71 | connect(this, SIGNAL(dspSkyPlot(const QString&, const QByteArray&, QVector<t_polarPoint*>*,
|
---|
72 | const QByteArray&, QVector<t_polarPoint*>*,
|
---|
73 | const QByteArray&, double)),
|
---|
74 | this, SLOT(slotDspSkyPlot(const QString&, const QByteArray&, QVector<t_polarPoint*>*,
|
---|
75 | const QByteArray&, QVector<t_polarPoint*>*,
|
---|
76 | const QByteArray&, double)));
|
---|
77 |
|
---|
78 | connect(this, SIGNAL(dspAvailPlot(const QString&, const QByteArray&)),
|
---|
79 | this, SLOT(slotDspAvailPlot(const QString&, const QByteArray&)));
|
---|
80 | }
|
---|
81 |
|
---|
82 | // Destructor
|
---|
83 | ////////////////////////////////////////////////////////////////////////////
|
---|
84 | t_reqcAnalyze::~t_reqcAnalyze() {
|
---|
85 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
86 | delete _rnxObsFiles[ii];
|
---|
87 | }
|
---|
88 | for (int ii = 0; ii < _ephs.size(); ii++) {
|
---|
89 | delete _ephs[ii];
|
---|
90 | }
|
---|
91 | delete _log; _log = 0;
|
---|
92 | delete _logFile; _logFile = 0;
|
---|
93 | if (BNC_CORE->mode() != t_bncCore::interactive) {
|
---|
94 | qApp->exit(0);
|
---|
95 | }
|
---|
96 | }
|
---|
97 |
|
---|
98 | //
|
---|
99 | ////////////////////////////////////////////////////////////////////////////
|
---|
100 | void t_reqcAnalyze::run() {
|
---|
101 |
|
---|
102 | // Open Log File
|
---|
103 | // -------------
|
---|
104 | _logFile = new QFile(_logFileName);
|
---|
105 | if (_logFile->open(QIODevice::WriteOnly | QIODevice::Text)) {
|
---|
106 | _log = new QTextStream();
|
---|
107 | _log->setDevice(_logFile);
|
---|
108 | }
|
---|
109 |
|
---|
110 | // Initialize RINEX Observation Files
|
---|
111 | // ----------------------------------
|
---|
112 | t_reqcEdit::initRnxObsFiles(_obsFileNames, _rnxObsFiles, _log);
|
---|
113 |
|
---|
114 | // Read Ephemerides
|
---|
115 | // ----------------
|
---|
116 | t_reqcEdit::readEphemerides(_navFileNames, _ephs);
|
---|
117 |
|
---|
118 | // Loop over all RINEX Files
|
---|
119 | // -------------------------
|
---|
120 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
121 | analyzeFile(_rnxObsFiles[ii]);
|
---|
122 | }
|
---|
123 |
|
---|
124 | // Exit
|
---|
125 | // ----
|
---|
126 | emit finished();
|
---|
127 | deleteLater();
|
---|
128 | }
|
---|
129 |
|
---|
130 | //
|
---|
131 | ////////////////////////////////////////////////////////////////////////////
|
---|
132 | void t_reqcAnalyze::analyzeFile(t_rnxObsFile* obsFile) {
|
---|
133 |
|
---|
134 | QMutexLocker lock(&_mutex);
|
---|
135 |
|
---|
136 | if (_log) {
|
---|
137 | *_log << "\nAnalyze File\n"
|
---|
138 | << "------------\n"
|
---|
139 | << "File: " << obsFile->fileName().toAscii().data() << endl;
|
---|
140 | }
|
---|
141 |
|
---|
142 | _qcFile.clear();
|
---|
143 |
|
---|
144 | // A priori Coordinates
|
---|
145 | // --------------------
|
---|
146 | ColumnVector xyzSta = obsFile->xyz();
|
---|
147 |
|
---|
148 | // Loop over all Epochs
|
---|
149 | // --------------------
|
---|
150 | try {
|
---|
151 | bool firstEpo = true;
|
---|
152 | while ( (_currEpo = obsFile->nextEpoch()) != 0) {
|
---|
153 | if (firstEpo) {
|
---|
154 | firstEpo = false;
|
---|
155 | _qcFile._startTime = _currEpo->tt;
|
---|
156 | _qcFile._antennaName = obsFile->antennaName();
|
---|
157 | _qcFile._markerName = obsFile->markerName();
|
---|
158 | _qcFile._receiverType = obsFile->receiverType();
|
---|
159 | _qcFile._interval = obsFile->interval();
|
---|
160 | }
|
---|
161 | _qcFile._endTime = _currEpo->tt;
|
---|
162 |
|
---|
163 | t_qcEpo qcEpo;
|
---|
164 | qcEpo._epoTime = _currEpo->tt;
|
---|
165 | qcEpo._PDOP = cmpDOP(xyzSta);
|
---|
166 |
|
---|
167 | // Loop over all satellites
|
---|
168 | // ------------------------
|
---|
169 | for (unsigned iObs = 0; iObs < _currEpo->rnxSat.size(); iObs++) {
|
---|
170 | const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iObs];
|
---|
171 | t_satObs satObs;
|
---|
172 | t_rnxObsFile::setObsFromRnx(obsFile, _currEpo, rnxSat, satObs);
|
---|
173 | t_qcObs qcObs;
|
---|
174 | if (setQcObs(satObs, qcObs) == success) {
|
---|
175 | qcEpo._qcObs[satObs._prn] = qcObs;
|
---|
176 | updateQcSat(qcObs, _qcFile._qcSat[satObs._prn]);
|
---|
177 | }
|
---|
178 | }
|
---|
179 | _qcFile._qcEpo.push_back(qcEpo);
|
---|
180 | }
|
---|
181 |
|
---|
182 | preparePlotData(obsFile);
|
---|
183 |
|
---|
184 | printReport();
|
---|
185 | }
|
---|
186 | catch (QString str) {
|
---|
187 | if (_log) {
|
---|
188 | *_log << "Exception " << str << endl;
|
---|
189 | }
|
---|
190 | else {
|
---|
191 | qDebug() << str;
|
---|
192 | }
|
---|
193 | }
|
---|
194 | }
|
---|
195 |
|
---|
196 | // Compute Dilution of Precision
|
---|
197 | ////////////////////////////////////////////////////////////////////////////
|
---|
198 | double t_reqcAnalyze::cmpDOP(const ColumnVector& xyzSta) const {
|
---|
199 |
|
---|
200 | if (xyzSta.size() != 3) {
|
---|
201 | return 0.0;
|
---|
202 | }
|
---|
203 |
|
---|
204 | unsigned nSat = _currEpo->rnxSat.size();
|
---|
205 |
|
---|
206 | if (nSat < 4) {
|
---|
207 | return 0.0;
|
---|
208 | }
|
---|
209 |
|
---|
210 | Matrix AA(nSat, 4);
|
---|
211 |
|
---|
212 | unsigned nSatUsed = 0;
|
---|
213 | for (unsigned iSat = 0; iSat < nSat; iSat++) {
|
---|
214 |
|
---|
215 | const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iSat];
|
---|
216 | const t_prn& prn = rnxSat.prn;
|
---|
217 |
|
---|
218 | t_eph* eph = 0;
|
---|
219 | for (int ie = 0; ie < _ephs.size(); ie++) {
|
---|
220 | if (_ephs[ie]->prn() == prn) {
|
---|
221 | eph = _ephs[ie];
|
---|
222 | break;
|
---|
223 | }
|
---|
224 | }
|
---|
225 | if (eph) {
|
---|
226 | ColumnVector xSat(4);
|
---|
227 | ColumnVector vv(3);
|
---|
228 | if (eph->getCrd(_currEpo->tt, xSat, vv, false) == success) {
|
---|
229 | ++nSatUsed;
|
---|
230 | ColumnVector dx = xSat.Rows(1,3) - xyzSta;
|
---|
231 | double rho = dx.norm_Frobenius();
|
---|
232 | AA(nSatUsed,1) = dx(1) / rho;
|
---|
233 | AA(nSatUsed,2) = dx(2) / rho;
|
---|
234 | AA(nSatUsed,3) = dx(3) / rho;
|
---|
235 | AA(nSatUsed,4) = 1.0;
|
---|
236 | }
|
---|
237 | }
|
---|
238 | }
|
---|
239 |
|
---|
240 | if (nSatUsed < 4) {
|
---|
241 | return 0.0;
|
---|
242 | }
|
---|
243 |
|
---|
244 | AA = AA.Rows(1, nSatUsed);
|
---|
245 |
|
---|
246 | SymmetricMatrix QQ;
|
---|
247 | QQ << AA.t() * AA;
|
---|
248 | QQ = QQ.i();
|
---|
249 |
|
---|
250 | return sqrt(QQ.trace());
|
---|
251 | }
|
---|
252 |
|
---|
253 | //
|
---|
254 | ////////////////////////////////////////////////////////////////////////////
|
---|
255 | void t_reqcAnalyze::updateQcSat(const t_qcObs& qcObs, t_qcSat& qcSat) {
|
---|
256 | if (qcObs._hasL1 && qcObs._hasL2) {
|
---|
257 | qcSat._numObs += 1;
|
---|
258 | }
|
---|
259 | if (qcObs._slipL1 && qcObs._slipL2) {
|
---|
260 | qcSat._numSlipsFlagged += 1;
|
---|
261 | }
|
---|
262 | }
|
---|
263 |
|
---|
264 | //
|
---|
265 | ////////////////////////////////////////////////////////////////////////////
|
---|
266 | t_irc t_reqcAnalyze::setQcObs(const t_satObs& satObs, t_qcObs& qcObs) {
|
---|
267 |
|
---|
268 | if (satObs._prn.system() == 'R') {
|
---|
269 | t_ephGlo* ephGlo = 0;
|
---|
270 | for (int ie = 0; ie < _ephs.size(); ie++) {
|
---|
271 | if (_ephs[ie]->prn() == satObs._prn) {
|
---|
272 | ephGlo = dynamic_cast<t_ephGlo*>(_ephs[ie]);
|
---|
273 | break;
|
---|
274 | }
|
---|
275 | }
|
---|
276 | if (ephGlo) {
|
---|
277 | qcObs._slotSet = true;
|
---|
278 | qcObs._slotNum = ephGlo->slotNum();
|
---|
279 | }
|
---|
280 | }
|
---|
281 |
|
---|
282 | bool okFlag = false;
|
---|
283 |
|
---|
284 | // Availability and Slip Flags
|
---|
285 | // ---------------------------
|
---|
286 | double L1 = 0.0;
|
---|
287 | double L2 = 0.0;
|
---|
288 | double P1 = 0.0;
|
---|
289 | double P2 = 0.0;
|
---|
290 |
|
---|
291 | for (unsigned iFrq = 0; iFrq < satObs._obs.size(); iFrq++) {
|
---|
292 | const t_frqObs* frqObs = satObs._obs[iFrq];
|
---|
293 | if (frqObs->_rnxType2ch[0] == '1') {
|
---|
294 | if (frqObs->_phaseValid) {
|
---|
295 | L1 = frqObs->_phase;
|
---|
296 | qcObs._hasL1 = true;
|
---|
297 | qcObs._slipL1 = frqObs->_slip;
|
---|
298 | }
|
---|
299 | if (frqObs->_codeValid) {
|
---|
300 | P1 = frqObs->_code;
|
---|
301 | }
|
---|
302 | if (frqObs->_snrValid) {
|
---|
303 | qcObs._SNR1 = frqObs->_snr;
|
---|
304 | }
|
---|
305 | }
|
---|
306 | else if ( (satObs._prn.system() != 'E' && frqObs->_rnxType2ch[0] == '2') ||
|
---|
307 | (satObs._prn.system() == 'E' && frqObs->_rnxType2ch[0] == '5') ) {
|
---|
308 | if (frqObs->_phaseValid) {
|
---|
309 | L2 = frqObs->_phase;
|
---|
310 | qcObs._hasL2 = true;
|
---|
311 | qcObs._slipL2 = frqObs->_slip;
|
---|
312 | }
|
---|
313 | if (frqObs->_codeValid) {
|
---|
314 | P2 = frqObs->_code;
|
---|
315 | }
|
---|
316 | if (frqObs->_snrValid) {
|
---|
317 | qcObs._SNR2 = frqObs->_snr;
|
---|
318 | }
|
---|
319 | }
|
---|
320 | }
|
---|
321 |
|
---|
322 | // Compute the Multipath
|
---|
323 | // ----------------------
|
---|
324 | if (L1 != 0.0 && L2 != 0.0) {
|
---|
325 | double f1 = 0.0;
|
---|
326 | double f2 = 0.0;
|
---|
327 | if (satObs._prn.system() == 'G') {
|
---|
328 | f1 = t_CST::freq(t_frequency::G1, 0);
|
---|
329 | f2 = t_CST::freq(t_frequency::G2, 0);
|
---|
330 | }
|
---|
331 | else if (satObs._prn.system() == 'R') {
|
---|
332 | f1 = t_CST::freq(t_frequency::R1, qcObs._slotNum);
|
---|
333 | f2 = t_CST::freq(t_frequency::R2, qcObs._slotNum);
|
---|
334 | }
|
---|
335 | else if (satObs._prn.system() == 'E') {
|
---|
336 | f1 = t_CST::freq(t_frequency::E1, 0);
|
---|
337 | f2 = t_CST::freq(t_frequency::E5, 0);
|
---|
338 | }
|
---|
339 |
|
---|
340 | L1 = L1 * t_CST::c / f1;
|
---|
341 | L2 = L2 * t_CST::c / f2;
|
---|
342 |
|
---|
343 | if (P1 != 0.0) {
|
---|
344 | qcObs._MP1 = P1 - L1 - 2.0*f2*f2/(f1*f1-f2*f2) * (L1 - L2);
|
---|
345 | okFlag = true;
|
---|
346 | }
|
---|
347 | if (P2 != 0.0) {
|
---|
348 | qcObs._MP2 = P2 - L2 - 2.0*f1*f1/(f1*f1-f2*f2) * (L1 - L2);
|
---|
349 | okFlag = true;
|
---|
350 | }
|
---|
351 | }
|
---|
352 |
|
---|
353 | if (okFlag) {
|
---|
354 | return success;
|
---|
355 | }
|
---|
356 | else {
|
---|
357 | return failure;
|
---|
358 | }
|
---|
359 | }
|
---|
360 |
|
---|
361 | //
|
---|
362 | ////////////////////////////////////////////////////////////////////////////
|
---|
363 | void t_reqcAnalyze::preparePlotData(const t_rnxObsFile* obsFile) {
|
---|
364 |
|
---|
365 | ColumnVector xyzSta = obsFile->xyz();
|
---|
366 |
|
---|
367 | QVector<t_polarPoint*>* dataMP1 = new QVector<t_polarPoint*>;
|
---|
368 | QVector<t_polarPoint*>* dataMP2 = new QVector<t_polarPoint*>;
|
---|
369 | QVector<t_polarPoint*>* dataSNR1 = new QVector<t_polarPoint*>;
|
---|
370 | QVector<t_polarPoint*>* dataSNR2 = new QVector<t_polarPoint*>;
|
---|
371 |
|
---|
372 | const double SLIPTRESH = 10.0; // cycle-slip threshold (meters)
|
---|
373 | const double chunkStep = 600.0; // 10 minutes
|
---|
374 |
|
---|
375 | bncSettings settings;
|
---|
376 | QString reqSkyPlotSystems = settings.value("reqcSkyPlotSystems").toString();
|
---|
377 | bool plotGPS = false;
|
---|
378 | bool plotGlo = false;
|
---|
379 | bool plotGal = false;
|
---|
380 | if (reqSkyPlotSystems == "GPS") {
|
---|
381 | plotGPS = true;
|
---|
382 | }
|
---|
383 | else if (reqSkyPlotSystems == "GLONASS") {
|
---|
384 | plotGlo = true;
|
---|
385 | }
|
---|
386 | else if (reqSkyPlotSystems == "Galileo") {
|
---|
387 | plotGal = true;
|
---|
388 | }
|
---|
389 | else {
|
---|
390 | plotGPS = true;
|
---|
391 | plotGlo = true;
|
---|
392 | plotGal = true;
|
---|
393 | }
|
---|
394 |
|
---|
395 | // Loop over all satellites available
|
---|
396 | // ----------------------------------
|
---|
397 | QMutableMapIterator<t_prn, t_qcSat> it(_qcFile._qcSat);
|
---|
398 | while (it.hasNext()) {
|
---|
399 | it.next();
|
---|
400 | const t_prn& prn = it.key();
|
---|
401 | t_qcSat& qcSat = it.value();
|
---|
402 |
|
---|
403 | // Loop over all Chunks of Data
|
---|
404 | // ----------------------------
|
---|
405 | for (bncTime chunkStart = _qcFile._startTime;
|
---|
406 | chunkStart < _qcFile._endTime; chunkStart += chunkStep) {
|
---|
407 |
|
---|
408 | // Chunk (sampled) Epoch
|
---|
409 | // ---------------------
|
---|
410 | _qcFile._qcEpoSampled.push_back(t_qcEpo());
|
---|
411 | t_qcEpo& qcEpoSampled = _qcFile._qcEpoSampled.back();
|
---|
412 | t_qcObs& qcObsSampled = qcEpoSampled._qcObs[prn];
|
---|
413 |
|
---|
414 | QVector<double> MP1;
|
---|
415 | QVector<double> MP2;
|
---|
416 |
|
---|
417 | // Loop over all Epochs within one Chunk of Data
|
---|
418 | // ---------------------------------------------
|
---|
419 | bncTime prevTime;
|
---|
420 | for (int iEpo = 0; iEpo < _qcFile._qcEpo.size(); iEpo++) {
|
---|
421 | const t_qcEpo& qcEpo = _qcFile._qcEpo[iEpo];
|
---|
422 | if (qcEpo._epoTime < chunkStart) {
|
---|
423 | continue;
|
---|
424 | }
|
---|
425 | if (!qcEpo._qcObs.contains(prn)) {
|
---|
426 | continue;
|
---|
427 | }
|
---|
428 |
|
---|
429 | const t_qcObs& qcObs = qcEpo._qcObs[prn];
|
---|
430 |
|
---|
431 | // Compute the Azimuth and Zenith Distance
|
---|
432 | // ---------------------------------------
|
---|
433 | if (chunkStart == qcEpo._epoTime) {
|
---|
434 | qcEpoSampled._epoTime = qcEpo._epoTime;
|
---|
435 | qcEpoSampled._PDOP = qcEpo._PDOP;
|
---|
436 |
|
---|
437 | if (qcObs._slotSet) {
|
---|
438 | qcObsSampled._slotSet = true;
|
---|
439 | qcObsSampled._slotNum = qcObs._slotNum;
|
---|
440 | }
|
---|
441 | if (xyzSta.size()) {
|
---|
442 | t_eph* eph = 0;
|
---|
443 | for (int ie = 0; ie < _ephs.size(); ie++) {
|
---|
444 | if (_ephs[ie]->prn() == prn) {
|
---|
445 | eph = _ephs[ie];
|
---|
446 | break;
|
---|
447 | }
|
---|
448 | }
|
---|
449 | if (eph) {
|
---|
450 | ColumnVector xc(4);
|
---|
451 | ColumnVector vv(3);
|
---|
452 | if (eph->getCrd(qcEpo._epoTime, xc, vv, false) == success) {
|
---|
453 | double rho, eleSat, azSat;
|
---|
454 | topos(xyzSta(1), xyzSta(2), xyzSta(3), xc(1), xc(2), xc(3), rho, eleSat, azSat);
|
---|
455 | qcObsSampled._azDeg = azSat * 180.0/M_PI;
|
---|
456 | qcObsSampled._eleDeg = eleSat * 180.0/M_PI;
|
---|
457 | }
|
---|
458 | }
|
---|
459 | }
|
---|
460 | }
|
---|
461 |
|
---|
462 | // Check Interval
|
---|
463 | // --------------
|
---|
464 | if (prevTime.valid()) {
|
---|
465 | double dt = qcEpo._epoTime - prevTime;
|
---|
466 | if (dt > 1.5 * _qcFile._interval) {
|
---|
467 | qcObsSampled._gapL1 = true;
|
---|
468 | qcObsSampled._gapL2 = true;
|
---|
469 | }
|
---|
470 | }
|
---|
471 | prevTime = qcEpo._epoTime;
|
---|
472 |
|
---|
473 | // Check L1 and L2 availability
|
---|
474 | // ----------------------------
|
---|
475 | if (qcObs._hasL1) {
|
---|
476 | qcObsSampled._hasL1 = true;
|
---|
477 | }
|
---|
478 | if (qcObs._hasL2) {
|
---|
479 | qcObsSampled._hasL2 = true;
|
---|
480 | }
|
---|
481 |
|
---|
482 | // Check Minimal Signal-to-Noise Ratio
|
---|
483 | // -----------------------------------
|
---|
484 | if ( qcObs._SNR1 > 0 && (qcObsSampled._SNR1 == 0 || qcObsSampled._SNR1 > qcObs._SNR1) ) {
|
---|
485 | qcObsSampled._SNR1 = qcObs._SNR1;
|
---|
486 | }
|
---|
487 | if ( qcObs._SNR2 > 0 && (qcObsSampled._SNR2 == 0 || qcObsSampled._SNR2 > qcObs._SNR2) ) {
|
---|
488 | qcObsSampled._SNR2 = qcObs._SNR2;
|
---|
489 | }
|
---|
490 |
|
---|
491 | // Check Slip Flags
|
---|
492 | // ----------------
|
---|
493 | if (qcObs._slipL1) {
|
---|
494 | qcObsSampled._slipL1 = true;
|
---|
495 | }
|
---|
496 | if (qcObs._slipL2) {
|
---|
497 | qcObsSampled._slipL2 = true;
|
---|
498 | }
|
---|
499 |
|
---|
500 | MP1 << qcObs._MP1;
|
---|
501 | MP2 << qcObs._MP2;
|
---|
502 | }
|
---|
503 |
|
---|
504 | // Compute the Multipath
|
---|
505 | // ---------------------
|
---|
506 | if ( MP1.size() > 0 && MP2.size() > 0 &&
|
---|
507 | ( (prn.system() == 'G' && plotGPS ) ||
|
---|
508 | (prn.system() == 'R' && plotGlo && qcObsSampled._slotSet) ||
|
---|
509 | (prn.system() == 'E' && plotGal ) ) ) {
|
---|
510 |
|
---|
511 | double meanMP1 = 0.0;
|
---|
512 | double meanMP2 = 0.0;
|
---|
513 | for (int ii = 0; ii < MP1.size(); ii++) {
|
---|
514 | meanMP1 += MP1[ii];
|
---|
515 | meanMP2 += MP2[ii];
|
---|
516 | }
|
---|
517 | meanMP1 /= MP1.size();
|
---|
518 | meanMP2 /= MP2.size();
|
---|
519 |
|
---|
520 | bool slipMP = false;
|
---|
521 | double stdMP1 = 0.0;
|
---|
522 | double stdMP2 = 0.0;
|
---|
523 | for (int ii = 0; ii < MP1.size(); ii++) {
|
---|
524 | double diff1 = MP1[ii] - meanMP1;
|
---|
525 | double diff2 = MP2[ii] - meanMP2;
|
---|
526 | if (fabs(diff1) > SLIPTRESH || fabs(diff2) > SLIPTRESH) {
|
---|
527 | slipMP = true;
|
---|
528 | break;
|
---|
529 | }
|
---|
530 | stdMP1 += diff1 * diff1;
|
---|
531 | stdMP1 += diff2 * diff2;
|
---|
532 | }
|
---|
533 |
|
---|
534 | if (slipMP) {
|
---|
535 | qcObsSampled._slipL1 = true;
|
---|
536 | qcObsSampled._slipL2 = true;
|
---|
537 | qcSat._numSlipsFound += 1;
|
---|
538 | }
|
---|
539 | else {
|
---|
540 | stdMP1 = sqrt(stdMP1 / MP1.size());
|
---|
541 | stdMP2 = sqrt(stdMP2 / MP2.size());
|
---|
542 | (*dataMP1) << (new t_polarPoint(qcObsSampled._azDeg, 90.0 - qcObsSampled._eleDeg, stdMP1));
|
---|
543 | (*dataMP2) << (new t_polarPoint(qcObsSampled._azDeg, 90.0 - qcObsSampled._eleDeg, stdMP2));
|
---|
544 | }
|
---|
545 | }
|
---|
546 |
|
---|
547 | // Signal-to-Noise Ratio Plot Data
|
---|
548 | // -------------------------------
|
---|
549 | if ( (prn.system() == 'G' && plotGPS) ||
|
---|
550 | (prn.system() == 'R' && plotGlo) ||
|
---|
551 | (prn.system() == 'E' && plotGal) ) {
|
---|
552 | (*dataSNR1) << (new t_polarPoint(qcObsSampled._azDeg, 90.0 - qcObsSampled._eleDeg, qcObsSampled._SNR1));
|
---|
553 | (*dataSNR2) << (new t_polarPoint(qcObsSampled._azDeg, 90.0 - qcObsSampled._eleDeg, qcObsSampled._SNR2));
|
---|
554 | }
|
---|
555 | }
|
---|
556 | }
|
---|
557 |
|
---|
558 | // Show the plots
|
---|
559 | // --------------
|
---|
560 | if (BNC_CORE->GUIenabled()) {
|
---|
561 | QFileInfo fileInfo(obsFile->fileName());
|
---|
562 | QByteArray title = fileInfo.fileName().toAscii();
|
---|
563 | emit dspSkyPlot(obsFile->fileName(), "MP1", dataMP1, "MP2", dataMP2, "Meters", 2.0);
|
---|
564 | emit dspSkyPlot(obsFile->fileName(), "SNR1", dataSNR1, "SNR2", dataSNR2, "dbHz", 54.0);
|
---|
565 | emit dspAvailPlot(obsFile->fileName(), title);
|
---|
566 | }
|
---|
567 | else {
|
---|
568 | for (int ii = 0; ii < dataMP1->size(); ii++) {
|
---|
569 | delete dataMP1->at(ii);
|
---|
570 | }
|
---|
571 | delete dataMP1;
|
---|
572 | for (int ii = 0; ii < dataMP2->size(); ii++) {
|
---|
573 | delete dataMP2->at(ii);
|
---|
574 | }
|
---|
575 | delete dataMP2;
|
---|
576 | for (int ii = 0; ii < dataSNR1->size(); ii++) {
|
---|
577 | delete dataSNR1->at(ii);
|
---|
578 | }
|
---|
579 | delete dataSNR1;
|
---|
580 | for (int ii = 0; ii < dataSNR2->size(); ii++) {
|
---|
581 | delete dataSNR2->at(ii);
|
---|
582 | }
|
---|
583 | delete dataSNR2;
|
---|
584 | }
|
---|
585 | }
|
---|
586 |
|
---|
587 | //
|
---|
588 | ////////////////////////////////////////////////////////////////////////////
|
---|
589 | void t_reqcAnalyze::slotDspSkyPlot(const QString& fileName, const QByteArray& title1,
|
---|
590 | QVector<t_polarPoint*>* data1, const QByteArray& title2,
|
---|
591 | QVector<t_polarPoint*>* data2, const QByteArray& scaleTitle,
|
---|
592 | double maxValue) {
|
---|
593 |
|
---|
594 | if (BNC_CORE->GUIenabled()) {
|
---|
595 |
|
---|
596 | if (maxValue == 0.0) {
|
---|
597 | if (data1) {
|
---|
598 | for (int ii = 0; ii < data1->size(); ii++) {
|
---|
599 | double val = data1->at(ii)->_value;
|
---|
600 | if (maxValue < val) {
|
---|
601 | maxValue = val;
|
---|
602 | }
|
---|
603 | }
|
---|
604 | }
|
---|
605 | if (data2) {
|
---|
606 | for (int ii = 0; ii < data2->size(); ii++) {
|
---|
607 | double val = data2->at(ii)->_value;
|
---|
608 | if (maxValue < val) {
|
---|
609 | maxValue = val;
|
---|
610 | }
|
---|
611 | }
|
---|
612 | }
|
---|
613 | }
|
---|
614 |
|
---|
615 | QwtInterval scaleInterval(0.0, maxValue);
|
---|
616 |
|
---|
617 | QVector<QWidget*> plots;
|
---|
618 | if (data1) {
|
---|
619 | t_polarPlot* plot1 = new t_polarPlot(QwtText(title1), scaleInterval,
|
---|
620 | BNC_CORE->mainWindow());
|
---|
621 | plot1->addCurve(data1);
|
---|
622 | plots << plot1;
|
---|
623 | }
|
---|
624 | if (data2) {
|
---|
625 | t_polarPlot* plot2 = new t_polarPlot(QwtText(title2), scaleInterval,
|
---|
626 | BNC_CORE->mainWindow());
|
---|
627 | plot2->addCurve(data2);
|
---|
628 | plots << plot2;
|
---|
629 | }
|
---|
630 |
|
---|
631 | t_graphWin* graphWin = new t_graphWin(0, fileName, plots,
|
---|
632 | &scaleTitle, &scaleInterval);
|
---|
633 |
|
---|
634 | graphWin->show();
|
---|
635 |
|
---|
636 | bncSettings settings;
|
---|
637 | QString dirName = settings.value("reqcPlotDir").toString();
|
---|
638 | if (!dirName.isEmpty()) {
|
---|
639 | QByteArray ext = (scaleTitle == "Meters") ? "_M.png" : "_S.png";
|
---|
640 | graphWin->savePNG(dirName, ext);
|
---|
641 | }
|
---|
642 | }
|
---|
643 | }
|
---|
644 |
|
---|
645 | //
|
---|
646 | ////////////////////////////////////////////////////////////////////////////
|
---|
647 | void t_reqcAnalyze::slotDspAvailPlot(const QString& fileName, const QByteArray& title) {
|
---|
648 |
|
---|
649 | QMap<t_prn, t_plotData> plotData;
|
---|
650 |
|
---|
651 | if (BNC_CORE->GUIenabled()) {
|
---|
652 | t_availPlot* plotA = new t_availPlot(0, plotData);
|
---|
653 | plotA->setTitle(title);
|
---|
654 |
|
---|
655 | t_elePlot* plotZ = new t_elePlot(0, plotData);
|
---|
656 |
|
---|
657 | t_dopPlot* plotD = new t_dopPlot(0, plotData);
|
---|
658 |
|
---|
659 | QVector<QWidget*> plots;
|
---|
660 | plots << plotA << plotZ << plotD;
|
---|
661 | t_graphWin* graphWin = new t_graphWin(0, fileName, plots, 0, 0);
|
---|
662 |
|
---|
663 | int ww = QFontMetrics(graphWin->font()).width('w');
|
---|
664 | graphWin->setMinimumSize(120*ww, 40*ww);
|
---|
665 |
|
---|
666 | graphWin->show();
|
---|
667 |
|
---|
668 | bncSettings settings;
|
---|
669 | QString dirName = settings.value("reqcPlotDir").toString();
|
---|
670 | if (!dirName.isEmpty()) {
|
---|
671 | QByteArray ext = "_A.png";
|
---|
672 | graphWin->savePNG(dirName, ext);
|
---|
673 | }
|
---|
674 | }
|
---|
675 | }
|
---|
676 |
|
---|
677 | // Finish the report
|
---|
678 | ////////////////////////////////////////////////////////////////////////////
|
---|
679 | void t_reqcAnalyze::printReport() {
|
---|
680 |
|
---|
681 | if (!_log) {
|
---|
682 | return;
|
---|
683 | }
|
---|
684 |
|
---|
685 | *_log << "Marker name: " << _qcFile._markerName << endl
|
---|
686 | << "Receiver: " << _qcFile._receiverType << endl
|
---|
687 | << "Antenna: " << _qcFile._antennaName << endl
|
---|
688 | << "Start time: " << _qcFile._startTime.datestr().c_str() << ' '
|
---|
689 | << _qcFile._startTime.timestr().c_str() << endl
|
---|
690 | << "End time: " << _qcFile._endTime.datestr().c_str() << ' '
|
---|
691 | << _qcFile._endTime.timestr().c_str() << endl
|
---|
692 | << "Interval: " << _qcFile._interval << endl
|
---|
693 | << "# Sat.: " << _qcFile._qcSat.size() << endl;
|
---|
694 |
|
---|
695 | int numObs = 0;
|
---|
696 | int numSlipsFlagged = 0;
|
---|
697 | int numSlipsFound = 0;
|
---|
698 | QMapIterator<t_prn, t_qcSat> it(_qcFile._qcSat);
|
---|
699 | while (it.hasNext()) {
|
---|
700 | it.next();
|
---|
701 | const t_qcSat& qcSat = it.value();
|
---|
702 | numObs += qcSat._numObs;
|
---|
703 | numSlipsFlagged += qcSat._numSlipsFlagged;
|
---|
704 | numSlipsFound += qcSat._numSlipsFound;
|
---|
705 | }
|
---|
706 | *_log << "# Obs.: " << numObs << endl
|
---|
707 | << "# Slips (file): " << numSlipsFlagged << endl
|
---|
708 | << "# Slips (found): " << numSlipsFound << endl;
|
---|
709 |
|
---|
710 | _log->flush();
|
---|
711 | }
|
---|