| 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>
|
|---|
| 42 | #include <cmath>
|
|---|
| 43 | #include <newmatio.h>
|
|---|
| 44 |
|
|---|
| 45 | #include "bncmodel.h"
|
|---|
| 46 | #include "bncpppclient.h"
|
|---|
| 47 | #include "bancroft.h"
|
|---|
| 48 | #include "bncutils.h"
|
|---|
| 49 | #include "bncsettings.h"
|
|---|
| 50 |
|
|---|
| 51 | using namespace std;
|
|---|
| 52 |
|
|---|
| 53 | const unsigned MINOBS = 4;
|
|---|
| 54 | const double MINELE = 10.0 * M_PI / 180.0;
|
|---|
| 55 | const double sig_crd_0 = 100.0;
|
|---|
| 56 | const double sig_crd_p = 100.0;
|
|---|
| 57 | const double sig_clk_0 = 1000.0;
|
|---|
| 58 | const double sig_trp_0 = 0.01;
|
|---|
| 59 | const double sig_trp_p = 1e-6;
|
|---|
| 60 | const double sig_amb_0 = 100.0;
|
|---|
| 61 | const double sig_P3 = 1.0;
|
|---|
| 62 | const double sig_L3 = 0.01;
|
|---|
| 63 |
|
|---|
| 64 | // Constructor
|
|---|
| 65 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 66 | bncParam::bncParam(bncParam::parType typeIn, int indexIn,
|
|---|
| 67 | const QString& prnIn) {
|
|---|
| 68 | type = typeIn;
|
|---|
| 69 | index = indexIn;
|
|---|
| 70 | prn = prnIn;
|
|---|
| 71 | index_old = 0;
|
|---|
| 72 | x0 = 0.0;
|
|---|
| 73 | xx = 0.0;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | // Destructor
|
|---|
| 77 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 78 | bncParam::~bncParam() {
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | // Partial
|
|---|
| 82 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 83 | double bncParam::partial(t_satData* satData, const QString& prnIn) {
|
|---|
| 84 | if (type == CRD_X) {
|
|---|
| 85 | return (x0 - satData->xx(1)) / satData->rho;
|
|---|
| 86 | }
|
|---|
| 87 | else if (type == CRD_Y) {
|
|---|
| 88 | return (x0 - satData->xx(2)) / satData->rho;
|
|---|
| 89 | }
|
|---|
| 90 | else if (type == CRD_Z) {
|
|---|
| 91 | return (x0 - satData->xx(3)) / satData->rho;
|
|---|
| 92 | }
|
|---|
| 93 | else if (type == RECCLK) {
|
|---|
| 94 | return 1.0;
|
|---|
| 95 | }
|
|---|
| 96 | else if (type == TROPO) {
|
|---|
| 97 | return 1.0 / sin(satData->eleSat);
|
|---|
| 98 | }
|
|---|
| 99 | else if (type == AMB_L3) {
|
|---|
| 100 | if (prnIn == prn) {
|
|---|
| 101 | return 1.0;
|
|---|
| 102 | }
|
|---|
| 103 | else {
|
|---|
| 104 | return 0.0;
|
|---|
| 105 | }
|
|---|
| 106 | }
|
|---|
| 107 | return 0.0;
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | // Constructor
|
|---|
| 111 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 112 | bncModel::bncModel() {
|
|---|
| 113 |
|
|---|
| 114 | bncSettings settings;
|
|---|
| 115 |
|
|---|
| 116 | _static = false;
|
|---|
| 117 | if ( Qt::CheckState(settings.value("pppStatic").toInt()) == Qt::Checked) {
|
|---|
| 118 | _static = true;
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | _usePhase = false;
|
|---|
| 122 | if ( Qt::CheckState(settings.value("pppUsePhase").toInt()) == Qt::Checked) {
|
|---|
| 123 | _usePhase = true;
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | _estTropo = false;
|
|---|
| 127 | if ( Qt::CheckState(settings.value("pppEstTropo").toInt()) == Qt::Checked) {
|
|---|
| 128 | _estTropo = true;
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | _xcBanc.ReSize(4); _xcBanc = 0.0;
|
|---|
| 132 | _ellBanc.ReSize(3); _ellBanc = 0.0;
|
|---|
| 133 |
|
|---|
| 134 | _params.push_back(new bncParam(bncParam::CRD_X, 1, ""));
|
|---|
| 135 | _params.push_back(new bncParam(bncParam::CRD_Y, 2, ""));
|
|---|
| 136 | _params.push_back(new bncParam(bncParam::CRD_Z, 3, ""));
|
|---|
| 137 | _params.push_back(new bncParam(bncParam::RECCLK, 4, ""));
|
|---|
| 138 | if (_estTropo) {
|
|---|
| 139 | _params.push_back(new bncParam(bncParam::TROPO, 5, ""));
|
|---|
| 140 | }
|
|---|
| 141 |
|
|---|
| 142 | unsigned nPar = _params.size();
|
|---|
| 143 |
|
|---|
| 144 | _QQ.ReSize(nPar);
|
|---|
| 145 | _xx.ReSize(nPar);
|
|---|
| 146 | _QQ = 0.0;
|
|---|
| 147 | _xx = 0.0;
|
|---|
| 148 |
|
|---|
| 149 | _QQ(1,1) = sig_crd_0 * sig_crd_0;
|
|---|
| 150 | _QQ(2,2) = sig_crd_0 * sig_crd_0;
|
|---|
| 151 | _QQ(3,3) = sig_crd_0 * sig_crd_0;
|
|---|
| 152 | _QQ(4,4) = sig_clk_0 * sig_clk_0;
|
|---|
| 153 | if (_estTropo) {
|
|---|
| 154 | _QQ(5,5) = sig_trp_0 * sig_trp_0;
|
|---|
| 155 | }
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | // Destructor
|
|---|
| 159 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 160 | bncModel::~bncModel() {
|
|---|
| 161 | }
|
|---|
| 162 |
|
|---|
| 163 | // Bancroft Solution
|
|---|
| 164 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 165 | t_irc bncModel::cmpBancroft(t_epoData* epoData) {
|
|---|
| 166 |
|
|---|
| 167 | if (epoData->size() < MINOBS) {
|
|---|
| 168 | return failure;
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | Matrix BB(epoData->size(), 4);
|
|---|
| 172 |
|
|---|
| 173 | QMapIterator<QString, t_satData*> it(epoData->satData);
|
|---|
| 174 | int iObs = 0;
|
|---|
| 175 | while (it.hasNext()) {
|
|---|
| 176 | ++iObs;
|
|---|
| 177 | it.next();
|
|---|
| 178 | QString prn = it.key();
|
|---|
| 179 | t_satData* satData = it.value();
|
|---|
| 180 | BB(iObs, 1) = satData->xx(1);
|
|---|
| 181 | BB(iObs, 2) = satData->xx(2);
|
|---|
| 182 | BB(iObs, 3) = satData->xx(3);
|
|---|
| 183 | BB(iObs, 4) = satData->P3 + satData->clk;
|
|---|
| 184 | }
|
|---|
| 185 |
|
|---|
| 186 | bancroft(BB, _xcBanc);
|
|---|
| 187 |
|
|---|
| 188 | // Ellipsoidal Coordinates
|
|---|
| 189 | // ------------------------
|
|---|
| 190 | xyz2ell(_xcBanc.data(), _ellBanc.data());
|
|---|
| 191 |
|
|---|
| 192 | // Compute Satellite Elevations
|
|---|
| 193 | // ----------------------------
|
|---|
| 194 | QMutableMapIterator<QString, t_satData*> it2(epoData->satData);
|
|---|
| 195 | while (it2.hasNext()) {
|
|---|
| 196 | it2.next();
|
|---|
| 197 | QString prn = it2.key();
|
|---|
| 198 | t_satData* satData = it2.value();
|
|---|
| 199 |
|
|---|
| 200 | ColumnVector dx = satData->xx - _xcBanc.Rows(1,3);
|
|---|
| 201 | double rho = dx.norm_Frobenius();
|
|---|
| 202 |
|
|---|
| 203 | double neu[3];
|
|---|
| 204 | xyz2neu(_ellBanc.data(), dx.data(), neu);
|
|---|
| 205 |
|
|---|
| 206 | satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
|
|---|
| 207 | if (neu[2] < 0) {
|
|---|
| 208 | satData->eleSat *= -1.0;
|
|---|
| 209 | }
|
|---|
| 210 | satData->azSat = atan2(neu[1], neu[0]);
|
|---|
| 211 |
|
|---|
| 212 | if (satData->eleSat < MINELE) {
|
|---|
| 213 | delete satData;
|
|---|
| 214 | it2.remove();
|
|---|
| 215 | }
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | return success;
|
|---|
| 219 | }
|
|---|
| 220 |
|
|---|
| 221 | // Computed Value
|
|---|
| 222 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 223 | double bncModel::cmpValue(t_satData* satData) {
|
|---|
| 224 |
|
|---|
| 225 | ColumnVector xRec(3);
|
|---|
| 226 | xRec(1) = x();
|
|---|
| 227 | xRec(2) = y();
|
|---|
| 228 | xRec(3) = z();
|
|---|
| 229 |
|
|---|
| 230 | double rho0 = (satData->xx - xRec).norm_Frobenius();
|
|---|
| 231 | double dPhi = t_CST::omega * rho0 / t_CST::c;
|
|---|
| 232 |
|
|---|
| 233 | xRec(1) = x() * cos(dPhi) - y() * sin(dPhi);
|
|---|
| 234 | xRec(2) = y() * cos(dPhi) + x() * sin(dPhi);
|
|---|
| 235 | xRec(3) = z();
|
|---|
| 236 |
|
|---|
| 237 | satData->rho = (satData->xx - xRec).norm_Frobenius();
|
|---|
| 238 |
|
|---|
| 239 | double tropDelay = delay_saast(satData->eleSat) +
|
|---|
| 240 | trp() / sin(satData->eleSat);
|
|---|
| 241 |
|
|---|
| 242 | return satData->rho + clk() - satData->clk + tropDelay;
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 | // Tropospheric Model (Saastamoinen)
|
|---|
| 246 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 247 | double bncModel::delay_saast(double Ele) {
|
|---|
| 248 |
|
|---|
| 249 | double height = _ellBanc(3);
|
|---|
| 250 |
|
|---|
| 251 | double pp = 1013.25 * pow(1.0 - 2.26e-5 * height, 5.225);
|
|---|
| 252 | double TT = 18.0 - height * 0.0065 + 273.15;
|
|---|
| 253 | double hh = 50.0 * exp(-6.396e-4 * height);
|
|---|
| 254 | double ee = hh / 100.0 * exp(-37.2465 + 0.213166*TT - 0.000256908*TT*TT);
|
|---|
| 255 |
|
|---|
| 256 | double h_km = height / 1000.0;
|
|---|
| 257 |
|
|---|
| 258 | if (h_km < 0.0) h_km = 0.0;
|
|---|
| 259 | if (h_km > 5.0) h_km = 5.0;
|
|---|
| 260 | int ii = int(h_km + 1);
|
|---|
| 261 | double href = ii - 1;
|
|---|
| 262 |
|
|---|
| 263 | double bCor[6];
|
|---|
| 264 | bCor[0] = 1.156;
|
|---|
| 265 | bCor[1] = 1.006;
|
|---|
| 266 | bCor[2] = 0.874;
|
|---|
| 267 | bCor[3] = 0.757;
|
|---|
| 268 | bCor[4] = 0.654;
|
|---|
| 269 | bCor[5] = 0.563;
|
|---|
| 270 |
|
|---|
| 271 | double BB = bCor[ii-1] + (bCor[ii]-bCor[ii-1]) * (h_km - href);
|
|---|
| 272 |
|
|---|
| 273 | double zen = M_PI/2.0 - Ele;
|
|---|
| 274 |
|
|---|
| 275 | return (0.002277/cos(zen)) * (pp + ((1255.0/TT)+0.05)*ee - BB*(tan(zen)*tan(zen)));
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| 278 | // Prediction Step of the Filter
|
|---|
| 279 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 280 | void bncModel::predict(t_epoData* epoData) {
|
|---|
| 281 |
|
|---|
| 282 | if (_usePhase) {
|
|---|
| 283 |
|
|---|
| 284 | // Make a copy of QQ and xx, set parameter indices
|
|---|
| 285 | // -----------------------------------------------
|
|---|
| 286 | SymmetricMatrix QQ_old = _QQ;
|
|---|
| 287 | ColumnVector xx_old = _xx;
|
|---|
| 288 |
|
|---|
| 289 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 290 | _params[iPar-1]->index_old = _params[iPar-1]->index;
|
|---|
| 291 | _params[iPar-1]->index = 0;
|
|---|
| 292 | }
|
|---|
| 293 |
|
|---|
| 294 | // Remove Ambiguity Parameters without observations
|
|---|
| 295 | // ------------------------------------------------
|
|---|
| 296 | int iPar = 0;
|
|---|
| 297 | QMutableVectorIterator<bncParam*> it(_params);
|
|---|
| 298 | while (it.hasNext()) {
|
|---|
| 299 | bncParam* par = it.next();
|
|---|
| 300 | bool removed = false;
|
|---|
| 301 | if (par->type == bncParam::AMB_L3) {
|
|---|
| 302 | if (epoData->satData.find(par->prn) == epoData->satData.end()) {
|
|---|
| 303 | removed = true;
|
|---|
| 304 | delete par;
|
|---|
| 305 | it.remove();
|
|---|
| 306 | }
|
|---|
| 307 | }
|
|---|
| 308 | if (! removed) {
|
|---|
| 309 | ++iPar;
|
|---|
| 310 | par->index = iPar;
|
|---|
| 311 | }
|
|---|
| 312 | }
|
|---|
| 313 |
|
|---|
| 314 | // Add new ambiguity parameters
|
|---|
| 315 | // ----------------------------
|
|---|
| 316 | QMapIterator<QString, t_satData*> itObs(epoData->satData);
|
|---|
| 317 | while (itObs.hasNext()) {
|
|---|
| 318 | itObs.next();
|
|---|
| 319 | QString prn = itObs.key();
|
|---|
| 320 | bool found = false;
|
|---|
| 321 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 322 | if (_params[iPar-1]->type == bncParam::AMB_L3 &&
|
|---|
| 323 | _params[iPar-1]->prn == prn) {
|
|---|
| 324 | found = true;
|
|---|
| 325 | break;
|
|---|
| 326 | }
|
|---|
| 327 | }
|
|---|
| 328 | if (!found) {
|
|---|
| 329 | bncParam* par = new bncParam(bncParam::AMB_L3, _params.size()+1, prn);
|
|---|
| 330 | _params.push_back(par);
|
|---|
| 331 | }
|
|---|
| 332 | }
|
|---|
| 333 |
|
|---|
| 334 | int nPar = _params.size();
|
|---|
| 335 | _xx.ReSize(nPar); _xx = 0.0;
|
|---|
| 336 | _QQ.ReSize(nPar); _QQ = 0.0;
|
|---|
| 337 | for (int i1 = 1; i1 <= nPar; i1++) {
|
|---|
| 338 | bncParam* p1 = _params[i1-1];
|
|---|
| 339 | if (p1->index_old != 0) {
|
|---|
| 340 | _xx(p1->index) = xx_old(p1->index_old);
|
|---|
| 341 | _QQ(p1->index, p1->index) = QQ_old(p1->index_old, p1->index_old);
|
|---|
| 342 | for (int i2 = 1; i2 <= nPar; i2++) {
|
|---|
| 343 | bncParam* p2 = _params[i2-1];
|
|---|
| 344 | if (p2->index_old != 0) {
|
|---|
| 345 | _QQ(p1->index, p2->index) = QQ_old(p1->index_old, p2->index_old);
|
|---|
| 346 | }
|
|---|
| 347 | }
|
|---|
| 348 | }
|
|---|
| 349 | }
|
|---|
| 350 |
|
|---|
| 351 | for (int ii = 1; ii <= nPar; ii++) {
|
|---|
| 352 | bncParam* par = _params[ii-1];
|
|---|
| 353 | if (par->index_old == 0) {
|
|---|
| 354 | _QQ(par->index, par->index) = sig_amb_0 * sig_amb_0;
|
|---|
| 355 | }
|
|---|
| 356 | par->index_old = par->index;
|
|---|
| 357 | }
|
|---|
| 358 | }
|
|---|
| 359 |
|
|---|
| 360 | // Coordinates
|
|---|
| 361 | // -----------
|
|---|
| 362 | if (_static) {
|
|---|
| 363 | if (x() == 0.0 && y() == 0.0 && z() == 0.0) {
|
|---|
| 364 | _params[0]->x0 = _xcBanc(1);
|
|---|
| 365 | _params[1]->x0 = _xcBanc(2);
|
|---|
| 366 | _params[2]->x0 = _xcBanc(3);
|
|---|
| 367 | }
|
|---|
| 368 | else {
|
|---|
| 369 | _params[0]->x0 += _params[0]->xx;
|
|---|
| 370 | _params[1]->x0 += _params[1]->xx;
|
|---|
| 371 | _params[2]->x0 += _params[2]->xx;
|
|---|
| 372 | }
|
|---|
| 373 | }
|
|---|
| 374 | else {
|
|---|
| 375 | _params[0]->x0 = _xcBanc(1);
|
|---|
| 376 | _params[1]->x0 = _xcBanc(2);
|
|---|
| 377 | _params[2]->x0 = _xcBanc(3);
|
|---|
| 378 |
|
|---|
| 379 | _QQ(1,1) += sig_crd_p * sig_crd_p;
|
|---|
| 380 | _QQ(2,2) += sig_crd_p * sig_crd_p;
|
|---|
| 381 | _QQ(3,3) += sig_crd_p * sig_crd_p;
|
|---|
| 382 | }
|
|---|
| 383 |
|
|---|
| 384 | // Receiver Clocks
|
|---|
| 385 | // ---------------
|
|---|
| 386 | _params[3]->x0 = _xcBanc(4);
|
|---|
| 387 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 388 | _QQ(iPar, 4) = 0.0;
|
|---|
| 389 | }
|
|---|
| 390 | _QQ(4,4) = sig_clk_0 * sig_clk_0;
|
|---|
| 391 |
|
|---|
| 392 | // Tropospheric Delay
|
|---|
| 393 | // ------------------
|
|---|
| 394 | if (_estTropo) {
|
|---|
| 395 | _params[4]->x0 += _params[4]->xx;
|
|---|
| 396 | _QQ(5,5) += sig_trp_p * sig_trp_p;
|
|---|
| 397 | }
|
|---|
| 398 |
|
|---|
| 399 | // Ambiguities
|
|---|
| 400 | // -----------
|
|---|
| 401 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 402 | if (_params[iPar-1]->type == bncParam::AMB_L3) {
|
|---|
| 403 | _params[iPar-1]->x0 += _params[iPar-1]->xx;
|
|---|
| 404 | }
|
|---|
| 405 | }
|
|---|
| 406 |
|
|---|
| 407 | // Nullify the Solution Vector
|
|---|
| 408 | // ---------------------------
|
|---|
| 409 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 410 | _params[iPar-1]->xx = 0.0;
|
|---|
| 411 | }
|
|---|
| 412 | _xx = 0.0;
|
|---|
| 413 | }
|
|---|
| 414 |
|
|---|
| 415 | // Update Step of the Filter (currently just a single-epoch solution)
|
|---|
| 416 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 417 | t_irc bncModel::update(t_epoData* epoData) {
|
|---|
| 418 |
|
|---|
| 419 | if (epoData->size() < MINOBS) {
|
|---|
| 420 | return failure;
|
|---|
| 421 | }
|
|---|
| 422 |
|
|---|
| 423 | predict(epoData);
|
|---|
| 424 |
|
|---|
| 425 | unsigned nPar = _params.size();
|
|---|
| 426 | unsigned nObs = _usePhase ? 2 * epoData->size() : epoData->size();
|
|---|
| 427 |
|
|---|
| 428 | // Create First-Design Matrix
|
|---|
| 429 | // --------------------------
|
|---|
| 430 | Matrix AA(nObs, nPar); // first design matrix
|
|---|
| 431 | ColumnVector ll(nObs); // tems observed-computed
|
|---|
| 432 | SymmetricMatrix PP(nObs); PP = 0.0;
|
|---|
| 433 |
|
|---|
| 434 | unsigned iObs = 0;
|
|---|
| 435 | QMapIterator<QString, t_satData*> itObs(epoData->satData);
|
|---|
| 436 | while (itObs.hasNext()) {
|
|---|
| 437 | ++iObs;
|
|---|
| 438 | itObs.next();
|
|---|
| 439 | QString prn = itObs.key();
|
|---|
| 440 | t_satData* satData = itObs.value();
|
|---|
| 441 |
|
|---|
| 442 | double rhoCmp = cmpValue(satData);
|
|---|
| 443 |
|
|---|
| 444 | ll(iObs) = satData->P3 - rhoCmp;
|
|---|
| 445 | PP(iObs,iObs) = 1.0 / (sig_P3 * sig_P3);
|
|---|
| 446 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 447 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, "");
|
|---|
| 448 | }
|
|---|
| 449 |
|
|---|
| 450 | if (_usePhase) {
|
|---|
| 451 | ++iObs;
|
|---|
| 452 | ll(iObs) = satData->L3 - rhoCmp;
|
|---|
| 453 | PP(iObs,iObs) = 1.0 / (sig_L3 * sig_L3);
|
|---|
| 454 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 455 | if (_params[iPar-1]->type == bncParam::AMB_L3 &&
|
|---|
| 456 | _params[iPar-1]->prn == prn) {
|
|---|
| 457 | ll(iObs) -= _params[iPar-1]->x0;
|
|---|
| 458 | }
|
|---|
| 459 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, prn);
|
|---|
| 460 | }
|
|---|
| 461 | }
|
|---|
| 462 | }
|
|---|
| 463 |
|
|---|
| 464 | // Compute Kalman Update
|
|---|
| 465 | // ---------------------
|
|---|
| 466 | if (false) {
|
|---|
| 467 | SymmetricMatrix HH; HH << PP + AA * _QQ * AA.t();
|
|---|
| 468 | SymmetricMatrix Hi = HH.i();
|
|---|
| 469 | Matrix KK = _QQ * AA.t() * Hi;
|
|---|
| 470 | ColumnVector v1 = ll - AA * _xx;
|
|---|
| 471 | _xx = _xx + KK * v1;
|
|---|
| 472 | IdentityMatrix Id(nPar);
|
|---|
| 473 | _QQ << (Id - KK * AA) * _QQ;
|
|---|
| 474 | }
|
|---|
| 475 | else {
|
|---|
| 476 | Matrix ATP = AA.t() * PP;
|
|---|
| 477 | SymmetricMatrix NN = _QQ.i();
|
|---|
| 478 | ColumnVector bb = NN * _xx + ATP * ll;
|
|---|
| 479 | NN << NN + ATP * AA;
|
|---|
| 480 | _QQ = NN.i();
|
|---|
| 481 | _xx = _QQ * bb;
|
|---|
| 482 | }
|
|---|
| 483 |
|
|---|
| 484 | // Set Solution Vector
|
|---|
| 485 | // -------------------
|
|---|
| 486 | QVectorIterator<bncParam*> itPar(_params);
|
|---|
| 487 | while (itPar.hasNext()) {
|
|---|
| 488 | bncParam* par = itPar.next();
|
|---|
| 489 | par->xx = _xx(par->index);
|
|---|
| 490 | }
|
|---|
| 491 |
|
|---|
| 492 | return success;
|
|---|
| 493 | }
|
|---|