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

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