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

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