| 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 <iomanip>
|
|---|
| 43 | #include <qwt_plot_renderer.h>
|
|---|
| 44 |
|
|---|
| 45 | #include "reqcanalyze.h"
|
|---|
| 46 | #include "bncapp.h"
|
|---|
| 47 | #include "bncsettings.h"
|
|---|
| 48 | #include "reqcedit.h"
|
|---|
| 49 | #include "bncutils.h"
|
|---|
| 50 | #include "bncpostprocess.h"
|
|---|
| 51 | #include "graphwin.h"
|
|---|
| 52 | #include "polarplot.h"
|
|---|
| 53 | #include "availplot.h"
|
|---|
| 54 |
|
|---|
| 55 | using namespace std;
|
|---|
| 56 |
|
|---|
| 57 | const double SLIPTRESH = 5.0; // cycle-slip threshold (meters)
|
|---|
| 58 |
|
|---|
| 59 | // Constructor
|
|---|
| 60 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 61 | t_reqcAnalyze::t_reqcAnalyze(QObject* parent) : QThread(parent) {
|
|---|
| 62 |
|
|---|
| 63 | bncSettings settings;
|
|---|
| 64 |
|
|---|
| 65 | _logFileName = settings.value("reqcOutLogFile").toString(); expandEnvVar(_logFileName);
|
|---|
| 66 | _logFile = 0;
|
|---|
| 67 | _log = 0;
|
|---|
| 68 | _obsFileNames = settings.value("reqcObsFile").toString().split(",", QString::SkipEmptyParts);
|
|---|
| 69 | _navFileNames = settings.value("reqcNavFile").toString().split(",", QString::SkipEmptyParts);
|
|---|
| 70 |
|
|---|
| 71 | _currEpo = 0;
|
|---|
| 72 |
|
|---|
| 73 | connect(this, SIGNAL(dspSkyPlot(const QString&,
|
|---|
| 74 | const QByteArray&,
|
|---|
| 75 | QVector<t_polarPoint*>*,
|
|---|
| 76 | const QByteArray&,
|
|---|
| 77 | QVector<t_polarPoint*>*,
|
|---|
| 78 | const QByteArray&, double)),
|
|---|
| 79 | this, SLOT(slotDspSkyPlot(const QString&,
|
|---|
| 80 | const QByteArray&,
|
|---|
| 81 | QVector<t_polarPoint*>*,
|
|---|
| 82 | const QByteArray&,
|
|---|
| 83 | QVector<t_polarPoint*>*,
|
|---|
| 84 | const QByteArray&, double)));
|
|---|
| 85 |
|
|---|
| 86 | connect(this, SIGNAL(dspAvailPlot(const QString&, const QByteArray&)),
|
|---|
| 87 | this, SLOT(slotDspAvailPlot(const QString&, const QByteArray&)));
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | // Destructor
|
|---|
| 91 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 92 | t_reqcAnalyze::~t_reqcAnalyze() {
|
|---|
| 93 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
|---|
| 94 | delete _rnxObsFiles[ii];
|
|---|
| 95 | }
|
|---|
| 96 | for (int ii = 0; ii < _ephs.size(); ii++) {
|
|---|
| 97 | delete _ephs[ii];
|
|---|
| 98 | }
|
|---|
| 99 | delete _log; _log = 0;
|
|---|
| 100 | delete _logFile; _logFile = 0;
|
|---|
| 101 | bncApp* app = (bncApp*) qApp;
|
|---|
| 102 | if ( app->mode() != bncApp::interactive) {
|
|---|
| 103 | app->exit(0);
|
|---|
| 104 | }
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 | //
|
|---|
| 108 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 109 | void t_reqcAnalyze::slotDspSkyPlot(const QString& fileName,
|
|---|
| 110 | const QByteArray& title1,
|
|---|
| 111 | QVector<t_polarPoint*>* data1,
|
|---|
| 112 | const QByteArray& title2,
|
|---|
| 113 | QVector<t_polarPoint*>* data2,
|
|---|
| 114 | const QByteArray& scaleTitle,
|
|---|
| 115 | double maxValue) {
|
|---|
| 116 |
|
|---|
| 117 | bncApp* app = dynamic_cast<bncApp*>(qApp);
|
|---|
| 118 | if (app->GUIenabled()) {
|
|---|
| 119 |
|
|---|
| 120 | if (maxValue == 0.0) {
|
|---|
| 121 | if (data1) {
|
|---|
| 122 | for (int ii = 0; ii < data1->size(); ii++) {
|
|---|
| 123 | double val = data1->at(ii)->_value;
|
|---|
| 124 | if (maxValue < val) {
|
|---|
| 125 | maxValue = val;
|
|---|
| 126 | }
|
|---|
| 127 | }
|
|---|
| 128 | }
|
|---|
| 129 | if (data2) {
|
|---|
| 130 | for (int ii = 0; ii < data2->size(); ii++) {
|
|---|
| 131 | double val = data2->at(ii)->_value;
|
|---|
| 132 | if (maxValue < val) {
|
|---|
| 133 | maxValue = val;
|
|---|
| 134 | }
|
|---|
| 135 | }
|
|---|
| 136 | }
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | QwtInterval scaleInterval(0.0, maxValue);
|
|---|
| 140 |
|
|---|
| 141 | QVector<QWidget*> plots;
|
|---|
| 142 | if (data1) {
|
|---|
| 143 | t_polarPlot* plot1 = new t_polarPlot(QwtText(title1), scaleInterval,
|
|---|
| 144 | app->mainWindow());
|
|---|
| 145 | plot1->addCurve(data1);
|
|---|
| 146 | plots << plot1;
|
|---|
| 147 | }
|
|---|
| 148 | if (data2) {
|
|---|
| 149 | t_polarPlot* plot2 = new t_polarPlot(QwtText(title2), scaleInterval,
|
|---|
| 150 | app->mainWindow());
|
|---|
| 151 | plot2->addCurve(data2);
|
|---|
| 152 | plots << plot2;
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 | t_graphWin* graphWin = new t_graphWin(0, fileName, plots,
|
|---|
| 156 | &scaleTitle, &scaleInterval);
|
|---|
| 157 |
|
|---|
| 158 | graphWin->show();
|
|---|
| 159 |
|
|---|
| 160 | bncSettings settings;
|
|---|
| 161 | QString dirName = settings.value("reqcPlotDir").toString();
|
|---|
| 162 | if (!dirName.isEmpty()) {
|
|---|
| 163 | QByteArray ext = scaleTitle.isEmpty() ? "_S.png" : "_M.png";
|
|---|
| 164 | graphWin->savePNG(dirName, ext);
|
|---|
| 165 | }
|
|---|
| 166 | }
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | //
|
|---|
| 170 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 171 | void t_reqcAnalyze::run() {
|
|---|
| 172 |
|
|---|
| 173 | // Open Log File
|
|---|
| 174 | // -------------
|
|---|
| 175 | _logFile = new QFile(_logFileName);
|
|---|
| 176 | if (_logFile->open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|---|
| 177 | _log = new QTextStream();
|
|---|
| 178 | _log->setDevice(_logFile);
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | // Initialize RINEX Observation Files
|
|---|
| 182 | // ----------------------------------
|
|---|
| 183 | t_reqcEdit::initRnxObsFiles(_obsFileNames, _rnxObsFiles, _log);
|
|---|
| 184 |
|
|---|
| 185 | // Read Ephemerides
|
|---|
| 186 | // ----------------
|
|---|
| 187 | t_reqcEdit::readEphemerides(_navFileNames, _ephs);
|
|---|
| 188 |
|
|---|
| 189 | // Loop over all RINEX Files
|
|---|
| 190 | // -------------------------
|
|---|
| 191 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
|---|
| 192 | analyzeFile(_rnxObsFiles[ii]);
|
|---|
| 193 | }
|
|---|
| 194 |
|
|---|
| 195 | // Exit
|
|---|
| 196 | // ----
|
|---|
| 197 | emit finished();
|
|---|
| 198 | deleteLater();
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|
| 201 | //
|
|---|
| 202 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 203 | void t_reqcAnalyze::analyzeFile(t_rnxObsFile* obsFile) {
|
|---|
| 204 |
|
|---|
| 205 | if (_log) {
|
|---|
| 206 | *_log << "\nAnalyze File\n"
|
|---|
| 207 | << "------------\n"
|
|---|
| 208 | << obsFile->fileName().toAscii().data() << endl << endl;
|
|---|
| 209 | }
|
|---|
| 210 |
|
|---|
| 211 | _allObsMap.clear();
|
|---|
| 212 | _availDataMap.clear();
|
|---|
| 213 |
|
|---|
| 214 | // A priori Coordinates
|
|---|
| 215 | // --------------------
|
|---|
| 216 | ColumnVector xyz = obsFile->xyz();
|
|---|
| 217 |
|
|---|
| 218 | // Loop over all Epochs
|
|---|
| 219 | // --------------------
|
|---|
| 220 | try {
|
|---|
| 221 | while ( (_currEpo = obsFile->nextEpoch()) != 0) {
|
|---|
| 222 |
|
|---|
| 223 | // Loop over all satellites
|
|---|
| 224 | // ------------------------
|
|---|
| 225 | for (unsigned iObs = 0; iObs < _currEpo->rnxSat.size(); iObs++) {
|
|---|
| 226 | const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iObs];
|
|---|
| 227 | t_obs obs;
|
|---|
| 228 | t_postProcessing::setObsFromRnx(obsFile, _currEpo, rnxSat, obs);
|
|---|
| 229 |
|
|---|
| 230 | if (obs.satSys == 'R') {
|
|---|
| 231 | // TODO: set channel number
|
|---|
| 232 | }
|
|---|
| 233 |
|
|---|
| 234 | QString prn = QString("%1%2").arg(obs.satSys)
|
|---|
| 235 | .arg(obs.satNum, 2, 10, QChar('0'));
|
|---|
| 236 |
|
|---|
| 237 | _allObsMap[prn].addObs(obs);
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 | } // while (_currEpo)
|
|---|
| 241 | }
|
|---|
| 242 | catch (QString str) {
|
|---|
| 243 | if (_log) {
|
|---|
| 244 | *_log << "Exception " << str << endl;
|
|---|
| 245 | }
|
|---|
| 246 | else {
|
|---|
| 247 | qDebug() << str;
|
|---|
| 248 | }
|
|---|
| 249 | return;
|
|---|
| 250 | }
|
|---|
| 251 |
|
|---|
| 252 | // Analyze the Multipath
|
|---|
| 253 | // ---------------------
|
|---|
| 254 | QVector<t_polarPoint*>* dataMP1 = new QVector<t_polarPoint*>;
|
|---|
| 255 | QVector<t_polarPoint*>* dataMP2 = new QVector<t_polarPoint*>;
|
|---|
| 256 | QVector<t_polarPoint*>* dataSNR1 = new QVector<t_polarPoint*>;
|
|---|
| 257 | QVector<t_polarPoint*>* dataSNR2 = new QVector<t_polarPoint*>;
|
|---|
| 258 |
|
|---|
| 259 | QMutableMapIterator<QString, t_allObs> it(_allObsMap);
|
|---|
| 260 | while (it.hasNext()) {
|
|---|
| 261 | it.next();
|
|---|
| 262 | QString prn = it.key();
|
|---|
| 263 | preparePlotData(prn, xyz, obsFile->interval(),
|
|---|
| 264 | dataMP1, dataMP2, dataSNR1, dataSNR2);
|
|---|
| 265 | }
|
|---|
| 266 |
|
|---|
| 267 | emit dspSkyPlot(obsFile->fileName(), "MP1", dataMP1, "MP2", dataMP2,
|
|---|
| 268 | "Meters", 2.0);
|
|---|
| 269 |
|
|---|
| 270 | emit dspSkyPlot(obsFile->fileName(), "SNR1", dataSNR1, "SNR2", dataSNR2,
|
|---|
| 271 | "", 9.0);
|
|---|
| 272 |
|
|---|
| 273 | QFileInfo fileInfo(obsFile->fileName());
|
|---|
| 274 | QByteArray title = fileInfo.fileName().toAscii();
|
|---|
| 275 |
|
|---|
| 276 | emit dspAvailPlot(obsFile->fileName(), title);
|
|---|
| 277 |
|
|---|
| 278 | if (_log) {
|
|---|
| 279 | _log->flush();
|
|---|
| 280 | }
|
|---|
| 281 | }
|
|---|
| 282 |
|
|---|
| 283 | //
|
|---|
| 284 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 285 | void t_reqcAnalyze::t_allObs::addObs(const t_obs& obs) {
|
|---|
| 286 |
|
|---|
| 287 | t_oneObs* newObs = new t_oneObs(obs.GPSWeek, obs.GPSWeeks);
|
|---|
| 288 | bool okFlag = false;
|
|---|
| 289 |
|
|---|
| 290 | // Availability and Slip Flags
|
|---|
| 291 | // ---------------------------
|
|---|
| 292 | double L1 = obs.measdata("L1", 3.0);
|
|---|
| 293 | if (L1 != 0) {
|
|---|
| 294 | newObs->_hasL1 = true;
|
|---|
| 295 | }
|
|---|
| 296 | double L2 = obs.measdata("L2", 3.0);
|
|---|
| 297 | if (L2 != 0) {
|
|---|
| 298 | newObs->_hasL2 = true;
|
|---|
| 299 | }
|
|---|
| 300 | if (obs.slipL1) {
|
|---|
| 301 | newObs->_slipL1 = true;
|
|---|
| 302 | }
|
|---|
| 303 | if (obs.slipL2) {
|
|---|
| 304 | newObs->_slipL2 = true;
|
|---|
| 305 | }
|
|---|
| 306 |
|
|---|
| 307 | // Compute the Multipath
|
|---|
| 308 | // ----------------------
|
|---|
| 309 | if (L1 != 0.0 && L2 != 0.0) {
|
|---|
| 310 | double f1 = t_CST::f1(obs.satSys, obs.slotNum);
|
|---|
| 311 | double f2 = t_CST::f2(obs.satSys, obs.slotNum);
|
|---|
| 312 |
|
|---|
| 313 | L1 = L1 * t_CST::c / f1;
|
|---|
| 314 | L2 = L2 * t_CST::c / f2;
|
|---|
| 315 |
|
|---|
| 316 | double P1 = obs.measdata("C1", 3.0);
|
|---|
| 317 | if (P1 != 0.0) {
|
|---|
| 318 | newObs->_MP1 = P1 - L1 - 2.0*f2*f2/(f1*f1-f2*f2) * (L1 - L2);
|
|---|
| 319 | okFlag = true;
|
|---|
| 320 | }
|
|---|
| 321 | double P2 = obs.measdata("C2", 3.0);
|
|---|
| 322 | if (P2 != 0.0) {
|
|---|
| 323 | newObs->_MP2 = P2 - L2 - 2.0*f1*f1/(f1*f1-f2*f2) * (L1 - L2);
|
|---|
| 324 | okFlag = true;
|
|---|
| 325 | }
|
|---|
| 326 | }
|
|---|
| 327 |
|
|---|
| 328 | // Signal-to-Noise
|
|---|
| 329 | // ---------------
|
|---|
| 330 | double S1 = obs.measdata("S1", 3.0);
|
|---|
| 331 | if (S1 != 0.0) {
|
|---|
| 332 | newObs->_SNR1 = floor(S1/6);
|
|---|
| 333 | if (newObs->_SNR1 > 9.0) {
|
|---|
| 334 | newObs->_SNR1 = 9.0;
|
|---|
| 335 | }
|
|---|
| 336 | if (newObs->_SNR1 < 1.0) {
|
|---|
| 337 | newObs->_SNR1 = 1.0;
|
|---|
| 338 | }
|
|---|
| 339 | okFlag = true;
|
|---|
| 340 | }
|
|---|
| 341 | else {
|
|---|
| 342 | if (obs.snrL1 > 0) {
|
|---|
| 343 | newObs->_SNR1 = obs.snrL1;
|
|---|
| 344 | okFlag = true;
|
|---|
| 345 | }
|
|---|
| 346 | }
|
|---|
| 347 | double S2 = obs.measdata("S2", 3.0);
|
|---|
| 348 | if (S2 != 0.0) {
|
|---|
| 349 | newObs->_SNR2 = floor(S2/6);
|
|---|
| 350 | if (newObs->_SNR2 > 9.0) {
|
|---|
| 351 | newObs->_SNR2 = 9.0;
|
|---|
| 352 | }
|
|---|
| 353 | if (newObs->_SNR2 < 1.0) {
|
|---|
| 354 | newObs->_SNR2 = 1.0;
|
|---|
| 355 | }
|
|---|
| 356 | okFlag = true;
|
|---|
| 357 | }
|
|---|
| 358 | else {
|
|---|
| 359 | if (obs.snrL2 > 0) {
|
|---|
| 360 | newObs->_SNR2 = obs.snrL2;
|
|---|
| 361 | okFlag = true;
|
|---|
| 362 | }
|
|---|
| 363 | }
|
|---|
| 364 |
|
|---|
| 365 | // Remember the Observation
|
|---|
| 366 | // ------------------------
|
|---|
| 367 | if (okFlag) {
|
|---|
| 368 | _oneObsVec << newObs;
|
|---|
| 369 | }
|
|---|
| 370 | else {
|
|---|
| 371 | delete newObs;
|
|---|
| 372 | }
|
|---|
| 373 | }
|
|---|
| 374 |
|
|---|
| 375 | //
|
|---|
| 376 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 377 | void t_reqcAnalyze::preparePlotData(const QString& prn, const ColumnVector& xyz,
|
|---|
| 378 | double obsInterval,
|
|---|
| 379 | QVector<t_polarPoint*>* dataMP1,
|
|---|
| 380 | QVector<t_polarPoint*>* dataMP2,
|
|---|
| 381 | QVector<t_polarPoint*>* dataSNR1,
|
|---|
| 382 | QVector<t_polarPoint*>* dataSNR2) {
|
|---|
| 383 |
|
|---|
| 384 | const int chunkStep = int( 30.0 / obsInterval); // chunk step (30 sec)
|
|---|
| 385 | const int numEpo = int(600.0 / obsInterval); // # epochs in one chunk (10 min)
|
|---|
| 386 |
|
|---|
| 387 | t_allObs& allObs = _allObsMap[prn];
|
|---|
| 388 |
|
|---|
| 389 | // Loop over all Chunks of Data
|
|---|
| 390 | // ----------------------------
|
|---|
| 391 | for (int chunkStart = 0; chunkStart + numEpo < allObs._oneObsVec.size();
|
|---|
| 392 | chunkStart += chunkStep) {
|
|---|
| 393 |
|
|---|
| 394 | // Chunk-Speicific Variables
|
|---|
| 395 | // -------------------------
|
|---|
| 396 | bncTime currTime;
|
|---|
| 397 | bncTime prevTime;
|
|---|
| 398 | bncTime chunkStartTime;
|
|---|
| 399 | bool availL1 = false;
|
|---|
| 400 | bool availL2 = false;
|
|---|
| 401 | bool gapL1 = false;
|
|---|
| 402 | bool gapL2 = false;
|
|---|
| 403 | bool slipL1 = false;
|
|---|
| 404 | bool slipL2 = false;
|
|---|
| 405 | bool slipMP = false;
|
|---|
| 406 | double meanMP1 = 0.0;
|
|---|
| 407 | double meanMP2 = 0.0;
|
|---|
| 408 | double minSNR1 = 0.0;
|
|---|
| 409 | double minSNR2 = 0.0;
|
|---|
| 410 | double aziDeg = 0.0;
|
|---|
| 411 | double zenDeg = 0.0;
|
|---|
| 412 |
|
|---|
| 413 | // Loop over all Epochs within one Chunk of Data
|
|---|
| 414 | // ---------------------------------------------
|
|---|
| 415 | for (int ii = 0; ii < numEpo; ii++) {
|
|---|
| 416 | int iEpo = chunkStart + ii;
|
|---|
| 417 | const t_oneObs* oneObs = allObs._oneObsVec[iEpo];
|
|---|
| 418 |
|
|---|
| 419 | currTime.set(oneObs->_GPSWeek, oneObs->_GPSWeeks);
|
|---|
| 420 |
|
|---|
| 421 | // Compute the Azimuth and Zenith Distance
|
|---|
| 422 | // ---------------------------------------
|
|---|
| 423 | if (ii == 0) {
|
|---|
| 424 | chunkStartTime = currTime;
|
|---|
| 425 |
|
|---|
| 426 | if (xyz.size()) {
|
|---|
| 427 | t_eph* eph = 0;
|
|---|
| 428 | for (int ie = 0; ie < _ephs.size(); ie++) {
|
|---|
| 429 | if (_ephs[ie]->prn() == prn) {
|
|---|
| 430 | eph = _ephs[ie];
|
|---|
| 431 | break;
|
|---|
| 432 | }
|
|---|
| 433 | }
|
|---|
| 434 |
|
|---|
| 435 | if (eph) {
|
|---|
| 436 | double xSat, ySat, zSat, clkSat;
|
|---|
| 437 | eph->position(oneObs->_GPSWeek, oneObs->_GPSWeeks,
|
|---|
| 438 | xSat, ySat, zSat, clkSat);
|
|---|
| 439 |
|
|---|
| 440 | double rho, eleSat, azSat;
|
|---|
| 441 | topos(xyz(1), xyz(2), xyz(3), xSat, ySat, zSat, rho, eleSat, azSat);
|
|---|
| 442 |
|
|---|
| 443 | aziDeg = azSat * 180.0/M_PI;
|
|---|
| 444 | zenDeg = 90.0 - eleSat * 180.0/M_PI;
|
|---|
| 445 | }
|
|---|
| 446 | }
|
|---|
| 447 | }
|
|---|
| 448 |
|
|---|
| 449 | // Check Interval
|
|---|
| 450 | // --------------
|
|---|
| 451 | if (prevTime.valid()) {
|
|---|
| 452 | double dt = currTime - prevTime;
|
|---|
| 453 | if (dt != obsInterval) {
|
|---|
| 454 | gapL1 = true;
|
|---|
| 455 | gapL2 = true;
|
|---|
| 456 | }
|
|---|
| 457 | }
|
|---|
| 458 | prevTime = currTime;
|
|---|
| 459 |
|
|---|
| 460 | // Check L1 and L2 availability
|
|---|
| 461 | // ----------------------------
|
|---|
| 462 | if (oneObs->_hasL1) {
|
|---|
| 463 | availL1 = true;
|
|---|
| 464 | }
|
|---|
| 465 | else {
|
|---|
| 466 | gapL1 = true;
|
|---|
| 467 | }
|
|---|
| 468 | if (oneObs->_hasL2) {
|
|---|
| 469 | availL2 = true;
|
|---|
| 470 | }
|
|---|
| 471 | else {
|
|---|
| 472 | gapL2 = true;
|
|---|
| 473 | }
|
|---|
| 474 |
|
|---|
| 475 | // Check Minimal Signal-to-Noise Ratio
|
|---|
| 476 | // -----------------------------------
|
|---|
| 477 | if ( oneObs->_SNR1 > 0 && (minSNR1 == 0 || minSNR1 > oneObs->_SNR1) ) {
|
|---|
| 478 | minSNR1 = oneObs->_SNR1;
|
|---|
| 479 | }
|
|---|
| 480 | if ( oneObs->_SNR2 > 0 && (minSNR2 == 0 || minSNR2 > oneObs->_SNR2) ) {
|
|---|
| 481 | minSNR2 = oneObs->_SNR2;
|
|---|
| 482 | }
|
|---|
| 483 |
|
|---|
| 484 | // Check Slip Flags
|
|---|
| 485 | // ----------------
|
|---|
| 486 | if (oneObs->_slipL1) {
|
|---|
| 487 | slipL1 = true;
|
|---|
| 488 | }
|
|---|
| 489 | if (oneObs->_slipL2) {
|
|---|
| 490 | slipL2 = true;
|
|---|
| 491 | }
|
|---|
| 492 |
|
|---|
| 493 | // Check Slip Threshold
|
|---|
| 494 | // --------------------
|
|---|
| 495 | if (ii > 0) {
|
|---|
| 496 | double diff1 = oneObs->_MP1 - allObs._oneObsVec[iEpo-1]->_MP1;
|
|---|
| 497 | double diff2 = oneObs->_MP2 - allObs._oneObsVec[iEpo-1]->_MP2;
|
|---|
| 498 | if (fabs(diff1) > SLIPTRESH || fabs(diff2) > SLIPTRESH) {
|
|---|
| 499 | slipMP = true;
|
|---|
| 500 | }
|
|---|
| 501 | }
|
|---|
| 502 |
|
|---|
| 503 | meanMP1 += oneObs->_MP1;
|
|---|
| 504 | meanMP2 += oneObs->_MP2;
|
|---|
| 505 | }
|
|---|
| 506 |
|
|---|
| 507 | // Availability Plot Data
|
|---|
| 508 | // ----------------------
|
|---|
| 509 | double mjdX24 = chunkStartTime.mjddec() * 24.0;
|
|---|
| 510 | if (availL1) {
|
|---|
| 511 | if (slipL1) {
|
|---|
| 512 | _availDataMap[prn]._L1slip << mjdX24;
|
|---|
| 513 | }
|
|---|
| 514 | else if (gapL1) {
|
|---|
| 515 | _availDataMap[prn]._L1gap << mjdX24;
|
|---|
| 516 | }
|
|---|
| 517 | else {
|
|---|
| 518 | _availDataMap[prn]._L1ok << mjdX24;
|
|---|
| 519 | }
|
|---|
| 520 | }
|
|---|
| 521 | if (availL2) {
|
|---|
| 522 | if (slipL2) {
|
|---|
| 523 | _availDataMap[prn]._L2slip << mjdX24;
|
|---|
| 524 | }
|
|---|
| 525 | else if (gapL2) {
|
|---|
| 526 | _availDataMap[prn]._L2gap << mjdX24;
|
|---|
| 527 | }
|
|---|
| 528 | else {
|
|---|
| 529 | _availDataMap[prn]._L2ok << mjdX24;
|
|---|
| 530 | }
|
|---|
| 531 | }
|
|---|
| 532 |
|
|---|
| 533 | // Signal-to-Noise Ration Plot Data
|
|---|
| 534 | // --------------------------------
|
|---|
| 535 | (*dataSNR1) << (new t_polarPoint(aziDeg, zenDeg, minSNR1));
|
|---|
| 536 | (*dataSNR2) << (new t_polarPoint(aziDeg, zenDeg, minSNR2));
|
|---|
| 537 |
|
|---|
| 538 | // Compute the Multipath
|
|---|
| 539 | // ---------------------
|
|---|
| 540 | if (!slipMP) {
|
|---|
| 541 | meanMP1 /= numEpo;
|
|---|
| 542 | meanMP2 /= numEpo;
|
|---|
| 543 | double MP1 = 0.0;
|
|---|
| 544 | double MP2 = 0.0;
|
|---|
| 545 | for (int ii = 0; ii < numEpo; ii++) {
|
|---|
| 546 | int iEpo = chunkStart + ii;
|
|---|
| 547 | const t_oneObs* oneObs = allObs._oneObsVec[iEpo];
|
|---|
| 548 | double diff1 = oneObs->_MP1 - meanMP1;
|
|---|
| 549 | double diff2 = oneObs->_MP2 - meanMP2;
|
|---|
| 550 | MP1 += diff1 * diff1;
|
|---|
| 551 | MP2 += diff2 * diff2;
|
|---|
| 552 | }
|
|---|
| 553 | MP1 = sqrt(MP1 / (numEpo-1));
|
|---|
| 554 | MP2 = sqrt(MP2 / (numEpo-1));
|
|---|
| 555 | (*dataMP1) << (new t_polarPoint(aziDeg, zenDeg, MP1));
|
|---|
| 556 | (*dataMP2) << (new t_polarPoint(aziDeg, zenDeg, MP2));
|
|---|
| 557 | }
|
|---|
| 558 | }
|
|---|
| 559 | }
|
|---|
| 560 |
|
|---|
| 561 | //
|
|---|
| 562 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 563 | void t_reqcAnalyze::slotDspAvailPlot(const QString& fileName,
|
|---|
| 564 | const QByteArray& title) {
|
|---|
| 565 |
|
|---|
| 566 | if (dynamic_cast<bncApp*>(qApp)->GUIenabled()) {
|
|---|
| 567 |
|
|---|
| 568 | t_availPlot* plot = new t_availPlot(0, &_availDataMap);
|
|---|
| 569 | plot->setTitle(title);
|
|---|
| 570 |
|
|---|
| 571 | QVector<QWidget*> plots;
|
|---|
| 572 | plots << plot;
|
|---|
| 573 | t_graphWin* graphWin = new t_graphWin(0, fileName, plots, 0, 0);
|
|---|
| 574 | graphWin->show();
|
|---|
| 575 |
|
|---|
| 576 | bncSettings settings;
|
|---|
| 577 | QString dirName = settings.value("reqcPlotDir").toString();
|
|---|
| 578 | if (!dirName.isEmpty()) {
|
|---|
| 579 | QByteArray ext = "_A.png";
|
|---|
| 580 | graphWin->savePNG(dirName, ext);
|
|---|
| 581 | }
|
|---|
| 582 | }
|
|---|
| 583 | }
|
|---|