[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 |
|
---|
[4357] | 59 | const double SLIPTRESH = 5.0; // cycle-slip threshold (meters)
|
---|
| 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 |
|
---|
[4517] | 207 | if (_log) {
|
---|
| 208 | *_log << "\nAnalyze File\n"
|
---|
| 209 | << "------------\n"
|
---|
[4690] | 210 | << "File: " << obsFile->fileName().toAscii().data() << endl;
|
---|
[4517] | 211 | }
|
---|
[4260] | 212 |
|
---|
[4584] | 213 | _allObsMap.clear();
|
---|
| 214 | _availDataMap.clear();
|
---|
[4343] | 215 |
|
---|
[4342] | 216 | // A priori Coordinates
|
---|
| 217 | // --------------------
|
---|
[4679] | 218 | ColumnVector xyzSta = obsFile->xyz();
|
---|
[4342] | 219 |
|
---|
[4262] | 220 | // Loop over all Epochs
|
---|
| 221 | // --------------------
|
---|
[4541] | 222 | try {
|
---|
[4675] | 223 | unsigned iEpo = 0;
|
---|
[4541] | 224 | while ( (_currEpo = obsFile->nextEpoch()) != 0) {
|
---|
[4688] | 225 |
|
---|
| 226 | if (iEpo == 0) {
|
---|
| 227 | _obsStat._startTime = _currEpo->tt;
|
---|
| 228 | _obsStat._antennaName = obsFile->antennaName();
|
---|
| 229 | _obsStat._markerName = obsFile->markerName();
|
---|
| 230 | _obsStat._receiverType = obsFile->receiverType();
|
---|
| 231 | _obsStat._interval = obsFile->interval();
|
---|
| 232 | }
|
---|
| 233 | _obsStat._endTime = _currEpo->tt;
|
---|
[4541] | 234 |
|
---|
| 235 | // Loop over all satellites
|
---|
| 236 | // ------------------------
|
---|
| 237 | for (unsigned iObs = 0; iObs < _currEpo->rnxSat.size(); iObs++) {
|
---|
| 238 | const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iObs];
|
---|
| 239 | t_obs obs;
|
---|
| 240 | t_postProcessing::setObsFromRnx(obsFile, _currEpo, rnxSat, obs);
|
---|
| 241 |
|
---|
| 242 | if (obs.satSys == 'R') {
|
---|
[4590] | 243 | // TODO: set channel number
|
---|
[4541] | 244 | }
|
---|
| 245 |
|
---|
| 246 | QString prn = QString("%1%2").arg(obs.satSys)
|
---|
| 247 | .arg(obs.satNum, 2, 10, QChar('0'));
|
---|
| 248 |
|
---|
[4584] | 249 | _allObsMap[prn].addObs(obs);
|
---|
[4675] | 250 |
|
---|
[4692] | 251 | _obsStat._prnStat[prn]._numObs += 1;
|
---|
[4262] | 252 | }
|
---|
[4541] | 253 |
|
---|
[4679] | 254 | prepareObsStat(iEpo, obsFile->interval(), xyzSta);
|
---|
[4678] | 255 | iEpo++;
|
---|
| 256 |
|
---|
[4541] | 257 | } // while (_currEpo)
|
---|
| 258 | }
|
---|
| 259 | catch (QString str) {
|
---|
| 260 | if (_log) {
|
---|
| 261 | *_log << "Exception " << str << endl;
|
---|
[4262] | 262 | }
|
---|
[4541] | 263 | else {
|
---|
| 264 | qDebug() << str;
|
---|
| 265 | }
|
---|
| 266 | return;
|
---|
| 267 | }
|
---|
[4262] | 268 |
|
---|
[4268] | 269 | // Analyze the Multipath
|
---|
| 270 | // ---------------------
|
---|
[4572] | 271 | QVector<t_polarPoint*>* dataMP1 = new QVector<t_polarPoint*>;
|
---|
| 272 | QVector<t_polarPoint*>* dataMP2 = new QVector<t_polarPoint*>;
|
---|
| 273 | QVector<t_polarPoint*>* dataSNR1 = new QVector<t_polarPoint*>;
|
---|
| 274 | QVector<t_polarPoint*>* dataSNR2 = new QVector<t_polarPoint*>;
|
---|
[4268] | 275 |
|
---|
[4584] | 276 | QMutableMapIterator<QString, t_allObs> it(_allObsMap);
|
---|
[4268] | 277 | while (it.hasNext()) {
|
---|
| 278 | it.next();
|
---|
[4584] | 279 | QString prn = it.key();
|
---|
[4679] | 280 | preparePlotData(prn, xyzSta, obsFile->interval(),
|
---|
[4675] | 281 | dataMP1, dataMP2, dataSNR1, dataSNR2);
|
---|
[4268] | 282 | }
|
---|
| 283 |
|
---|
[4572] | 284 | emit dspSkyPlot(obsFile->fileName(), "MP1", dataMP1, "MP2", dataMP2,
|
---|
| 285 | "Meters", 2.0);
|
---|
[4300] | 286 |
|
---|
[4572] | 287 | emit dspSkyPlot(obsFile->fileName(), "SNR1", dataSNR1, "SNR2", dataSNR2,
|
---|
| 288 | "", 9.0);
|
---|
| 289 |
|
---|
[4605] | 290 | QFileInfo fileInfo(obsFile->fileName());
|
---|
| 291 | QByteArray title = fileInfo.fileName().toAscii();
|
---|
[4572] | 292 |
|
---|
[4605] | 293 | emit dspAvailPlot(obsFile->fileName(), title);
|
---|
| 294 |
|
---|
[4689] | 295 | printReport();
|
---|
[4254] | 296 | }
|
---|
[4263] | 297 |
|
---|
| 298 | //
|
---|
| 299 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4584] | 300 | void t_reqcAnalyze::t_allObs::addObs(const t_obs& obs) {
|
---|
[4265] | 301 |
|
---|
[4584] | 302 | t_oneObs* newObs = new t_oneObs(obs.GPSWeek, obs.GPSWeeks);
|
---|
[4354] | 303 | bool okFlag = false;
|
---|
[4338] | 304 |
|
---|
[4608] | 305 | // Availability and Slip Flags
|
---|
| 306 | // ---------------------------
|
---|
[4424] | 307 | double L1 = obs.measdata("L1", 3.0);
|
---|
[4571] | 308 | if (L1 != 0) {
|
---|
| 309 | newObs->_hasL1 = true;
|
---|
| 310 | }
|
---|
[4424] | 311 | double L2 = obs.measdata("L2", 3.0);
|
---|
[4571] | 312 | if (L2 != 0) {
|
---|
| 313 | newObs->_hasL2 = true;
|
---|
| 314 | }
|
---|
[4608] | 315 | if (obs.slipL1) {
|
---|
| 316 | newObs->_slipL1 = true;
|
---|
| 317 | }
|
---|
| 318 | if (obs.slipL2) {
|
---|
| 319 | newObs->_slipL2 = true;
|
---|
| 320 | }
|
---|
| 321 |
|
---|
| 322 | // Compute the Multipath
|
---|
| 323 | // ----------------------
|
---|
[4391] | 324 | if (L1 != 0.0 && L2 != 0.0) {
|
---|
[4266] | 325 | double f1 = t_CST::f1(obs.satSys, obs.slotNum);
|
---|
| 326 | double f2 = t_CST::f2(obs.satSys, obs.slotNum);
|
---|
| 327 |
|
---|
[4391] | 328 | L1 = L1 * t_CST::c / f1;
|
---|
| 329 | L2 = L2 * t_CST::c / f2;
|
---|
[4266] | 330 |
|
---|
[4424] | 331 | double P1 = obs.measdata("C1", 3.0);
|
---|
[4391] | 332 | if (P1 != 0.0) {
|
---|
| 333 | newObs->_MP1 = P1 - L1 - 2.0*f2*f2/(f1*f1-f2*f2) * (L1 - L2);
|
---|
[4354] | 334 | okFlag = true;
|
---|
[4268] | 335 | }
|
---|
[4424] | 336 | double P2 = obs.measdata("C2", 3.0);
|
---|
[4391] | 337 | if (P2 != 0.0) {
|
---|
| 338 | newObs->_MP2 = P2 - L2 - 2.0*f1*f1/(f1*f1-f2*f2) * (L1 - L2);
|
---|
[4354] | 339 | okFlag = true;
|
---|
[4268] | 340 | }
|
---|
[4265] | 341 | }
|
---|
[4338] | 342 |
|
---|
[4559] | 343 | // Signal-to-Noise
|
---|
| 344 | // ---------------
|
---|
| 345 | double S1 = obs.measdata("S1", 3.0);
|
---|
| 346 | if (S1 != 0.0) {
|
---|
[4562] | 347 | newObs->_SNR1 = floor(S1/6);
|
---|
| 348 | if (newObs->_SNR1 > 9.0) {
|
---|
| 349 | newObs->_SNR1 = 9.0;
|
---|
| 350 | }
|
---|
| 351 | if (newObs->_SNR1 < 1.0) {
|
---|
| 352 | newObs->_SNR1 = 1.0;
|
---|
| 353 | }
|
---|
[4559] | 354 | okFlag = true;
|
---|
| 355 | }
|
---|
[4562] | 356 | else {
|
---|
| 357 | if (obs.snrL1 > 0) {
|
---|
| 358 | newObs->_SNR1 = obs.snrL1;
|
---|
| 359 | okFlag = true;
|
---|
| 360 | }
|
---|
| 361 | }
|
---|
[4559] | 362 | double S2 = obs.measdata("S2", 3.0);
|
---|
| 363 | if (S2 != 0.0) {
|
---|
[4562] | 364 | newObs->_SNR2 = floor(S2/6);
|
---|
| 365 | if (newObs->_SNR2 > 9.0) {
|
---|
| 366 | newObs->_SNR2 = 9.0;
|
---|
| 367 | }
|
---|
| 368 | if (newObs->_SNR2 < 1.0) {
|
---|
| 369 | newObs->_SNR2 = 1.0;
|
---|
| 370 | }
|
---|
[4559] | 371 | okFlag = true;
|
---|
| 372 | }
|
---|
[4562] | 373 | else {
|
---|
| 374 | if (obs.snrL2 > 0) {
|
---|
| 375 | newObs->_SNR2 = obs.snrL2;
|
---|
| 376 | okFlag = true;
|
---|
| 377 | }
|
---|
| 378 | }
|
---|
[4559] | 379 |
|
---|
[4354] | 380 | // Remember the Observation
|
---|
| 381 | // ------------------------
|
---|
| 382 | if (okFlag) {
|
---|
[4584] | 383 | _oneObsVec << newObs;
|
---|
[4354] | 384 | }
|
---|
| 385 | else {
|
---|
| 386 | delete newObs;
|
---|
| 387 | }
|
---|
[4263] | 388 | }
|
---|
[4350] | 389 |
|
---|
| 390 | //
|
---|
| 391 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4679] | 392 | void t_reqcAnalyze::prepareObsStat(unsigned iEpo, double obsInterval,
|
---|
| 393 | const ColumnVector& xyzSta) {
|
---|
[4677] | 394 | const int sampl = int(30.0 / obsInterval);
|
---|
| 395 | if (iEpo % sampl == 0) {
|
---|
[4676] | 396 | double mjdX24 = _currEpo->tt.mjddec() * 24.0;
|
---|
| 397 | if (iEpo != 0) {
|
---|
| 398 | _obsStat._mjdX24 << mjdX24;
|
---|
| 399 | _obsStat._numSat << _obsStat._numSat.last();
|
---|
[4680] | 400 | _obsStat._PDOP << _obsStat._PDOP.last();
|
---|
[4676] | 401 | }
|
---|
| 402 | _obsStat._mjdX24 << mjdX24;
|
---|
[4675] | 403 | _obsStat._numSat << _currEpo->rnxSat.size();
|
---|
[4680] | 404 | _obsStat._PDOP << cmpDOP(xyzSta);
|
---|
[4675] | 405 | }
|
---|
| 406 | }
|
---|
| 407 |
|
---|
| 408 | //
|
---|
| 409 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4679] | 410 | void t_reqcAnalyze::preparePlotData(const QString& prn,
|
---|
| 411 | const ColumnVector& xyzSta,
|
---|
[4572] | 412 | double obsInterval,
|
---|
| 413 | QVector<t_polarPoint*>* dataMP1,
|
---|
| 414 | QVector<t_polarPoint*>* dataMP2,
|
---|
| 415 | QVector<t_polarPoint*>* dataSNR1,
|
---|
[4675] | 416 | QVector<t_polarPoint*>* dataSNR2) {
|
---|
[4350] | 417 |
|
---|
[4544] | 418 | const int chunkStep = int( 30.0 / obsInterval); // chunk step (30 sec)
|
---|
| 419 | const int numEpo = int(600.0 / obsInterval); // # epochs in one chunk (10 min)
|
---|
[4350] | 420 |
|
---|
[4584] | 421 | t_allObs& allObs = _allObsMap[prn];
|
---|
| 422 |
|
---|
[4591] | 423 | // Loop over all Chunks of Data
|
---|
| 424 | // ----------------------------
|
---|
[4584] | 425 | for (int chunkStart = 0; chunkStart + numEpo < allObs._oneObsVec.size();
|
---|
[4361] | 426 | chunkStart += chunkStep) {
|
---|
[4351] | 427 |
|
---|
[4675] | 428 | // Chunk-Specific Variables
|
---|
| 429 | // ------------------------
|
---|
[4591] | 430 | bncTime currTime;
|
---|
| 431 | bncTime prevTime;
|
---|
[4590] | 432 | bncTime chunkStartTime;
|
---|
[4675] | 433 | double mjdX24 = 0.0;
|
---|
[4607] | 434 | bool availL1 = false;
|
---|
| 435 | bool availL2 = false;
|
---|
| 436 | bool gapL1 = false;
|
---|
| 437 | bool gapL2 = false;
|
---|
| 438 | bool slipL1 = false;
|
---|
| 439 | bool slipL2 = false;
|
---|
| 440 | bool slipMP = false;
|
---|
| 441 | double meanMP1 = 0.0;
|
---|
| 442 | double meanMP2 = 0.0;
|
---|
| 443 | double minSNR1 = 0.0;
|
---|
| 444 | double minSNR2 = 0.0;
|
---|
| 445 | double aziDeg = 0.0;
|
---|
| 446 | double zenDeg = 0.0;
|
---|
[4659] | 447 | bool zenFlag = false;
|
---|
[4353] | 448 |
|
---|
[4591] | 449 | // Loop over all Epochs within one Chunk of Data
|
---|
| 450 | // ---------------------------------------------
|
---|
[4361] | 451 | for (int ii = 0; ii < numEpo; ii++) {
|
---|
[4351] | 452 | int iEpo = chunkStart + ii;
|
---|
[4584] | 453 | const t_oneObs* oneObs = allObs._oneObsVec[iEpo];
|
---|
[4572] | 454 |
|
---|
[4590] | 455 | currTime.set(oneObs->_GPSWeek, oneObs->_GPSWeeks);
|
---|
| 456 |
|
---|
| 457 | // Compute the Azimuth and Zenith Distance
|
---|
| 458 | // ---------------------------------------
|
---|
[4572] | 459 | if (ii == 0) {
|
---|
[4590] | 460 | chunkStartTime = currTime;
|
---|
[4675] | 461 | mjdX24 = chunkStartTime.mjddec() * 24.0;
|
---|
[4590] | 462 |
|
---|
[4679] | 463 | if (xyzSta.size()) {
|
---|
[4590] | 464 | t_eph* eph = 0;
|
---|
| 465 | for (int ie = 0; ie < _ephs.size(); ie++) {
|
---|
| 466 | if (_ephs[ie]->prn() == prn) {
|
---|
| 467 | eph = _ephs[ie];
|
---|
| 468 | break;
|
---|
| 469 | }
|
---|
| 470 | }
|
---|
| 471 |
|
---|
| 472 | if (eph) {
|
---|
| 473 | double xSat, ySat, zSat, clkSat;
|
---|
| 474 | eph->position(oneObs->_GPSWeek, oneObs->_GPSWeeks,
|
---|
| 475 | xSat, ySat, zSat, clkSat);
|
---|
| 476 |
|
---|
| 477 | double rho, eleSat, azSat;
|
---|
[4679] | 478 | topos(xyzSta(1), xyzSta(2), xyzSta(3),
|
---|
| 479 | xSat, ySat, zSat, rho, eleSat, azSat);
|
---|
[4590] | 480 |
|
---|
| 481 | aziDeg = azSat * 180.0/M_PI;
|
---|
| 482 | zenDeg = 90.0 - eleSat * 180.0/M_PI;
|
---|
[4659] | 483 | zenFlag = true;
|
---|
[4590] | 484 | }
|
---|
| 485 | }
|
---|
[4572] | 486 | }
|
---|
[4675] | 487 |
|
---|
[4590] | 488 | // Check Interval
|
---|
| 489 | // --------------
|
---|
| 490 | if (prevTime.valid()) {
|
---|
[4591] | 491 | double dt = currTime - prevTime;
|
---|
| 492 | if (dt != obsInterval) {
|
---|
| 493 | gapL1 = true;
|
---|
| 494 | gapL2 = true;
|
---|
| 495 | }
|
---|
[4590] | 496 | }
|
---|
| 497 | prevTime = currTime;
|
---|
[4563] | 498 |
|
---|
[4590] | 499 | // Check L1 and L2 availability
|
---|
| 500 | // ----------------------------
|
---|
| 501 | if (oneObs->_hasL1) {
|
---|
| 502 | availL1 = true;
|
---|
[4566] | 503 | }
|
---|
[4590] | 504 | else {
|
---|
[4591] | 505 | gapL1 = true;
|
---|
[4566] | 506 | }
|
---|
[4590] | 507 | if (oneObs->_hasL2) {
|
---|
| 508 | availL2 = true;
|
---|
| 509 | }
|
---|
| 510 | else {
|
---|
[4591] | 511 | gapL2 = true;
|
---|
[4590] | 512 | }
|
---|
| 513 |
|
---|
| 514 | // Check Minimal Signal-to-Noise Ratio
|
---|
| 515 | // -----------------------------------
|
---|
| 516 | if ( oneObs->_SNR1 > 0 && (minSNR1 == 0 || minSNR1 > oneObs->_SNR1) ) {
|
---|
| 517 | minSNR1 = oneObs->_SNR1;
|
---|
| 518 | }
|
---|
| 519 | if ( oneObs->_SNR2 > 0 && (minSNR2 == 0 || minSNR2 > oneObs->_SNR2) ) {
|
---|
| 520 | minSNR2 = oneObs->_SNR2;
|
---|
| 521 | }
|
---|
| 522 |
|
---|
[4607] | 523 | // Check Slip Flags
|
---|
| 524 | // ----------------
|
---|
| 525 | if (oneObs->_slipL1) {
|
---|
| 526 | slipL1 = true;
|
---|
| 527 | }
|
---|
| 528 | if (oneObs->_slipL2) {
|
---|
| 529 | slipL2 = true;
|
---|
| 530 | }
|
---|
| 531 |
|
---|
| 532 | // Check Slip Threshold
|
---|
| 533 | // --------------------
|
---|
[4353] | 534 | if (ii > 0) {
|
---|
[4584] | 535 | double diff1 = oneObs->_MP1 - allObs._oneObsVec[iEpo-1]->_MP1;
|
---|
| 536 | double diff2 = oneObs->_MP2 - allObs._oneObsVec[iEpo-1]->_MP2;
|
---|
[4357] | 537 | if (fabs(diff1) > SLIPTRESH || fabs(diff2) > SLIPTRESH) {
|
---|
[4607] | 538 | slipMP = true;
|
---|
[4353] | 539 | }
|
---|
| 540 | }
|
---|
| 541 |
|
---|
[4590] | 542 | meanMP1 += oneObs->_MP1;
|
---|
| 543 | meanMP2 += oneObs->_MP2;
|
---|
[4353] | 544 | }
|
---|
| 545 |
|
---|
[4590] | 546 | // Availability Plot Data
|
---|
| 547 | // ----------------------
|
---|
| 548 | if (availL1) {
|
---|
[4607] | 549 | if (slipL1) {
|
---|
[4617] | 550 | _availDataMap[prn]._L1slip << mjdX24;
|
---|
[4591] | 551 | }
|
---|
| 552 | else if (gapL1) {
|
---|
[4617] | 553 | _availDataMap[prn]._L1gap << mjdX24;
|
---|
[4591] | 554 | }
|
---|
| 555 | else {
|
---|
[4617] | 556 | _availDataMap[prn]._L1ok << mjdX24;
|
---|
[4591] | 557 | }
|
---|
[4351] | 558 | }
|
---|
[4591] | 559 | if (availL2) {
|
---|
[4607] | 560 | if (slipL2) {
|
---|
[4617] | 561 | _availDataMap[prn]._L2slip << mjdX24;
|
---|
[4591] | 562 | }
|
---|
| 563 | else if (gapL2) {
|
---|
[4617] | 564 | _availDataMap[prn]._L2gap << mjdX24;
|
---|
[4591] | 565 | }
|
---|
| 566 | else {
|
---|
[4617] | 567 | _availDataMap[prn]._L2ok << mjdX24;
|
---|
[4591] | 568 | }
|
---|
| 569 | }
|
---|
[4659] | 570 | if (zenFlag) {
|
---|
[4662] | 571 | _availDataMap[prn]._eleTim << mjdX24;
|
---|
| 572 | _availDataMap[prn]._eleDeg << 90.0 - zenDeg;
|
---|
[4659] | 573 | }
|
---|
[4351] | 574 |
|
---|
[4590] | 575 | // Signal-to-Noise Ration Plot Data
|
---|
| 576 | // --------------------------------
|
---|
| 577 | (*dataSNR1) << (new t_polarPoint(aziDeg, zenDeg, minSNR1));
|
---|
| 578 | (*dataSNR2) << (new t_polarPoint(aziDeg, zenDeg, minSNR2));
|
---|
[4355] | 579 |
|
---|
[4590] | 580 | // Compute the Multipath
|
---|
| 581 | // ---------------------
|
---|
[4607] | 582 | if (!slipMP) {
|
---|
[4590] | 583 | meanMP1 /= numEpo;
|
---|
| 584 | meanMP2 /= numEpo;
|
---|
| 585 | double MP1 = 0.0;
|
---|
| 586 | double MP2 = 0.0;
|
---|
| 587 | for (int ii = 0; ii < numEpo; ii++) {
|
---|
| 588 | int iEpo = chunkStart + ii;
|
---|
| 589 | const t_oneObs* oneObs = allObs._oneObsVec[iEpo];
|
---|
| 590 | double diff1 = oneObs->_MP1 - meanMP1;
|
---|
| 591 | double diff2 = oneObs->_MP2 - meanMP2;
|
---|
| 592 | MP1 += diff1 * diff1;
|
---|
| 593 | MP2 += diff2 * diff2;
|
---|
[4355] | 594 | }
|
---|
[4590] | 595 | MP1 = sqrt(MP1 / (numEpo-1));
|
---|
| 596 | MP2 = sqrt(MP2 / (numEpo-1));
|
---|
| 597 | (*dataMP1) << (new t_polarPoint(aziDeg, zenDeg, MP1));
|
---|
| 598 | (*dataMP2) << (new t_polarPoint(aziDeg, zenDeg, MP2));
|
---|
[4355] | 599 | }
|
---|
[4350] | 600 | }
|
---|
| 601 | }
|
---|
[4572] | 602 |
|
---|
| 603 | //
|
---|
| 604 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 605 | void t_reqcAnalyze::slotDspAvailPlot(const QString& fileName,
|
---|
[4584] | 606 | const QByteArray& title) {
|
---|
[4572] | 607 |
|
---|
[4574] | 608 | if (dynamic_cast<bncApp*>(qApp)->GUIenabled()) {
|
---|
[4573] | 609 |
|
---|
[4659] | 610 | t_availPlot* plotA = new t_availPlot(0, &_availDataMap);
|
---|
| 611 | plotA->setTitle(title);
|
---|
[4573] | 612 |
|
---|
[4662] | 613 | t_elePlot* plotZ = new t_elePlot(0, &_availDataMap);
|
---|
[4659] | 614 |
|
---|
[4672] | 615 | t_dopPlot* plotD = new t_dopPlot(0, &_obsStat);
|
---|
[4671] | 616 |
|
---|
[4573] | 617 | QVector<QWidget*> plots;
|
---|
[4671] | 618 | plots << plotA << plotZ << plotD;
|
---|
[4573] | 619 | t_graphWin* graphWin = new t_graphWin(0, fileName, plots, 0, 0);
|
---|
[4666] | 620 |
|
---|
| 621 | int ww = QFontMetrics(graphWin->font()).width('w');
|
---|
| 622 | graphWin->setMinimumSize(120*ww, 40*ww);
|
---|
| 623 |
|
---|
[4573] | 624 | graphWin->show();
|
---|
| 625 |
|
---|
| 626 | bncSettings settings;
|
---|
| 627 | QString dirName = settings.value("reqcPlotDir").toString();
|
---|
| 628 | if (!dirName.isEmpty()) {
|
---|
[4606] | 629 | QByteArray ext = "_A.png";
|
---|
[4579] | 630 | graphWin->savePNG(dirName, ext);
|
---|
[4573] | 631 | }
|
---|
| 632 | }
|
---|
[4572] | 633 | }
|
---|
[4679] | 634 |
|
---|
| 635 | // Compute Dilution of Precision
|
---|
| 636 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 637 | double t_reqcAnalyze::cmpDOP(const ColumnVector& xyzSta) const {
|
---|
| 638 |
|
---|
| 639 | if (xyzSta.size() != 3) {
|
---|
| 640 | return 0.0;
|
---|
| 641 | }
|
---|
| 642 |
|
---|
| 643 | unsigned nSat = _currEpo->rnxSat.size();
|
---|
| 644 |
|
---|
| 645 | if (nSat < 4) {
|
---|
| 646 | return 0.0;
|
---|
| 647 | }
|
---|
| 648 |
|
---|
| 649 | Matrix AA(nSat, 4);
|
---|
| 650 |
|
---|
| 651 | unsigned nSatUsed = 0;
|
---|
| 652 | for (unsigned iSat = 0; iSat < nSat; iSat++) {
|
---|
| 653 |
|
---|
| 654 | const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iSat];
|
---|
| 655 |
|
---|
| 656 | QString prn = QString("%1%2").arg(rnxSat.satSys)
|
---|
| 657 | .arg(rnxSat.satNum, 2, 10, QChar('0'));
|
---|
| 658 |
|
---|
| 659 | t_eph* eph = 0;
|
---|
| 660 | for (int ie = 0; ie < _ephs.size(); ie++) {
|
---|
| 661 | if (_ephs[ie]->prn() == prn) {
|
---|
| 662 | eph = _ephs[ie];
|
---|
| 663 | break;
|
---|
| 664 | }
|
---|
| 665 | }
|
---|
| 666 | if (eph) {
|
---|
| 667 | ++nSatUsed;
|
---|
| 668 | ColumnVector xSat(3);
|
---|
| 669 | double clkSat;
|
---|
| 670 | eph->position(_currEpo->tt.gpsw(), _currEpo->tt.gpssec(),
|
---|
| 671 | xSat(1), xSat(2), xSat(3), clkSat);
|
---|
| 672 | ColumnVector dx = xSat - xyzSta;
|
---|
[4681] | 673 | double rho = dx.norm_Frobenius();
|
---|
| 674 | AA(nSatUsed,1) = dx(1) / rho;
|
---|
| 675 | AA(nSatUsed,2) = dx(2) / rho;
|
---|
| 676 | AA(nSatUsed,3) = dx(3) / rho;
|
---|
| 677 | AA(nSatUsed,4) = 1.0;
|
---|
[4679] | 678 | }
|
---|
[4681] | 679 | }
|
---|
[4679] | 680 |
|
---|
[4681] | 681 | if (nSatUsed < 4) {
|
---|
| 682 | return 0.0;
|
---|
[4679] | 683 | }
|
---|
| 684 |
|
---|
[4681] | 685 | AA = AA.Rows(1, nSatUsed);
|
---|
| 686 |
|
---|
| 687 | SymmetricMatrix QQ;
|
---|
| 688 | QQ << AA.t() * AA;
|
---|
| 689 | QQ = QQ.i();
|
---|
| 690 |
|
---|
| 691 | return sqrt(QQ.trace());
|
---|
[4679] | 692 | }
|
---|
[4689] | 693 |
|
---|
| 694 | // Finish the report
|
---|
| 695 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 696 | void t_reqcAnalyze::printReport() {
|
---|
| 697 |
|
---|
| 698 | if (!_log) {
|
---|
| 699 | return;
|
---|
| 700 | }
|
---|
| 701 |
|
---|
| 702 | *_log << "Marker name: " << _obsStat._markerName << endl
|
---|
| 703 | << "Receiver: " << _obsStat._receiverType << endl
|
---|
| 704 | << "Antenna: " << _obsStat._antennaName << endl
|
---|
| 705 | << "Start time: " << _obsStat._startTime.datestr().c_str() << ' '
|
---|
[4690] | 706 | << _obsStat._startTime.timestr().c_str() << endl
|
---|
| 707 | << "End time: " << _obsStat._endTime.datestr().c_str() << ' '
|
---|
[4691] | 708 | << _obsStat._endTime.timestr().c_str() << endl
|
---|
| 709 | << "Interval: " << _obsStat._interval << endl
|
---|
| 710 | << "# Sat.: " << _obsStat._prnStat.size() << endl;
|
---|
[4689] | 711 |
|
---|
[4693] | 712 | int numObs = 0;
|
---|
| 713 | QMapIterator<QString, t_prnStat> it(_obsStat._prnStat);
|
---|
| 714 | while (it.hasNext()) {
|
---|
| 715 | it.next();
|
---|
| 716 | const t_prnStat& prnStat = it.value();
|
---|
| 717 | numObs += prnStat._numObs;
|
---|
| 718 | }
|
---|
| 719 | *_log << "# Obs.: " << numObs << endl;
|
---|
| 720 |
|
---|
[4689] | 721 | _log->flush();
|
---|
| 722 | }
|
---|