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