[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>
|
---|
[4361] | 42 | #include <iomanip>
|
---|
[4579] | 43 | #include <qwt_plot_renderer.h>
|
---|
[4574] | 44 |
|
---|
[3899] | 45 | #include "reqcanalyze.h"
|
---|
[3973] | 46 | #include "bncapp.h"
|
---|
[3899] | 47 | #include "bncsettings.h"
|
---|
[4254] | 48 | #include "reqcedit.h"
|
---|
[4255] | 49 | #include "bncutils.h"
|
---|
[4262] | 50 | #include "bncpostprocess.h"
|
---|
[4300] | 51 | #include "graphwin.h"
|
---|
[4307] | 52 | #include "polarplot.h"
|
---|
[4577] | 53 | #include "availplot.h"
|
---|
[4662] | 54 | #include "eleplot.h"
|
---|
[4672] | 55 | #include "dopplot.h"
|
---|
[3899] | 56 |
|
---|
| 57 | using namespace std;
|
---|
| 58 |
|
---|
[4700] | 59 | const double SLIPTRESH = 10.0; // cycle-slip threshold (meters)
|
---|
[4357] | 60 |
|
---|
[3899] | 61 | // Constructor
|
---|
| 62 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 63 | t_reqcAnalyze::t_reqcAnalyze(QObject* parent) : QThread(parent) {
|
---|
| 64 |
|
---|
| 65 | bncSettings settings;
|
---|
[4254] | 66 |
|
---|
[4257] | 67 | _logFileName = settings.value("reqcOutLogFile").toString(); expandEnvVar(_logFileName);
|
---|
| 68 | _logFile = 0;
|
---|
| 69 | _log = 0;
|
---|
[4254] | 70 | _obsFileNames = settings.value("reqcObsFile").toString().split(",", QString::SkipEmptyParts);
|
---|
[4257] | 71 | _navFileNames = settings.value("reqcNavFile").toString().split(",", QString::SkipEmptyParts);
|
---|
[4266] | 72 |
|
---|
| 73 | _currEpo = 0;
|
---|
[4300] | 74 |
|
---|
[4572] | 75 | connect(this, SIGNAL(dspSkyPlot(const QString&,
|
---|
| 76 | const QByteArray&,
|
---|
| 77 | QVector<t_polarPoint*>*,
|
---|
| 78 | const QByteArray&,
|
---|
| 79 | QVector<t_polarPoint*>*,
|
---|
| 80 | const QByteArray&, double)),
|
---|
| 81 | this, SLOT(slotDspSkyPlot(const QString&,
|
---|
[4556] | 82 | const QByteArray&,
|
---|
| 83 | QVector<t_polarPoint*>*,
|
---|
| 84 | const QByteArray&,
|
---|
| 85 | QVector<t_polarPoint*>*,
|
---|
[4572] | 86 | const QByteArray&, double)));
|
---|
| 87 |
|
---|
[4584] | 88 | connect(this, SIGNAL(dspAvailPlot(const QString&, const QByteArray&)),
|
---|
| 89 | this, SLOT(slotDspAvailPlot(const QString&, const QByteArray&)));
|
---|
[3899] | 90 | }
|
---|
| 91 |
|
---|
| 92 | // Destructor
|
---|
| 93 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 94 | t_reqcAnalyze::~t_reqcAnalyze() {
|
---|
[4255] | 95 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 96 | delete _rnxObsFiles[ii];
|
---|
| 97 | }
|
---|
| 98 | for (int ii = 0; ii < _ephs.size(); ii++) {
|
---|
| 99 | delete _ephs[ii];
|
---|
| 100 | }
|
---|
| 101 | delete _log; _log = 0;
|
---|
| 102 | delete _logFile; _logFile = 0;
|
---|
[4452] | 103 | bncApp* app = (bncApp*) qApp;
|
---|
| 104 | if ( app->mode() != bncApp::interactive) {
|
---|
| 105 | app->exit(0);
|
---|
| 106 | }
|
---|
[3899] | 107 | }
|
---|
| 108 |
|
---|
| 109 | //
|
---|
| 110 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4572] | 111 | void t_reqcAnalyze::slotDspSkyPlot(const QString& fileName,
|
---|
| 112 | const QByteArray& title1,
|
---|
| 113 | QVector<t_polarPoint*>* data1,
|
---|
| 114 | const QByteArray& title2,
|
---|
| 115 | QVector<t_polarPoint*>* data2,
|
---|
| 116 | const QByteArray& scaleTitle,
|
---|
| 117 | double maxValue) {
|
---|
[4342] | 118 |
|
---|
[4346] | 119 | bncApp* app = dynamic_cast<bncApp*>(qApp);
|
---|
[4448] | 120 | if (app->GUIenabled()) {
|
---|
[4334] | 121 |
|
---|
[4556] | 122 | if (maxValue == 0.0) {
|
---|
| 123 | if (data1) {
|
---|
| 124 | for (int ii = 0; ii < data1->size(); ii++) {
|
---|
[4566] | 125 | double val = data1->at(ii)->_value;
|
---|
| 126 | if (maxValue < val) {
|
---|
| 127 | maxValue = val;
|
---|
[4556] | 128 | }
|
---|
| 129 | }
|
---|
[4356] | 130 | }
|
---|
[4557] | 131 | if (data2) {
|
---|
[4556] | 132 | for (int ii = 0; ii < data2->size(); ii++) {
|
---|
[4566] | 133 | double val = data2->at(ii)->_value;
|
---|
| 134 | if (maxValue < val) {
|
---|
| 135 | maxValue = val;
|
---|
[4556] | 136 | }
|
---|
| 137 | }
|
---|
[4356] | 138 | }
|
---|
| 139 | }
|
---|
[4357] | 140 |
|
---|
[4556] | 141 | QwtInterval scaleInterval(0.0, maxValue);
|
---|
[4356] | 142 |
|
---|
[4556] | 143 | QVector<QWidget*> plots;
|
---|
| 144 | if (data1) {
|
---|
| 145 | t_polarPlot* plot1 = new t_polarPlot(QwtText(title1), scaleInterval,
|
---|
| 146 | app->mainWindow());
|
---|
| 147 | plot1->addCurve(data1);
|
---|
| 148 | plots << plot1;
|
---|
| 149 | }
|
---|
[4557] | 150 | if (data2) {
|
---|
[4556] | 151 | t_polarPlot* plot2 = new t_polarPlot(QwtText(title2), scaleInterval,
|
---|
[4356] | 152 | app->mainWindow());
|
---|
[4556] | 153 | plot2->addCurve(data2);
|
---|
| 154 | plots << plot2;
|
---|
| 155 | }
|
---|
[4334] | 156 |
|
---|
[4564] | 157 | t_graphWin* graphWin = new t_graphWin(0, fileName, plots,
|
---|
[4573] | 158 | &scaleTitle, &scaleInterval);
|
---|
[4334] | 159 |
|
---|
[4445] | 160 | graphWin->show();
|
---|
| 161 |
|
---|
[4451] | 162 | bncSettings settings;
|
---|
| 163 | QString dirName = settings.value("reqcPlotDir").toString();
|
---|
| 164 | if (!dirName.isEmpty()) {
|
---|
[4606] | 165 | QByteArray ext = scaleTitle.isEmpty() ? "_S.png" : "_M.png";
|
---|
[4579] | 166 | graphWin->savePNG(dirName, ext);
|
---|
[4451] | 167 | }
|
---|
[4308] | 168 | }
|
---|
[4300] | 169 | }
|
---|
| 170 |
|
---|
| 171 | //
|
---|
| 172 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3899] | 173 | void t_reqcAnalyze::run() {
|
---|
| 174 |
|
---|
[4255] | 175 | // Open Log File
|
---|
| 176 | // -------------
|
---|
| 177 | _logFile = new QFile(_logFileName);
|
---|
[4517] | 178 | if (_logFile->open(QIODevice::WriteOnly | QIODevice::Text)) {
|
---|
| 179 | _log = new QTextStream();
|
---|
| 180 | _log->setDevice(_logFile);
|
---|
| 181 | }
|
---|
[4255] | 182 |
|
---|
| 183 | // Initialize RINEX Observation Files
|
---|
| 184 | // ----------------------------------
|
---|
[4525] | 185 | t_reqcEdit::initRnxObsFiles(_obsFileNames, _rnxObsFiles, _log);
|
---|
[3899] | 186 |
|
---|
[4257] | 187 | // Read Ephemerides
|
---|
| 188 | // ----------------
|
---|
| 189 | t_reqcEdit::readEphemerides(_navFileNames, _ephs);
|
---|
| 190 |
|
---|
[4255] | 191 | // Loop over all RINEX Files
|
---|
| 192 | // -------------------------
|
---|
[4254] | 193 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 194 | analyzeFile(_rnxObsFiles[ii]);
|
---|
| 195 | }
|
---|
| 196 |
|
---|
[4255] | 197 | // Exit
|
---|
| 198 | // ----
|
---|
[4452] | 199 | emit finished();
|
---|
| 200 | deleteLater();
|
---|
[3899] | 201 | }
|
---|
[4254] | 202 |
|
---|
| 203 | //
|
---|
| 204 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4260] | 205 | void t_reqcAnalyze::analyzeFile(t_rnxObsFile* obsFile) {
|
---|
[4259] | 206 |
|
---|
[4715] | 207 | _mutex.lock();
|
---|
[4704] | 208 |
|
---|
[4517] | 209 | if (_log) {
|
---|
| 210 | *_log << "\nAnalyze File\n"
|
---|
| 211 | << "------------\n"
|
---|
[4701] | 212 | << "File: " << obsFile->fileName().toAscii().data() << endl;
|
---|
[4517] | 213 | }
|
---|
[4260] | 214 |
|
---|
[4584] | 215 | _allObsMap.clear();
|
---|
| 216 | _availDataMap.clear();
|
---|
[4717] | 217 | _obsStat.reset();
|
---|
[4343] | 218 |
|
---|
[4342] | 219 | // A priori Coordinates
|
---|
| 220 | // --------------------
|
---|
[4679] | 221 | ColumnVector xyzSta = obsFile->xyz();
|
---|
[4342] | 222 |
|
---|
[4262] | 223 | // Loop over all Epochs
|
---|
| 224 | // --------------------
|
---|
[4541] | 225 | try {
|
---|
[4675] | 226 | unsigned iEpo = 0;
|
---|
[4541] | 227 | while ( (_currEpo = obsFile->nextEpoch()) != 0) {
|
---|
[4688] | 228 |
|
---|
| 229 | if (iEpo == 0) {
|
---|
| 230 | _obsStat._startTime = _currEpo->tt;
|
---|
| 231 | _obsStat._antennaName = obsFile->antennaName();
|
---|
| 232 | _obsStat._markerName = obsFile->markerName();
|
---|
| 233 | _obsStat._receiverType = obsFile->receiverType();
|
---|
| 234 | _obsStat._interval = obsFile->interval();
|
---|
| 235 | }
|
---|
| 236 | _obsStat._endTime = _currEpo->tt;
|
---|
[4541] | 237 |
|
---|
| 238 | // Loop over all satellites
|
---|
| 239 | // ------------------------
|
---|
| 240 | for (unsigned iObs = 0; iObs < _currEpo->rnxSat.size(); iObs++) {
|
---|
| 241 | const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iObs];
|
---|
| 242 | t_obs obs;
|
---|
| 243 | t_postProcessing::setObsFromRnx(obsFile, _currEpo, rnxSat, obs);
|
---|
| 244 |
|
---|
| 245 | if (obs.satSys == 'R') {
|
---|
[4590] | 246 | // TODO: set channel number
|
---|
[4541] | 247 | }
|
---|
| 248 |
|
---|
| 249 | QString prn = QString("%1%2").arg(obs.satSys)
|
---|
| 250 | .arg(obs.satNum, 2, 10, QChar('0'));
|
---|
| 251 |
|
---|
[4694] | 252 | t_irc irc = _allObsMap[prn].addObs(obs);
|
---|
[4675] | 253 |
|
---|
[4694] | 254 | if (irc == success) {
|
---|
| 255 | const t_oneObs* newObs = _allObsMap[prn]._oneObsVec.last();
|
---|
| 256 | if (newObs->_hasL1 && newObs->_hasL2) {
|
---|
| 257 | _obsStat._prnStat[prn]._numObs += 1;
|
---|
| 258 | }
|
---|
[4695] | 259 | if (newObs->_slipL1 && newObs->_slipL2) {
|
---|
[4701] | 260 | _obsStat._prnStat[prn]._numSlipsFlagged += 1;
|
---|
[4695] | 261 | }
|
---|
[4694] | 262 | }
|
---|
[4262] | 263 | }
|
---|
[4541] | 264 |
|
---|
[4679] | 265 | prepareObsStat(iEpo, obsFile->interval(), xyzSta);
|
---|
[4678] | 266 | iEpo++;
|
---|
| 267 |
|
---|
[4541] | 268 | } // while (_currEpo)
|
---|
| 269 | }
|
---|
| 270 | catch (QString str) {
|
---|
| 271 | if (_log) {
|
---|
| 272 | *_log << "Exception " << str << endl;
|
---|
[4262] | 273 | }
|
---|
[4541] | 274 | else {
|
---|
| 275 | qDebug() << str;
|
---|
| 276 | }
|
---|
[4715] | 277 | _mutex.unlock();
|
---|
[4541] | 278 | return;
|
---|
| 279 | }
|
---|
[4262] | 280 |
|
---|
[4268] | 281 | // Analyze the Multipath
|
---|
| 282 | // ---------------------
|
---|
[4572] | 283 | QVector<t_polarPoint*>* dataMP1 = new QVector<t_polarPoint*>;
|
---|
| 284 | QVector<t_polarPoint*>* dataMP2 = new QVector<t_polarPoint*>;
|
---|
| 285 | QVector<t_polarPoint*>* dataSNR1 = new QVector<t_polarPoint*>;
|
---|
| 286 | QVector<t_polarPoint*>* dataSNR2 = new QVector<t_polarPoint*>;
|
---|
[4268] | 287 |
|
---|
[4584] | 288 | QMutableMapIterator<QString, t_allObs> it(_allObsMap);
|
---|
[4268] | 289 | while (it.hasNext()) {
|
---|
| 290 | it.next();
|
---|
[4584] | 291 | QString prn = it.key();
|
---|
[4679] | 292 | preparePlotData(prn, xyzSta, obsFile->interval(),
|
---|
[4675] | 293 | dataMP1, dataMP2, dataSNR1, dataSNR2);
|
---|
[4268] | 294 | }
|
---|
| 295 |
|
---|
[4706] | 296 | printReport(dataMP1, dataMP2, dataSNR1, dataSNR2);
|
---|
| 297 |
|
---|
| 298 | QFileInfo fileInfo(obsFile->fileName());
|
---|
| 299 | QByteArray title = fileInfo.fileName().toAscii();
|
---|
| 300 |
|
---|
[4572] | 301 | emit dspSkyPlot(obsFile->fileName(), "MP1", dataMP1, "MP2", dataMP2,
|
---|
| 302 | "Meters", 2.0);
|
---|
| 303 | emit dspSkyPlot(obsFile->fileName(), "SNR1", dataSNR1, "SNR2", dataSNR2,
|
---|
| 304 | "", 9.0);
|
---|
[4605] | 305 | emit dspAvailPlot(obsFile->fileName(), title);
|
---|
[4254] | 306 | }
|
---|
[4263] | 307 |
|
---|
| 308 | //
|
---|
| 309 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4694] | 310 | t_irc t_reqcAnalyze::t_allObs::addObs(const t_obs& obs) {
|
---|
[4265] | 311 |
|
---|
[4584] | 312 | t_oneObs* newObs = new t_oneObs(obs.GPSWeek, obs.GPSWeeks);
|
---|
[4354] | 313 | bool okFlag = false;
|
---|
[4338] | 314 |
|
---|
[4608] | 315 | // Availability and Slip Flags
|
---|
| 316 | // ---------------------------
|
---|
[4424] | 317 | double L1 = obs.measdata("L1", 3.0);
|
---|
[4571] | 318 | if (L1 != 0) {
|
---|
| 319 | newObs->_hasL1 = true;
|
---|
| 320 | }
|
---|
[4424] | 321 | double L2 = obs.measdata("L2", 3.0);
|
---|
[4571] | 322 | if (L2 != 0) {
|
---|
| 323 | newObs->_hasL2 = true;
|
---|
| 324 | }
|
---|
[4608] | 325 | if (obs.slipL1) {
|
---|
| 326 | newObs->_slipL1 = true;
|
---|
| 327 | }
|
---|
| 328 | if (obs.slipL2) {
|
---|
| 329 | newObs->_slipL2 = true;
|
---|
| 330 | }
|
---|
| 331 |
|
---|
| 332 | // Compute the Multipath
|
---|
| 333 | // ----------------------
|
---|
[4391] | 334 | if (L1 != 0.0 && L2 != 0.0) {
|
---|
[4266] | 335 | double f1 = t_CST::f1(obs.satSys, obs.slotNum);
|
---|
| 336 | double f2 = t_CST::f2(obs.satSys, obs.slotNum);
|
---|
| 337 |
|
---|
[4391] | 338 | L1 = L1 * t_CST::c / f1;
|
---|
| 339 | L2 = L2 * t_CST::c / f2;
|
---|
[4266] | 340 |
|
---|
[4424] | 341 | double P1 = obs.measdata("C1", 3.0);
|
---|
[4391] | 342 | if (P1 != 0.0) {
|
---|
| 343 | newObs->_MP1 = P1 - L1 - 2.0*f2*f2/(f1*f1-f2*f2) * (L1 - L2);
|
---|
[4354] | 344 | okFlag = true;
|
---|
[4268] | 345 | }
|
---|
[4424] | 346 | double P2 = obs.measdata("C2", 3.0);
|
---|
[4391] | 347 | if (P2 != 0.0) {
|
---|
| 348 | newObs->_MP2 = P2 - L2 - 2.0*f1*f1/(f1*f1-f2*f2) * (L1 - L2);
|
---|
[4354] | 349 | okFlag = true;
|
---|
[4268] | 350 | }
|
---|
[4265] | 351 | }
|
---|
[4338] | 352 |
|
---|
[4559] | 353 | // Signal-to-Noise
|
---|
| 354 | // ---------------
|
---|
| 355 | double S1 = obs.measdata("S1", 3.0);
|
---|
| 356 | if (S1 != 0.0) {
|
---|
[4562] | 357 | newObs->_SNR1 = floor(S1/6);
|
---|
| 358 | if (newObs->_SNR1 > 9.0) {
|
---|
| 359 | newObs->_SNR1 = 9.0;
|
---|
| 360 | }
|
---|
| 361 | if (newObs->_SNR1 < 1.0) {
|
---|
| 362 | newObs->_SNR1 = 1.0;
|
---|
| 363 | }
|
---|
[4559] | 364 | okFlag = true;
|
---|
| 365 | }
|
---|
[4562] | 366 | else {
|
---|
| 367 | if (obs.snrL1 > 0) {
|
---|
| 368 | newObs->_SNR1 = obs.snrL1;
|
---|
| 369 | okFlag = true;
|
---|
| 370 | }
|
---|
| 371 | }
|
---|
[4559] | 372 | double S2 = obs.measdata("S2", 3.0);
|
---|
| 373 | if (S2 != 0.0) {
|
---|
[4562] | 374 | newObs->_SNR2 = floor(S2/6);
|
---|
| 375 | if (newObs->_SNR2 > 9.0) {
|
---|
| 376 | newObs->_SNR2 = 9.0;
|
---|
| 377 | }
|
---|
| 378 | if (newObs->_SNR2 < 1.0) {
|
---|
| 379 | newObs->_SNR2 = 1.0;
|
---|
| 380 | }
|
---|
[4559] | 381 | okFlag = true;
|
---|
| 382 | }
|
---|
[4562] | 383 | else {
|
---|
| 384 | if (obs.snrL2 > 0) {
|
---|
| 385 | newObs->_SNR2 = obs.snrL2;
|
---|
| 386 | okFlag = true;
|
---|
| 387 | }
|
---|
| 388 | }
|
---|
[4559] | 389 |
|
---|
[4354] | 390 | // Remember the Observation
|
---|
| 391 | // ------------------------
|
---|
| 392 | if (okFlag) {
|
---|
[4584] | 393 | _oneObsVec << newObs;
|
---|
[4694] | 394 | return success;
|
---|
[4354] | 395 | }
|
---|
| 396 | else {
|
---|
| 397 | delete newObs;
|
---|
[4694] | 398 | return failure;
|
---|
[4354] | 399 | }
|
---|
[4263] | 400 | }
|
---|
[4350] | 401 |
|
---|
| 402 | //
|
---|
| 403 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4679] | 404 | void t_reqcAnalyze::prepareObsStat(unsigned iEpo, double obsInterval,
|
---|
| 405 | const ColumnVector& xyzSta) {
|
---|
[4677] | 406 | const int sampl = int(30.0 / obsInterval);
|
---|
| 407 | if (iEpo % sampl == 0) {
|
---|
[4676] | 408 | double mjdX24 = _currEpo->tt.mjddec() * 24.0;
|
---|
| 409 | if (iEpo != 0) {
|
---|
| 410 | _obsStat._mjdX24 << mjdX24;
|
---|
| 411 | _obsStat._numSat << _obsStat._numSat.last();
|
---|
[4680] | 412 | _obsStat._PDOP << _obsStat._PDOP.last();
|
---|
[4676] | 413 | }
|
---|
| 414 | _obsStat._mjdX24 << mjdX24;
|
---|
[4675] | 415 | _obsStat._numSat << _currEpo->rnxSat.size();
|
---|
[4680] | 416 | _obsStat._PDOP << cmpDOP(xyzSta);
|
---|
[4675] | 417 | }
|
---|
| 418 | }
|
---|
| 419 |
|
---|
| 420 | //
|
---|
| 421 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4679] | 422 | void t_reqcAnalyze::preparePlotData(const QString& prn,
|
---|
| 423 | const ColumnVector& xyzSta,
|
---|
[4572] | 424 | double obsInterval,
|
---|
| 425 | QVector<t_polarPoint*>* dataMP1,
|
---|
| 426 | QVector<t_polarPoint*>* dataMP2,
|
---|
| 427 | QVector<t_polarPoint*>* dataSNR1,
|
---|
[4675] | 428 | QVector<t_polarPoint*>* dataSNR2) {
|
---|
[4350] | 429 |
|
---|
[4544] | 430 | const int chunkStep = int( 30.0 / obsInterval); // chunk step (30 sec)
|
---|
| 431 | const int numEpo = int(600.0 / obsInterval); // # epochs in one chunk (10 min)
|
---|
[4350] | 432 |
|
---|
[4584] | 433 | t_allObs& allObs = _allObsMap[prn];
|
---|
| 434 |
|
---|
[4591] | 435 | // Loop over all Chunks of Data
|
---|
| 436 | // ----------------------------
|
---|
[4702] | 437 | bool slipFound = false;
|
---|
[4584] | 438 | for (int chunkStart = 0; chunkStart + numEpo < allObs._oneObsVec.size();
|
---|
[4361] | 439 | chunkStart += chunkStep) {
|
---|
[4351] | 440 |
|
---|
[4703] | 441 | if (chunkStart * chunkStep == numEpo) {
|
---|
[4702] | 442 | slipFound = false;
|
---|
| 443 | }
|
---|
| 444 |
|
---|
[4675] | 445 | // Chunk-Specific Variables
|
---|
| 446 | // ------------------------
|
---|
[4591] | 447 | bncTime currTime;
|
---|
| 448 | bncTime prevTime;
|
---|
[4590] | 449 | bncTime chunkStartTime;
|
---|
[4675] | 450 | double mjdX24 = 0.0;
|
---|
[4607] | 451 | bool availL1 = false;
|
---|
| 452 | bool availL2 = false;
|
---|
| 453 | bool gapL1 = false;
|
---|
| 454 | bool gapL2 = false;
|
---|
| 455 | bool slipL1 = false;
|
---|
| 456 | bool slipL2 = false;
|
---|
| 457 | double meanMP1 = 0.0;
|
---|
| 458 | double meanMP2 = 0.0;
|
---|
| 459 | double minSNR1 = 0.0;
|
---|
| 460 | double minSNR2 = 0.0;
|
---|
| 461 | double aziDeg = 0.0;
|
---|
| 462 | double zenDeg = 0.0;
|
---|
[4659] | 463 | bool zenFlag = false;
|
---|
[4353] | 464 |
|
---|
[4591] | 465 | // Loop over all Epochs within one Chunk of Data
|
---|
| 466 | // ---------------------------------------------
|
---|
[4361] | 467 | for (int ii = 0; ii < numEpo; ii++) {
|
---|
[4351] | 468 | int iEpo = chunkStart + ii;
|
---|
[4584] | 469 | const t_oneObs* oneObs = allObs._oneObsVec[iEpo];
|
---|
[4572] | 470 |
|
---|
[4590] | 471 | currTime.set(oneObs->_GPSWeek, oneObs->_GPSWeeks);
|
---|
| 472 |
|
---|
| 473 | // Compute the Azimuth and Zenith Distance
|
---|
| 474 | // ---------------------------------------
|
---|
[4572] | 475 | if (ii == 0) {
|
---|
[4590] | 476 | chunkStartTime = currTime;
|
---|
[4675] | 477 | mjdX24 = chunkStartTime.mjddec() * 24.0;
|
---|
[4590] | 478 |
|
---|
[4679] | 479 | if (xyzSta.size()) {
|
---|
[4590] | 480 | t_eph* eph = 0;
|
---|
| 481 | for (int ie = 0; ie < _ephs.size(); ie++) {
|
---|
| 482 | if (_ephs[ie]->prn() == prn) {
|
---|
| 483 | eph = _ephs[ie];
|
---|
| 484 | break;
|
---|
| 485 | }
|
---|
| 486 | }
|
---|
| 487 |
|
---|
| 488 | if (eph) {
|
---|
| 489 | double xSat, ySat, zSat, clkSat;
|
---|
| 490 | eph->position(oneObs->_GPSWeek, oneObs->_GPSWeeks,
|
---|
| 491 | xSat, ySat, zSat, clkSat);
|
---|
| 492 |
|
---|
| 493 | double rho, eleSat, azSat;
|
---|
[4679] | 494 | topos(xyzSta(1), xyzSta(2), xyzSta(3),
|
---|
| 495 | xSat, ySat, zSat, rho, eleSat, azSat);
|
---|
[4590] | 496 |
|
---|
| 497 | aziDeg = azSat * 180.0/M_PI;
|
---|
| 498 | zenDeg = 90.0 - eleSat * 180.0/M_PI;
|
---|
[4659] | 499 | zenFlag = true;
|
---|
[4590] | 500 | }
|
---|
| 501 | }
|
---|
[4572] | 502 | }
|
---|
[4675] | 503 |
|
---|
[4590] | 504 | // Check Interval
|
---|
| 505 | // --------------
|
---|
| 506 | if (prevTime.valid()) {
|
---|
[4591] | 507 | double dt = currTime - prevTime;
|
---|
| 508 | if (dt != obsInterval) {
|
---|
| 509 | gapL1 = true;
|
---|
| 510 | gapL2 = true;
|
---|
| 511 | }
|
---|
[4590] | 512 | }
|
---|
| 513 | prevTime = currTime;
|
---|
[4563] | 514 |
|
---|
[4590] | 515 | // Check L1 and L2 availability
|
---|
| 516 | // ----------------------------
|
---|
| 517 | if (oneObs->_hasL1) {
|
---|
| 518 | availL1 = true;
|
---|
[4566] | 519 | }
|
---|
[4590] | 520 | else {
|
---|
[4591] | 521 | gapL1 = true;
|
---|
[4566] | 522 | }
|
---|
[4590] | 523 | if (oneObs->_hasL2) {
|
---|
| 524 | availL2 = true;
|
---|
| 525 | }
|
---|
| 526 | else {
|
---|
[4591] | 527 | gapL2 = true;
|
---|
[4590] | 528 | }
|
---|
| 529 |
|
---|
| 530 | // Check Minimal Signal-to-Noise Ratio
|
---|
| 531 | // -----------------------------------
|
---|
| 532 | if ( oneObs->_SNR1 > 0 && (minSNR1 == 0 || minSNR1 > oneObs->_SNR1) ) {
|
---|
| 533 | minSNR1 = oneObs->_SNR1;
|
---|
| 534 | }
|
---|
| 535 | if ( oneObs->_SNR2 > 0 && (minSNR2 == 0 || minSNR2 > oneObs->_SNR2) ) {
|
---|
| 536 | minSNR2 = oneObs->_SNR2;
|
---|
| 537 | }
|
---|
| 538 |
|
---|
[4607] | 539 | // Check Slip Flags
|
---|
| 540 | // ----------------
|
---|
| 541 | if (oneObs->_slipL1) {
|
---|
| 542 | slipL1 = true;
|
---|
| 543 | }
|
---|
| 544 | if (oneObs->_slipL2) {
|
---|
| 545 | slipL2 = true;
|
---|
| 546 | }
|
---|
| 547 |
|
---|
[4698] | 548 | meanMP1 += oneObs->_MP1;
|
---|
| 549 | meanMP2 += oneObs->_MP2;
|
---|
| 550 | }
|
---|
| 551 |
|
---|
| 552 | // Compute the Multipath
|
---|
| 553 | // ---------------------
|
---|
[4700] | 554 | if (prn[0] != 'R') { // TODO
|
---|
| 555 | bool slipMP = false;
|
---|
| 556 | meanMP1 /= numEpo;
|
---|
| 557 | meanMP2 /= numEpo;
|
---|
| 558 | double MP1 = 0.0;
|
---|
| 559 | double MP2 = 0.0;
|
---|
| 560 | for (int ii = 0; ii < numEpo; ii++) {
|
---|
| 561 | int iEpo = chunkStart + ii;
|
---|
| 562 | const t_oneObs* oneObs = allObs._oneObsVec[iEpo];
|
---|
| 563 | double diff1 = oneObs->_MP1 - meanMP1;
|
---|
| 564 | double diff2 = oneObs->_MP2 - meanMP2;
|
---|
| 565 |
|
---|
| 566 | // Check Slip Threshold
|
---|
| 567 | // --------------------
|
---|
| 568 | if (fabs(diff1) > SLIPTRESH || fabs(diff2) > SLIPTRESH) {
|
---|
| 569 | slipMP = true;
|
---|
| 570 | break;
|
---|
| 571 | }
|
---|
| 572 |
|
---|
| 573 | MP1 += diff1 * diff1;
|
---|
| 574 | MP2 += diff2 * diff2;
|
---|
[4353] | 575 | }
|
---|
[4700] | 576 | if (slipMP) {
|
---|
| 577 | slipL1 = true;
|
---|
| 578 | slipL2 = true;
|
---|
[4702] | 579 | if (!slipFound) {
|
---|
| 580 | slipFound = true;
|
---|
| 581 | _obsStat._prnStat[prn]._numSlipsFound += 1;
|
---|
| 582 | }
|
---|
[4700] | 583 | }
|
---|
| 584 | else {
|
---|
| 585 | MP1 = sqrt(MP1 / (numEpo-1));
|
---|
| 586 | MP2 = sqrt(MP2 / (numEpo-1));
|
---|
| 587 | (*dataMP1) << (new t_polarPoint(aziDeg, zenDeg, MP1));
|
---|
| 588 | (*dataMP2) << (new t_polarPoint(aziDeg, zenDeg, MP2));
|
---|
| 589 | }
|
---|
[4353] | 590 | }
|
---|
| 591 |
|
---|
[4590] | 592 | // Availability Plot Data
|
---|
| 593 | // ----------------------
|
---|
| 594 | if (availL1) {
|
---|
[4607] | 595 | if (slipL1) {
|
---|
[4617] | 596 | _availDataMap[prn]._L1slip << mjdX24;
|
---|
[4591] | 597 | }
|
---|
| 598 | else if (gapL1) {
|
---|
[4617] | 599 | _availDataMap[prn]._L1gap << mjdX24;
|
---|
[4591] | 600 | }
|
---|
| 601 | else {
|
---|
[4617] | 602 | _availDataMap[prn]._L1ok << mjdX24;
|
---|
[4591] | 603 | }
|
---|
[4351] | 604 | }
|
---|
[4591] | 605 | if (availL2) {
|
---|
[4607] | 606 | if (slipL2) {
|
---|
[4617] | 607 | _availDataMap[prn]._L2slip << mjdX24;
|
---|
[4591] | 608 | }
|
---|
| 609 | else if (gapL2) {
|
---|
[4617] | 610 | _availDataMap[prn]._L2gap << mjdX24;
|
---|
[4591] | 611 | }
|
---|
| 612 | else {
|
---|
[4617] | 613 | _availDataMap[prn]._L2ok << mjdX24;
|
---|
[4591] | 614 | }
|
---|
| 615 | }
|
---|
[4659] | 616 | if (zenFlag) {
|
---|
[4662] | 617 | _availDataMap[prn]._eleTim << mjdX24;
|
---|
| 618 | _availDataMap[prn]._eleDeg << 90.0 - zenDeg;
|
---|
[4659] | 619 | }
|
---|
[4351] | 620 |
|
---|
[4590] | 621 | // Signal-to-Noise Ration Plot Data
|
---|
| 622 | // --------------------------------
|
---|
| 623 | (*dataSNR1) << (new t_polarPoint(aziDeg, zenDeg, minSNR1));
|
---|
| 624 | (*dataSNR2) << (new t_polarPoint(aziDeg, zenDeg, minSNR2));
|
---|
[4350] | 625 | }
|
---|
| 626 | }
|
---|
[4572] | 627 |
|
---|
| 628 | //
|
---|
| 629 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 630 | void t_reqcAnalyze::slotDspAvailPlot(const QString& fileName,
|
---|
[4584] | 631 | const QByteArray& title) {
|
---|
[4572] | 632 |
|
---|
[4574] | 633 | if (dynamic_cast<bncApp*>(qApp)->GUIenabled()) {
|
---|
[4659] | 634 | t_availPlot* plotA = new t_availPlot(0, &_availDataMap);
|
---|
| 635 | plotA->setTitle(title);
|
---|
[4573] | 636 |
|
---|
[4662] | 637 | t_elePlot* plotZ = new t_elePlot(0, &_availDataMap);
|
---|
[4659] | 638 |
|
---|
[4672] | 639 | t_dopPlot* plotD = new t_dopPlot(0, &_obsStat);
|
---|
[4671] | 640 |
|
---|
[4573] | 641 | QVector<QWidget*> plots;
|
---|
[4671] | 642 | plots << plotA << plotZ << plotD;
|
---|
[4573] | 643 | t_graphWin* graphWin = new t_graphWin(0, fileName, plots, 0, 0);
|
---|
[4666] | 644 |
|
---|
| 645 | int ww = QFontMetrics(graphWin->font()).width('w');
|
---|
| 646 | graphWin->setMinimumSize(120*ww, 40*ww);
|
---|
| 647 |
|
---|
[4573] | 648 | graphWin->show();
|
---|
| 649 |
|
---|
| 650 | bncSettings settings;
|
---|
| 651 | QString dirName = settings.value("reqcPlotDir").toString();
|
---|
| 652 | if (!dirName.isEmpty()) {
|
---|
[4606] | 653 | QByteArray ext = "_A.png";
|
---|
[4579] | 654 | graphWin->savePNG(dirName, ext);
|
---|
[4573] | 655 | }
|
---|
| 656 | }
|
---|
[4715] | 657 | _mutex.unlock();
|
---|
[4572] | 658 | }
|
---|
[4679] | 659 |
|
---|
| 660 | // Compute Dilution of Precision
|
---|
| 661 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 662 | double t_reqcAnalyze::cmpDOP(const ColumnVector& xyzSta) const {
|
---|
| 663 |
|
---|
| 664 | if (xyzSta.size() != 3) {
|
---|
| 665 | return 0.0;
|
---|
| 666 | }
|
---|
| 667 |
|
---|
| 668 | unsigned nSat = _currEpo->rnxSat.size();
|
---|
| 669 |
|
---|
| 670 | if (nSat < 4) {
|
---|
| 671 | return 0.0;
|
---|
| 672 | }
|
---|
| 673 |
|
---|
| 674 | Matrix AA(nSat, 4);
|
---|
| 675 |
|
---|
| 676 | unsigned nSatUsed = 0;
|
---|
| 677 | for (unsigned iSat = 0; iSat < nSat; iSat++) {
|
---|
| 678 |
|
---|
| 679 | const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iSat];
|
---|
| 680 |
|
---|
| 681 | QString prn = QString("%1%2").arg(rnxSat.satSys)
|
---|
| 682 | .arg(rnxSat.satNum, 2, 10, QChar('0'));
|
---|
| 683 |
|
---|
| 684 | t_eph* eph = 0;
|
---|
| 685 | for (int ie = 0; ie < _ephs.size(); ie++) {
|
---|
| 686 | if (_ephs[ie]->prn() == prn) {
|
---|
| 687 | eph = _ephs[ie];
|
---|
| 688 | break;
|
---|
| 689 | }
|
---|
| 690 | }
|
---|
| 691 | if (eph) {
|
---|
| 692 | ++nSatUsed;
|
---|
| 693 | ColumnVector xSat(3);
|
---|
| 694 | double clkSat;
|
---|
| 695 | eph->position(_currEpo->tt.gpsw(), _currEpo->tt.gpssec(),
|
---|
| 696 | xSat(1), xSat(2), xSat(3), clkSat);
|
---|
| 697 | ColumnVector dx = xSat - xyzSta;
|
---|
[4681] | 698 | double rho = dx.norm_Frobenius();
|
---|
| 699 | AA(nSatUsed,1) = dx(1) / rho;
|
---|
| 700 | AA(nSatUsed,2) = dx(2) / rho;
|
---|
| 701 | AA(nSatUsed,3) = dx(3) / rho;
|
---|
| 702 | AA(nSatUsed,4) = 1.0;
|
---|
[4679] | 703 | }
|
---|
[4681] | 704 | }
|
---|
[4679] | 705 |
|
---|
[4681] | 706 | if (nSatUsed < 4) {
|
---|
| 707 | return 0.0;
|
---|
[4679] | 708 | }
|
---|
| 709 |
|
---|
[4681] | 710 | AA = AA.Rows(1, nSatUsed);
|
---|
| 711 |
|
---|
| 712 | SymmetricMatrix QQ;
|
---|
| 713 | QQ << AA.t() * AA;
|
---|
| 714 | QQ = QQ.i();
|
---|
| 715 |
|
---|
| 716 | return sqrt(QQ.trace());
|
---|
[4679] | 717 | }
|
---|
[4689] | 718 |
|
---|
| 719 | // Finish the report
|
---|
| 720 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4696] | 721 | void t_reqcAnalyze::printReport(QVector<t_polarPoint*>* dataMP1,
|
---|
| 722 | QVector<t_polarPoint*>* dataMP2,
|
---|
| 723 | QVector<t_polarPoint*>* dataSNR1,
|
---|
| 724 | QVector<t_polarPoint*>* dataSNR2) {
|
---|
[4689] | 725 | if (!_log) {
|
---|
| 726 | return;
|
---|
| 727 | }
|
---|
| 728 |
|
---|
[4701] | 729 | *_log << "Marker name: " << _obsStat._markerName << endl
|
---|
| 730 | << "Receiver: " << _obsStat._receiverType << endl
|
---|
| 731 | << "Antenna: " << _obsStat._antennaName << endl
|
---|
| 732 | << "Start time: " << _obsStat._startTime.datestr().c_str() << ' '
|
---|
| 733 | << _obsStat._startTime.timestr().c_str() << endl
|
---|
| 734 | << "End time: " << _obsStat._endTime.datestr().c_str() << ' '
|
---|
| 735 | << _obsStat._endTime.timestr().c_str() << endl
|
---|
| 736 | << "Interval: " << _obsStat._interval << endl
|
---|
| 737 | << "# Sat.: " << _obsStat._prnStat.size() << endl;
|
---|
[4689] | 738 |
|
---|
[4701] | 739 | int numObs = 0;
|
---|
| 740 | int numSlipsFlagged = 0;
|
---|
| 741 | int numSlipsFound = 0;
|
---|
[4693] | 742 | QMapIterator<QString, t_prnStat> it(_obsStat._prnStat);
|
---|
| 743 | while (it.hasNext()) {
|
---|
| 744 | it.next();
|
---|
| 745 | const t_prnStat& prnStat = it.value();
|
---|
[4701] | 746 | numObs += prnStat._numObs;
|
---|
| 747 | numSlipsFlagged += prnStat._numSlipsFlagged;
|
---|
| 748 | numSlipsFound += prnStat._numSlipsFound;
|
---|
[4693] | 749 | }
|
---|
[4701] | 750 | *_log << "# Obs.: " << numObs << endl
|
---|
| 751 | << "# Slips (file): " << numSlipsFlagged << endl
|
---|
| 752 | << "# Slips (found): " << numSlipsFound << endl;
|
---|
[4693] | 753 |
|
---|
[4697] | 754 | for (int kk = 1; kk <= 4; kk++) {
|
---|
| 755 | QVector<t_polarPoint*>* data = 0;
|
---|
| 756 | QString text;
|
---|
| 757 | if (kk == 1) {
|
---|
| 758 | data = dataMP1;
|
---|
[4701] | 759 | text = "Mean MP1: ";
|
---|
[4697] | 760 | }
|
---|
| 761 | else if (kk == 2) {
|
---|
| 762 | data = dataMP2;
|
---|
[4701] | 763 | text = "Mean MP2: ";
|
---|
[4697] | 764 | }
|
---|
| 765 | else if (kk == 3) {
|
---|
| 766 | data = dataSNR1;
|
---|
[4701] | 767 | text = "Mean SNR1: ";
|
---|
[4697] | 768 | }
|
---|
| 769 | else if (kk == 4) {
|
---|
| 770 | data = dataSNR2;
|
---|
[4701] | 771 | text = "Mean SNR2: ";
|
---|
[4697] | 772 | }
|
---|
| 773 | double mean = 0.0;
|
---|
| 774 | for (int ii = 0; ii < data->size(); ii++) {
|
---|
| 775 | const t_polarPoint* point = data->at(ii);
|
---|
| 776 | mean += point->_value;
|
---|
| 777 | }
|
---|
| 778 | mean /= data->size();
|
---|
| 779 | *_log << text << mean << endl;
|
---|
| 780 | }
|
---|
| 781 |
|
---|
[4689] | 782 | _log->flush();
|
---|
| 783 | }
|
---|