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