source: ntrip/trunk/BNC/bncmodel.cpp@ 3005

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