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

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