[2057] | 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: bncParam, bncModel
|
---|
| 30 | *
|
---|
| 31 | * Purpose: Model for PPP
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 01-Dec-2009
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
| 41 | #include <iomanip>
|
---|
[2063] | 42 | #include <cmath>
|
---|
[2060] | 43 | #include <newmatio.h>
|
---|
[2113] | 44 | #include <sstream>
|
---|
[2057] | 45 |
|
---|
| 46 | #include "bncmodel.h"
|
---|
[2113] | 47 | #include "bncapp.h"
|
---|
[2058] | 48 | #include "bncpppclient.h"
|
---|
| 49 | #include "bancroft.h"
|
---|
[2063] | 50 | #include "bncutils.h"
|
---|
[2077] | 51 | #include "bncsettings.h"
|
---|
[2580] | 52 | #include "bnctides.h"
|
---|
[2881] | 53 | #include "bncantex.h"
|
---|
[2057] | 54 |
|
---|
| 55 | using namespace std;
|
---|
| 56 |
|
---|
[2243] | 57 | const unsigned MINOBS = 4;
|
---|
[2287] | 58 | const double MINELE_GPS = 10.0 * M_PI / 180.0;
|
---|
| 59 | const double MINELE_GLO = 10.0 * M_PI / 180.0;
|
---|
[2780] | 60 | const double MINELE_GAL = 10.0 * M_PI / 180.0;
|
---|
[2243] | 61 | const double MAXRES_CODE_GPS = 10.0;
|
---|
| 62 | const double MAXRES_PHASE_GPS = 0.10;
|
---|
[2539] | 63 | const double MAXRES_PHASE_GLO = 0.05;
|
---|
[2784] | 64 | const double MAXRES_CODE_GAL = 10.0;
|
---|
| 65 | const double MAXRES_PHASE_GAL = 0.10;
|
---|
[2070] | 66 |
|
---|
[2057] | 67 | // Constructor
|
---|
| 68 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2080] | 69 | bncParam::bncParam(bncParam::parType typeIn, int indexIn,
|
---|
| 70 | const QString& prnIn) {
|
---|
| 71 | type = typeIn;
|
---|
| 72 | index = indexIn;
|
---|
| 73 | prn = prnIn;
|
---|
| 74 | index_old = 0;
|
---|
| 75 | xx = 0.0;
|
---|
[2473] | 76 |
|
---|
[2057] | 77 | }
|
---|
| 78 |
|
---|
| 79 | // Destructor
|
---|
| 80 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 81 | bncParam::~bncParam() {
|
---|
| 82 | }
|
---|
| 83 |
|
---|
[2060] | 84 | // Partial
|
---|
| 85 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2239] | 86 | double bncParam::partial(t_satData* satData, bool phase) {
|
---|
| 87 |
|
---|
| 88 | // Coordinates
|
---|
| 89 | // -----------
|
---|
[2060] | 90 | if (type == CRD_X) {
|
---|
[2109] | 91 | return (xx - satData->xx(1)) / satData->rho;
|
---|
[2060] | 92 | }
|
---|
| 93 | else if (type == CRD_Y) {
|
---|
[2109] | 94 | return (xx - satData->xx(2)) / satData->rho;
|
---|
[2060] | 95 | }
|
---|
| 96 | else if (type == CRD_Z) {
|
---|
[2109] | 97 | return (xx - satData->xx(3)) / satData->rho;
|
---|
[2060] | 98 | }
|
---|
[2239] | 99 |
|
---|
| 100 | // Receiver Clocks
|
---|
| 101 | // ---------------
|
---|
[2265] | 102 | else if (type == RECCLK) {
|
---|
| 103 | return 1.0;
|
---|
[2060] | 104 | }
|
---|
[2239] | 105 |
|
---|
| 106 | // Troposphere
|
---|
| 107 | // -----------
|
---|
[2084] | 108 | else if (type == TROPO) {
|
---|
| 109 | return 1.0 / sin(satData->eleSat);
|
---|
| 110 | }
|
---|
[2239] | 111 |
|
---|
[2782] | 112 | // Galileo Offset
|
---|
| 113 | // --------------
|
---|
| 114 | else if (type == GALILEO_OFFSET) {
|
---|
| 115 | if (satData->prn[0] == 'E') {
|
---|
| 116 | return 1.0;
|
---|
| 117 | }
|
---|
| 118 | else {
|
---|
| 119 | return 0.0;
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
| 122 |
|
---|
[2239] | 123 | // Ambiguities
|
---|
| 124 | // -----------
|
---|
[2080] | 125 | else if (type == AMB_L3) {
|
---|
[2239] | 126 | if (phase && satData->prn == prn) {
|
---|
[2080] | 127 | return 1.0;
|
---|
| 128 | }
|
---|
| 129 | else {
|
---|
| 130 | return 0.0;
|
---|
| 131 | }
|
---|
| 132 | }
|
---|
[2239] | 133 |
|
---|
| 134 | // Default return
|
---|
| 135 | // --------------
|
---|
[2060] | 136 | return 0.0;
|
---|
| 137 | }
|
---|
| 138 |
|
---|
[2058] | 139 | // Constructor
|
---|
| 140 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2113] | 141 | bncModel::bncModel(QByteArray staID) {
|
---|
[2084] | 142 |
|
---|
[2113] | 143 | _staID = staID;
|
---|
| 144 |
|
---|
[3107] | 145 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
| 146 | ((bncApp*)qApp), SLOT(slotMessage(const QByteArray,bool)));
|
---|
| 147 |
|
---|
[2648] | 148 | bncSettings settings;
|
---|
| 149 |
|
---|
[2720] | 150 | // Observation Sigmas
|
---|
| 151 | // ------------------
|
---|
| 152 | _sigP3 = 5.0;
|
---|
| 153 | if (!settings.value("pppSigmaCode").toString().isEmpty()) {
|
---|
| 154 | _sigP3 = settings.value("pppSigmaCode").toDouble();
|
---|
| 155 | }
|
---|
| 156 | _sigL3 = 0.02;
|
---|
| 157 | if (!settings.value("pppSigmaPhase").toString().isEmpty()) {
|
---|
[2741] | 158 | _sigL3 = settings.value("pppSigmaPhase").toDouble();
|
---|
[2720] | 159 | }
|
---|
[2648] | 160 |
|
---|
[2720] | 161 | // Parameter Sigmas
|
---|
| 162 | // ----------------
|
---|
| 163 | _sigCrd0 = 100.0;
|
---|
| 164 | if (!settings.value("pppSigCrd0").toString().isEmpty()) {
|
---|
| 165 | _sigCrd0 = settings.value("pppSigCrd0").toDouble();
|
---|
| 166 | }
|
---|
| 167 | _sigCrdP = 100.0;
|
---|
| 168 | if (!settings.value("pppSigCrdP").toString().isEmpty()) {
|
---|
| 169 | _sigCrdP = settings.value("pppSigCrdP").toDouble();
|
---|
| 170 | }
|
---|
| 171 | _sigTrp0 = 0.1;
|
---|
| 172 | if (!settings.value("pppSigTrp0").toString().isEmpty()) {
|
---|
| 173 | _sigTrp0 = settings.value("pppSigTrp0").toDouble();
|
---|
| 174 | }
|
---|
| 175 | _sigTrpP = 1e-6;
|
---|
| 176 | if (!settings.value("pppSigTrpP").toString().isEmpty()) {
|
---|
| 177 | _sigTrpP = settings.value("pppSigTrpP").toDouble();
|
---|
| 178 | }
|
---|
[2782] | 179 | _sigClk0 = 1000.0;
|
---|
| 180 | _sigAmb0 = 1000.0;
|
---|
| 181 | _sigGalileoOffset0 = 1000.0;
|
---|
[2784] | 182 | _sigGalileoOffsetP = 0.0;
|
---|
[2648] | 183 |
|
---|
[2720] | 184 | // Quick-Start Mode
|
---|
| 185 | // ----------------
|
---|
| 186 | _quickStart = 0;
|
---|
[2726] | 187 | if (settings.value("pppRefCrdX").toString() != "" &&
|
---|
| 188 | settings.value("pppRefCrdY").toString() != "" &&
|
---|
| 189 | settings.value("pppRefCrdZ").toString() != "" &&
|
---|
[2720] | 190 | !settings.value("pppQuickStart").toString().isEmpty()) {
|
---|
[2745] | 191 | _quickStart = settings.value("pppQuickStart").toDouble();
|
---|
[2720] | 192 | }
|
---|
| 193 |
|
---|
[3107] | 194 | // Several options
|
---|
| 195 | // ---------------
|
---|
[2084] | 196 | _usePhase = false;
|
---|
| 197 | if ( Qt::CheckState(settings.value("pppUsePhase").toInt()) == Qt::Checked) {
|
---|
| 198 | _usePhase = true;
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | _estTropo = false;
|
---|
| 202 | if ( Qt::CheckState(settings.value("pppEstTropo").toInt()) == Qt::Checked) {
|
---|
| 203 | _estTropo = true;
|
---|
| 204 | }
|
---|
| 205 |
|
---|
[3107] | 206 | _useGalileo = false;
|
---|
[2799] | 207 | if ( Qt::CheckState(settings.value("pppGalileo").toInt()) == Qt::Checked) {
|
---|
[3107] | 208 | _useGalileo = true;
|
---|
[2782] | 209 | }
|
---|
[2073] | 210 |
|
---|
[2125] | 211 | // NMEA Output
|
---|
| 212 | // -----------
|
---|
| 213 | QString nmeaFileName = settings.value("nmeaFile").toString();
|
---|
| 214 | if (nmeaFileName.isEmpty()) {
|
---|
| 215 | _nmeaFile = 0;
|
---|
| 216 | _nmeaStream = 0;
|
---|
| 217 | }
|
---|
| 218 | else {
|
---|
| 219 | expandEnvVar(nmeaFileName);
|
---|
| 220 | _nmeaFile = new QFile(nmeaFileName);
|
---|
| 221 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
|
---|
| 222 | _nmeaFile->open(QIODevice::WriteOnly | QIODevice::Append);
|
---|
| 223 | }
|
---|
| 224 | else {
|
---|
| 225 | _nmeaFile->open(QIODevice::WriteOnly);
|
---|
| 226 | }
|
---|
| 227 | _nmeaStream = new QTextStream();
|
---|
| 228 | _nmeaStream->setDevice(_nmeaFile);
|
---|
| 229 | }
|
---|
[2881] | 230 |
|
---|
[3107] | 231 | // Antenna Name, ANTEX File
|
---|
| 232 | // ------------------------
|
---|
[2896] | 233 | _antex = 0;
|
---|
[2881] | 234 | QString antexFileName = settings.value("pppAntex").toString();
|
---|
| 235 | if (!antexFileName.isEmpty()) {
|
---|
| 236 | _antex = new bncAntex();
|
---|
[2883] | 237 | if (_antex->readFile(antexFileName) != success) {
|
---|
[2938] | 238 | emit newMessage("wrong ANTEX file", true);
|
---|
[2887] | 239 | delete _antex;
|
---|
| 240 | _antex = 0;
|
---|
[2883] | 241 | }
|
---|
[2938] | 242 | else {
|
---|
| 243 | _antennaName = settings.value("pppAntenna").toString();
|
---|
| 244 | }
|
---|
[2881] | 245 | }
|
---|
[3107] | 246 |
|
---|
| 247 | // Bancroft Coordinates
|
---|
| 248 | // --------------------
|
---|
| 249 | _xcBanc.ReSize(4); _xcBanc = 0.0;
|
---|
| 250 | _ellBanc.ReSize(3); _ellBanc = 0.0;
|
---|
[2058] | 251 | }
|
---|
| 252 |
|
---|
[3108] | 253 | // Destructor
|
---|
[3107] | 254 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3108] | 255 | bncModel::~bncModel() {
|
---|
| 256 | delete _nmeaStream;
|
---|
| 257 | delete _nmeaFile;
|
---|
| 258 | for (int ii = 0; ii < _posAverage.size(); ++ii) {
|
---|
| 259 | delete _posAverage[ii];
|
---|
| 260 | }
|
---|
| 261 | delete _antex;
|
---|
| 262 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 263 | delete _params[iPar-1];
|
---|
| 264 | }
|
---|
| 265 | }
|
---|
| 266 |
|
---|
| 267 | // Reset Parameters and Variance-Covariance Matrix
|
---|
| 268 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3107] | 269 | void bncModel::reset() {
|
---|
| 270 |
|
---|
| 271 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 272 | delete _params[iPar-1];
|
---|
| 273 | }
|
---|
| 274 | _params.clear();
|
---|
| 275 |
|
---|
| 276 | int nextPar = 0;
|
---|
| 277 | _params.push_back(new bncParam(bncParam::CRD_X, ++nextPar, ""));
|
---|
| 278 | _params.push_back(new bncParam(bncParam::CRD_Y, ++nextPar, ""));
|
---|
| 279 | _params.push_back(new bncParam(bncParam::CRD_Z, ++nextPar, ""));
|
---|
| 280 | _params.push_back(new bncParam(bncParam::RECCLK, ++nextPar, ""));
|
---|
| 281 | if (_estTropo) {
|
---|
| 282 | _params.push_back(new bncParam(bncParam::TROPO, ++nextPar, ""));
|
---|
| 283 | }
|
---|
| 284 | if (_useGalileo) {
|
---|
| 285 | _params.push_back(new bncParam(bncParam::GALILEO_OFFSET, ++nextPar, ""));
|
---|
| 286 | }
|
---|
| 287 |
|
---|
| 288 | _QQ.ReSize(_params.size());
|
---|
| 289 | _QQ = 0.0;
|
---|
| 290 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 291 | bncParam* pp = _params[iPar-1];
|
---|
| 292 | pp->xx = 0.0;
|
---|
| 293 | if (pp->isCrd()) {
|
---|
| 294 | _QQ(iPar,iPar) = _sigCrd0 * _sigCrd0;
|
---|
| 295 | }
|
---|
| 296 | else if (pp->type == bncParam::RECCLK) {
|
---|
| 297 | _QQ(iPar,iPar) = _sigClk0 * _sigClk0;
|
---|
| 298 | }
|
---|
| 299 | else if (pp->type == bncParam::TROPO) {
|
---|
| 300 | _QQ(iPar,iPar) = _sigTrp0 * _sigTrp0;
|
---|
| 301 | }
|
---|
| 302 | else if (pp->type == bncParam::GALILEO_OFFSET) {
|
---|
| 303 | _QQ(iPar,iPar) = _sigGalileoOffset0 * _sigGalileoOffset0;
|
---|
| 304 | }
|
---|
| 305 | }
|
---|
| 306 | }
|
---|
| 307 |
|
---|
[2058] | 308 | // Bancroft Solution
|
---|
| 309 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 310 | t_irc bncModel::cmpBancroft(t_epoData* epoData) {
|
---|
| 311 |
|
---|
[2231] | 312 | if (epoData->sizeGPS() < MINOBS) {
|
---|
[2547] | 313 | _log += "bncModel::cmpBancroft: not enough data\n";
|
---|
[2058] | 314 | return failure;
|
---|
| 315 | }
|
---|
| 316 |
|
---|
[2231] | 317 | Matrix BB(epoData->sizeGPS(), 4);
|
---|
[2058] | 318 |
|
---|
[2231] | 319 | QMapIterator<QString, t_satData*> it(epoData->satDataGPS);
|
---|
[2791] | 320 | int iObsBanc = 0;
|
---|
[2058] | 321 | while (it.hasNext()) {
|
---|
[2791] | 322 | ++iObsBanc;
|
---|
[2058] | 323 | it.next();
|
---|
| 324 | QString prn = it.key();
|
---|
| 325 | t_satData* satData = it.value();
|
---|
[2791] | 326 | BB(iObsBanc, 1) = satData->xx(1);
|
---|
| 327 | BB(iObsBanc, 2) = satData->xx(2);
|
---|
| 328 | BB(iObsBanc, 3) = satData->xx(3);
|
---|
| 329 | BB(iObsBanc, 4) = satData->P3 + satData->clk;
|
---|
[2058] | 330 | }
|
---|
| 331 |
|
---|
| 332 | bancroft(BB, _xcBanc);
|
---|
| 333 |
|
---|
[2064] | 334 | // Ellipsoidal Coordinates
|
---|
| 335 | // ------------------------
|
---|
| 336 | xyz2ell(_xcBanc.data(), _ellBanc.data());
|
---|
[2063] | 337 |
|
---|
[2064] | 338 | // Compute Satellite Elevations
|
---|
| 339 | // ----------------------------
|
---|
[2231] | 340 | QMutableMapIterator<QString, t_satData*> iGPS(epoData->satDataGPS);
|
---|
| 341 | while (iGPS.hasNext()) {
|
---|
| 342 | iGPS.next();
|
---|
| 343 | t_satData* satData = iGPS.value();
|
---|
[2789] | 344 | cmpEle(satData);
|
---|
[2287] | 345 | if (satData->eleSat < MINELE_GPS) {
|
---|
[2070] | 346 | delete satData;
|
---|
[2231] | 347 | iGPS.remove();
|
---|
[2070] | 348 | }
|
---|
[2064] | 349 | }
|
---|
| 350 |
|
---|
[2231] | 351 | QMutableMapIterator<QString, t_satData*> iGlo(epoData->satDataGlo);
|
---|
| 352 | while (iGlo.hasNext()) {
|
---|
| 353 | iGlo.next();
|
---|
| 354 | t_satData* satData = iGlo.value();
|
---|
[2789] | 355 | cmpEle(satData);
|
---|
[2287] | 356 | if (satData->eleSat < MINELE_GLO) {
|
---|
[2231] | 357 | delete satData;
|
---|
| 358 | iGlo.remove();
|
---|
| 359 | }
|
---|
| 360 | }
|
---|
| 361 |
|
---|
[2780] | 362 | QMutableMapIterator<QString, t_satData*> iGal(epoData->satDataGal);
|
---|
| 363 | while (iGal.hasNext()) {
|
---|
| 364 | iGal.next();
|
---|
| 365 | t_satData* satData = iGal.value();
|
---|
[2789] | 366 | cmpEle(satData);
|
---|
[2780] | 367 | if (satData->eleSat < MINELE_GAL) {
|
---|
| 368 | delete satData;
|
---|
| 369 | iGal.remove();
|
---|
| 370 | }
|
---|
| 371 | }
|
---|
| 372 |
|
---|
[2058] | 373 | return success;
|
---|
| 374 | }
|
---|
[2060] | 375 |
|
---|
| 376 | // Computed Value
|
---|
| 377 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2583] | 378 | double bncModel::cmpValue(t_satData* satData, bool phase) {
|
---|
[2060] | 379 |
|
---|
[2073] | 380 | ColumnVector xRec(3);
|
---|
| 381 | xRec(1) = x();
|
---|
| 382 | xRec(2) = y();
|
---|
| 383 | xRec(3) = z();
|
---|
[2060] | 384 |
|
---|
[2073] | 385 | double rho0 = (satData->xx - xRec).norm_Frobenius();
|
---|
[2060] | 386 | double dPhi = t_CST::omega * rho0 / t_CST::c;
|
---|
| 387 |
|
---|
[2073] | 388 | xRec(1) = x() * cos(dPhi) - y() * sin(dPhi);
|
---|
| 389 | xRec(2) = y() * cos(dPhi) + x() * sin(dPhi);
|
---|
| 390 | xRec(3) = z();
|
---|
| 391 |
|
---|
[2580] | 392 | tides(_time, xRec);
|
---|
| 393 |
|
---|
[2060] | 394 | satData->rho = (satData->xx - xRec).norm_Frobenius();
|
---|
| 395 |
|
---|
[2084] | 396 | double tropDelay = delay_saast(satData->eleSat) +
|
---|
| 397 | trp() / sin(satData->eleSat);
|
---|
[2060] | 398 |
|
---|
[2583] | 399 | double wind = 0.0;
|
---|
| 400 | if (phase) {
|
---|
| 401 | wind = windUp(satData->prn, satData->xx, xRec) * satData->lambda3;
|
---|
| 402 | }
|
---|
| 403 |
|
---|
[2783] | 404 | double offset = 0.0;
|
---|
| 405 | if (satData->prn[0] == 'E') {
|
---|
| 406 | offset = Galileo_offset();
|
---|
| 407 | }
|
---|
| 408 |
|
---|
[2894] | 409 | double phaseCenter = 0.0;
|
---|
[2938] | 410 | if (_antex) {
|
---|
| 411 | bool found;
|
---|
| 412 | phaseCenter = _antex->pco(_antennaName, satData->eleSat, found);
|
---|
| 413 | if (!found) {
|
---|
| 414 | emit newMessage("ANTEX: antenna >"
|
---|
| 415 | + _antennaName.toAscii() + "< not found", true);
|
---|
| 416 | }
|
---|
[2894] | 417 | }
|
---|
| 418 |
|
---|
| 419 | return satData->rho + phaseCenter + clk()
|
---|
| 420 | + offset - satData->clk + tropDelay + wind;
|
---|
[2060] | 421 | }
|
---|
| 422 |
|
---|
[2063] | 423 | // Tropospheric Model (Saastamoinen)
|
---|
| 424 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2065] | 425 | double bncModel::delay_saast(double Ele) {
|
---|
[2063] | 426 |
|
---|
[2769] | 427 | double xyz[3];
|
---|
| 428 | xyz[0] = x();
|
---|
| 429 | xyz[1] = y();
|
---|
| 430 | xyz[2] = z();
|
---|
| 431 | double ell[3];
|
---|
| 432 | xyz2ell(xyz, ell);
|
---|
| 433 | double height = ell[2];
|
---|
[2063] | 434 |
|
---|
[2064] | 435 | double pp = 1013.25 * pow(1.0 - 2.26e-5 * height, 5.225);
|
---|
| 436 | double TT = 18.0 - height * 0.0065 + 273.15;
|
---|
| 437 | double hh = 50.0 * exp(-6.396e-4 * height);
|
---|
[2063] | 438 | double ee = hh / 100.0 * exp(-37.2465 + 0.213166*TT - 0.000256908*TT*TT);
|
---|
| 439 |
|
---|
[2064] | 440 | double h_km = height / 1000.0;
|
---|
[2063] | 441 |
|
---|
| 442 | if (h_km < 0.0) h_km = 0.0;
|
---|
| 443 | if (h_km > 5.0) h_km = 5.0;
|
---|
| 444 | int ii = int(h_km + 1);
|
---|
| 445 | double href = ii - 1;
|
---|
| 446 |
|
---|
| 447 | double bCor[6];
|
---|
| 448 | bCor[0] = 1.156;
|
---|
| 449 | bCor[1] = 1.006;
|
---|
| 450 | bCor[2] = 0.874;
|
---|
| 451 | bCor[3] = 0.757;
|
---|
| 452 | bCor[4] = 0.654;
|
---|
| 453 | bCor[5] = 0.563;
|
---|
| 454 |
|
---|
| 455 | double BB = bCor[ii-1] + (bCor[ii]-bCor[ii-1]) * (h_km - href);
|
---|
| 456 |
|
---|
| 457 | double zen = M_PI/2.0 - Ele;
|
---|
| 458 |
|
---|
| 459 | return (0.002277/cos(zen)) * (pp + ((1255.0/TT)+0.05)*ee - BB*(tan(zen)*tan(zen)));
|
---|
| 460 | }
|
---|
| 461 |
|
---|
[2073] | 462 | // Prediction Step of the Filter
|
---|
| 463 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2080] | 464 | void bncModel::predict(t_epoData* epoData) {
|
---|
[2073] | 465 |
|
---|
[2648] | 466 | bncSettings settings;
|
---|
[2244] | 467 |
|
---|
[3106] | 468 | _time = epoData->tt; // current epoch time
|
---|
| 469 |
|
---|
[3118] | 470 | _maxSolGap = settings.value("pppMaxSolGap").toDouble();
|
---|
| 471 |
|
---|
[2648] | 472 | bool firstCrd = false;
|
---|
[3118] | 473 | if (!_lastTimeOK.valid() || (_maxSolGap > 0 && _time - _lastTimeOK > _maxSolGap)) {
|
---|
[2648] | 474 | firstCrd = true;
|
---|
[2874] | 475 | _startTime = epoData->tt;
|
---|
[3107] | 476 | reset();
|
---|
[2648] | 477 | }
|
---|
| 478 |
|
---|
[2726] | 479 | // Use different white noise for Quick-Start mode
|
---|
[2720] | 480 | // ----------------------------------------------
|
---|
| 481 | double sigCrdP_used = _sigCrdP;
|
---|
[2874] | 482 | if ( _quickStart > 0.0 && _quickStart > (epoData->tt - _startTime) ) {
|
---|
[2720] | 483 | sigCrdP_used = 0.0;
|
---|
[2648] | 484 | }
|
---|
| 485 |
|
---|
[2244] | 486 | // Predict Parameter values, add white noise
|
---|
| 487 | // -----------------------------------------
|
---|
| 488 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 489 | bncParam* pp = _params[iPar-1];
|
---|
| 490 |
|
---|
| 491 | // Coordinates
|
---|
| 492 | // -----------
|
---|
| 493 | if (pp->type == bncParam::CRD_X) {
|
---|
[2720] | 494 | if (firstCrd) {
|
---|
[2726] | 495 | if (settings.value("pppRefCrdX").toString() != "" &&
|
---|
| 496 | settings.value("pppRefCrdY").toString() != "" &&
|
---|
| 497 | settings.value("pppRefCrdZ").toString() != "") {
|
---|
[2648] | 498 | pp->xx = settings.value("pppRefCrdX").toDouble();
|
---|
| 499 | }
|
---|
| 500 | else {
|
---|
| 501 | pp->xx = _xcBanc(1);
|
---|
| 502 | }
|
---|
[2244] | 503 | }
|
---|
[2720] | 504 | _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
|
---|
[2244] | 505 | }
|
---|
| 506 | else if (pp->type == bncParam::CRD_Y) {
|
---|
[2720] | 507 | if (firstCrd) {
|
---|
[2726] | 508 | if (settings.value("pppRefCrdX").toString() != "" &&
|
---|
| 509 | settings.value("pppRefCrdY").toString() != "" &&
|
---|
| 510 | settings.value("pppRefCrdZ").toString() != "") {
|
---|
[2648] | 511 | pp->xx = settings.value("pppRefCrdY").toDouble();
|
---|
| 512 | }
|
---|
| 513 | else {
|
---|
| 514 | pp->xx = _xcBanc(2);
|
---|
| 515 | }
|
---|
[2244] | 516 | }
|
---|
[2720] | 517 | _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
|
---|
[2244] | 518 | }
|
---|
| 519 | else if (pp->type == bncParam::CRD_Z) {
|
---|
[2720] | 520 | if (firstCrd) {
|
---|
[2726] | 521 | if (settings.value("pppRefCrdX").toString() != "" &&
|
---|
| 522 | settings.value("pppRefCrdY").toString() != "" &&
|
---|
| 523 | settings.value("pppRefCrdZ").toString() != "") {
|
---|
[2648] | 524 | pp->xx = settings.value("pppRefCrdZ").toDouble();
|
---|
| 525 | }
|
---|
| 526 | else {
|
---|
| 527 | pp->xx = _xcBanc(3);
|
---|
| 528 | }
|
---|
[2244] | 529 | }
|
---|
[2720] | 530 | _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
|
---|
[2244] | 531 | }
|
---|
| 532 |
|
---|
| 533 | // Receiver Clocks
|
---|
| 534 | // ---------------
|
---|
[2265] | 535 | else if (pp->type == bncParam::RECCLK) {
|
---|
[2244] | 536 | pp->xx = _xcBanc(4);
|
---|
| 537 | for (int jj = 1; jj <= _params.size(); jj++) {
|
---|
| 538 | _QQ(iPar, jj) = 0.0;
|
---|
| 539 | }
|
---|
[2720] | 540 | _QQ(iPar,iPar) = _sigClk0 * _sigClk0;
|
---|
[2244] | 541 | }
|
---|
| 542 |
|
---|
| 543 | // Tropospheric Delay
|
---|
| 544 | // ------------------
|
---|
| 545 | else if (pp->type == bncParam::TROPO) {
|
---|
[2720] | 546 | _QQ(iPar,iPar) += _sigTrpP * _sigTrpP;
|
---|
[2244] | 547 | }
|
---|
[2782] | 548 |
|
---|
| 549 | // Galileo Offset
|
---|
| 550 | // --------------
|
---|
| 551 | else if (pp->type == bncParam::GALILEO_OFFSET) {
|
---|
| 552 | _QQ(iPar,iPar) += _sigGalileoOffsetP * _sigGalileoOffsetP;
|
---|
| 553 | }
|
---|
[2244] | 554 | }
|
---|
| 555 |
|
---|
| 556 | // Add New Ambiguities if necessary
|
---|
| 557 | // --------------------------------
|
---|
[2083] | 558 | if (_usePhase) {
|
---|
[2080] | 559 |
|
---|
[2083] | 560 | // Make a copy of QQ and xx, set parameter indices
|
---|
| 561 | // -----------------------------------------------
|
---|
| 562 | SymmetricMatrix QQ_old = _QQ;
|
---|
| 563 |
|
---|
| 564 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 565 | _params[iPar-1]->index_old = _params[iPar-1]->index;
|
---|
| 566 | _params[iPar-1]->index = 0;
|
---|
| 567 | }
|
---|
| 568 |
|
---|
| 569 | // Remove Ambiguity Parameters without observations
|
---|
| 570 | // ------------------------------------------------
|
---|
| 571 | int iPar = 0;
|
---|
| 572 | QMutableVectorIterator<bncParam*> it(_params);
|
---|
| 573 | while (it.hasNext()) {
|
---|
| 574 | bncParam* par = it.next();
|
---|
| 575 | bool removed = false;
|
---|
| 576 | if (par->type == bncParam::AMB_L3) {
|
---|
[2231] | 577 | if (epoData->satDataGPS.find(par->prn) == epoData->satDataGPS.end() &&
|
---|
[2780] | 578 | epoData->satDataGlo.find(par->prn) == epoData->satDataGlo.end() &&
|
---|
| 579 | epoData->satDataGal.find(par->prn) == epoData->satDataGal.end() ) {
|
---|
[2083] | 580 | removed = true;
|
---|
| 581 | delete par;
|
---|
| 582 | it.remove();
|
---|
| 583 | }
|
---|
[2080] | 584 | }
|
---|
[2083] | 585 | if (! removed) {
|
---|
| 586 | ++iPar;
|
---|
| 587 | par->index = iPar;
|
---|
| 588 | }
|
---|
[2080] | 589 | }
|
---|
[2083] | 590 |
|
---|
| 591 | // Add new ambiguity parameters
|
---|
| 592 | // ----------------------------
|
---|
[2231] | 593 | QMapIterator<QString, t_satData*> iGPS(epoData->satDataGPS);
|
---|
| 594 | while (iGPS.hasNext()) {
|
---|
| 595 | iGPS.next();
|
---|
[2244] | 596 | t_satData* satData = iGPS.value();
|
---|
[2789] | 597 | addAmb(satData);
|
---|
[2080] | 598 | }
|
---|
[2231] | 599 |
|
---|
| 600 | QMapIterator<QString, t_satData*> iGlo(epoData->satDataGlo);
|
---|
| 601 | while (iGlo.hasNext()) {
|
---|
| 602 | iGlo.next();
|
---|
[2233] | 603 | t_satData* satData = iGlo.value();
|
---|
[2789] | 604 | addAmb(satData);
|
---|
[2231] | 605 | }
|
---|
[2780] | 606 |
|
---|
| 607 | QMapIterator<QString, t_satData*> iGal(epoData->satDataGal);
|
---|
| 608 | while (iGal.hasNext()) {
|
---|
| 609 | iGal.next();
|
---|
| 610 | t_satData* satData = iGal.value();
|
---|
[2789] | 611 | addAmb(satData);
|
---|
[2780] | 612 | }
|
---|
[2083] | 613 |
|
---|
| 614 | int nPar = _params.size();
|
---|
| 615 | _QQ.ReSize(nPar); _QQ = 0.0;
|
---|
| 616 | for (int i1 = 1; i1 <= nPar; i1++) {
|
---|
| 617 | bncParam* p1 = _params[i1-1];
|
---|
| 618 | if (p1->index_old != 0) {
|
---|
| 619 | _QQ(p1->index, p1->index) = QQ_old(p1->index_old, p1->index_old);
|
---|
| 620 | for (int i2 = 1; i2 <= nPar; i2++) {
|
---|
| 621 | bncParam* p2 = _params[i2-1];
|
---|
| 622 | if (p2->index_old != 0) {
|
---|
| 623 | _QQ(p1->index, p2->index) = QQ_old(p1->index_old, p2->index_old);
|
---|
| 624 | }
|
---|
[2080] | 625 | }
|
---|
| 626 | }
|
---|
| 627 | }
|
---|
[2083] | 628 |
|
---|
| 629 | for (int ii = 1; ii <= nPar; ii++) {
|
---|
| 630 | bncParam* par = _params[ii-1];
|
---|
| 631 | if (par->index_old == 0) {
|
---|
[2720] | 632 | _QQ(par->index, par->index) = _sigAmb0 * _sigAmb0;
|
---|
[2083] | 633 | }
|
---|
| 634 | par->index_old = par->index;
|
---|
[2080] | 635 | }
|
---|
| 636 | }
|
---|
[2073] | 637 | }
|
---|
| 638 |
|
---|
[2060] | 639 | // Update Step of the Filter (currently just a single-epoch solution)
|
---|
| 640 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 641 | t_irc bncModel::update(t_epoData* epoData) {
|
---|
| 642 |
|
---|
[2473] | 643 | bncSettings settings;
|
---|
| 644 |
|
---|
[2248] | 645 | _log.clear();
|
---|
[2124] | 646 |
|
---|
[2827] | 647 | if (settings.value("pppSPP").toString() == "PPP") {
|
---|
| 648 | _log += "Precise Point Positioning of Epoch "
|
---|
| 649 | + QByteArray(_time.timestr(1).c_str()) +
|
---|
| 650 | "\n---------------------------------------------------------------\n";
|
---|
| 651 | }
|
---|
| 652 | else {
|
---|
| 653 | _log += "Single Point Positioning of Epoch "
|
---|
| 654 | + QByteArray(_time.timestr(1).c_str()) +
|
---|
[2547] | 655 | "\n--------------------------------------------------------------\n";
|
---|
[2827] | 656 | }
|
---|
[2547] | 657 |
|
---|
[2112] | 658 | SymmetricMatrix QQsav;
|
---|
[2109] | 659 | ColumnVector dx;
|
---|
[2112] | 660 | ColumnVector vv;
|
---|
[2073] | 661 |
|
---|
[2113] | 662 | // Loop over all outliers
|
---|
| 663 | // ----------------------
|
---|
[2108] | 664 | do {
|
---|
| 665 |
|
---|
| 666 | // Bancroft Solution
|
---|
| 667 | // -----------------
|
---|
| 668 | if (cmpBancroft(epoData) != success) {
|
---|
[2124] | 669 | emit newMessage(_log, false);
|
---|
[2108] | 670 | return failure;
|
---|
| 671 | }
|
---|
[2080] | 672 |
|
---|
[2108] | 673 | // Status Prediction
|
---|
| 674 | // -----------------
|
---|
| 675 | predict(epoData);
|
---|
| 676 |
|
---|
[2109] | 677 | // Create First-Design Matrix
|
---|
| 678 | // --------------------------
|
---|
[2108] | 679 | unsigned nPar = _params.size();
|
---|
[2231] | 680 | unsigned nObs = 0;
|
---|
| 681 | if (_usePhase) {
|
---|
[2780] | 682 | nObs = 2 * (epoData->sizeGPS() + epoData->sizeGal()) + epoData->sizeGlo();
|
---|
[2231] | 683 | }
|
---|
| 684 | else {
|
---|
[2780] | 685 | nObs = epoData->sizeGPS() + epoData->sizeGal(); // Glonass code not used
|
---|
[2231] | 686 | }
|
---|
[2108] | 687 |
|
---|
[2540] | 688 | if (nObs < nPar) {
|
---|
[2547] | 689 | _log += "bncModel::update: nObs < nPar\n";
|
---|
[2540] | 690 | emit newMessage(_log, false);
|
---|
| 691 | return failure;
|
---|
| 692 | }
|
---|
| 693 |
|
---|
[2108] | 694 | Matrix AA(nObs, nPar); // first design matrix
|
---|
| 695 | ColumnVector ll(nObs); // tems observed-computed
|
---|
[2283] | 696 | DiagonalMatrix PP(nObs); PP = 0.0;
|
---|
[2108] | 697 |
|
---|
| 698 | unsigned iObs = 0;
|
---|
[2231] | 699 |
|
---|
| 700 | // GPS code and (optionally) phase observations
|
---|
| 701 | // --------------------------------------------
|
---|
| 702 | QMapIterator<QString, t_satData*> itGPS(epoData->satDataGPS);
|
---|
| 703 | while (itGPS.hasNext()) {
|
---|
| 704 | itGPS.next();
|
---|
| 705 | t_satData* satData = itGPS.value();
|
---|
[2790] | 706 | addObs(iObs, satData, AA, ll, PP);
|
---|
[2080] | 707 | }
|
---|
[2231] | 708 |
|
---|
| 709 | // Glonass phase observations
|
---|
| 710 | // --------------------------
|
---|
[2790] | 711 | QMapIterator<QString, t_satData*> itGlo(epoData->satDataGlo);
|
---|
| 712 | while (itGlo.hasNext()) {
|
---|
| 713 | itGlo.next();
|
---|
| 714 | t_satData* satData = itGlo.value();
|
---|
| 715 | addObs(iObs, satData, AA, ll, PP);
|
---|
[2231] | 716 | }
|
---|
| 717 |
|
---|
[2780] | 718 | // Galileo code and (optionally) phase observations
|
---|
| 719 | // ------------------------------------------------
|
---|
| 720 | QMapIterator<QString, t_satData*> itGal(epoData->satDataGal);
|
---|
| 721 | while (itGal.hasNext()) {
|
---|
| 722 | itGal.next();
|
---|
| 723 | t_satData* satData = itGal.value();
|
---|
[2790] | 724 | addObs(iObs, satData, AA, ll, PP);
|
---|
[2780] | 725 | }
|
---|
| 726 |
|
---|
[2112] | 727 | // Compute Filter Update
|
---|
[2108] | 728 | // ---------------------
|
---|
[2112] | 729 | QQsav = _QQ;
|
---|
| 730 |
|
---|
[2283] | 731 | kalman(AA, ll, PP, _QQ, dx);
|
---|
| 732 |
|
---|
| 733 | vv = ll - AA * dx;
|
---|
| 734 |
|
---|
[2791] | 735 | // Print Residuals
|
---|
| 736 | // ---------------
|
---|
| 737 | if (true) {
|
---|
| 738 | ostringstream str;
|
---|
| 739 | str.setf(ios::fixed);
|
---|
[2245] | 740 |
|
---|
[2791] | 741 | QMapIterator<QString, t_satData*> itGPS(epoData->satDataGPS);
|
---|
| 742 | while (itGPS.hasNext()) {
|
---|
| 743 | itGPS.next();
|
---|
| 744 | t_satData* satData = itGPS.value();
|
---|
| 745 | printRes(vv, str, satData);
|
---|
[2246] | 746 | }
|
---|
[2791] | 747 | QMapIterator<QString, t_satData*> itGlo(epoData->satDataGlo);
|
---|
| 748 | while (itGlo.hasNext()) {
|
---|
| 749 | itGlo.next();
|
---|
| 750 | t_satData* satData = itGlo.value();
|
---|
| 751 | printRes(vv, str, satData);
|
---|
[2265] | 752 | }
|
---|
[2791] | 753 | QMapIterator<QString, t_satData*> itGal(epoData->satDataGal);
|
---|
| 754 | while (itGal.hasNext()) {
|
---|
| 755 | itGal.next();
|
---|
| 756 | t_satData* satData = itGal.value();
|
---|
| 757 | printRes(vv, str, satData);
|
---|
[2246] | 758 | }
|
---|
[2791] | 759 | _log += str.str().c_str();
|
---|
[2265] | 760 | }
|
---|
[2246] | 761 |
|
---|
[2231] | 762 | } while (outlierDetection(QQsav, vv, epoData->satDataGPS,
|
---|
[2780] | 763 | epoData->satDataGlo, epoData->satDataGal) != 0);
|
---|
[2111] | 764 |
|
---|
[2670] | 765 | // Remember the Epoch-specific Results for the computation of means
|
---|
| 766 | // ----------------------------------------------------------------
|
---|
| 767 | pppPos* newPos = new pppPos;
|
---|
| 768 | newPos->time = epoData->tt;
|
---|
| 769 |
|
---|
[2109] | 770 | // Set Solution Vector
|
---|
| 771 | // -------------------
|
---|
[2265] | 772 | ostringstream strB;
|
---|
| 773 | strB.setf(ios::fixed);
|
---|
[2073] | 774 | QVectorIterator<bncParam*> itPar(_params);
|
---|
[2060] | 775 | while (itPar.hasNext()) {
|
---|
| 776 | bncParam* par = itPar.next();
|
---|
[2109] | 777 | par->xx += dx(par->index);
|
---|
[2265] | 778 |
|
---|
| 779 | if (par->type == bncParam::RECCLK) {
|
---|
[2798] | 780 | strB << "\n clk = " << setw(10) << setprecision(3) << par->xx
|
---|
[2124] | 781 | << " +- " << setw(6) << setprecision(3)
|
---|
| 782 | << sqrt(_QQ(par->index,par->index));
|
---|
| 783 | }
|
---|
| 784 | else if (par->type == bncParam::AMB_L3) {
|
---|
[2265] | 785 | strB << "\n amb " << par->prn.toAscii().data() << " = "
|
---|
[2798] | 786 | << setw(10) << setprecision(3) << par->xx
|
---|
[2124] | 787 | << " +- " << setw(6) << setprecision(3)
|
---|
| 788 | << sqrt(_QQ(par->index,par->index));
|
---|
| 789 | }
|
---|
[2212] | 790 | else if (par->type == bncParam::TROPO) {
|
---|
[2670] | 791 | double aprTrp = delay_saast(M_PI/2.0);
|
---|
[2547] | 792 | strB << "\n trp = " << par->prn.toAscii().data()
|
---|
[2670] | 793 | << setw(7) << setprecision(3) << aprTrp << " "
|
---|
[2213] | 794 | << setw(6) << setprecision(3) << showpos << par->xx << noshowpos
|
---|
[2212] | 795 | << " +- " << setw(6) << setprecision(3)
|
---|
| 796 | << sqrt(_QQ(par->index,par->index));
|
---|
[2670] | 797 | newPos->xnt[6] = aprTrp + par->xx;
|
---|
[2212] | 798 | }
|
---|
[2782] | 799 | else if (par->type == bncParam::GALILEO_OFFSET) {
|
---|
[2798] | 800 | strB << "\n offset = " << setw(10) << setprecision(3) << par->xx
|
---|
[2782] | 801 | << " +- " << setw(6) << setprecision(3)
|
---|
| 802 | << sqrt(_QQ(par->index,par->index));
|
---|
| 803 | }
|
---|
[2060] | 804 | }
|
---|
[2265] | 805 | strB << '\n';
|
---|
[2547] | 806 | _log += strB.str().c_str();
|
---|
| 807 | emit newMessage(_log, false);
|
---|
[2060] | 808 |
|
---|
[2547] | 809 | // Final Message (both log file and screen)
|
---|
| 810 | // ----------------------------------------
|
---|
| 811 | ostringstream strC;
|
---|
| 812 | strC.setf(ios::fixed);
|
---|
| 813 | strC << _staID.data() << " PPP "
|
---|
[2599] | 814 | << epoData->tt.timestr(1) << " " << epoData->sizeAll() << " "
|
---|
[2231] | 815 | << setw(14) << setprecision(3) << x() << " +- "
|
---|
| 816 | << setw(6) << setprecision(3) << sqrt(_QQ(1,1)) << " "
|
---|
| 817 | << setw(14) << setprecision(3) << y() << " +- "
|
---|
| 818 | << setw(6) << setprecision(3) << sqrt(_QQ(2,2)) << " "
|
---|
| 819 | << setw(14) << setprecision(3) << z() << " +- "
|
---|
[2124] | 820 | << setw(6) << setprecision(3) << sqrt(_QQ(3,3));
|
---|
[2113] | 821 |
|
---|
[2370] | 822 | // NEU Output
|
---|
| 823 | // ----------
|
---|
[2862] | 824 | double xyzRef[3];
|
---|
| 825 |
|
---|
[2726] | 826 | if (settings.value("pppRefCrdX").toString() != "" &&
|
---|
| 827 | settings.value("pppRefCrdY").toString() != "" &&
|
---|
| 828 | settings.value("pppRefCrdZ").toString() != "") {
|
---|
[2649] | 829 |
|
---|
[2370] | 830 | xyzRef[0] = settings.value("pppRefCrdX").toDouble();
|
---|
| 831 | xyzRef[1] = settings.value("pppRefCrdY").toDouble();
|
---|
| 832 | xyzRef[2] = settings.value("pppRefCrdZ").toDouble();
|
---|
[2649] | 833 |
|
---|
[2670] | 834 | newPos->xnt[0] = x() - xyzRef[0];
|
---|
| 835 | newPos->xnt[1] = y() - xyzRef[1];
|
---|
| 836 | newPos->xnt[2] = z() - xyzRef[2];
|
---|
[2649] | 837 |
|
---|
| 838 | double ellRef[3];
|
---|
[2370] | 839 | xyz2ell(xyzRef, ellRef);
|
---|
[2670] | 840 | xyz2neu(ellRef, newPos->xnt, &newPos->xnt[3]);
|
---|
[2649] | 841 |
|
---|
[2547] | 842 | strC << " NEU "
|
---|
[2670] | 843 | << setw(8) << setprecision(3) << newPos->xnt[3] << " "
|
---|
| 844 | << setw(8) << setprecision(3) << newPos->xnt[4] << " "
|
---|
[2797] | 845 | << setw(8) << setprecision(3) << newPos->xnt[5] << endl;
|
---|
[2649] | 846 |
|
---|
[2370] | 847 | }
|
---|
| 848 |
|
---|
[2547] | 849 | emit newMessage(QByteArray(strC.str().c_str()), true);
|
---|
| 850 |
|
---|
[2671] | 851 | if (settings.value("pppAverage").toString() == "") {
|
---|
| 852 | delete newPos;
|
---|
| 853 | }
|
---|
| 854 | else {
|
---|
| 855 |
|
---|
| 856 | _posAverage.push_back(newPos);
|
---|
[2599] | 857 |
|
---|
[2648] | 858 | // Time Span for Average Computation
|
---|
| 859 | // ---------------------------------
|
---|
| 860 | double tRangeAverage = settings.value("pppAverage").toDouble() * 60.;
|
---|
| 861 | if (tRangeAverage < 0) {
|
---|
| 862 | tRangeAverage = 0;
|
---|
| 863 | }
|
---|
| 864 | if (tRangeAverage > 86400) {
|
---|
| 865 | tRangeAverage = 86400;
|
---|
| 866 | }
|
---|
[2599] | 867 |
|
---|
[2648] | 868 | // Compute the Mean
|
---|
| 869 | // ----------------
|
---|
[2670] | 870 | ColumnVector mean(7); mean = 0.0;
|
---|
[2648] | 871 |
|
---|
[2599] | 872 | QMutableVectorIterator<pppPos*> it(_posAverage);
|
---|
| 873 | while (it.hasNext()) {
|
---|
| 874 | pppPos* pp = it.next();
|
---|
[2648] | 875 | if ( (epoData->tt - pp->time) >= tRangeAverage ) {
|
---|
[2599] | 876 | delete pp;
|
---|
| 877 | it.remove();
|
---|
| 878 | }
|
---|
[2648] | 879 | else {
|
---|
[2670] | 880 | for (int ii = 0; ii < 7; ++ii) {
|
---|
| 881 | mean[ii] += pp->xnt[ii];
|
---|
[2649] | 882 | }
|
---|
[2648] | 883 | }
|
---|
[2599] | 884 | }
|
---|
[2648] | 885 |
|
---|
| 886 | int nn = _posAverage.size();
|
---|
| 887 |
|
---|
[2649] | 888 | if (nn > 0) {
|
---|
[2648] | 889 |
|
---|
[2649] | 890 | mean /= nn;
|
---|
| 891 |
|
---|
| 892 | // Compute the Deviation
|
---|
| 893 | // ---------------------
|
---|
[2670] | 894 | ColumnVector std(7); std = 0.0;
|
---|
[2649] | 895 | QVectorIterator<pppPos*> it2(_posAverage);
|
---|
| 896 | while (it2.hasNext()) {
|
---|
| 897 | pppPos* pp = it2.next();
|
---|
[2670] | 898 | for (int ii = 0; ii < 7; ++ii) {
|
---|
| 899 | std[ii] += (pp->xnt[ii] - mean[ii]) * (pp->xnt[ii] - mean[ii]);
|
---|
[2649] | 900 | }
|
---|
| 901 | }
|
---|
[2670] | 902 | for (int ii = 0; ii < 7; ++ii) {
|
---|
[2649] | 903 | std[ii] = sqrt(std[ii] / nn);
|
---|
| 904 | }
|
---|
[3169] | 905 |
|
---|
| 906 | if (settings.value("pppRefCrdX").toString() != "" &&
|
---|
| 907 | settings.value("pppRefCrdY").toString() != "" &&
|
---|
| 908 | settings.value("pppRefCrdZ").toString() != "") {
|
---|
[2649] | 909 |
|
---|
[3169] | 910 | ostringstream strD; strD.setf(ios::fixed);
|
---|
| 911 | strD << _staID.data() << " AVE-XYZ "
|
---|
| 912 | << epoData->tt.timestr(1) << " "
|
---|
| 913 | << setw(13) << setprecision(3) << mean[0] + xyzRef[0] << " +- "
|
---|
| 914 | << setw(6) << setprecision(3) << std[0] << " "
|
---|
| 915 | << setw(14) << setprecision(3) << mean[1] + xyzRef[1] << " +- "
|
---|
| 916 | << setw(6) << setprecision(3) << std[1] << " "
|
---|
| 917 | << setw(14) << setprecision(3) << mean[2] + xyzRef[2] << " +- "
|
---|
| 918 | << setw(6) << setprecision(3) << std[2];
|
---|
| 919 | emit newMessage(QByteArray(strD.str().c_str()), true);
|
---|
[2649] | 920 |
|
---|
[3169] | 921 | ostringstream strE; strE.setf(ios::fixed);
|
---|
| 922 | strE << _staID.data() << " AVE-NEU "
|
---|
| 923 | << epoData->tt.timestr(1) << " "
|
---|
| 924 | << setw(13) << setprecision(3) << mean[3] << " +- "
|
---|
| 925 | << setw(6) << setprecision(3) << std[3] << " "
|
---|
| 926 | << setw(14) << setprecision(3) << mean[4] << " +- "
|
---|
| 927 | << setw(6) << setprecision(3) << std[4] << " "
|
---|
| 928 | << setw(14) << setprecision(3) << mean[5] << " +- "
|
---|
| 929 | << setw(6) << setprecision(3) << std[5];
|
---|
| 930 | emit newMessage(QByteArray(strE.str().c_str()), true);
|
---|
[2649] | 931 |
|
---|
[3169] | 932 | if ( Qt::CheckState(settings.value("pppEstTropo").toInt()) == Qt::Checked) {
|
---|
| 933 | ostringstream strF; strF.setf(ios::fixed);
|
---|
| 934 | strF << _staID.data() << " AVE-TRP "
|
---|
| 935 | << epoData->tt.timestr(1) << " "
|
---|
| 936 | << setw(13) << setprecision(3) << mean[6] << " +- "
|
---|
| 937 | << setw(6) << setprecision(3) << std[6] << endl;
|
---|
| 938 | emit newMessage(QByteArray(strF.str().c_str()), true);
|
---|
| 939 | }
|
---|
[2726] | 940 | }
|
---|
[2599] | 941 | }
|
---|
| 942 | }
|
---|
| 943 |
|
---|
[2131] | 944 | // NMEA Output
|
---|
| 945 | // -----------
|
---|
[2181] | 946 | double xyz[3];
|
---|
| 947 | xyz[0] = x();
|
---|
| 948 | xyz[1] = y();
|
---|
| 949 | xyz[2] = z();
|
---|
| 950 | double ell[3];
|
---|
| 951 | xyz2ell(xyz, ell);
|
---|
| 952 | double phiDeg = ell[0] * 180 / M_PI;
|
---|
| 953 | double lamDeg = ell[1] * 180 / M_PI;
|
---|
[2132] | 954 |
|
---|
[2181] | 955 | char phiCh = 'N';
|
---|
| 956 | if (phiDeg < 0) {
|
---|
| 957 | phiDeg = -phiDeg;
|
---|
| 958 | phiCh = 'S';
|
---|
| 959 | }
|
---|
| 960 | char lamCh = 'E';
|
---|
| 961 | if (lamDeg < 0) {
|
---|
[2563] | 962 | lamDeg = -lamDeg;
|
---|
| 963 | lamCh = 'W';
|
---|
[2181] | 964 | }
|
---|
[2132] | 965 |
|
---|
[2566] | 966 | string datestr = epoData->tt.datestr(0); // yyyymmdd
|
---|
| 967 | ostringstream strRMC;
|
---|
| 968 | strRMC.setf(ios::fixed);
|
---|
| 969 | strRMC << "GPRMC,"
|
---|
| 970 | << epoData->tt.timestr(0,0) << ",A,"
|
---|
| 971 | << setw(2) << setfill('0') << int(phiDeg)
|
---|
| 972 | << setw(6) << setprecision(3) << setfill('0')
|
---|
| 973 | << fmod(60*phiDeg,60) << ',' << phiCh << ','
|
---|
| 974 | << setw(3) << setfill('0') << int(lamDeg)
|
---|
| 975 | << setw(6) << setprecision(3) << setfill('0')
|
---|
| 976 | << fmod(60*lamDeg,60) << ',' << lamCh << ",,,"
|
---|
[2569] | 977 | << datestr[6] << datestr[7] << datestr[4] << datestr[5]
|
---|
| 978 | << datestr[2] << datestr[3] << ",,";
|
---|
[2566] | 979 |
|
---|
| 980 | writeNMEAstr(QString(strRMC.str().c_str()));
|
---|
| 981 |
|
---|
[2181] | 982 | double dop = 2.0; // TODO
|
---|
[2133] | 983 |
|
---|
[2566] | 984 | ostringstream strGGA;
|
---|
| 985 | strGGA.setf(ios::fixed);
|
---|
| 986 | strGGA << "GPGGA,"
|
---|
| 987 | << epoData->tt.timestr(0,0) << ','
|
---|
| 988 | << setw(2) << setfill('0') << int(phiDeg)
|
---|
| 989 | << setw(10) << setprecision(7) << setfill('0')
|
---|
| 990 | << fmod(60*phiDeg,60) << ',' << phiCh << ','
|
---|
| 991 | << setw(3) << setfill('0') << int(lamDeg)
|
---|
| 992 | << setw(10) << setprecision(7) << setfill('0')
|
---|
| 993 | << fmod(60*lamDeg,60) << ',' << lamCh
|
---|
| 994 | << ",1," << setw(2) << setfill('0') << epoData->sizeAll() << ','
|
---|
| 995 | << setw(3) << setprecision(1) << dop << ','
|
---|
[2569] | 996 | << setprecision(3) << ell[2] << ",M,0.0,M,,";
|
---|
[2181] | 997 |
|
---|
[2566] | 998 | writeNMEAstr(QString(strGGA.str().c_str()));
|
---|
[2131] | 999 |
|
---|
[3106] | 1000 | _lastTimeOK = _time; // remember time of last successful update
|
---|
[2060] | 1001 | return success;
|
---|
| 1002 | }
|
---|
[2112] | 1003 |
|
---|
| 1004 | // Outlier Detection
|
---|
| 1005 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1006 | int bncModel::outlierDetection(const SymmetricMatrix& QQsav,
|
---|
| 1007 | const ColumnVector& vv,
|
---|
[2231] | 1008 | QMap<QString, t_satData*>& satDataGPS,
|
---|
[2780] | 1009 | QMap<QString, t_satData*>& satDataGlo,
|
---|
| 1010 | QMap<QString, t_satData*>& satDataGal) {
|
---|
[2112] | 1011 |
|
---|
[2792] | 1012 | QString prnCode;
|
---|
| 1013 | QString prnPhase;
|
---|
| 1014 | double maxResCode = 0.0;
|
---|
| 1015 | double maxResPhase = 0.0;
|
---|
[2231] | 1016 |
|
---|
[2792] | 1017 | QString prnRemoved;
|
---|
| 1018 | double maxRes;
|
---|
[2112] | 1019 |
|
---|
[2793] | 1020 | int irc = 0;
|
---|
| 1021 |
|
---|
| 1022 | // Check Glonass
|
---|
| 1023 | // -------------
|
---|
| 1024 | if (irc == 0) {
|
---|
| 1025 | findMaxRes(vv,satDataGlo, prnCode, maxResCode, prnPhase, maxResPhase);
|
---|
| 1026 | if (maxResPhase > MAXRES_PHASE_GLO) {
|
---|
| 1027 | satDataGlo.remove(prnPhase);
|
---|
| 1028 | prnRemoved = prnPhase;
|
---|
| 1029 | maxRes = maxResPhase;
|
---|
| 1030 | irc = 1;
|
---|
| 1031 | }
|
---|
[2792] | 1032 | }
|
---|
[2112] | 1033 |
|
---|
[2793] | 1034 | // Check Galileo
|
---|
| 1035 | // -------------
|
---|
| 1036 | if (irc == 0) {
|
---|
[2792] | 1037 | findMaxRes(vv,satDataGal, prnCode, maxResCode, prnPhase, maxResPhase);
|
---|
| 1038 | if (maxResPhase > MAXRES_PHASE_GAL) {
|
---|
| 1039 | satDataGal.remove(prnPhase);
|
---|
| 1040 | prnRemoved = prnPhase;
|
---|
| 1041 | maxRes = maxResPhase;
|
---|
[2793] | 1042 | irc = 1;
|
---|
[2112] | 1043 | }
|
---|
[2792] | 1044 | else if (maxResCode > MAXRES_CODE_GAL) {
|
---|
| 1045 | satDataGal.remove(prnCode);
|
---|
| 1046 | prnRemoved = prnCode;
|
---|
| 1047 | maxRes = maxResCode;
|
---|
[2793] | 1048 | irc = 1;
|
---|
[2238] | 1049 | }
|
---|
[2793] | 1050 | }
|
---|
[2112] | 1051 |
|
---|
[2793] | 1052 | // Check GPS
|
---|
| 1053 | // ---------
|
---|
| 1054 | if (irc == 0) {
|
---|
| 1055 | findMaxRes(vv,satDataGPS, prnCode, maxResCode, prnPhase, maxResPhase);
|
---|
| 1056 | if (maxResPhase > MAXRES_PHASE_GPS) {
|
---|
| 1057 | satDataGPS.remove(prnPhase);
|
---|
| 1058 | prnRemoved = prnPhase;
|
---|
| 1059 | maxRes = maxResPhase;
|
---|
| 1060 | irc = 1;
|
---|
[2780] | 1061 | }
|
---|
[2793] | 1062 | else if (maxResCode > MAXRES_CODE_GPS) {
|
---|
| 1063 | satDataGPS.remove(prnCode);
|
---|
| 1064 | prnRemoved = prnCode;
|
---|
| 1065 | maxRes = maxResCode;
|
---|
| 1066 | irc = 1;
|
---|
| 1067 | }
|
---|
[2780] | 1068 | }
|
---|
| 1069 |
|
---|
[2793] | 1070 | if (irc != 0) {
|
---|
[2792] | 1071 | _log += "Outlier " + prnRemoved.toAscii() + " "
|
---|
| 1072 | + QByteArray::number(maxRes, 'f', 3) + "\n";
|
---|
[2248] | 1073 | _QQ = QQsav;
|
---|
| 1074 | }
|
---|
[2793] | 1075 |
|
---|
| 1076 | return irc;
|
---|
[2112] | 1077 | }
|
---|
[2130] | 1078 |
|
---|
| 1079 | //
|
---|
| 1080 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1081 | void bncModel::writeNMEAstr(const QString& nmStr) {
|
---|
| 1082 |
|
---|
| 1083 | unsigned char XOR = 0;
|
---|
| 1084 | for (int ii = 0; ii < nmStr.length(); ii++) {
|
---|
| 1085 | XOR ^= (unsigned char) nmStr[ii].toAscii();
|
---|
| 1086 | }
|
---|
[2181] | 1087 |
|
---|
| 1088 | QString outStr = '$' + nmStr
|
---|
| 1089 | + QString("*%1\n").arg(int(XOR), 0, 16).toUpper();
|
---|
[2130] | 1090 |
|
---|
[2178] | 1091 | if (_nmeaStream) {
|
---|
[2181] | 1092 | *_nmeaStream << outStr;
|
---|
[2178] | 1093 | _nmeaStream->flush();
|
---|
| 1094 | }
|
---|
[2130] | 1095 |
|
---|
[2181] | 1096 | emit newNMEAstr(outStr.toAscii());
|
---|
[2130] | 1097 | }
|
---|
[2283] | 1098 |
|
---|
| 1099 | ////
|
---|
| 1100 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 1101 | void bncModel::kalman(const Matrix& AA, const ColumnVector& ll,
|
---|
| 1102 | const DiagonalMatrix& PP,
|
---|
| 1103 | SymmetricMatrix& QQ, ColumnVector& dx) {
|
---|
| 1104 |
|
---|
| 1105 | int nObs = AA.Nrows();
|
---|
| 1106 | int nPar = AA.Ncols();
|
---|
| 1107 |
|
---|
| 1108 | UpperTriangularMatrix SS = Cholesky(QQ).t();
|
---|
| 1109 |
|
---|
| 1110 | Matrix SA = SS*AA.t();
|
---|
| 1111 | Matrix SRF(nObs+nPar, nObs+nPar); SRF = 0;
|
---|
| 1112 | for (int ii = 1; ii <= nObs; ++ii) {
|
---|
| 1113 | SRF(ii,ii) = 1.0 / sqrt(PP(ii,ii));
|
---|
| 1114 | }
|
---|
| 1115 |
|
---|
| 1116 | SRF.SubMatrix (nObs+1, nObs+nPar, 1, nObs) = SA;
|
---|
| 1117 | SRF.SymSubMatrix(nObs+1, nObs+nPar) = SS;
|
---|
| 1118 |
|
---|
| 1119 | UpperTriangularMatrix UU;
|
---|
| 1120 | QRZ(SRF, UU);
|
---|
| 1121 |
|
---|
| 1122 | SS = UU.SymSubMatrix(nObs+1, nObs+nPar);
|
---|
| 1123 | UpperTriangularMatrix SH_rt = UU.SymSubMatrix(1, nObs);
|
---|
| 1124 | Matrix YY = UU.SubMatrix(1, nObs, nObs+1, nObs+nPar);
|
---|
| 1125 |
|
---|
| 1126 | UpperTriangularMatrix SHi = SH_rt.i();
|
---|
| 1127 |
|
---|
| 1128 | Matrix KT = SHi * YY;
|
---|
| 1129 | SymmetricMatrix Hi; Hi << SHi * SHi.t();
|
---|
| 1130 |
|
---|
| 1131 | dx = KT.t() * ll;
|
---|
| 1132 | QQ << (SS.t() * SS);
|
---|
| 1133 | }
|
---|
[2582] | 1134 |
|
---|
| 1135 | // Phase Wind-Up Correction
|
---|
| 1136 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 1137 | double bncModel::windUp(const QString& prn, const ColumnVector& rSat,
|
---|
| 1138 | const ColumnVector& rRec) {
|
---|
| 1139 |
|
---|
| 1140 | double Mjd = _time.mjd() + _time.daysec() / 86400.0;
|
---|
| 1141 |
|
---|
| 1142 | // First time - initialize to zero
|
---|
| 1143 | // -------------------------------
|
---|
| 1144 | if (!_windUpTime.contains(prn)) {
|
---|
| 1145 | _windUpSum[prn] = 0.0;
|
---|
| 1146 | }
|
---|
| 1147 |
|
---|
| 1148 | // Compute the correction for new time
|
---|
| 1149 | // -----------------------------------
|
---|
[2942] | 1150 | if (!_windUpTime.contains(prn) || _windUpTime[prn] != Mjd) {
|
---|
[2582] | 1151 | _windUpTime[prn] = Mjd;
|
---|
| 1152 |
|
---|
| 1153 | // Unit Vector GPS Satellite --> Receiver
|
---|
| 1154 | // --------------------------------------
|
---|
| 1155 | ColumnVector rho = rRec - rSat;
|
---|
| 1156 | rho /= rho.norm_Frobenius();
|
---|
| 1157 |
|
---|
| 1158 | // GPS Satellite unit Vectors sz, sy, sx
|
---|
| 1159 | // -------------------------------------
|
---|
| 1160 | ColumnVector sz = -rSat / rSat.norm_Frobenius();
|
---|
| 1161 |
|
---|
| 1162 | ColumnVector xSun = Sun(Mjd);
|
---|
| 1163 | xSun /= xSun.norm_Frobenius();
|
---|
| 1164 |
|
---|
| 1165 | ColumnVector sy = crossproduct(sz, xSun);
|
---|
| 1166 | ColumnVector sx = crossproduct(sy, sz);
|
---|
| 1167 |
|
---|
| 1168 | // Effective Dipole of the GPS Satellite Antenna
|
---|
| 1169 | // ---------------------------------------------
|
---|
| 1170 | ColumnVector dipSat = sx - rho * DotProduct(rho,sx)
|
---|
| 1171 | - crossproduct(rho, sy);
|
---|
| 1172 |
|
---|
| 1173 | // Receiver unit Vectors rx, ry
|
---|
| 1174 | // ----------------------------
|
---|
| 1175 | ColumnVector rx(3);
|
---|
| 1176 | ColumnVector ry(3);
|
---|
| 1177 |
|
---|
| 1178 | double recEll[3]; xyz2ell(rRec.data(), recEll) ;
|
---|
| 1179 | double neu[3];
|
---|
| 1180 |
|
---|
| 1181 | neu[0] = 1.0;
|
---|
| 1182 | neu[1] = 0.0;
|
---|
| 1183 | neu[2] = 0.0;
|
---|
| 1184 | neu2xyz(recEll, neu, rx.data());
|
---|
| 1185 |
|
---|
| 1186 | neu[0] = 0.0;
|
---|
| 1187 | neu[1] = -1.0;
|
---|
| 1188 | neu[2] = 0.0;
|
---|
| 1189 | neu2xyz(recEll, neu, ry.data());
|
---|
| 1190 |
|
---|
| 1191 | // Effective Dipole of the Receiver Antenna
|
---|
| 1192 | // ----------------------------------------
|
---|
| 1193 | ColumnVector dipRec = rx - rho * DotProduct(rho,rx)
|
---|
| 1194 | + crossproduct(rho, ry);
|
---|
| 1195 |
|
---|
| 1196 | // Resulting Effect
|
---|
| 1197 | // ----------------
|
---|
| 1198 | double alpha = DotProduct(dipSat,dipRec) /
|
---|
| 1199 | (dipSat.norm_Frobenius() * dipRec.norm_Frobenius());
|
---|
| 1200 |
|
---|
| 1201 | if (alpha > 1.0) alpha = 1.0;
|
---|
| 1202 | if (alpha < -1.0) alpha = -1.0;
|
---|
| 1203 |
|
---|
| 1204 | double dphi = acos(alpha) / 2.0 / M_PI; // in cycles
|
---|
| 1205 |
|
---|
| 1206 | if ( DotProduct(rho, crossproduct(dipSat, dipRec)) < 0.0 ) {
|
---|
| 1207 | dphi = -dphi;
|
---|
| 1208 | }
|
---|
| 1209 |
|
---|
| 1210 | _windUpSum[prn] = floor(_windUpSum[prn] - dphi + 0.5) + dphi;
|
---|
| 1211 | }
|
---|
| 1212 |
|
---|
| 1213 | return _windUpSum[prn];
|
---|
| 1214 | }
|
---|
[2789] | 1215 |
|
---|
| 1216 | //
|
---|
| 1217 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 1218 | void bncModel::cmpEle(t_satData* satData) {
|
---|
| 1219 | ColumnVector rr = satData->xx - _xcBanc.Rows(1,3);
|
---|
| 1220 | double rho = rr.norm_Frobenius();
|
---|
| 1221 |
|
---|
| 1222 | double neu[3];
|
---|
| 1223 | xyz2neu(_ellBanc.data(), rr.data(), neu);
|
---|
| 1224 |
|
---|
| 1225 | satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
|
---|
| 1226 | if (neu[2] < 0) {
|
---|
| 1227 | satData->eleSat *= -1.0;
|
---|
| 1228 | }
|
---|
| 1229 | satData->azSat = atan2(neu[1], neu[0]);
|
---|
| 1230 | }
|
---|
| 1231 |
|
---|
| 1232 | //
|
---|
| 1233 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 1234 | void bncModel::addAmb(t_satData* satData) {
|
---|
| 1235 | bool found = false;
|
---|
| 1236 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 1237 | if (_params[iPar-1]->type == bncParam::AMB_L3 &&
|
---|
| 1238 | _params[iPar-1]->prn == satData->prn) {
|
---|
| 1239 | found = true;
|
---|
| 1240 | break;
|
---|
| 1241 | }
|
---|
| 1242 | }
|
---|
| 1243 | if (!found) {
|
---|
| 1244 | bncParam* par = new bncParam(bncParam::AMB_L3,
|
---|
| 1245 | _params.size()+1, satData->prn);
|
---|
| 1246 | _params.push_back(par);
|
---|
| 1247 | par->xx = satData->L3 - cmpValue(satData, true);
|
---|
| 1248 | }
|
---|
| 1249 | }
|
---|
[2790] | 1250 |
|
---|
| 1251 | //
|
---|
| 1252 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 1253 | void bncModel::addObs(unsigned& iObs, t_satData* satData,
|
---|
| 1254 | Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP) {
|
---|
| 1255 |
|
---|
[2791] | 1256 | // Code Observations
|
---|
| 1257 | // -----------------
|
---|
[2790] | 1258 | if (satData->system() != 'R') {
|
---|
| 1259 | ++iObs;
|
---|
| 1260 | ll(iObs) = satData->P3 - cmpValue(satData, false);
|
---|
| 1261 | PP(iObs,iObs) = 1.0 / (_sigP3 * _sigP3);
|
---|
| 1262 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 1263 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, false);
|
---|
| 1264 | }
|
---|
[2791] | 1265 | satData->indexCode = iObs;
|
---|
[2790] | 1266 | }
|
---|
| 1267 |
|
---|
[2791] | 1268 | // Phase Observations
|
---|
| 1269 | // ------------------
|
---|
[2790] | 1270 | if (_usePhase) {
|
---|
| 1271 | ++iObs;
|
---|
| 1272 | ll(iObs) = satData->L3 - cmpValue(satData, true);
|
---|
| 1273 | PP(iObs,iObs) = 1.0 / (_sigL3 * _sigL3);
|
---|
| 1274 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 1275 | if (_params[iPar-1]->type == bncParam::AMB_L3 &&
|
---|
| 1276 | _params[iPar-1]->prn == satData->prn) {
|
---|
| 1277 | ll(iObs) -= _params[iPar-1]->xx;
|
---|
| 1278 | }
|
---|
| 1279 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, true);
|
---|
| 1280 | }
|
---|
[2791] | 1281 | satData->indexPhase = iObs;
|
---|
[2790] | 1282 | }
|
---|
| 1283 | }
|
---|
[2791] | 1284 |
|
---|
| 1285 | //
|
---|
| 1286 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 1287 | void bncModel::printRes(const ColumnVector& vv,
|
---|
| 1288 | ostringstream& str, t_satData* satData) {
|
---|
[2800] | 1289 | if (satData->indexPhase) {
|
---|
[2797] | 1290 | str << _time.timestr(1)
|
---|
[2800] | 1291 | << " RES " << satData->prn.toAscii().data() << " L3 "
|
---|
| 1292 | << setw(9) << setprecision(4) << vv(satData->indexPhase);
|
---|
| 1293 | if (satData->indexCode) {
|
---|
| 1294 | str << " P3 " << setw(9) << setprecision(4) << vv(satData->indexCode);
|
---|
[2797] | 1295 | }
|
---|
| 1296 | str << endl;
|
---|
[2791] | 1297 | }
|
---|
| 1298 | }
|
---|
[2792] | 1299 |
|
---|
| 1300 | //
|
---|
| 1301 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 1302 | void bncModel::findMaxRes(const ColumnVector& vv,
|
---|
| 1303 | const QMap<QString, t_satData*>& satData,
|
---|
| 1304 | QString& prnCode, double& maxResCode,
|
---|
| 1305 | QString& prnPhase, double& maxResPhase) {
|
---|
| 1306 | maxResCode = 0.0;
|
---|
| 1307 | maxResPhase = 0.0;
|
---|
| 1308 |
|
---|
| 1309 | QMapIterator<QString, t_satData*> it(satData);
|
---|
| 1310 | while (it.hasNext()) {
|
---|
| 1311 | it.next();
|
---|
| 1312 | t_satData* satData = it.value();
|
---|
| 1313 | if (satData->indexCode) {
|
---|
| 1314 | if (fabs(vv(satData->indexCode)) > maxResCode) {
|
---|
| 1315 | maxResCode = fabs(vv(satData->indexCode));
|
---|
| 1316 | prnCode = satData->prn;
|
---|
| 1317 | }
|
---|
| 1318 | }
|
---|
| 1319 | if (satData->indexPhase) {
|
---|
| 1320 | if (fabs(vv(satData->indexPhase)) > maxResPhase) {
|
---|
| 1321 | maxResPhase = fabs(vv(satData->indexPhase));
|
---|
| 1322 | prnPhase = satData->prn;
|
---|
| 1323 | }
|
---|
| 1324 | }
|
---|
| 1325 | }
|
---|
| 1326 | }
|
---|
| 1327 |
|
---|