source: ntrip/branches/BNC_2.12/src/PPP_SSR_I/pppFilter.cpp@ 9281

Last change on this file since 9281 was 9281, checked in by stuerze, 3 years ago

small bug fixes

  • Property svn:keywords set to Author Date Id Rev URL;svn:eol-style=native
  • Property svn:mime-type set to text/plain
File size: 38.8 KB
RevLine 
[7235]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: t_pppParam, t_pppFilter
30 *
31 * Purpose: Model for PPP
32 *
33 * Author: L. Mervart
34 *
35 * Created: 01-Dec-2009
36 *
[7287]37 * Changes:
[7235]38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iomanip>
42#include <cmath>
43#include <sstream>
44#include <newmatio.h>
45#include <newmatap.h>
46
47#include "pppFilter.h"
48#include "pppClient.h"
49#include "bncutils.h"
50#include "bncantex.h"
51#include "pppOptions.h"
52#include "pppModel.h"
53
54using namespace BNC_PPP;
55using namespace std;
56
57const double MAXRES_CODE = 2.98 * 3.0;
[7960]58const double MAXRES_PHASE_GPS = 0.04;
[7235]59const double MAXRES_PHASE_GLONASS = 2.98 * 0.03;
[7953]60const double GLONASS_WEIGHT_FACTOR = 5.0;
[9086]61const double BDS_WEIGHT_FACTOR = 5.0;
[7235]62
63#define LOG (_pppClient->log())
64#define OPT (_pppClient->opt())
65
66// Constructor
67////////////////////////////////////////////////////////////////////////////
[7287]68t_pppParam::t_pppParam(t_pppParam::parType typeIn, int indexIn,
[7235]69 const QString& prnIn) {
70 type = typeIn;
71 index = indexIn;
72 prn = prnIn;
73 index_old = 0;
74 xx = 0.0;
75 numEpo = 0;
76}
77
78// Destructor
79////////////////////////////////////////////////////////////////////////////
80t_pppParam::~t_pppParam() {
81}
82
83// Partial
84////////////////////////////////////////////////////////////////////////////
85double t_pppParam::partial(t_satData* satData, bool phase) {
86
87 Tracer tracer("t_pppParam::partial");
88
89 // Coordinates
90 // -----------
91 if (type == CRD_X) {
[7287]92 return (xx - satData->xx(1)) / satData->rho;
[7235]93 }
94 else if (type == CRD_Y) {
[7287]95 return (xx - satData->xx(2)) / satData->rho;
[7235]96 }
97 else if (type == CRD_Z) {
[7287]98 return (xx - satData->xx(3)) / satData->rho;
[7235]99 }
100
101 // Receiver Clocks
102 // ---------------
103 else if (type == RECCLK) {
104 return 1.0;
105 }
106
107 // Troposphere
108 // -----------
109 else if (type == TROPO) {
[7287]110 return 1.0 / sin(satData->eleSat);
[7235]111 }
112
113 // Glonass Offset
114 // --------------
115 else if (type == GLONASS_OFFSET) {
116 if (satData->prn[0] == 'R') {
117 return 1.0;
118 }
119 else {
120 return 0.0;
121 }
122 }
123
124 // Galileo Offset
125 // --------------
126 else if (type == GALILEO_OFFSET) {
127 if (satData->prn[0] == 'E') {
128 return 1.0;
129 }
130 else {
131 return 0.0;
132 }
133 }
134
135 // BDS Offset
136 // ----------
137 else if (type == BDS_OFFSET) {
138 if (satData->prn[0] == 'C') {
139 return 1.0;
140 }
141 else {
142 return 0.0;
143 }
144 }
145
146 // Ambiguities
147 // -----------
148 else if (type == AMB_L3) {
149 if (phase && satData->prn == prn) {
150 return 1.0;
151 }
152 else {
153 return 0.0;
154 }
155 }
156
157 // Default return
158 // --------------
159 return 0.0;
160}
161
162// Constructor
163////////////////////////////////////////////////////////////////////////////
164t_pppFilter::t_pppFilter(t_pppClient* pppClient) {
165
166 _pppClient = pppClient;
167 _tides = new t_tides();
168
169 // Antenna Name, ANTEX File
170 // ------------------------
171 _antex = 0;
172 if (!OPT->_antexFileName.empty()) {
173 _antex = new bncAntex(OPT->_antexFileName.c_str());
174 }
175
176 // Bancroft Coordinates
177 // --------------------
178 _xcBanc.ReSize(4); _xcBanc = 0.0;
179 _ellBanc.ReSize(3); _ellBanc = 0.0;
180
181 // Save copy of data (used in outlier detection)
182 // ---------------------------------------------
183 _epoData_sav = new t_epoData();
184
185 // Some statistics
186 // ---------------
187 _neu.ReSize(3); _neu = 0.0;
188 _numSat = 0;
[7933]189 _hDop = 0.0;
[7235]190}
191
192// Destructor
193////////////////////////////////////////////////////////////////////////////
194t_pppFilter::~t_pppFilter() {
195 delete _tides;
196 delete _antex;
197 for (int iPar = 1; iPar <= _params.size(); iPar++) {
198 delete _params[iPar-1];
199 }
200 for (int iPar = 1; iPar <= _params_sav.size(); iPar++) {
201 delete _params_sav[iPar-1];
202 }
203 delete _epoData_sav;
204}
205
206// Reset Parameters and Variance-Covariance Matrix
207////////////////////////////////////////////////////////////////////////////
208void t_pppFilter::reset() {
209
210 Tracer tracer("t_pppFilter::reset");
211
212 double lastTrp = 0.0;
213 for (int ii = 0; ii < _params.size(); ii++) {
214 t_pppParam* pp = _params[ii];
215 if (pp->type == t_pppParam::TROPO) {
216 lastTrp = pp->xx;
217 }
218 delete pp;
219 }
220 _params.clear();
221
222 int nextPar = 0;
223 _params.push_back(new t_pppParam(t_pppParam::CRD_X, ++nextPar, ""));
224 _params.push_back(new t_pppParam(t_pppParam::CRD_Y, ++nextPar, ""));
225 _params.push_back(new t_pppParam(t_pppParam::CRD_Z, ++nextPar, ""));
226 _params.push_back(new t_pppParam(t_pppParam::RECCLK, ++nextPar, ""));
227 if (OPT->estTrp()) {
228 _params.push_back(new t_pppParam(t_pppParam::TROPO, ++nextPar, ""));
229 }
230 if (OPT->useSystem('R')) {
231 _params.push_back(new t_pppParam(t_pppParam::GLONASS_OFFSET, ++nextPar, ""));
232 }
233 if (OPT->useSystem('E')) {
234 _params.push_back(new t_pppParam(t_pppParam::GALILEO_OFFSET, ++nextPar, ""));
235 }
236 if (OPT->useSystem('C')) {
237 _params.push_back(new t_pppParam(t_pppParam::BDS_OFFSET, ++nextPar, ""));
238 }
239
[7287]240 _QQ.ReSize(_params.size());
[7235]241 _QQ = 0.0;
242 for (int iPar = 1; iPar <= _params.size(); iPar++) {
243 t_pppParam* pp = _params[iPar-1];
244 pp->xx = 0.0;
245 if (pp->isCrd()) {
[7287]246 _QQ(iPar,iPar) = OPT->_aprSigCrd(1) * OPT->_aprSigCrd(1);
[7235]247 }
248 else if (pp->type == t_pppParam::RECCLK) {
[7287]249 _QQ(iPar,iPar) = OPT->_noiseClk * OPT->_noiseClk;
[7235]250 }
251 else if (pp->type == t_pppParam::TROPO) {
[7287]252 _QQ(iPar,iPar) = OPT->_aprSigTrp * OPT->_aprSigTrp;
[7235]253 pp->xx = lastTrp;
254 }
255 else if (pp->type == t_pppParam::GLONASS_OFFSET) {
256 _QQ(iPar,iPar) = 1000.0 * 1000.0;
257 }
258 else if (pp->type == t_pppParam::GALILEO_OFFSET) {
259 _QQ(iPar,iPar) = 1000.0 * 1000.0;
260 }
261 else if (pp->type == t_pppParam::BDS_OFFSET) {
262 _QQ(iPar,iPar) = 1000.0 * 1000.0;
263 }
264 }
265}
266
267// Bancroft Solution
268////////////////////////////////////////////////////////////////////////////
269t_irc t_pppFilter::cmpBancroft(t_epoData* epoData) {
270
271 Tracer tracer("t_pppFilter::cmpBancroft");
272
273 if (int(epoData->sizeSys('G')) < OPT->_minObs) {
274 LOG << "t_pppFilter::cmpBancroft: not enough data\n";
275 return failure;
276 }
277
278 Matrix BB(epoData->sizeSys('G'), 4);
279
280 QMapIterator<QString, t_satData*> it(epoData->satData);
281 int iObsBanc = 0;
282 while (it.hasNext()) {
283 it.next();
284 t_satData* satData = it.value();
285 if (satData->system() == 'G') {
286 ++iObsBanc;
287 QString prn = it.key();
288 BB(iObsBanc, 1) = satData->xx(1);
289 BB(iObsBanc, 2) = satData->xx(2);
290 BB(iObsBanc, 3) = satData->xx(3);
291 BB(iObsBanc, 4) = satData->P3 + satData->clk;
292 }
293 }
294
295 bancroft(BB, _xcBanc);
296
[8452]297 if (std::isnan(_xcBanc(1)) ||
298 std::isnan(_xcBanc(2)) ||
299 std::isnan(_xcBanc(3))) {
[7852]300 return failure;
301 }
302
[7235]303 // Ellipsoidal Coordinates
304 // ------------------------
305 xyz2ell(_xcBanc.data(), _ellBanc.data());
306
307 // Compute Satellite Elevations
308 // ----------------------------
309 QMutableMapIterator<QString, t_satData*> im(epoData->satData);
310 while (im.hasNext()) {
311 im.next();
312 t_satData* satData = im.value();
313 cmpEle(satData);
314 if (satData->eleSat < OPT->_minEle) {
315 delete satData;
316 im.remove();
317 }
318 }
319
320 return success;
321}
322
323// Computed Value
324////////////////////////////////////////////////////////////////////////////
325double t_pppFilter::cmpValue(t_satData* satData, bool phase) {
326
327 Tracer tracer("t_pppFilter::cmpValue");
328
329 ColumnVector xRec(3);
330 xRec(1) = x();
331 xRec(2) = y();
332 xRec(3) = z();
333
334 double rho0 = (satData->xx - xRec).norm_Frobenius();
[7287]335 double dPhi = t_CST::omega * rho0 / t_CST::c;
[7235]336
[7287]337 xRec(1) = x() * cos(dPhi) - y() * sin(dPhi);
338 xRec(2) = y() * cos(dPhi) + x() * sin(dPhi);
[7235]339 xRec(3) = z();
340
341 xRec += _tides->displacement(_time, xRec);
342
343 satData->rho = (satData->xx - xRec).norm_Frobenius();
344
[7287]345 double tropDelay = delay_saast(satData->eleSat) +
[7235]346 trp() / sin(satData->eleSat);
347
348 double wind = 0.0;
349 if (phase) {
350 wind = windUp(satData->prn, satData->xx, xRec) * satData->lambda3;
351 }
352
353 double offset = 0.0;
354 t_frequency::type frqA = t_frequency::G1;
355 t_frequency::type frqB = t_frequency::G2;
356 if (satData->prn[0] == 'R') {
357 offset = Glonass_offset();
358 frqA = t_frequency::R1;
359 frqB = t_frequency::R2;
360 }
361 else if (satData->prn[0] == 'E') {
362 offset = Galileo_offset();
[9043]363 frqA = t_frequency::E1;
364 frqB = t_frequency::E5;
[7235]365 }
366 else if (satData->prn[0] == 'C') {
367 offset = Bds_offset();
[9043]368 frqA = t_frequency::C2;
369 frqB = t_frequency::C7;
[7235]370 }
371 double phaseCenter = 0.0;
[7287]372 if (_antex) {
[7235]373 bool found;
374 phaseCenter = satData->lkA * _antex->rcvCorr(OPT->_antNameRover, frqA,
375 satData->eleSat, satData->azSat,
376 found)
377 + satData->lkB * _antex->rcvCorr(OPT->_antNameRover, frqB,
378 satData->eleSat, satData->azSat,
379 found);
380 if (!found) {
381 LOG << "ANTEX: antenna >" << OPT->_antNameRover << "< not found\n";
382 }
383 }
384
385 double antennaOffset = 0.0;
386 double cosa = cos(satData->azSat);
387 double sina = sin(satData->azSat);
388 double cose = cos(satData->eleSat);
389 double sine = sin(satData->eleSat);
[7287]390 antennaOffset = -OPT->_neuEccRover(1) * cosa*cose
391 -OPT->_neuEccRover(2) * sina*cose
[7235]392 -OPT->_neuEccRover(3) * sine;
393
[7287]394 return satData->rho + phaseCenter + antennaOffset + clk()
[7235]395 + offset - satData->clk + tropDelay + wind;
396}
397
398// Tropospheric Model (Saastamoinen)
399////////////////////////////////////////////////////////////////////////////
400double t_pppFilter::delay_saast(double Ele) {
401
402 Tracer tracer("t_pppFilter::delay_saast");
403
[7287]404 double xyz[3];
[7235]405 xyz[0] = x();
406 xyz[1] = y();
407 xyz[2] = z();
[7287]408 double ell[3];
[7235]409 xyz2ell(xyz, ell);
410 double height = ell[2];
[9281]411 // Prevent pp from causing segmentation fault (Loukis)
412 if (height > 40000.0 ) {
413 return 0.000000001;
414 }
[7235]415
416 double pp = 1013.25 * pow(1.0 - 2.26e-5 * height, 5.225);
417 double TT = 18.0 - height * 0.0065 + 273.15;
418 double hh = 50.0 * exp(-6.396e-4 * height);
419 double ee = hh / 100.0 * exp(-37.2465 + 0.213166*TT - 0.000256908*TT*TT);
420
421 double h_km = height / 1000.0;
[7287]422
[7235]423 if (h_km < 0.0) h_km = 0.0;
424 if (h_km > 5.0) h_km = 5.0;
425 int ii = int(h_km + 1);
426 double href = ii - 1;
[7287]427
428 double bCor[6];
[7235]429 bCor[0] = 1.156;
430 bCor[1] = 1.006;
431 bCor[2] = 0.874;
432 bCor[3] = 0.757;
433 bCor[4] = 0.654;
434 bCor[5] = 0.563;
[7287]435
[7235]436 double BB = bCor[ii-1] + (bCor[ii]-bCor[ii-1]) * (h_km - href);
[7287]437
[7235]438 double zen = M_PI/2.0 - Ele;
439
440 return (0.002277/cos(zen)) * (pp + ((1255.0/TT)+0.05)*ee - BB*(tan(zen)*tan(zen)));
441}
442
443// Prediction Step of the Filter
444////////////////////////////////////////////////////////////////////////////
445void t_pppFilter::predict(int iPhase, t_epoData* epoData) {
446
447 Tracer tracer("t_pppFilter::predict");
448
449 if (iPhase == 0) {
450
451 const double maxSolGap = 60.0;
452
453 bool firstCrd = false;
454 if (!_lastTimeOK.valid() || (maxSolGap > 0.0 && _time - _lastTimeOK > maxSolGap)) {
455 firstCrd = true;
456 _startTime = epoData->tt;
457 reset();
458 }
[7287]459
[7235]460 // Use different white noise for Quick-Start mode
461 // ----------------------------------------------
462 double sigCrdP_used = OPT->_noiseCrd(1);
463 if ( OPT->_seedingTime > 0.0 && OPT->_seedingTime > (epoData->tt - _startTime) ) {
464 sigCrdP_used = 0.0;
465 }
466
467 // Predict Parameter values, add white noise
468 // -----------------------------------------
469 for (int iPar = 1; iPar <= _params.size(); iPar++) {
470 t_pppParam* pp = _params[iPar-1];
[7287]471
[7235]472 // Coordinates
473 // -----------
474 if (pp->type == t_pppParam::CRD_X) {
475 if (firstCrd) {
476 if (OPT->xyzAprRoverSet()) {
477 pp->xx = OPT->_xyzAprRover[0];
478 }
479 else {
480 pp->xx = _xcBanc(1);
481 }
482 }
483 _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
484 }
485 else if (pp->type == t_pppParam::CRD_Y) {
486 if (firstCrd) {
487 if (OPT->xyzAprRoverSet()) {
488 pp->xx = OPT->_xyzAprRover[1];
489 }
490 else {
491 pp->xx = _xcBanc(2);
492 }
493 }
494 _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
495 }
496 else if (pp->type == t_pppParam::CRD_Z) {
497 if (firstCrd) {
498 if (OPT->xyzAprRoverSet()) {
499 pp->xx = OPT->_xyzAprRover[2];
500 }
501 else {
502 pp->xx = _xcBanc(3);
503 }
504 }
505 _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
[7287]506 }
507
[7235]508 // Receiver Clocks
509 // ---------------
510 else if (pp->type == t_pppParam::RECCLK) {
511 pp->xx = _xcBanc(4);
512 for (int jj = 1; jj <= _params.size(); jj++) {
513 _QQ(iPar, jj) = 0.0;
514 }
515 _QQ(iPar,iPar) = OPT->_noiseClk * OPT->_noiseClk;
516 }
[7287]517
[7235]518 // Tropospheric Delay
519 // ------------------
520 else if (pp->type == t_pppParam::TROPO) {
521 _QQ(iPar,iPar) += OPT->_noiseTrp * OPT->_noiseTrp;
522 }
[7287]523
[7235]524 // Glonass Offset
525 // --------------
526 else if (pp->type == t_pppParam::GLONASS_OFFSET) {
527 pp->xx = 0.0;
528 for (int jj = 1; jj <= _params.size(); jj++) {
529 _QQ(iPar, jj) = 0.0;
530 }
531 _QQ(iPar,iPar) = 1000.0 * 1000.0;
532 }
533
534 // Galileo Offset
535 // --------------
536 else if (pp->type == t_pppParam::GALILEO_OFFSET) {
537 _QQ(iPar,iPar) += 0.1 * 0.1;
538 }
539
540 // BDS Offset
541 // ----------
542 else if (pp->type == t_pppParam::BDS_OFFSET) {
[7287]543 _QQ(iPar,iPar) += 0.1 * 0.1; //TODO: TEST
[7235]544 }
545 }
546 }
547
548 // Add New Ambiguities if necessary
549 // --------------------------------
550 if (OPT->ambLCs('G').size() || OPT->ambLCs('R').size() ||
551 OPT->ambLCs('E').size() || OPT->ambLCs('C').size()) {
552
553 // Make a copy of QQ and xx, set parameter indices
554 // -----------------------------------------------
555 SymmetricMatrix QQ_old = _QQ;
[7287]556
[7235]557 for (int iPar = 1; iPar <= _params.size(); iPar++) {
558 _params[iPar-1]->index_old = _params[iPar-1]->index;
559 _params[iPar-1]->index = 0;
560 }
[7287]561
[7235]562 // Remove Ambiguity Parameters without observations
563 // ------------------------------------------------
564 int iPar = 0;
565 QMutableVectorIterator<t_pppParam*> im(_params);
566 while (im.hasNext()) {
567 t_pppParam* par = im.next();
568 bool removed = false;
569 if (par->type == t_pppParam::AMB_L3) {
570 if (epoData->satData.find(par->prn) == epoData->satData.end()) {
571 removed = true;
572 delete par;
573 im.remove();
574 }
575 }
576 if (! removed) {
577 ++iPar;
578 par->index = iPar;
579 }
580 }
[7287]581
[7235]582 // Add new ambiguity parameters
583 // ----------------------------
584 QMapIterator<QString, t_satData*> it(epoData->satData);
585 while (it.hasNext()) {
586 it.next();
587 t_satData* satData = it.value();
588 addAmb(satData);
589 }
[7287]590
[7235]591 int nPar = _params.size();
592 _QQ.ReSize(nPar); _QQ = 0.0;
593 for (int i1 = 1; i1 <= nPar; i1++) {
594 t_pppParam* 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 t_pppParam* 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 }
602 }
603 }
604 }
[7287]605
[7235]606 for (int ii = 1; ii <= nPar; ii++) {
607 t_pppParam* par = _params[ii-1];
608 if (par->index_old == 0) {
609 _QQ(par->index, par->index) = OPT->_aprSigAmb * OPT->_aprSigAmb;
610 }
611 par->index_old = par->index;
612 }
613 }
614}
615
616// Update Step of the Filter (currently just a single-epoch solution)
617////////////////////////////////////////////////////////////////////////////
618t_irc t_pppFilter::update(t_epoData* epoData) {
619
620 Tracer tracer("t_pppFilter::update");
621
622 _time = epoData->tt; // current epoch time
623
624 if (OPT->useOrbClkCorr()) {
[7536]625 LOG << "Precise Point Positioning of Epoch " << _time.datestr() << "_" << _time.timestr(3)
[7235]626 << "\n---------------------------------------------------------------\n";
627 }
628 else {
[7536]629 LOG << "Single Point Positioning of Epoch " << _time.datestr() << "_" << _time.timestr(3)
630 << "\n---------------------------------------------------------------\n";
[7235]631 }
632
633 // Outlier Detection Loop
634 // ----------------------
635 if (update_p(epoData) != success) {
636 return failure;
637 }
638
639 // Set Solution Vector
640 // -------------------
641 LOG.setf(ios::fixed);
642 QVectorIterator<t_pppParam*> itPar(_params);
643 while (itPar.hasNext()) {
644 t_pppParam* par = itPar.next();
645 if (par->type == t_pppParam::RECCLK) {
[7536]646 LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
647 << " CLK " << setw(10) << setprecision(3) << par->xx
[7287]648 << " +- " << setw(6) << setprecision(3)
[7235]649 << sqrt(_QQ(par->index,par->index));
650 }
651 else if (par->type == t_pppParam::AMB_L3) {
652 ++par->numEpo;
[7536]653 LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
654 << " AMB " << par->prn.mid(0,3).toAscii().data() << " "
[7287]655 << setw(10) << setprecision(3) << par->xx
656 << " +- " << setw(6) << setprecision(3)
[7235]657 << sqrt(_QQ(par->index,par->index))
[7544]658 << " epo = " << par->numEpo;
[7235]659 }
660 else if (par->type == t_pppParam::TROPO) {
661 double aprTrp = delay_saast(M_PI/2.0);
[7536]662 LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
663 << " TRP " << par->prn.mid(0,3).toAscii().data()
[7235]664 << setw(7) << setprecision(3) << aprTrp << " "
665 << setw(6) << setprecision(3) << showpos << par->xx << noshowpos
[7287]666 << " +- " << setw(6) << setprecision(3)
[7235]667 << sqrt(_QQ(par->index,par->index));
668 }
669 else if (par->type == t_pppParam::GLONASS_OFFSET) {
[7536]670 LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
671 << " OFFGLO " << setw(10) << setprecision(3) << par->xx
[7287]672 << " +- " << setw(6) << setprecision(3)
[7235]673 << sqrt(_QQ(par->index,par->index));
674 }
675 else if (par->type == t_pppParam::GALILEO_OFFSET) {
[7536]676 LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
677 << " OFFGAL " << setw(10) << setprecision(3) << par->xx
[7287]678 << " +- " << setw(6) << setprecision(3)
[7235]679 << sqrt(_QQ(par->index,par->index));
680 }
681 else if (par->type == t_pppParam::BDS_OFFSET) {
[7536]682 LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
683 << " OFFBDS " << setw(10) << setprecision(3) << par->xx
[7235]684 << " +- " << setw(6) << setprecision(3)
685 << sqrt(_QQ(par->index,par->index));
686 }
687 }
688
689 LOG << endl << endl;
690
691 // Compute dilution of precision
692 // -----------------------------
693 cmpDOP(epoData);
694
695 // Final Message (both log file and screen)
696 // ----------------------------------------
[7544]697 LOG << epoData->tt.datestr() << "_" << epoData->tt.timestr(3)
698 << " " << OPT->_roverName
699 << " X = "
700 << setprecision(4) << x() << " +- "
701 << setprecision(4) << sqrt(_QQ(1,1))
[7235]702
[7544]703 << " Y = "
704 << setprecision(4) << y() << " +- "
705 << setprecision(4) << sqrt(_QQ(2,2))
706
707 << " Z = "
708 << setprecision(4) << z() << " +- "
709 << setprecision(4) << sqrt(_QQ(3,3));
710
[7235]711 // NEU Output
712 // ----------
713 if (OPT->xyzAprRoverSet()) {
[7544]714 SymmetricMatrix QQxyz = _QQ.SymSubMatrix(1,3);
[7235]715
[7544]716 ColumnVector xyz(3);
717 xyz(1) = x() - OPT->_xyzAprRover[0];
718 xyz(2) = y() - OPT->_xyzAprRover[1];
719 xyz(3) = z() - OPT->_xyzAprRover[2];
[7235]720
[7544]721 ColumnVector ellRef(3);
722 xyz2ell(OPT->_xyzAprRover.data(), ellRef.data());
723 xyz2neu(ellRef.data(), xyz.data(), _neu.data());
724
725 SymmetricMatrix QQneu(3);
726 covariXYZ_NEU(QQxyz, ellRef.data(), QQneu);
727
728 LOG << " dN = "
729 << setprecision(4) << _neu[0] << " +- "
730 << setprecision(4) << sqrt(QQneu[0][0])
731
732 << " dE = "
733 << setprecision(4) << _neu[1] << " +- "
734 << setprecision(4) << sqrt(QQneu[1][1])
735
736 << " dU = "
737 << setprecision(4) << _neu[2] << " +- "
738 << setprecision(4) << sqrt(QQneu[2][2]) << endl << endl;
[7235]739 }
740 else {
741 LOG << endl << endl;
742 }
743
744 _lastTimeOK = _time; // remember time of last successful update
745 return success;
746}
747
748// Outlier Detection
749////////////////////////////////////////////////////////////////////////////
750QString t_pppFilter::outlierDetection(int iPhase, const ColumnVector& vv,
[7960]751 QMap<QString, t_satData*>& satData) {
[7235]752
753 Tracer tracer("t_pppFilter::outlierDetection");
754
755 QString prnGPS;
756 QString prnGlo;
[7287]757 double maxResGPS = 0.0; // GPS + Galileo
758 double maxResGlo = 0.0; // GLONASS + BDS
[7235]759 findMaxRes(vv, satData, prnGPS, prnGlo, maxResGPS, maxResGlo);
760
761 if (iPhase == 1) {
[7287]762 if (maxResGlo > 2.98 * OPT->_maxResL1) {
[7235]763 LOG << "Outlier Phase " << prnGlo.mid(0,3).toAscii().data() << ' ' << maxResGlo << endl;
764 return prnGlo;
765 }
[7960]766 else if (maxResGPS > MAXRES_PHASE_GPS) {
[7235]767 LOG << "Outlier Phase " << prnGPS.mid(0,3).toAscii().data() << ' ' << maxResGPS << endl;
768 return prnGPS;
769 }
770 }
771 else if (iPhase == 0 && maxResGPS > 2.98 * OPT->_maxResC1) {
772 LOG << "Outlier Code " << prnGPS.mid(0,3).toAscii().data() << ' ' << maxResGPS << endl;
773 return prnGPS;
774 }
775
776 return QString();
777}
778
779// Phase Wind-Up Correction
780///////////////////////////////////////////////////////////////////////////
781double t_pppFilter::windUp(const QString& prn, const ColumnVector& rSat,
782 const ColumnVector& rRec) {
783
784 Tracer tracer("t_pppFilter::windUp");
785
786 double Mjd = _time.mjd() + _time.daysec() / 86400.0;
787
788 // First time - initialize to zero
789 // -------------------------------
790 if (!_windUpTime.contains(prn)) {
791 _windUpSum[prn] = 0.0;
792 }
793
794 // Compute the correction for new time
795 // -----------------------------------
796 if (!_windUpTime.contains(prn) || _windUpTime[prn] != Mjd) {
[7287]797 _windUpTime[prn] = Mjd;
[7235]798
799 // Unit Vector GPS Satellite --> Receiver
800 // --------------------------------------
801 ColumnVector rho = rRec - rSat;
802 rho /= rho.norm_Frobenius();
[7287]803
[7235]804 // GPS Satellite unit Vectors sz, sy, sx
805 // -------------------------------------
806 ColumnVector sz = -rSat / rSat.norm_Frobenius();
807
808 ColumnVector xSun = t_astro::Sun(Mjd);
809 xSun /= xSun.norm_Frobenius();
810
811 ColumnVector sy = crossproduct(sz, xSun);
812 ColumnVector sx = crossproduct(sy, sz);
813
814 // Effective Dipole of the GPS Satellite Antenna
815 // ---------------------------------------------
[7287]816 ColumnVector dipSat = sx - rho * DotProduct(rho,sx)
[7235]817 - crossproduct(rho, sy);
[7287]818
[7235]819 // Receiver unit Vectors rx, ry
820 // ----------------------------
821 ColumnVector rx(3);
822 ColumnVector ry(3);
823
824 double recEll[3]; xyz2ell(rRec.data(), recEll) ;
825 double neu[3];
[7287]826
[7235]827 neu[0] = 1.0;
828 neu[1] = 0.0;
829 neu[2] = 0.0;
830 neu2xyz(recEll, neu, rx.data());
[7287]831
[7235]832 neu[0] = 0.0;
833 neu[1] = -1.0;
834 neu[2] = 0.0;
835 neu2xyz(recEll, neu, ry.data());
[7287]836
[7235]837 // Effective Dipole of the Receiver Antenna
838 // ----------------------------------------
[7287]839 ColumnVector dipRec = rx - rho * DotProduct(rho,rx)
[7235]840 + crossproduct(rho, ry);
[7287]841
[7235]842 // Resulting Effect
843 // ----------------
[7287]844 double alpha = DotProduct(dipSat,dipRec) /
[7235]845 (dipSat.norm_Frobenius() * dipRec.norm_Frobenius());
[7287]846
[7235]847 if (alpha > 1.0) alpha = 1.0;
848 if (alpha < -1.0) alpha = -1.0;
[7287]849
[7235]850 double dphi = acos(alpha) / 2.0 / M_PI; // in cycles
[7287]851
[7235]852 if ( DotProduct(rho, crossproduct(dipSat, dipRec)) < 0.0 ) {
853 dphi = -dphi;
854 }
855
856 _windUpSum[prn] = floor(_windUpSum[prn] - dphi + 0.5) + dphi;
857 }
858
[7287]859 return _windUpSum[prn];
[7235]860}
861
[7287]862//
[7235]863///////////////////////////////////////////////////////////////////////////
864void t_pppFilter::cmpEle(t_satData* satData) {
865 Tracer tracer("t_pppFilter::cmpEle");
866 ColumnVector rr = satData->xx - _xcBanc.Rows(1,3);
867 double rho = rr.norm_Frobenius();
868
869 double neu[3];
870 xyz2neu(_ellBanc.data(), rr.data(), neu);
871
872 satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
873 if (neu[2] < 0) {
874 satData->eleSat *= -1.0;
875 }
876 satData->azSat = atan2(neu[1], neu[0]);
877}
878
[7287]879//
[7235]880///////////////////////////////////////////////////////////////////////////
881void t_pppFilter::addAmb(t_satData* satData) {
882 Tracer tracer("t_pppFilter::addAmb");
883 if (!OPT->ambLCs(satData->system()).size()){
884 return;
885 }
886 bool found = false;
887 for (int iPar = 1; iPar <= _params.size(); iPar++) {
[7287]888 if (_params[iPar-1]->type == t_pppParam::AMB_L3 &&
[7235]889 _params[iPar-1]->prn == satData->prn) {
890 found = true;
891 break;
892 }
893 }
894 if (!found) {
[7287]895 t_pppParam* par = new t_pppParam(t_pppParam::AMB_L3,
[7235]896 _params.size()+1, satData->prn);
897 _params.push_back(par);
898 par->xx = satData->L3 - cmpValue(satData, true);
899 }
900}
901
[7287]902//
[7235]903///////////////////////////////////////////////////////////////////////////
904void t_pppFilter::addObs(int iPhase, unsigned& iObs, t_satData* satData,
905 Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP) {
906
907 Tracer tracer("t_pppFilter::addObs");
908
909 const double ELEWGHT = 20.0;
910 double ellWgtCoef = 1.0;
[7287]911 double eleD = satData->eleSat * 180.0 / M_PI;
[7235]912 if (eleD < ELEWGHT) {
913 ellWgtCoef = 1.5 - 0.5 / (ELEWGHT - 10.0) * (eleD - 10.0);
914 }
915
916 // Remember Observation Index
917 // --------------------------
918 ++iObs;
919 satData->obsIndex = iObs;
920
921 // Phase Observations
922 // ------------------
923
924 if (iPhase == 1) {
925 ll(iObs) = satData->L3 - cmpValue(satData, true);
926 double sigL3 = 2.98 * OPT->_sigmaL1;
927 if (satData->system() == 'R') {
928 sigL3 *= GLONASS_WEIGHT_FACTOR;
929 }
930 if (satData->system() == 'C') {
931 sigL3 *= BDS_WEIGHT_FACTOR;
932 }
933 PP(iObs,iObs) = 1.0 / (sigL3 * sigL3) / (ellWgtCoef * ellWgtCoef);
934 for (int iPar = 1; iPar <= _params.size(); iPar++) {
935 if (_params[iPar-1]->type == t_pppParam::AMB_L3 &&
936 _params[iPar-1]->prn == satData->prn) {
937 ll(iObs) -= _params[iPar-1]->xx;
[7287]938 }
[7235]939 AA(iObs, iPar) = _params[iPar-1]->partial(satData, true);
940 }
941 }
942
943 // Code Observations
944 // -----------------
945 else {
946 double sigP3 = 2.98 * OPT->_sigmaC1;
947 ll(iObs) = satData->P3 - cmpValue(satData, false);
948 PP(iObs,iObs) = 1.0 / (sigP3 * sigP3) / (ellWgtCoef * ellWgtCoef);
949 for (int iPar = 1; iPar <= _params.size(); iPar++) {
950 AA(iObs, iPar) = _params[iPar-1]->partial(satData, false);
951 }
952 }
953}
954
[7287]955//
[7235]956///////////////////////////////////////////////////////////////////////////
[7287]957QByteArray t_pppFilter::printRes(int iPhase, const ColumnVector& vv,
[7235]958 const QMap<QString, t_satData*>& satDataMap) {
959
960 Tracer tracer("t_pppFilter::printRes");
961
962 ostringstream str;
963 str.setf(ios::fixed);
964 bool useObs;
965 QMapIterator<QString, t_satData*> it(satDataMap);
966 while (it.hasNext()) {
967 it.next();
968 t_satData* satData = it.value();
969 (iPhase == 0) ? useObs = OPT->codeLCs(satData->system()).size() :
970 useObs = OPT->ambLCs(satData->system()).size();
971 if (satData->obsIndex != 0 && useObs) {
[7536]972 str << _time.datestr() << "_" << _time.timestr(3)
[7235]973 << " RES " << satData->prn.mid(0,3).toAscii().data()
974 << (iPhase ? " L3 " : " P3 ")
975 << setw(9) << setprecision(4) << vv(satData->obsIndex) << endl;
976 }
977 }
978
979 return QByteArray(str.str().c_str());
980}
981
[7287]982//
[7235]983///////////////////////////////////////////////////////////////////////////
984void t_pppFilter::findMaxRes(const ColumnVector& vv,
985 const QMap<QString, t_satData*>& satData,
[7287]986 QString& prnGPS, QString& prnGlo,
987 double& maxResGPS, double& maxResGlo) {
[7235]988
989 Tracer tracer("t_pppFilter::findMaxRes");
990
991 maxResGPS = 0.0;
992 maxResGlo = 0.0;
993
994 QMapIterator<QString, t_satData*> it(satData);
995 while (it.hasNext()) {
996 it.next();
997 t_satData* satData = it.value();
998 if (satData->obsIndex != 0) {
999 QString prn = satData->prn;
[7287]1000 if (prn[0] == 'R' || prn[0] == 'C') {
[7235]1001 if (fabs(vv(satData->obsIndex)) > maxResGlo) {
1002 maxResGlo = fabs(vv(satData->obsIndex));
1003 prnGlo = prn;
1004 }
1005 }
1006 else {
1007 if (fabs(vv(satData->obsIndex)) > maxResGPS) {
1008 maxResGPS = fabs(vv(satData->obsIndex));
1009 prnGPS = prn;
1010 }
1011 }
1012 }
1013 }
1014}
[7287]1015
[7235]1016// Update Step (private - loop over outliers)
1017////////////////////////////////////////////////////////////////////////////
1018t_irc t_pppFilter::update_p(t_epoData* epoData) {
1019
1020 Tracer tracer("t_pppFilter::update_p");
1021
1022 // Save Variance-Covariance Matrix, and Status Vector
1023 // --------------------------------------------------
1024 rememberState(epoData);
1025
1026 QString lastOutlierPrn;
1027
1028 // Try with all satellites, then with all minus one, etc.
1029 // ------------------------------------------------------
1030 while (selectSatellites(lastOutlierPrn, epoData->satData) == success) {
1031
1032 QByteArray strResCode;
1033 QByteArray strResPhase;
1034
1035 // Bancroft Solution
1036 // -----------------
1037 if (cmpBancroft(epoData) != success) {
1038 break;
1039 }
1040
1041 // First update using code observations, then phase observations
[7287]1042 // -------------------------------------------------------------
[7235]1043 bool usePhase = OPT->ambLCs('G').size() || OPT->ambLCs('R').size() ||
1044 OPT->ambLCs('E').size() || OPT->ambLCs('C').size() ;
1045
[7545]1046 char sys[] ={'G', 'R', 'E', 'C'};
1047
1048 bool satnumPrinted[] = {false, false, false, false};
1049
[7235]1050 for (int iPhase = 0; iPhase <= (usePhase ? 1 : 0); iPhase++) {
1051
1052 // Status Prediction
1053 // -----------------
1054 predict(iPhase, epoData);
[7287]1055
[7235]1056 // Create First-Design Matrix
1057 // --------------------------
1058 unsigned nPar = _params.size();
1059 unsigned nObs = 0;
1060 nObs = epoData->sizeAll();
1061 bool useObs = false;
1062 for (unsigned ii = 0; ii < sizeof(sys); ii++) {
1063 const char s = sys[ii];
1064 (iPhase == 0) ? useObs = OPT->codeLCs(s).size() : useObs = OPT->ambLCs(s).size();
1065 if (!useObs) {
1066 nObs -= epoData->sizeSys(s);
1067 }
[7536]1068 else {
[7545]1069 if (!satnumPrinted[ii]) {
1070 satnumPrinted[ii] = true;
[7544]1071 LOG << _time.datestr() << "_" << _time.timestr(3)
1072 << " SATNUM " << s << ' ' << right << setw(2)
1073 << epoData->sizeSys(s) << endl;
1074 }
[7536]1075 }
[7235]1076 }
[7287]1077
[7975]1078 if (int(nObs) < OPT->_minObs) {
[7852]1079 restoreState(epoData);
1080 return failure;
1081 }
1082
[7235]1083 // Prepare first-design Matrix, vector observed-computed
1084 // -----------------------------------------------------
1085 Matrix AA(nObs, nPar); // first design matrix
[7287]1086 ColumnVector ll(nObs); // terms observed-computed
[7235]1087 DiagonalMatrix PP(nObs); PP = 0.0;
[7287]1088
[7235]1089 unsigned iObs = 0;
1090 QMapIterator<QString, t_satData*> it(epoData->satData);
[7536]1091
[7235]1092 while (it.hasNext()) {
1093 it.next();
1094 t_satData* satData = it.value();
1095 QString prn = satData->prn;
1096 (iPhase == 0) ? useObs = OPT->codeLCs(satData->system()).size() :
1097 useObs = OPT->ambLCs(satData->system()).size();
1098 if (useObs) {
1099 addObs(iPhase, iObs, satData, AA, ll, PP);
1100 } else {
1101 satData->obsIndex = 0;
1102 }
1103 }
1104
1105 // Compute Filter Update
1106 // ---------------------
1107 ColumnVector dx(nPar); dx = 0.0;
1108 kalman(AA, ll, PP, _QQ, dx);
1109 ColumnVector vv = ll - AA * dx;
[7287]1110
[7235]1111 // Print Residuals
1112 // ---------------
[7287]1113 if (iPhase == 0) {
[7235]1114 strResCode = printRes(iPhase, vv, epoData->satData);
1115 }
1116 else {
1117 strResPhase = printRes(iPhase, vv, epoData->satData);
1118 }
1119
1120 // Check the residuals
1121 // -------------------
1122 lastOutlierPrn = outlierDetection(iPhase, vv, epoData->satData);
1123
1124 // No Outlier Detected
1125 // -------------------
1126 if (lastOutlierPrn.isEmpty()) {
1127
1128 QVectorIterator<t_pppParam*> itPar(_params);
1129 while (itPar.hasNext()) {
1130 t_pppParam* par = itPar.next();
1131 par->xx += dx(par->index);
1132 }
1133
1134 if (!usePhase || iPhase == 1) {
1135 if (_outlierGPS.size() > 0 || _outlierGlo.size() > 0) {
1136 LOG << "Neglected PRNs: ";
1137 if (!_outlierGPS.isEmpty()) {
1138 LOG << _outlierGPS.last().mid(0,3).toAscii().data() << ' ';
1139 }
1140 QStringListIterator itGlo(_outlierGlo);
1141 while (itGlo.hasNext()) {
1142 QString prn = itGlo.next();
1143 LOG << prn.mid(0,3).toAscii().data() << ' ';
1144 }
[7573]1145 LOG << endl;
[7235]1146 }
1147 LOG << strResCode.data() << strResPhase.data();
1148
1149 return success;
1150 }
1151 }
1152
1153 // Outlier Found
1154 // -------------
1155 else {
1156 restoreState(epoData);
1157 break;
1158 }
1159
1160 } // for iPhase
1161
1162 } // while selectSatellites
1163
1164 restoreState(epoData);
1165 return failure;
1166}
1167
1168// Remeber Original State Vector and Variance-Covariance Matrix
1169////////////////////////////////////////////////////////////////////////////
1170void t_pppFilter::rememberState(t_epoData* epoData) {
1171
1172 _QQ_sav = _QQ;
1173
1174 QVectorIterator<t_pppParam*> itSav(_params_sav);
1175 while (itSav.hasNext()) {
1176 t_pppParam* par = itSav.next();
1177 delete par;
1178 }
1179 _params_sav.clear();
1180
1181 QVectorIterator<t_pppParam*> it(_params);
1182 while (it.hasNext()) {
1183 t_pppParam* par = it.next();
1184 _params_sav.push_back(new t_pppParam(*par));
1185 }
1186
1187 _epoData_sav->deepCopy(epoData);
1188}
1189
1190// Restore Original State Vector and Variance-Covariance Matrix
1191////////////////////////////////////////////////////////////////////////////
1192void t_pppFilter::restoreState(t_epoData* epoData) {
1193
1194 _QQ = _QQ_sav;
1195
1196 QVectorIterator<t_pppParam*> it(_params);
1197 while (it.hasNext()) {
1198 t_pppParam* par = it.next();
1199 delete par;
1200 }
1201 _params.clear();
1202
1203 QVectorIterator<t_pppParam*> itSav(_params_sav);
1204 while (itSav.hasNext()) {
1205 t_pppParam* par = itSav.next();
1206 _params.push_back(new t_pppParam(*par));
1207 }
1208
1209 epoData->deepCopy(_epoData_sav);
1210}
1211
[7287]1212//
[7235]1213////////////////////////////////////////////////////////////////////////////
[7287]1214t_irc t_pppFilter::selectSatellites(const QString& lastOutlierPrn,
[7235]1215 QMap<QString, t_satData*>& satData) {
1216
[7287]1217 // First Call
[7235]1218 // ----------
1219 if (lastOutlierPrn.isEmpty()) {
1220 _outlierGPS.clear();
1221 _outlierGlo.clear();
1222 return success;
1223 }
1224
1225 // Second and next trials
1226 // ----------------------
1227 else {
1228
[7287]1229 if (lastOutlierPrn[0] == 'R' || lastOutlierPrn[0] == 'C') {
[7235]1230 _outlierGlo << lastOutlierPrn;
1231 }
1232
1233 // Remove all Glonass Outliers
1234 // ---------------------------
1235 QStringListIterator it(_outlierGlo);
1236 while (it.hasNext()) {
1237 QString prn = it.next();
1238 if (satData.contains(prn)) {
1239 delete satData.take(prn);
1240 }
1241 }
1242
[7287]1243 if (lastOutlierPrn[0] == 'R' || lastOutlierPrn[0] == 'C') {
[7235]1244 _outlierGPS.clear();
1245 return success;
1246 }
1247
1248 // GPS Outlier appeared for the first time - try to delete it
1249 // ----------------------------------------------------------
1250 if (_outlierGPS.indexOf(lastOutlierPrn) == -1) {
1251 _outlierGPS << lastOutlierPrn;
1252 if (satData.contains(lastOutlierPrn)) {
1253 delete satData.take(lastOutlierPrn);
1254 }
1255 return success;
1256 }
1257
1258 }
1259
1260 return failure;
1261}
1262
[7287]1263//
[7235]1264////////////////////////////////////////////////////////////////////////////
1265double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
1266 return aa(1)*bb(1) + aa(2)*bb(2) + aa(3)*bb(3) - aa(4)*bb(4);
1267}
1268
[7287]1269//
[7235]1270////////////////////////////////////////////////////////////////////////////
1271void t_pppFilter::bancroft(const Matrix& BBpass, ColumnVector& pos) {
1272
1273 if (pos.Nrows() != 4) {
1274 pos.ReSize(4);
1275 }
1276 pos = 0.0;
1277
1278 for (int iter = 1; iter <= 2; iter++) {
1279 Matrix BB = BBpass;
1280 int mm = BB.Nrows();
1281 for (int ii = 1; ii <= mm; ii++) {
1282 double xx = BB(ii,1);
1283 double yy = BB(ii,2);
1284 double traveltime = 0.072;
1285 if (iter > 1) {
1286 double zz = BB(ii,3);
[7287]1287 double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
1288 (yy-pos(2)) * (yy-pos(2)) +
[7235]1289 (zz-pos(3)) * (zz-pos(3)) );
1290 traveltime = rho / t_CST::c;
1291 }
1292 double angle = traveltime * t_CST::omega;
1293 double cosa = cos(angle);
1294 double sina = sin(angle);
1295 BB(ii,1) = cosa * xx + sina * yy;
1296 BB(ii,2) = -sina * xx + cosa * yy;
1297 }
[7287]1298
[7235]1299 Matrix BBB;
1300 if (mm > 4) {
1301 SymmetricMatrix hlp; hlp << BB.t() * BB;
1302 BBB = hlp.i() * BB.t();
1303 }
1304 else {
1305 BBB = BB.i();
1306 }
1307 ColumnVector ee(mm); ee = 1.0;
1308 ColumnVector alpha(mm); alpha = 0.0;
1309 for (int ii = 1; ii <= mm; ii++) {
[7287]1310 alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
[7235]1311 }
1312 ColumnVector BBBe = BBB * ee;
1313 ColumnVector BBBalpha = BBB * alpha;
1314 double aa = lorentz(BBBe, BBBe);
1315 double bb = lorentz(BBBe, BBBalpha)-1;
1316 double cc = lorentz(BBBalpha, BBBalpha);
1317 double root = sqrt(bb*bb-aa*cc);
1318
[7287]1319 Matrix hlpPos(4,2);
[7235]1320 hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
1321 hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
1322
1323 ColumnVector omc(2);
1324 for (int pp = 1; pp <= 2; pp++) {
1325 hlpPos(4,pp) = -hlpPos(4,pp);
[7287]1326 omc(pp) = BB(1,4) -
[7235]1327 sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
1328 (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
[7287]1329 (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
[7235]1330 hlpPos(4,pp);
1331 }
1332 if ( fabs(omc(1)) > fabs(omc(2)) ) {
1333 pos = hlpPos.Column(2);
1334 }
1335 else {
1336 pos = hlpPos.Column(1);
1337 }
1338 }
1339}
1340
[7287]1341//
[7235]1342////////////////////////////////////////////////////////////////////////////
1343void t_pppFilter::cmpDOP(t_epoData* epoData) {
1344
1345 Tracer tracer("t_pppFilter::cmpDOP");
1346
1347 _numSat = 0;
[7933]1348 _hDop = 0.0;
[7235]1349
1350 if (_params.size() < 4) {
1351 return;
1352 }
1353
1354 const unsigned numPar = 4;
1355 Matrix AA(epoData->sizeAll(), numPar);
1356 QMapIterator<QString, t_satData*> it(epoData->satData);
1357 while (it.hasNext()) {
1358 it.next();
1359 t_satData* satData = it.value();
1360 _numSat += 1;
1361 for (unsigned iPar = 0; iPar < numPar; iPar++) {
1362 AA[_numSat-1][iPar] = _params[iPar]->partial(satData, false);
1363 }
1364 }
1365 if (_numSat < 4) {
1366 return;
1367 }
1368 AA = AA.Rows(1, _numSat);
[7287]1369 SymmetricMatrix NN; NN << AA.t() * AA;
[7235]1370 SymmetricMatrix QQ = NN.i();
[7287]1371
[7933]1372 _hDop = sqrt(QQ(1,1) + QQ(2,2));
[7235]1373}
Note: See TracBrowser for help on using the repository browser.