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

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