[3899] | 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"
|
---|
[3973] | 43 | #include "bncapp.h"
|
---|
[3899] | 44 | #include "bncsettings.h"
|
---|
[4254] | 45 | #include "reqcedit.h"
|
---|
[4255] | 46 | #include "bncutils.h"
|
---|
[4262] | 47 | #include "bncpostprocess.h"
|
---|
[4300] | 48 | #include "graphwin.h"
|
---|
[4307] | 49 | #include "polarplot.h"
|
---|
[3899] | 50 |
|
---|
| 51 | using namespace std;
|
---|
| 52 |
|
---|
| 53 | // Constructor
|
---|
| 54 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 55 | t_reqcAnalyze::t_reqcAnalyze(QObject* parent) : QThread(parent) {
|
---|
| 56 |
|
---|
| 57 | bncSettings settings;
|
---|
[4254] | 58 |
|
---|
[4257] | 59 | _logFileName = settings.value("reqcOutLogFile").toString(); expandEnvVar(_logFileName);
|
---|
| 60 | _logFile = 0;
|
---|
| 61 | _log = 0;
|
---|
[4254] | 62 | _obsFileNames = settings.value("reqcObsFile").toString().split(",", QString::SkipEmptyParts);
|
---|
[4257] | 63 | _navFileNames = settings.value("reqcNavFile").toString().split(",", QString::SkipEmptyParts);
|
---|
[4266] | 64 |
|
---|
| 65 | _currEpo = 0;
|
---|
[4300] | 66 |
|
---|
| 67 | connect(this, SIGNAL(displayGraph()), this, SLOT(slotDisplayGraph()));
|
---|
[3899] | 68 | }
|
---|
| 69 |
|
---|
| 70 | // Destructor
|
---|
| 71 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 72 | t_reqcAnalyze::~t_reqcAnalyze() {
|
---|
[4255] | 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;
|
---|
[3899] | 81 | }
|
---|
| 82 |
|
---|
| 83 | //
|
---|
| 84 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4300] | 85 | void t_reqcAnalyze::slotDisplayGraph() {
|
---|
[4308] | 86 | if (((bncApp*) qApp)->mode() == bncApp::interactive) {
|
---|
| 87 | QVector<t_polarPlot*> 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 | }
|
---|
[4300] | 94 | }
|
---|
| 95 |
|
---|
| 96 | //
|
---|
| 97 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3899] | 98 | void t_reqcAnalyze::run() {
|
---|
| 99 |
|
---|
[4255] | 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 | // ----------------------------------
|
---|
[4254] | 109 | t_reqcEdit::initRnxObsFiles(_obsFileNames, _rnxObsFiles);
|
---|
[3899] | 110 |
|
---|
[4257] | 111 | // Read Ephemerides
|
---|
| 112 | // ----------------
|
---|
| 113 | t_reqcEdit::readEphemerides(_navFileNames, _ephs);
|
---|
| 114 |
|
---|
[4255] | 115 | // Loop over all RINEX Files
|
---|
| 116 | // -------------------------
|
---|
[4254] | 117 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 118 | analyzeFile(_rnxObsFiles[ii]);
|
---|
| 119 | }
|
---|
| 120 |
|
---|
[4255] | 121 | // Exit
|
---|
| 122 | // ----
|
---|
[3973] | 123 | bncApp* app = (bncApp*) qApp;
|
---|
| 124 | if ( app->mode() != bncApp::interactive) {
|
---|
| 125 | app->exit(0);
|
---|
| 126 | }
|
---|
| 127 | else {
|
---|
| 128 | emit finished();
|
---|
| 129 | deleteLater();
|
---|
| 130 | }
|
---|
[3899] | 131 | }
|
---|
[4254] | 132 |
|
---|
| 133 | //
|
---|
| 134 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4260] | 135 | void t_reqcAnalyze::analyzeFile(t_rnxObsFile* obsFile) {
|
---|
[4259] | 136 |
|
---|
[4260] | 137 | *_log << "Analyze File\n"
|
---|
| 138 | << "------------\n"
|
---|
| 139 | << obsFile->fileName().toAscii().data() << endl << endl;
|
---|
| 140 |
|
---|
[4262] | 141 | // Loop over all Epochs
|
---|
| 142 | // --------------------
|
---|
[4266] | 143 | while ( (_currEpo = obsFile->nextEpoch()) != 0) {
|
---|
[4260] | 144 |
|
---|
[4262] | 145 | // Loop over all satellites
|
---|
| 146 | // ------------------------
|
---|
[4266] | 147 | for (unsigned iObs = 0; iObs < _currEpo->rnxSat.size(); iObs++) {
|
---|
| 148 | const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iObs];
|
---|
[4262] | 149 | t_obs obs;
|
---|
[4266] | 150 | t_postProcessing::setObsFromRnx(obsFile, _currEpo, rnxSat, obs);
|
---|
[4260] | 151 |
|
---|
[4262] | 152 | if (obs.satSys == 'R') {
|
---|
[4266] | 153 | continue; // TODO: set channel number
|
---|
[4262] | 154 | }
|
---|
| 155 |
|
---|
[4263] | 156 | QString prn = QString("%1%2").arg(obs.satSys)
|
---|
| 157 | .arg(obs.satNum, 2, 10, QChar('0'));
|
---|
[4266] | 158 |
|
---|
[4268] | 159 | t_satStat& satStat = _satStat[prn];
|
---|
| 160 | satStat.addObs(obs);
|
---|
[4262] | 161 | }
|
---|
| 162 |
|
---|
[4266] | 163 | } // while (_currEpo)
|
---|
[4262] | 164 |
|
---|
[4268] | 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();
|
---|
[4270] | 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;
|
---|
[4268] | 192 | }
|
---|
| 193 | }
|
---|
[4269] | 194 |
|
---|
[4268] | 195 | }
|
---|
| 196 |
|
---|
[4300] | 197 | emit displayGraph();
|
---|
| 198 |
|
---|
[4259] | 199 | _log->flush();
|
---|
[4254] | 200 | }
|
---|
[4263] | 201 |
|
---|
| 202 | //
|
---|
| 203 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 204 | void t_reqcAnalyze::t_satStat::addObs(const t_obs& obs) {
|
---|
| 205 | if (currObs) {
|
---|
| 206 | delete prevObs;
|
---|
| 207 | prevObs = currObs;
|
---|
| 208 | }
|
---|
[4266] | 209 | currObs = new t_anaObs(obs);
|
---|
[4265] | 210 |
|
---|
[4268] | 211 | // Compute the Multipath
|
---|
| 212 | // ----------------------
|
---|
| 213 | if (obs.l1() != 0.0 && obs.l2() != 0.0) {
|
---|
[4266] | 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 |
|
---|
[4268] | 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 | }
|
---|
[4265] | 228 | }
|
---|
[4263] | 229 | }
|
---|