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