[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"
|
---|
[2057] | 52 |
|
---|
| 53 | using namespace std;
|
---|
| 54 |
|
---|
[2113] | 55 | const unsigned MINOBS = 4;
|
---|
| 56 | const double MINELE = 10.0 * M_PI / 180.0;
|
---|
| 57 | const double MAXRES_CODE = 10.0;
|
---|
| 58 | const double MAXRES_PHASE = 0.10;
|
---|
| 59 | const double sig_crd_0 = 100.0;
|
---|
| 60 | const double sig_crd_p = 100.0;
|
---|
| 61 | const double sig_clk_0 = 1000.0;
|
---|
| 62 | const double sig_trp_0 = 0.01;
|
---|
| 63 | const double sig_trp_p = 1e-6;
|
---|
| 64 | const double sig_amb_0 = 100.0;
|
---|
| 65 | const double sig_P3 = 1.0;
|
---|
| 66 | const double sig_L3 = 0.01;
|
---|
[2070] | 67 |
|
---|
[2057] | 68 | // Constructor
|
---|
| 69 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2080] | 70 | bncParam::bncParam(bncParam::parType typeIn, int indexIn,
|
---|
| 71 | const QString& prnIn) {
|
---|
| 72 | type = typeIn;
|
---|
| 73 | index = indexIn;
|
---|
| 74 | prn = prnIn;
|
---|
| 75 | index_old = 0;
|
---|
| 76 | xx = 0.0;
|
---|
[2057] | 77 | }
|
---|
| 78 |
|
---|
| 79 | // Destructor
|
---|
| 80 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 81 | bncParam::~bncParam() {
|
---|
| 82 | }
|
---|
| 83 |
|
---|
[2060] | 84 | // Partial
|
---|
| 85 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2080] | 86 | double bncParam::partial(t_satData* satData, const QString& prnIn) {
|
---|
[2060] | 87 | if (type == CRD_X) {
|
---|
[2109] | 88 | return (xx - satData->xx(1)) / satData->rho;
|
---|
[2060] | 89 | }
|
---|
| 90 | else if (type == CRD_Y) {
|
---|
[2109] | 91 | return (xx - satData->xx(2)) / satData->rho;
|
---|
[2060] | 92 | }
|
---|
| 93 | else if (type == CRD_Z) {
|
---|
[2109] | 94 | return (xx - satData->xx(3)) / satData->rho;
|
---|
[2060] | 95 | }
|
---|
| 96 | else if (type == RECCLK) {
|
---|
| 97 | return 1.0;
|
---|
| 98 | }
|
---|
[2084] | 99 | else if (type == TROPO) {
|
---|
| 100 | return 1.0 / sin(satData->eleSat);
|
---|
| 101 | }
|
---|
[2080] | 102 | else if (type == AMB_L3) {
|
---|
| 103 | if (prnIn == prn) {
|
---|
| 104 | return 1.0;
|
---|
| 105 | }
|
---|
| 106 | else {
|
---|
| 107 | return 0.0;
|
---|
| 108 | }
|
---|
| 109 | }
|
---|
[2060] | 110 | return 0.0;
|
---|
| 111 | }
|
---|
| 112 |
|
---|
[2058] | 113 | // Constructor
|
---|
| 114 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2113] | 115 | bncModel::bncModel(QByteArray staID) {
|
---|
[2084] | 116 |
|
---|
[2113] | 117 | _staID = staID;
|
---|
| 118 |
|
---|
| 119 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
| 120 | ((bncApp*)qApp), SLOT(slotMessage(const QByteArray,bool)));
|
---|
| 121 |
|
---|
[2084] | 122 | bncSettings settings;
|
---|
| 123 |
|
---|
| 124 | _static = false;
|
---|
| 125 | if ( Qt::CheckState(settings.value("pppStatic").toInt()) == Qt::Checked) {
|
---|
| 126 | _static = true;
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 | _usePhase = false;
|
---|
| 130 | if ( Qt::CheckState(settings.value("pppUsePhase").toInt()) == Qt::Checked) {
|
---|
| 131 | _usePhase = true;
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | _estTropo = false;
|
---|
| 135 | if ( Qt::CheckState(settings.value("pppEstTropo").toInt()) == Qt::Checked) {
|
---|
| 136 | _estTropo = true;
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | _xcBanc.ReSize(4); _xcBanc = 0.0;
|
---|
| 140 | _ellBanc.ReSize(3); _ellBanc = 0.0;
|
---|
| 141 |
|
---|
[2080] | 142 | _params.push_back(new bncParam(bncParam::CRD_X, 1, ""));
|
---|
| 143 | _params.push_back(new bncParam(bncParam::CRD_Y, 2, ""));
|
---|
| 144 | _params.push_back(new bncParam(bncParam::CRD_Z, 3, ""));
|
---|
| 145 | _params.push_back(new bncParam(bncParam::RECCLK, 4, ""));
|
---|
[2084] | 146 | if (_estTropo) {
|
---|
| 147 | _params.push_back(new bncParam(bncParam::TROPO, 5, ""));
|
---|
| 148 | }
|
---|
[2073] | 149 |
|
---|
| 150 | unsigned nPar = _params.size();
|
---|
[2084] | 151 |
|
---|
[2073] | 152 | _QQ.ReSize(nPar);
|
---|
| 153 | _QQ = 0.0;
|
---|
| 154 |
|
---|
| 155 | _QQ(1,1) = sig_crd_0 * sig_crd_0;
|
---|
| 156 | _QQ(2,2) = sig_crd_0 * sig_crd_0;
|
---|
| 157 | _QQ(3,3) = sig_crd_0 * sig_crd_0;
|
---|
| 158 | _QQ(4,4) = sig_clk_0 * sig_clk_0;
|
---|
[2084] | 159 | if (_estTropo) {
|
---|
| 160 | _QQ(5,5) = sig_trp_0 * sig_trp_0;
|
---|
[2077] | 161 | }
|
---|
[2058] | 162 | }
|
---|
| 163 |
|
---|
| 164 | // Destructor
|
---|
| 165 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 166 | bncModel::~bncModel() {
|
---|
| 167 | }
|
---|
| 168 |
|
---|
| 169 | // Bancroft Solution
|
---|
| 170 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 171 | t_irc bncModel::cmpBancroft(t_epoData* epoData) {
|
---|
| 172 |
|
---|
| 173 | if (epoData->size() < MINOBS) {
|
---|
| 174 | return failure;
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | Matrix BB(epoData->size(), 4);
|
---|
| 178 |
|
---|
| 179 | QMapIterator<QString, t_satData*> it(epoData->satData);
|
---|
| 180 | int iObs = 0;
|
---|
| 181 | while (it.hasNext()) {
|
---|
[2060] | 182 | ++iObs;
|
---|
[2058] | 183 | it.next();
|
---|
| 184 | QString prn = it.key();
|
---|
| 185 | t_satData* satData = it.value();
|
---|
| 186 | BB(iObs, 1) = satData->xx(1);
|
---|
| 187 | BB(iObs, 2) = satData->xx(2);
|
---|
| 188 | BB(iObs, 3) = satData->xx(3);
|
---|
| 189 | BB(iObs, 4) = satData->P3 + satData->clk;
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 | bancroft(BB, _xcBanc);
|
---|
| 193 |
|
---|
[2064] | 194 | // Ellipsoidal Coordinates
|
---|
| 195 | // ------------------------
|
---|
| 196 | xyz2ell(_xcBanc.data(), _ellBanc.data());
|
---|
[2063] | 197 |
|
---|
[2064] | 198 | // Compute Satellite Elevations
|
---|
| 199 | // ----------------------------
|
---|
| 200 | QMutableMapIterator<QString, t_satData*> it2(epoData->satData);
|
---|
| 201 | while (it2.hasNext()) {
|
---|
| 202 | it2.next();
|
---|
| 203 | QString prn = it2.key();
|
---|
| 204 | t_satData* satData = it2.value();
|
---|
[2063] | 205 |
|
---|
[2109] | 206 | ColumnVector rr = satData->xx - _xcBanc.Rows(1,3);
|
---|
| 207 | double rho = rr.norm_Frobenius();
|
---|
[2064] | 208 |
|
---|
| 209 | double neu[3];
|
---|
[2109] | 210 | xyz2neu(_ellBanc.data(), rr.data(), neu);
|
---|
[2064] | 211 |
|
---|
| 212 | satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
|
---|
| 213 | if (neu[2] < 0) {
|
---|
| 214 | satData->eleSat *= -1.0;
|
---|
| 215 | }
|
---|
| 216 | satData->azSat = atan2(neu[1], neu[0]);
|
---|
[2070] | 217 |
|
---|
| 218 | if (satData->eleSat < MINELE) {
|
---|
| 219 | delete satData;
|
---|
| 220 | it2.remove();
|
---|
| 221 | }
|
---|
[2064] | 222 | }
|
---|
| 223 |
|
---|
[2058] | 224 | return success;
|
---|
| 225 | }
|
---|
[2060] | 226 |
|
---|
| 227 | // Computed Value
|
---|
| 228 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2080] | 229 | double bncModel::cmpValue(t_satData* satData) {
|
---|
[2060] | 230 |
|
---|
[2073] | 231 | ColumnVector xRec(3);
|
---|
| 232 | xRec(1) = x();
|
---|
| 233 | xRec(2) = y();
|
---|
| 234 | xRec(3) = z();
|
---|
[2060] | 235 |
|
---|
[2073] | 236 | double rho0 = (satData->xx - xRec).norm_Frobenius();
|
---|
[2060] | 237 | double dPhi = t_CST::omega * rho0 / t_CST::c;
|
---|
| 238 |
|
---|
[2073] | 239 | xRec(1) = x() * cos(dPhi) - y() * sin(dPhi);
|
---|
| 240 | xRec(2) = y() * cos(dPhi) + x() * sin(dPhi);
|
---|
| 241 | xRec(3) = z();
|
---|
| 242 |
|
---|
[2060] | 243 | satData->rho = (satData->xx - xRec).norm_Frobenius();
|
---|
| 244 |
|
---|
[2084] | 245 | double tropDelay = delay_saast(satData->eleSat) +
|
---|
| 246 | trp() / sin(satData->eleSat);
|
---|
[2060] | 247 |
|
---|
[2073] | 248 | return satData->rho + clk() - satData->clk + tropDelay;
|
---|
[2060] | 249 | }
|
---|
| 250 |
|
---|
[2063] | 251 | // Tropospheric Model (Saastamoinen)
|
---|
| 252 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2065] | 253 | double bncModel::delay_saast(double Ele) {
|
---|
[2063] | 254 |
|
---|
[2064] | 255 | double height = _ellBanc(3);
|
---|
[2063] | 256 |
|
---|
[2064] | 257 | double pp = 1013.25 * pow(1.0 - 2.26e-5 * height, 5.225);
|
---|
| 258 | double TT = 18.0 - height * 0.0065 + 273.15;
|
---|
| 259 | double hh = 50.0 * exp(-6.396e-4 * height);
|
---|
[2063] | 260 | double ee = hh / 100.0 * exp(-37.2465 + 0.213166*TT - 0.000256908*TT*TT);
|
---|
| 261 |
|
---|
[2064] | 262 | double h_km = height / 1000.0;
|
---|
[2063] | 263 |
|
---|
| 264 | if (h_km < 0.0) h_km = 0.0;
|
---|
| 265 | if (h_km > 5.0) h_km = 5.0;
|
---|
| 266 | int ii = int(h_km + 1);
|
---|
| 267 | double href = ii - 1;
|
---|
| 268 |
|
---|
| 269 | double bCor[6];
|
---|
| 270 | bCor[0] = 1.156;
|
---|
| 271 | bCor[1] = 1.006;
|
---|
| 272 | bCor[2] = 0.874;
|
---|
| 273 | bCor[3] = 0.757;
|
---|
| 274 | bCor[4] = 0.654;
|
---|
| 275 | bCor[5] = 0.563;
|
---|
| 276 |
|
---|
| 277 | double BB = bCor[ii-1] + (bCor[ii]-bCor[ii-1]) * (h_km - href);
|
---|
| 278 |
|
---|
| 279 | double zen = M_PI/2.0 - Ele;
|
---|
| 280 |
|
---|
| 281 | return (0.002277/cos(zen)) * (pp + ((1255.0/TT)+0.05)*ee - BB*(tan(zen)*tan(zen)));
|
---|
| 282 | }
|
---|
| 283 |
|
---|
[2073] | 284 | // Prediction Step of the Filter
|
---|
| 285 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2080] | 286 | void bncModel::predict(t_epoData* epoData) {
|
---|
[2073] | 287 |
|
---|
[2083] | 288 | if (_usePhase) {
|
---|
[2080] | 289 |
|
---|
[2083] | 290 | // Make a copy of QQ and xx, set parameter indices
|
---|
| 291 | // -----------------------------------------------
|
---|
| 292 | SymmetricMatrix QQ_old = _QQ;
|
---|
| 293 |
|
---|
| 294 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 295 | _params[iPar-1]->index_old = _params[iPar-1]->index;
|
---|
| 296 | _params[iPar-1]->index = 0;
|
---|
| 297 | }
|
---|
| 298 |
|
---|
| 299 | // Remove Ambiguity Parameters without observations
|
---|
| 300 | // ------------------------------------------------
|
---|
| 301 | int iPar = 0;
|
---|
| 302 | QMutableVectorIterator<bncParam*> it(_params);
|
---|
| 303 | while (it.hasNext()) {
|
---|
| 304 | bncParam* par = it.next();
|
---|
| 305 | bool removed = false;
|
---|
| 306 | if (par->type == bncParam::AMB_L3) {
|
---|
| 307 | if (epoData->satData.find(par->prn) == epoData->satData.end()) {
|
---|
| 308 | removed = true;
|
---|
| 309 | delete par;
|
---|
| 310 | it.remove();
|
---|
| 311 | }
|
---|
[2080] | 312 | }
|
---|
[2083] | 313 | if (! removed) {
|
---|
| 314 | ++iPar;
|
---|
| 315 | par->index = iPar;
|
---|
| 316 | }
|
---|
[2080] | 317 | }
|
---|
[2083] | 318 |
|
---|
| 319 | // Add new ambiguity parameters
|
---|
| 320 | // ----------------------------
|
---|
| 321 | QMapIterator<QString, t_satData*> itObs(epoData->satData);
|
---|
| 322 | while (itObs.hasNext()) {
|
---|
| 323 | itObs.next();
|
---|
| 324 | QString prn = itObs.key();
|
---|
| 325 | bool found = false;
|
---|
| 326 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 327 | if (_params[iPar-1]->type == bncParam::AMB_L3 &&
|
---|
| 328 | _params[iPar-1]->prn == prn) {
|
---|
| 329 | found = true;
|
---|
| 330 | break;
|
---|
| 331 | }
|
---|
[2080] | 332 | }
|
---|
[2083] | 333 | if (!found) {
|
---|
| 334 | bncParam* par = new bncParam(bncParam::AMB_L3, _params.size()+1, prn);
|
---|
| 335 | _params.push_back(par);
|
---|
| 336 | }
|
---|
[2080] | 337 | }
|
---|
[2083] | 338 |
|
---|
| 339 | int nPar = _params.size();
|
---|
| 340 | _QQ.ReSize(nPar); _QQ = 0.0;
|
---|
| 341 | for (int i1 = 1; i1 <= nPar; i1++) {
|
---|
| 342 | bncParam* p1 = _params[i1-1];
|
---|
| 343 | if (p1->index_old != 0) {
|
---|
| 344 | _QQ(p1->index, p1->index) = QQ_old(p1->index_old, p1->index_old);
|
---|
| 345 | for (int i2 = 1; i2 <= nPar; i2++) {
|
---|
| 346 | bncParam* p2 = _params[i2-1];
|
---|
| 347 | if (p2->index_old != 0) {
|
---|
| 348 | _QQ(p1->index, p2->index) = QQ_old(p1->index_old, p2->index_old);
|
---|
| 349 | }
|
---|
[2080] | 350 | }
|
---|
| 351 | }
|
---|
| 352 | }
|
---|
[2083] | 353 |
|
---|
| 354 | for (int ii = 1; ii <= nPar; ii++) {
|
---|
| 355 | bncParam* par = _params[ii-1];
|
---|
| 356 | if (par->index_old == 0) {
|
---|
| 357 | _QQ(par->index, par->index) = sig_amb_0 * sig_amb_0;
|
---|
| 358 | }
|
---|
| 359 | par->index_old = par->index;
|
---|
[2080] | 360 | }
|
---|
| 361 | }
|
---|
| 362 |
|
---|
[2076] | 363 | // Coordinates
|
---|
| 364 | // -----------
|
---|
| 365 | if (_static) {
|
---|
| 366 | if (x() == 0.0 && y() == 0.0 && z() == 0.0) {
|
---|
[2109] | 367 | _params[0]->xx = _xcBanc(1);
|
---|
| 368 | _params[1]->xx = _xcBanc(2);
|
---|
| 369 | _params[2]->xx = _xcBanc(3);
|
---|
[2076] | 370 | }
|
---|
| 371 | }
|
---|
| 372 | else {
|
---|
[2109] | 373 | _params[0]->xx = _xcBanc(1);
|
---|
| 374 | _params[1]->xx = _xcBanc(2);
|
---|
| 375 | _params[2]->xx = _xcBanc(3);
|
---|
[2073] | 376 |
|
---|
[2076] | 377 | _QQ(1,1) += sig_crd_p * sig_crd_p;
|
---|
| 378 | _QQ(2,2) += sig_crd_p * sig_crd_p;
|
---|
| 379 | _QQ(3,3) += sig_crd_p * sig_crd_p;
|
---|
| 380 | }
|
---|
[2073] | 381 |
|
---|
[2076] | 382 | // Receiver Clocks
|
---|
| 383 | // ---------------
|
---|
[2109] | 384 | _params[3]->xx = _xcBanc(4);
|
---|
[2073] | 385 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 386 | _QQ(iPar, 4) = 0.0;
|
---|
| 387 | }
|
---|
| 388 | _QQ(4,4) = sig_clk_0 * sig_clk_0;
|
---|
| 389 |
|
---|
[2084] | 390 | // Tropospheric Delay
|
---|
| 391 | // ------------------
|
---|
| 392 | if (_estTropo) {
|
---|
| 393 | _QQ(5,5) += sig_trp_p * sig_trp_p;
|
---|
| 394 | }
|
---|
[2073] | 395 | }
|
---|
| 396 |
|
---|
[2060] | 397 | // Update Step of the Filter (currently just a single-epoch solution)
|
---|
| 398 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 399 | t_irc bncModel::update(t_epoData* epoData) {
|
---|
| 400 |
|
---|
[2112] | 401 | SymmetricMatrix QQsav;
|
---|
[2109] | 402 | ColumnVector dx;
|
---|
[2112] | 403 | ColumnVector vv;
|
---|
[2073] | 404 |
|
---|
[2113] | 405 | // Loop over all outliers
|
---|
| 406 | // ----------------------
|
---|
[2108] | 407 | do {
|
---|
| 408 |
|
---|
| 409 | // Bancroft Solution
|
---|
| 410 | // -----------------
|
---|
| 411 | if (cmpBancroft(epoData) != success) {
|
---|
| 412 | return failure;
|
---|
| 413 | }
|
---|
[2080] | 414 |
|
---|
[2116] | 415 | if (epoData->size() < MINOBS) {
|
---|
| 416 | return failure;
|
---|
| 417 | }
|
---|
| 418 |
|
---|
[2108] | 419 | // Status Prediction
|
---|
| 420 | // -----------------
|
---|
| 421 | predict(epoData);
|
---|
| 422 |
|
---|
[2109] | 423 | // Create First-Design Matrix
|
---|
| 424 | // --------------------------
|
---|
[2108] | 425 | unsigned nPar = _params.size();
|
---|
| 426 | unsigned nObs = _usePhase ? 2 * epoData->size() : epoData->size();
|
---|
| 427 |
|
---|
| 428 | Matrix AA(nObs, nPar); // first design matrix
|
---|
| 429 | ColumnVector ll(nObs); // tems observed-computed
|
---|
| 430 | SymmetricMatrix PP(nObs); PP = 0.0;
|
---|
| 431 |
|
---|
| 432 | unsigned iObs = 0;
|
---|
| 433 | QMapIterator<QString, t_satData*> itObs(epoData->satData);
|
---|
| 434 | while (itObs.hasNext()) {
|
---|
[2083] | 435 | ++iObs;
|
---|
[2108] | 436 | itObs.next();
|
---|
| 437 | QString prn = itObs.key();
|
---|
| 438 | t_satData* satData = itObs.value();
|
---|
| 439 |
|
---|
| 440 | double rhoCmp = cmpValue(satData);
|
---|
| 441 |
|
---|
[2117] | 442 | double ellWgtCoeff = 1.0;
|
---|
[2118] | 443 | //// double eleD = satData->eleSat * 180.0 / M_PI;
|
---|
| 444 | //// if (eleD < 25.0) {
|
---|
| 445 | //// ellWgtCoeff = 2.5 - (eleD - 10.0) * 0.1;
|
---|
| 446 | //// ellWgtCoeff *= ellWgtCoeff;
|
---|
| 447 | //// }
|
---|
[2117] | 448 |
|
---|
[2108] | 449 | ll(iObs) = satData->P3 - rhoCmp;
|
---|
[2117] | 450 | PP(iObs,iObs) = 1.0 / (sig_P3 * sig_P3) / ellWgtCoeff;
|
---|
[2083] | 451 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
[2108] | 452 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, "");
|
---|
[2083] | 453 | }
|
---|
[2108] | 454 |
|
---|
| 455 | if (_usePhase) {
|
---|
| 456 | ++iObs;
|
---|
| 457 | ll(iObs) = satData->L3 - rhoCmp;
|
---|
[2117] | 458 | PP(iObs,iObs) = 1.0 / (sig_L3 * sig_L3) / ellWgtCoeff;
|
---|
[2108] | 459 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 460 | if (_params[iPar-1]->type == bncParam::AMB_L3 &&
|
---|
| 461 | _params[iPar-1]->prn == prn) {
|
---|
[2109] | 462 | ll(iObs) -= _params[iPar-1]->xx;
|
---|
[2108] | 463 | }
|
---|
| 464 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, prn);
|
---|
| 465 | }
|
---|
| 466 | }
|
---|
[2080] | 467 | }
|
---|
[2108] | 468 |
|
---|
[2112] | 469 | // Compute Filter Update
|
---|
[2108] | 470 | // ---------------------
|
---|
[2112] | 471 | QQsav = _QQ;
|
---|
| 472 |
|
---|
| 473 | Matrix ATP = AA.t() * PP;
|
---|
[2109] | 474 | SymmetricMatrix NN = _QQ.i();
|
---|
[2112] | 475 | NN << NN + ATP * AA;
|
---|
| 476 | _QQ = NN.i();
|
---|
| 477 | dx = _QQ * ATP * ll;
|
---|
| 478 | vv = ll - AA * dx;
|
---|
[2060] | 479 |
|
---|
[2112] | 480 | } while (outlierDetection(QQsav, vv, epoData->satData) != 0);
|
---|
[2111] | 481 |
|
---|
[2109] | 482 | // Set Solution Vector
|
---|
| 483 | // -------------------
|
---|
[2073] | 484 | QVectorIterator<bncParam*> itPar(_params);
|
---|
[2060] | 485 | while (itPar.hasNext()) {
|
---|
| 486 | bncParam* par = itPar.next();
|
---|
[2109] | 487 | par->xx += dx(par->index);
|
---|
[2060] | 488 | }
|
---|
| 489 |
|
---|
[2113] | 490 | // Message (both log file and screen)
|
---|
| 491 | // ----------------------------------
|
---|
| 492 | ostringstream str;
|
---|
| 493 | str.setf(ios::fixed);
|
---|
| 494 | str << " PPP " << _staID.data() << " "
|
---|
| 495 | << epoData->tt.timestr(1) << " " << epoData->size() << " "
|
---|
[2114] | 496 | << setw(14) << setprecision(3) << x() << " +- "
|
---|
| 497 | << setw(6) << setprecision(3) << sqrt(_QQ(1,1)) << " "
|
---|
| 498 | << setw(14) << setprecision(3) << y() << " +- "
|
---|
| 499 | << setw(6) << setprecision(3) << sqrt(_QQ(2,2)) << " "
|
---|
| 500 | << setw(14) << setprecision(3) << z() << " +- "
|
---|
| 501 | << setw(6) << setprecision(3) << sqrt(_QQ(3,3));
|
---|
| 502 | if (_estTropo) {
|
---|
[2115] | 503 | str << " " << setw(6) << setprecision(3) << trp() << " +- "
|
---|
[2114] | 504 | << setw(6) << setprecision(3) << sqrt(_QQ(5,5));
|
---|
| 505 | }
|
---|
[2113] | 506 |
|
---|
| 507 | emit newMessage(QString(str.str().c_str()).toAscii(), true);
|
---|
| 508 |
|
---|
[2060] | 509 | return success;
|
---|
| 510 | }
|
---|
[2112] | 511 |
|
---|
| 512 | // Outlier Detection
|
---|
| 513 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 514 | int bncModel::outlierDetection(const SymmetricMatrix& QQsav,
|
---|
| 515 | const ColumnVector& vv,
|
---|
| 516 | QMap<QString, t_satData*>& satData) {
|
---|
| 517 |
|
---|
| 518 | double vvMaxCode = 0.0;
|
---|
| 519 | double vvMaxPhase = 0.0;
|
---|
| 520 | QMutableMapIterator<QString, t_satData*> itMaxCode(satData);
|
---|
| 521 | QMutableMapIterator<QString, t_satData*> itMaxPhase(satData);
|
---|
| 522 |
|
---|
| 523 | int ii = 0;
|
---|
| 524 | QMutableMapIterator<QString, t_satData*> it(satData);
|
---|
| 525 | while (it.hasNext()) {
|
---|
| 526 | it.next();
|
---|
| 527 | ++ii;
|
---|
| 528 |
|
---|
| 529 | if (vvMaxCode == 0.0 || fabs(vv(ii)) > vvMaxCode) {
|
---|
| 530 | vvMaxCode = fabs(vv(ii));
|
---|
| 531 | itMaxCode = it;
|
---|
| 532 | }
|
---|
| 533 |
|
---|
| 534 | if (_usePhase) {
|
---|
| 535 | ++ii;
|
---|
| 536 | if (vvMaxPhase == 0.0 || fabs(vv(ii)) > vvMaxPhase) {
|
---|
| 537 | vvMaxPhase = fabs(vv(ii));
|
---|
| 538 | itMaxPhase = it;
|
---|
| 539 | }
|
---|
| 540 | }
|
---|
| 541 | }
|
---|
| 542 |
|
---|
| 543 | if (vvMaxCode > MAXRES_CODE) {
|
---|
| 544 | QString prn = itMaxCode.key();
|
---|
| 545 | t_satData* satData = itMaxCode.value();
|
---|
| 546 | delete satData;
|
---|
| 547 | itMaxCode.remove();
|
---|
| 548 | _QQ = QQsav;
|
---|
[2114] | 549 |
|
---|
| 550 | QByteArray msg = "Outlier Code " + prn.toAscii() + " "
|
---|
| 551 | + QByteArray::number(vvMaxCode, 'f', 3);
|
---|
| 552 | emit newMessage(msg, true);
|
---|
| 553 |
|
---|
[2112] | 554 | return 1;
|
---|
| 555 | }
|
---|
| 556 | else if (vvMaxPhase > MAXRES_PHASE) {
|
---|
| 557 | QString prn = itMaxPhase.key();
|
---|
| 558 | t_satData* satData = itMaxPhase.value();
|
---|
| 559 | delete satData;
|
---|
| 560 | itMaxPhase.remove();
|
---|
| 561 | _QQ = QQsav;
|
---|
[2114] | 562 |
|
---|
| 563 | QByteArray msg = "Outlier Phase " + prn.toAscii() + " "
|
---|
| 564 | + QByteArray::number(vvMaxPhase, 'f', 3);
|
---|
| 565 | emit newMessage(msg, true);
|
---|
| 566 |
|
---|
[2112] | 567 | return 1;
|
---|
| 568 | }
|
---|
| 569 |
|
---|
| 570 | return 0;
|
---|
| 571 | }
|
---|