[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 |
|
---|
[4357] | 53 | const double SLIPTRESH = 5.0; // cycle-slip threshold (meters)
|
---|
| 54 |
|
---|
[3899] | 55 | // Constructor
|
---|
| 56 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 57 | t_reqcAnalyze::t_reqcAnalyze(QObject* parent) : QThread(parent) {
|
---|
| 58 |
|
---|
| 59 | bncSettings settings;
|
---|
[4254] | 60 |
|
---|
[4257] | 61 | _logFileName = settings.value("reqcOutLogFile").toString(); expandEnvVar(_logFileName);
|
---|
| 62 | _logFile = 0;
|
---|
| 63 | _log = 0;
|
---|
[4254] | 64 | _obsFileNames = settings.value("reqcObsFile").toString().split(",", QString::SkipEmptyParts);
|
---|
[4257] | 65 | _navFileNames = settings.value("reqcNavFile").toString().split(",", QString::SkipEmptyParts);
|
---|
[4266] | 66 |
|
---|
| 67 | _currEpo = 0;
|
---|
[4300] | 68 |
|
---|
[4342] | 69 | connect(this, SIGNAL(displayGraph(QVector<t_polarPoint*>*, QVector<t_polarPoint*>*)),
|
---|
| 70 | this, SLOT(slotDisplayGraph(QVector<t_polarPoint*>*, QVector<t_polarPoint*>*)));
|
---|
[3899] | 71 | }
|
---|
| 72 |
|
---|
| 73 | // Destructor
|
---|
| 74 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 75 | t_reqcAnalyze::~t_reqcAnalyze() {
|
---|
[4255] | 76 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 77 | delete _rnxObsFiles[ii];
|
---|
| 78 | }
|
---|
| 79 | for (int ii = 0; ii < _ephs.size(); ii++) {
|
---|
| 80 | delete _ephs[ii];
|
---|
| 81 | }
|
---|
| 82 | delete _log; _log = 0;
|
---|
| 83 | delete _logFile; _logFile = 0;
|
---|
[3899] | 84 | }
|
---|
| 85 |
|
---|
| 86 | //
|
---|
| 87 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4342] | 88 | void t_reqcAnalyze::slotDisplayGraph(QVector<t_polarPoint*>* dataMP1,
|
---|
| 89 | QVector<t_polarPoint*>* dataMP2) {
|
---|
| 90 |
|
---|
[4346] | 91 | bncApp* app = dynamic_cast<bncApp*>(qApp);
|
---|
| 92 | if (app->mode() == bncApp::interactive) {
|
---|
[4334] | 93 |
|
---|
[4356] | 94 | double maxMP = 0.0;
|
---|
| 95 | for (int ii = 0; ii < dataMP1->size(); ii++) {
|
---|
| 96 | double mp = dataMP1->at(ii)->_value;
|
---|
| 97 | if (maxMP < mp) {
|
---|
| 98 | maxMP = mp;
|
---|
| 99 | }
|
---|
| 100 | }
|
---|
| 101 | for (int ii = 0; ii < dataMP2->size(); ii++) {
|
---|
| 102 | double mp = dataMP2->at(ii)->_value;
|
---|
| 103 | if (maxMP < mp) {
|
---|
| 104 | maxMP = mp;
|
---|
| 105 | }
|
---|
| 106 | }
|
---|
[4357] | 107 | if (maxMP > SLIPTRESH) {
|
---|
| 108 | }
|
---|
| 109 |
|
---|
[4356] | 110 |
|
---|
| 111 | QwtInterval scaleInterval(0.0, maxMP);
|
---|
| 112 |
|
---|
| 113 | t_polarPlot* plotMP1 = new t_polarPlot(QwtText("MP1"), scaleInterval,
|
---|
| 114 | app->mainWindow());
|
---|
[4342] | 115 | plotMP1->addCurve(dataMP1);
|
---|
[4334] | 116 |
|
---|
[4356] | 117 | t_polarPlot* plotMP2 = new t_polarPlot(QwtText("MP2"), scaleInterval,
|
---|
| 118 | app->mainWindow());
|
---|
[4342] | 119 | plotMP2->addCurve(dataMP2);
|
---|
[4334] | 120 |
|
---|
[4310] | 121 | QVector<QWidget*> plots;
|
---|
[4334] | 122 | plots << plotMP1;
|
---|
| 123 | plots << plotMP2;
|
---|
| 124 |
|
---|
[4356] | 125 | t_graphWin* graphWin = new t_graphWin(0, plots, scaleInterval);
|
---|
[4334] | 126 |
|
---|
[4347] | 127 | graphWin->show();
|
---|
[4308] | 128 | }
|
---|
[4300] | 129 | }
|
---|
| 130 |
|
---|
| 131 | //
|
---|
| 132 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3899] | 133 | void t_reqcAnalyze::run() {
|
---|
| 134 |
|
---|
[4255] | 135 | // Open Log File
|
---|
| 136 | // -------------
|
---|
| 137 | _logFile = new QFile(_logFileName);
|
---|
| 138 | _logFile->open(QIODevice::WriteOnly | QIODevice::Text);
|
---|
| 139 | _log = new QTextStream();
|
---|
| 140 | _log->setDevice(_logFile);
|
---|
| 141 |
|
---|
| 142 | // Initialize RINEX Observation Files
|
---|
| 143 | // ----------------------------------
|
---|
[4254] | 144 | t_reqcEdit::initRnxObsFiles(_obsFileNames, _rnxObsFiles);
|
---|
[3899] | 145 |
|
---|
[4257] | 146 | // Read Ephemerides
|
---|
| 147 | // ----------------
|
---|
| 148 | t_reqcEdit::readEphemerides(_navFileNames, _ephs);
|
---|
| 149 |
|
---|
[4255] | 150 | // Loop over all RINEX Files
|
---|
| 151 | // -------------------------
|
---|
[4254] | 152 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 153 | analyzeFile(_rnxObsFiles[ii]);
|
---|
| 154 | }
|
---|
| 155 |
|
---|
[4255] | 156 | // Exit
|
---|
| 157 | // ----
|
---|
[3973] | 158 | bncApp* app = (bncApp*) qApp;
|
---|
| 159 | if ( app->mode() != bncApp::interactive) {
|
---|
| 160 | app->exit(0);
|
---|
| 161 | }
|
---|
| 162 | else {
|
---|
| 163 | emit finished();
|
---|
| 164 | deleteLater();
|
---|
| 165 | }
|
---|
[3899] | 166 | }
|
---|
[4254] | 167 |
|
---|
| 168 | //
|
---|
| 169 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4260] | 170 | void t_reqcAnalyze::analyzeFile(t_rnxObsFile* obsFile) {
|
---|
[4259] | 171 |
|
---|
[4352] | 172 | *_log << "\nAnalyze File\n"
|
---|
| 173 | << "------------\n"
|
---|
[4260] | 174 | << obsFile->fileName().toAscii().data() << endl << endl;
|
---|
| 175 |
|
---|
[4343] | 176 | _satStat.clear();
|
---|
| 177 |
|
---|
[4342] | 178 | // A priori Coordinates
|
---|
| 179 | // --------------------
|
---|
| 180 | ColumnVector xyz = obsFile->xyz();
|
---|
| 181 |
|
---|
[4262] | 182 | // Loop over all Epochs
|
---|
| 183 | // --------------------
|
---|
[4266] | 184 | while ( (_currEpo = obsFile->nextEpoch()) != 0) {
|
---|
[4260] | 185 |
|
---|
[4262] | 186 | // Loop over all satellites
|
---|
| 187 | // ------------------------
|
---|
[4266] | 188 | for (unsigned iObs = 0; iObs < _currEpo->rnxSat.size(); iObs++) {
|
---|
| 189 | const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iObs];
|
---|
[4262] | 190 | t_obs obs;
|
---|
[4266] | 191 | t_postProcessing::setObsFromRnx(obsFile, _currEpo, rnxSat, obs);
|
---|
[4260] | 192 |
|
---|
[4262] | 193 | if (obs.satSys == 'R') {
|
---|
[4266] | 194 | continue; // TODO: set channel number
|
---|
[4262] | 195 | }
|
---|
| 196 |
|
---|
[4263] | 197 | QString prn = QString("%1%2").arg(obs.satSys)
|
---|
| 198 | .arg(obs.satNum, 2, 10, QChar('0'));
|
---|
[4266] | 199 |
|
---|
[4268] | 200 | t_satStat& satStat = _satStat[prn];
|
---|
[4338] | 201 |
|
---|
[4355] | 202 | satStat.addObs(obs);
|
---|
[4262] | 203 | }
|
---|
| 204 |
|
---|
[4266] | 205 | } // while (_currEpo)
|
---|
[4262] | 206 |
|
---|
[4268] | 207 | // Analyze the Multipath
|
---|
| 208 | // ---------------------
|
---|
[4350] | 209 | QVector<t_polarPoint*>* dataMP1 = new QVector<t_polarPoint*>;
|
---|
| 210 | QVector<t_polarPoint*>* dataMP2 = new QVector<t_polarPoint*>;
|
---|
[4268] | 211 |
|
---|
| 212 | QMapIterator<QString, t_satStat> it(_satStat);
|
---|
| 213 | while (it.hasNext()) {
|
---|
| 214 | it.next();
|
---|
| 215 | QString prn = it.key();
|
---|
| 216 | const t_satStat& satStat = it.value();
|
---|
[4355] | 217 | analyzeMultipath(prn, satStat, xyz, dataMP1, dataMP2);
|
---|
[4268] | 218 | }
|
---|
| 219 |
|
---|
[4342] | 220 | emit displayGraph(dataMP1, dataMP2);
|
---|
[4300] | 221 |
|
---|
[4259] | 222 | _log->flush();
|
---|
[4254] | 223 | }
|
---|
[4263] | 224 |
|
---|
| 225 | //
|
---|
| 226 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4355] | 227 | void t_reqcAnalyze::t_satStat::addObs(const t_obs& obs) {
|
---|
[4265] | 228 |
|
---|
[4355] | 229 | t_anaObs* newObs = new t_anaObs(obs.GPSWeek, obs.GPSWeeks);
|
---|
[4354] | 230 | bool okFlag = false;
|
---|
[4338] | 231 |
|
---|
[4268] | 232 | // Compute the Multipath
|
---|
| 233 | // ----------------------
|
---|
| 234 | if (obs.l1() != 0.0 && obs.l2() != 0.0) {
|
---|
[4266] | 235 | double f1 = t_CST::f1(obs.satSys, obs.slotNum);
|
---|
| 236 | double f2 = t_CST::f2(obs.satSys, obs.slotNum);
|
---|
| 237 |
|
---|
| 238 | double L1 = obs.l1() * t_CST::c / f1;
|
---|
| 239 | double L2 = obs.l2() * t_CST::c / f2;
|
---|
| 240 |
|
---|
[4268] | 241 | if (obs.p1() != 0.0) {
|
---|
[4355] | 242 | newObs->_MP1 = obs.p1() - L1 - 2.0*f2*f2/(f1*f1-f2*f2) * (L1 - L2);
|
---|
[4354] | 243 | okFlag = true;
|
---|
[4268] | 244 | }
|
---|
| 245 | if (obs.p2() != 0.0) {
|
---|
[4355] | 246 | newObs->_MP2 = obs.p2() - L2 - 2.0*f1*f1/(f1*f1-f2*f2) * (L1 - L2);
|
---|
[4354] | 247 | okFlag = true;
|
---|
[4268] | 248 | }
|
---|
[4265] | 249 | }
|
---|
[4338] | 250 |
|
---|
[4354] | 251 | // Remember the Observation
|
---|
| 252 | // ------------------------
|
---|
| 253 | if (okFlag) {
|
---|
| 254 | anaObs << newObs;
|
---|
| 255 | }
|
---|
| 256 | else {
|
---|
| 257 | delete newObs;
|
---|
| 258 | }
|
---|
[4263] | 259 | }
|
---|
[4350] | 260 |
|
---|
| 261 | //
|
---|
| 262 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 263 | void t_reqcAnalyze::analyzeMultipath(const QString& prn,
|
---|
| 264 | const t_satStat& satStat,
|
---|
[4355] | 265 | const ColumnVector& xyz,
|
---|
[4350] | 266 | QVector<t_polarPoint*>* dataMP1,
|
---|
| 267 | QVector<t_polarPoint*>* dataMP2) {
|
---|
| 268 |
|
---|
[4353] | 269 | const int LENGTH = 10; // number of epochs in one chunk
|
---|
[4350] | 270 |
|
---|
[4351] | 271 | int numEpo = satStat.anaObs.size();
|
---|
| 272 |
|
---|
| 273 | for (int chunkStart = 0; chunkStart + LENGTH < numEpo; chunkStart += LENGTH) {
|
---|
| 274 |
|
---|
| 275 | // Compute Mean
|
---|
| 276 | // ------------
|
---|
[4353] | 277 | bool slipFlag = false;
|
---|
| 278 | double mean1 = 0.0;
|
---|
| 279 | double mean2 = 0.0;
|
---|
| 280 |
|
---|
[4351] | 281 | for (int ii = 0; ii < LENGTH; ii++) {
|
---|
| 282 | int iEpo = chunkStart + ii;
|
---|
| 283 | const t_anaObs* anaObs = satStat.anaObs[iEpo];
|
---|
[4355] | 284 | mean1 += anaObs->_MP1;
|
---|
| 285 | mean2 += anaObs->_MP2;
|
---|
[4353] | 286 |
|
---|
| 287 | // Check Slip
|
---|
| 288 | // ----------
|
---|
| 289 | if (ii > 0) {
|
---|
[4355] | 290 | double diff1 = anaObs->_MP1 - satStat.anaObs[iEpo-1]->_MP1;
|
---|
| 291 | double diff2 = anaObs->_MP2 - satStat.anaObs[iEpo-1]->_MP2;
|
---|
[4357] | 292 | if (fabs(diff1) > SLIPTRESH || fabs(diff2) > SLIPTRESH) {
|
---|
[4353] | 293 | slipFlag = true;
|
---|
| 294 | break;
|
---|
| 295 | }
|
---|
| 296 | }
|
---|
[4351] | 297 | }
|
---|
[4353] | 298 |
|
---|
| 299 | if (slipFlag) {
|
---|
| 300 | continue;
|
---|
| 301 | }
|
---|
| 302 |
|
---|
[4351] | 303 | mean1 /= LENGTH;
|
---|
| 304 | mean2 /= LENGTH;
|
---|
| 305 |
|
---|
| 306 | // Compute Standard Deviation
|
---|
| 307 | // --------------------------
|
---|
| 308 | double stddev1 = 0.0;
|
---|
| 309 | double stddev2 = 0.0;
|
---|
| 310 | for (int ii = 0; ii < LENGTH; ii++) {
|
---|
| 311 | int iEpo = chunkStart + ii;
|
---|
| 312 | const t_anaObs* anaObs = satStat.anaObs[iEpo];
|
---|
[4355] | 313 | double diff1 = anaObs->_MP1 - mean1;
|
---|
| 314 | double diff2 = anaObs->_MP2 - mean2;
|
---|
[4351] | 315 | stddev1 += diff1 * diff1;
|
---|
| 316 | stddev2 += diff2 * diff2;
|
---|
| 317 | }
|
---|
| 318 | double MP1 = sqrt(stddev1 / (LENGTH-1));
|
---|
| 319 | double MP2 = sqrt(stddev2 / (LENGTH-1));
|
---|
| 320 |
|
---|
[4355] | 321 | const t_anaObs* anaObs0 = satStat.anaObs[chunkStart];
|
---|
| 322 |
|
---|
| 323 | // Compute the Azimuth and Zenith Distance
|
---|
| 324 | // ---------------------------------------
|
---|
| 325 | double az = 0.0;
|
---|
| 326 | double zen = 0.0;
|
---|
| 327 | if (xyz.size()) {
|
---|
| 328 | t_eph* eph = 0;
|
---|
| 329 | for (int ie = 0; ie < _ephs.size(); ie++) {
|
---|
| 330 | if (_ephs[ie]->prn() == prn) {
|
---|
| 331 | eph = _ephs[ie];
|
---|
| 332 | break;
|
---|
| 333 | }
|
---|
| 334 | }
|
---|
| 335 |
|
---|
| 336 | if (eph) {
|
---|
| 337 | double xSat, ySat, zSat, clkSat;
|
---|
| 338 | eph->position(anaObs0->_GPSWeek, anaObs0->_GPSWeeks,
|
---|
| 339 | xSat, ySat, zSat, clkSat);
|
---|
| 340 |
|
---|
| 341 | double rho, eleSat, azSat;
|
---|
| 342 | topos(xyz(1), xyz(2), xyz(3), xSat, ySat, zSat, rho, eleSat, azSat);
|
---|
| 343 |
|
---|
| 344 | az = azSat * 180.0/M_PI;
|
---|
| 345 | zen = 90.0 - eleSat * 180.0/M_PI;
|
---|
| 346 | }
|
---|
| 347 | }
|
---|
| 348 |
|
---|
[4353] | 349 | // Add new Point
|
---|
| 350 | // -------------
|
---|
[4355] | 351 | (*dataMP1) << (new t_polarPoint(az, zen, MP1));
|
---|
| 352 | (*dataMP2) << (new t_polarPoint(az, zen, MP2));
|
---|
[4351] | 353 |
|
---|
| 354 | _log->setRealNumberNotation(QTextStream::FixedNotation);
|
---|
[4353] | 355 |
|
---|
[4351] | 356 | _log->setRealNumberPrecision(2);
|
---|
[4355] | 357 | *_log << "MP1 " << prn << " " << az << " " << zen << " ";
|
---|
[4353] | 358 | _log->setRealNumberPrecision(3);
|
---|
| 359 | *_log << MP1 << endl;
|
---|
| 360 |
|
---|
| 361 | _log->setRealNumberPrecision(2);
|
---|
[4355] | 362 | *_log << "MP2 " << prn << " " << az << " " << zen << " ";
|
---|
[4353] | 363 | _log->setRealNumberPrecision(3);
|
---|
| 364 | *_log << MP2 << endl;
|
---|
[4350] | 365 | }
|
---|
| 366 | }
|
---|