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

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