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 "reqcanalyze.h"
|
---|
43 | #include "bncapp.h"
|
---|
44 | #include "bncsettings.h"
|
---|
45 | #include "reqcedit.h"
|
---|
46 | #include "bncutils.h"
|
---|
47 | #include "bncpostprocess.h"
|
---|
48 |
|
---|
49 | using namespace std;
|
---|
50 |
|
---|
51 | // Constructor
|
---|
52 | ////////////////////////////////////////////////////////////////////////////
|
---|
53 | t_reqcAnalyze::t_reqcAnalyze(QObject* parent) : QThread(parent) {
|
---|
54 |
|
---|
55 | bncSettings settings;
|
---|
56 |
|
---|
57 | _logFileName = settings.value("reqcOutLogFile").toString(); expandEnvVar(_logFileName);
|
---|
58 | _logFile = 0;
|
---|
59 | _log = 0;
|
---|
60 | _obsFileNames = settings.value("reqcObsFile").toString().split(",", QString::SkipEmptyParts);
|
---|
61 | _navFileNames = settings.value("reqcNavFile").toString().split(",", QString::SkipEmptyParts);
|
---|
62 |
|
---|
63 | _currEpo = 0;
|
---|
64 | }
|
---|
65 |
|
---|
66 | // Destructor
|
---|
67 | ////////////////////////////////////////////////////////////////////////////
|
---|
68 | t_reqcAnalyze::~t_reqcAnalyze() {
|
---|
69 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
70 | delete _rnxObsFiles[ii];
|
---|
71 | }
|
---|
72 | for (int ii = 0; ii < _ephs.size(); ii++) {
|
---|
73 | delete _ephs[ii];
|
---|
74 | }
|
---|
75 | delete _log; _log = 0;
|
---|
76 | delete _logFile; _logFile = 0;
|
---|
77 | }
|
---|
78 |
|
---|
79 | //
|
---|
80 | ////////////////////////////////////////////////////////////////////////////
|
---|
81 | void t_reqcAnalyze::run() {
|
---|
82 |
|
---|
83 | // Open Log File
|
---|
84 | // -------------
|
---|
85 | _logFile = new QFile(_logFileName);
|
---|
86 | _logFile->open(QIODevice::WriteOnly | QIODevice::Text);
|
---|
87 | _log = new QTextStream();
|
---|
88 | _log->setDevice(_logFile);
|
---|
89 |
|
---|
90 | // Initialize RINEX Observation Files
|
---|
91 | // ----------------------------------
|
---|
92 | t_reqcEdit::initRnxObsFiles(_obsFileNames, _rnxObsFiles);
|
---|
93 |
|
---|
94 | // Read Ephemerides
|
---|
95 | // ----------------
|
---|
96 | t_reqcEdit::readEphemerides(_navFileNames, _ephs);
|
---|
97 |
|
---|
98 | // Loop over all RINEX Files
|
---|
99 | // -------------------------
|
---|
100 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
101 | analyzeFile(_rnxObsFiles[ii]);
|
---|
102 | }
|
---|
103 |
|
---|
104 | // Exit
|
---|
105 | // ----
|
---|
106 | bncApp* app = (bncApp*) qApp;
|
---|
107 | if ( app->mode() != bncApp::interactive) {
|
---|
108 | app->exit(0);
|
---|
109 | }
|
---|
110 | else {
|
---|
111 | emit finished();
|
---|
112 | deleteLater();
|
---|
113 | }
|
---|
114 | }
|
---|
115 |
|
---|
116 | //
|
---|
117 | ////////////////////////////////////////////////////////////////////////////
|
---|
118 | void t_reqcAnalyze::analyzeFile(t_rnxObsFile* obsFile) {
|
---|
119 |
|
---|
120 | *_log << "Analyze File\n"
|
---|
121 | << "------------\n"
|
---|
122 | << obsFile->fileName().toAscii().data() << endl << endl;
|
---|
123 |
|
---|
124 | // Loop over all Epochs
|
---|
125 | // --------------------
|
---|
126 | while ( (_currEpo = obsFile->nextEpoch()) != 0) {
|
---|
127 |
|
---|
128 | // Loop over all satellites
|
---|
129 | // ------------------------
|
---|
130 | for (unsigned iObs = 0; iObs < _currEpo->rnxSat.size(); iObs++) {
|
---|
131 | const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iObs];
|
---|
132 | t_obs obs;
|
---|
133 | t_postProcessing::setObsFromRnx(obsFile, _currEpo, rnxSat, obs);
|
---|
134 |
|
---|
135 | if (obs.satSys == 'R') {
|
---|
136 | continue; // TODO: set channel number
|
---|
137 | }
|
---|
138 |
|
---|
139 | QString prn = QString("%1%2").arg(obs.satSys)
|
---|
140 | .arg(obs.satNum, 2, 10, QChar('0'));
|
---|
141 |
|
---|
142 | t_satStat& satStat = _satStat[prn];
|
---|
143 | satStat.addObs(obs);
|
---|
144 | }
|
---|
145 |
|
---|
146 | } // while (_currEpo)
|
---|
147 |
|
---|
148 | // Analyze the Multipath
|
---|
149 | // ---------------------
|
---|
150 | _log->setRealNumberNotation(QTextStream::FixedNotation);
|
---|
151 | _log->setRealNumberPrecision(2);
|
---|
152 |
|
---|
153 | QMapIterator<QString, t_satStat> it(_satStat);
|
---|
154 | while (it.hasNext()) {
|
---|
155 | it.next();
|
---|
156 | QString prn = it.key();
|
---|
157 | const t_satStat& satStat = it.value();
|
---|
158 |
|
---|
159 | for (int im = 1; im <= 2; im++) {
|
---|
160 | const QVector<double>& MP = (im == 1) ? satStat.MP1 : satStat.MP2;
|
---|
161 | if (MP.size() > 1) {
|
---|
162 | double mean = 0.0;
|
---|
163 | for (int ii = 0; ii < MP.size(); ii++) {
|
---|
164 | mean += MP[ii];
|
---|
165 | }
|
---|
166 | mean /= MP.size();
|
---|
167 | double stddev = 0.0;
|
---|
168 | for (int ii = 0; ii < MP.size(); ii++) {
|
---|
169 | double diff = MP[ii] - mean;
|
---|
170 | stddev += diff * diff;
|
---|
171 | }
|
---|
172 | double multipath = sqrt(stddev / (MP.size()-1));
|
---|
173 |
|
---|
174 | *_log << "MP" << im << " " << prn << " " << multipath << endl;
|
---|
175 | }
|
---|
176 | }
|
---|
177 |
|
---|
178 | }
|
---|
179 |
|
---|
180 | _log->flush();
|
---|
181 | }
|
---|
182 |
|
---|
183 | //
|
---|
184 | ////////////////////////////////////////////////////////////////////////////
|
---|
185 | void t_reqcAnalyze::t_satStat::addObs(const t_obs& obs) {
|
---|
186 | if (currObs) {
|
---|
187 | delete prevObs;
|
---|
188 | prevObs = currObs;
|
---|
189 | }
|
---|
190 | currObs = new t_anaObs(obs);
|
---|
191 |
|
---|
192 | // Compute the Multipath
|
---|
193 | // ----------------------
|
---|
194 | if (obs.l1() != 0.0 && obs.l2() != 0.0) {
|
---|
195 | double f1 = t_CST::f1(obs.satSys, obs.slotNum);
|
---|
196 | double f2 = t_CST::f2(obs.satSys, obs.slotNum);
|
---|
197 |
|
---|
198 | double L1 = obs.l1() * t_CST::c / f1;
|
---|
199 | double L2 = obs.l2() * t_CST::c / f2;
|
---|
200 |
|
---|
201 | if (obs.p1() != 0.0) {
|
---|
202 | currObs->M1 = obs.p1() - L1 - 2.0*f2*f2/(f1*f1-f2*f2) * (L1 - L2);
|
---|
203 | MP1 << currObs->M1;
|
---|
204 | }
|
---|
205 | if (obs.p2() != 0.0) {
|
---|
206 | currObs->M2 = obs.p2() - L2 - 2.0*f1*f1/(f1*f1-f2*f2) * (L1 - L2);
|
---|
207 | MP2 << currObs->M2;
|
---|
208 | }
|
---|
209 | }
|
---|
210 | }
|
---|