source: ntrip/trunk/BNC/src/PPP/pppClient.cpp@ 10371

Last change on this file since 10371 was 10356, checked in by stuerze, 10 months ago

minor changes

  • Property svn:keywords set to Author Date Id Rev URL;svn:eol-style=native
  • Property svn:mime-type set to text/plain
File size: 21.9 KB
Line 
1/* -------------------------------------------------------------------------
2 * BKG NTRIP Client
3 * -------------------------------------------------------------------------
4 *
5 * Class: t_pppClient
6 *
7 * Purpose: PPP Client processing starts here
8 *
9 * Author: L. Mervart
10 *
11 * Created: 29-Jul-2014
12 *
13 * Changes:
14 *
15 * -----------------------------------------------------------------------*/
16
17#include <QThreadStorage>
18
19#include <iostream>
20#include <iomanip>
21#include <cmath>
22#include <stdlib.h>
23#include <string.h>
24#include <stdexcept>
25
26#include "pppClient.h"
27#include "pppEphPool.h"
28#include "pppObsPool.h"
29#include "bncconst.h"
30#include "bncutils.h"
31#include "pppStation.h"
32#include "bncantex.h"
33#include "pppFilter.h"
34
35using namespace BNC_PPP;
36using namespace std;
37
38// Global variable holding thread-specific pointers
39//////////////////////////////////////////////////////////////////////////////
40QThreadStorage<t_pppClient*> CLIENTS;
41
42// Static function returning thread-specific pointer
43//////////////////////////////////////////////////////////////////////////////
44t_pppClient* t_pppClient::instance() {
45 return CLIENTS.localData();
46}
47
48// Constructor
49//////////////////////////////////////////////////////////////////////////////
50t_pppClient::t_pppClient(const t_pppOptions* opt) {
51 _running = true;
52 _output = 0;
53 _opt = new t_pppOptions(*opt);
54 _log = new ostringstream();
55 _ephPool = new t_pppEphPool();
56 _obsPool = new t_pppObsPool();
57 _staRover = new t_pppStation();
58 _filter = new t_pppFilter();
59 _tides = new t_tides();
60 _antex = 0;
61 if (!_opt->_antexFileName.empty()) {
62 _antex = new bncAntex(_opt->_antexFileName.c_str());
63 }
64 if (!_opt->_blqFileName.empty()) {
65 if (_tides->readBlqFile(_opt->_blqFileName.c_str()) == success) {
66 //_tides->printAllBlqSets();
67 }
68 }
69 _offGlo = 0.0;
70 _offGal = 0.0;
71 _offBds = 0.0;
72 CLIENTS.setLocalData(this); // CLIENTS takes ownership over "this"
73}
74
75// Destructor
76//////////////////////////////////////////////////////////////////////////////
77t_pppClient::~t_pppClient() {
78 _running = false;
79 delete _log;
80 delete _opt;
81 delete _ephPool;
82 delete _obsPool;
83 delete _staRover;
84 if (_antex) {
85 delete _antex;
86 }
87 delete _filter;
88 delete _tides;
89 clearObs();
90}
91
92//
93//////////////////////////////////////////////////////////////////////////////
94void t_pppClient::putEphemeris(const t_eph* eph) {
95 const t_ephGPS* ephGPS = dynamic_cast<const t_ephGPS*>(eph);
96 const t_ephGlo* ephGlo = dynamic_cast<const t_ephGlo*>(eph);
97 const t_ephGal* ephGal = dynamic_cast<const t_ephGal*>(eph);
98 const t_ephBDS* ephBDS = dynamic_cast<const t_ephBDS*>(eph);
99 if (ephGPS) {
100 _ephPool->putEphemeris(new t_ephGPS(*ephGPS));
101 }
102 else if (ephGlo) {
103 _ephPool->putEphemeris(new t_ephGlo(*ephGlo));
104 }
105 else if (ephGal) {
106 _ephPool->putEphemeris(new t_ephGal(*ephGal));
107 }
108 else if (ephBDS) {
109 _ephPool->putEphemeris(new t_ephBDS(*ephBDS));
110 }
111}
112
113//
114//////////////////////////////////////////////////////////////////////////////
115void t_pppClient::putTec(const t_vTec* vTec) {
116 _obsPool->putTec(new t_vTec(*vTec));
117}
118
119//
120//////////////////////////////////////////////////////////////////////////////
121void t_pppClient::putOrbCorrections(const vector<t_orbCorr*>& corr) {
122 for (unsigned ii = 0; ii < corr.size(); ii++) {
123 _ephPool->putOrbCorrection(new t_orbCorr(*corr[ii]));
124 }
125}
126
127//
128//////////////////////////////////////////////////////////////////////////////
129void t_pppClient::putClkCorrections(const vector<t_clkCorr*>& corr) {
130 for (unsigned ii = 0; ii < corr.size(); ii++) {
131 _ephPool->putClkCorrection(new t_clkCorr(*corr[ii]));
132 }
133}
134
135//
136//////////////////////////////////////////////////////////////////////////////
137void t_pppClient::putCodeBiases(const vector<t_satCodeBias*>& biases) {
138 for (unsigned ii = 0; ii < biases.size(); ii++) {
139 _obsPool->putCodeBias(new t_satCodeBias(*biases[ii]));
140 }
141}
142
143//
144//////////////////////////////////////////////////////////////////////////////
145void t_pppClient::putPhaseBiases(const vector<t_satPhaseBias*>& biases) {
146 for (unsigned ii = 0; ii < biases.size(); ii++) {
147 _obsPool->putPhaseBias(new t_satPhaseBias(*biases[ii]));
148 }
149}
150
151//
152//////////////////////////////////////////////////////////////////////////////
153t_irc t_pppClient::prepareObs(const vector<t_satObs*>& satObs,
154 vector<t_pppSatObs*>& obsVector, bncTime& epoTime) {
155
156 // Default
157 // -------
158 epoTime.reset();
159 clearObs();
160
161 // Create vector of valid observations
162 // -----------------------------------
163 for (unsigned ii = 0; ii < satObs.size(); ii++) {
164 char sys = satObs[ii]->_prn.system();
165 if (_opt->useSystem(sys)) {
166 t_pppSatObs* pppSatObs = new t_pppSatObs(*satObs[ii]);
167 if (pppSatObs->isValid()) {
168 obsVector.push_back(pppSatObs);
169 }
170 else {
171 delete pppSatObs;
172 }
173 }
174 }
175
176 // Check whether data are synchronized, compute epoTime
177 // ----------------------------------------------------
178 const double MAXSYNC = 0.05; // synchronization limit
179 double meanDt = 0.0;
180 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
181 const t_pppSatObs* satObs = obsVector.at(ii);
182 if (epoTime.undef()) {
183 epoTime = satObs->time();
184 }
185 else {
186 double dt = satObs->time() - epoTime;
187 if (fabs(dt) > MAXSYNC) {
188 LOG << "t_pppClient::prepareObs asynchronous observations" << endl;
189 return failure;
190 }
191 meanDt += dt;
192 }
193 }
194
195 if (obsVector.size() > 0) {
196 epoTime += meanDt / obsVector.size();
197 }
198
199 return success;
200}
201
202//
203//////////////////////////////////////////////////////////////////////////////
204bool t_pppClient::preparePseudoObs(std::vector<t_pppSatObs*>& obsVector) {
205
206 bool pseudoObsIono = false;
207
208 if (_opt->_pseudoObsIono) {
209 vector<t_pppSatObs*>::iterator it = obsVector.begin();
210 while (it != obsVector.end()) {
211 t_pppSatObs* satObs = *it;
212 pseudoObsIono = satObs->setPseudoObsIono(t_frequency::G1);
213 it++;
214 }
215 }
216/*
217 vector<t_pppSatObs*>::iterator it = obsVector.begin();
218 while (it != obsVector.end()) {
219 t_pppSatObs* satObs = *it;
220 satObs->printObsMinusComputed();
221 it++;
222 }
223*/
224 return pseudoObsIono;
225}
226
227//
228//////////////////////////////////////////////////////////////////////////////
229void t_pppClient::useObsWithCodeBiasesOnly(std::vector<t_pppSatObs*>& obsVector) {
230
231 vector<t_pppSatObs*>::iterator it = obsVector.begin();
232 while (it != obsVector.end()) {
233 t_pppSatObs* pppSatObs = *it;
234 bool codeBiasesAvailable = false;
235 if (pppSatObs->getCodeBias(pppSatObs->fType1()) &&
236 pppSatObs->getCodeBias(pppSatObs->fType2())) {
237 codeBiasesAvailable = true;
238 }
239 if (codeBiasesAvailable) {
240 ++it;
241 }
242 else {
243 it = obsVector.erase(it);
244 delete pppSatObs;
245 }
246 }
247 return;
248}
249
250
251// Compute the Bancroft position, check for blunders
252//////////////////////////////////////////////////////////////////////////////
253t_irc t_pppClient::cmpBancroft(const bncTime& epoTime,
254 vector<t_pppSatObs*>& obsVector,
255 ColumnVector& xyzc, bool print) {
256 t_lc::type tLC = t_lc::dummy;
257 int numBancroft = obsVector.size();
258
259 while (_running) {
260 Matrix BB(numBancroft, 4);
261 int iObs = -1;
262 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
263 const t_pppSatObs* satObs = obsVector.at(ii);
264 if (tLC == t_lc::dummy) {
265 if (satObs->isValid(t_lc::cIF)) {
266 tLC = t_lc::cIF;
267 }
268 else if (satObs->isValid(t_lc::c1)) {
269 tLC = t_lc::c1;
270 }
271 else if (satObs->isValid(t_lc::c2)) {
272 tLC = t_lc::c2;
273 }
274 }
275 if ( satObs->isValid(tLC) &&
276 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
277 ++iObs;
278 BB[iObs][0] = satObs->xc()[0];
279 BB[iObs][1] = satObs->xc()[1];
280 BB[iObs][2] = satObs->xc()[2];
281 BB[iObs][3] = satObs->obsValue(tLC) - satObs->cmpValueForBanc(tLC);
282 }
283 }
284 if (iObs + 1 < _opt->_minObs) {
285 LOG << "t_pppClient::cmpBancroft not enough observations: " << iObs + 1 << endl;
286 return failure;
287 }
288 BB = BB.Rows(1,iObs+1);
289 if (bancroft(BB, xyzc) != success) {
290 return failure;
291 }
292
293 xyzc[3] /= t_CST::c;
294
295 // Check Blunders
296 // --------------
297 const double BLUNDER = 100.0;
298 double maxRes = 0.0;
299 unsigned maxResIndex = 0;
300 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
301 const t_pppSatObs* satObs = obsVector.at(ii);
302 if (satObs->isValid() && (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
303 ColumnVector rr = satObs->xc().Rows(1,3) - xyzc.Rows(1,3);
304 double res = rr.NormFrobenius() - satObs->obsValue(tLC)
305 - (satObs->xc()[3] - xyzc[3]) * t_CST::c;
306 if (fabs(res) > maxRes) {
307 maxRes = fabs(res);
308 maxResIndex = ii;
309 }
310 }
311 }
312 if (maxRes < BLUNDER) {
313 if (print) {
314 LOG.setf(ios::fixed);
315 LOG << "\nPPP of Epoch ";
316 if (!_epoTimeRover.undef()) LOG << string(_epoTimeRover);
317 LOG << "\n---------------------------------------------------------------\n";
318 LOG << string(epoTime) << " BANCROFT " << ": "
319 << setw(14) << setprecision(3) << xyzc[0] << ' '
320 << setw(14) << setprecision(3) << xyzc[1] << ' '
321 << setw(14) << setprecision(3) << xyzc[2] << ' '
322 << setw(14) << setprecision(3) << xyzc[3] * t_CST::c << endl << endl;
323 }
324 break;
325 }
326 else {
327 t_pppSatObs* satObs = obsVector.at(maxResIndex);
328 LOG << "t_pppClient::cmpBancroft Outlier " << satObs->prn().toString()
329 << " " << maxRes << endl;
330 delete satObs;
331 obsVector.erase(obsVector.begin() + maxResIndex);
332 }
333 }
334
335 return success;
336}
337
338// Compute A Priori Glonass Clock Offset
339//////////////////////////////////////////////////////////////////////////////
340double t_pppClient::cmpOffGlo(vector<t_pppSatObs*>& obsVector) {
341
342 t_lc::type tLC = t_lc::dummy;
343 double offGlo = 0.0;
344
345 if (_opt->useSystem('R')) {
346 while (obsVector.size() > 0) {
347 offGlo = 0.0;
348 double maxRes = 0.0;
349 int maxResIndex = -1;
350 unsigned nObs = 0;
351 t_prn maxResPrn;
352 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
353 const t_pppSatObs* satObs = obsVector.at(ii);
354 if (satObs->prn().system() == 'R') {
355 if (tLC == t_lc::dummy) {
356 tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
357 }
358 if (satObs->isValid(tLC) &&
359 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
360 double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
361 ++nObs;
362 offGlo += ll;
363 if (fabs(ll) > fabs(maxRes)) {
364 maxRes = ll;
365 maxResIndex = ii;
366 maxResPrn = satObs->prn();
367 }
368 }
369 }
370 }
371
372 if (nObs > 0) {
373 offGlo = offGlo / nObs;
374 }
375 else {
376 offGlo = 0.0;
377 }
378 if (fabs(maxRes) > 100.0) {
379 LOG << "t_pppClient::cmpOffGlo outlier " << maxResPrn.toString() << " " << maxRes << endl;
380 delete obsVector.at(maxResIndex);
381 obsVector.erase(obsVector.begin() + maxResIndex);
382 }
383 else {
384 break;
385 }
386 }
387 }
388 return offGlo;
389}
390
391// Compute A Priori Galileo Clock Offset
392//////////////////////////////////////////////////////////////////////////////
393double t_pppClient::cmpOffGal(vector<t_pppSatObs*>& obsVector) {
394
395 t_lc::type tLC = t_lc::dummy;
396 double offGal = 0.0;
397
398 if (_opt->useSystem('E')) {
399 while (obsVector.size() > 0) {
400 offGal = 0.0;
401 double maxRes = 0.0;
402 int maxResIndex = -1;
403 unsigned nObs = 0;
404 t_prn maxResPrn;
405 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
406 const t_pppSatObs* satObs = obsVector.at(ii);
407 if (satObs->prn().system() == 'E') {
408 if (tLC == t_lc::dummy) {
409 tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
410 }
411 if (satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
412 double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
413 ++nObs;
414 offGal += ll;
415 if (fabs(ll) > fabs(maxRes)) {
416 maxRes = ll;
417 maxResIndex = ii;
418 maxResPrn = satObs->prn();
419 }
420 }
421 }
422 }
423
424 if (nObs > 0) {
425 offGal = offGal / nObs;
426 }
427 else {
428 offGal = 0.0;
429 }
430
431 if (fabs(maxRes) > 100.0) {
432 LOG << "t_pppClient::cmpOffGal outlier " << maxResPrn.toString() << " " << maxRes << endl;
433 delete obsVector.at(maxResIndex);
434 obsVector.erase(obsVector.begin() + maxResIndex);
435 }
436 else {
437 break;
438 }
439 }
440 }
441 return offGal;
442}
443
444// Compute A Priori BDS Clock Offset
445//////////////////////////////////////////////////////////////////////////////
446double t_pppClient::cmpOffBds(vector<t_pppSatObs*>& obsVector) {
447
448 t_lc::type tLC = t_lc::dummy;
449 double offBds = 0.0;
450
451 if (_opt->useSystem('C')) {
452 while (obsVector.size() > 0) {
453 offBds = 0.0;
454 double maxRes = 0.0;
455 int maxResIndex = -1;
456 unsigned nObs = 0;
457 t_prn maxResPrn;
458 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
459 const t_pppSatObs* satObs = obsVector.at(ii);
460 if (satObs->prn().system() == 'C') {
461 if (tLC == t_lc::dummy) {
462 tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
463 }
464 if (satObs->isValid(tLC) &&
465 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
466 double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
467 ++nObs;
468 offBds += ll;
469 if (fabs(ll) > fabs(maxRes)) {
470 maxRes = ll;
471 maxResIndex = ii;
472 maxResPrn = satObs->prn();
473 }
474 }
475 }
476 }
477
478 if (nObs > 0) {
479 offBds = offBds / nObs;
480 }
481 else {
482 offBds = 0.0;
483 }
484
485 if (fabs(maxRes) > 100.0) {
486 LOG << "t_pppClient::cmpOffBDS outlier " << maxResPrn.toString() << " " << maxRes << endl;
487 delete obsVector.at(maxResIndex);
488 obsVector.erase(obsVector.begin() + maxResIndex);
489 }
490 else {
491 break;
492 }
493 }
494 }
495 return offBds;
496}
497
498//
499//////////////////////////////////////////////////////////////////////////////
500void t_pppClient::initOutput(t_output* output) {
501 _output = output;
502 _output->_numSat = 0;
503 _output->_hDop = 0.0;
504 _output->_error = false;
505}
506
507//
508//////////////////////////////////////////////////////////////////////////////
509void t_pppClient::clearObs() {
510 for (unsigned ii = 0; ii < _obsRover.size(); ii++) {
511 delete _obsRover.at(ii);
512 }
513 _obsRover.clear();
514}
515
516//
517//////////////////////////////////////////////////////////////////////////////
518void t_pppClient::finish(t_irc irc, int ind) {
519#ifdef BNC_DEBUG_PPP
520 LOG << "t_pppClient::finish(" << ind << "): " << irc << endl;
521#endif
522
523 clearObs();
524
525 _output->_epoTime = _epoTimeRover;
526
527 if (irc == success) {
528 _output->_xyzRover[0] = _staRover->xyzApr()[0] + _filter->x()[0];
529 _output->_xyzRover[1] = _staRover->xyzApr()[1] + _filter->x()[1];
530 _output->_xyzRover[2] = _staRover->xyzApr()[2] + _filter->x()[2];
531
532 xyz2neu(_staRover->ellApr().data(), _filter->x().data(), _output->_neu);
533
534 copy(&_filter->Q().data()[0], &_filter->Q().data()[6], _output->_covMatrix);
535
536 _output->_trp0 = t_tropo::delay_saast(_staRover->xyzApr(), M_PI/2.0);
537 _output->_trp = _filter->trp();
538 _output->_trpStdev = _filter->trpStdev();
539
540 _output->_numSat = _filter->numSat();
541 _output->_hDop = _filter->HDOP();
542 _output->_error = false;
543 }
544 else {
545 _output->_error = true;
546 }
547
548 _output->_log = _log->str();
549 delete _log; _log = new ostringstream();
550
551 return;
552}
553
554//
555//////////////////////////////////////////////////////////////////////////////
556t_irc t_pppClient::cmpModel(t_pppStation* station, const ColumnVector& xyzc,
557 vector<t_pppSatObs*>& obsVector) {
558 bncTime time;
559 time = _epoTimeRover;
560 station->setName(_opt->_roverName);
561 station->setAntName(_opt->_antNameRover);
562 station->setEpochTime(time);
563
564 if (_opt->xyzAprRoverSet()) {
565 station->setXyzApr(_opt->_xyzAprRover);
566 }
567 else {
568 station->setXyzApr(xyzc.Rows(1,3));
569 }
570 station->setNeuEcc(_opt->_neuEccRover);
571
572 // Receiver Clock
573 // --------------
574 station->setDClk(xyzc[3]);
575
576 // Tides
577 // -----
578 station->setTideDsplEarth(_tides->earth(time, station->xyzApr()));
579 station->setTideDsplOcean(_tides->ocean(time, station->xyzApr(), station->name()));
580
581 // Observation model
582 // -----------------
583 vector<t_pppSatObs*>::iterator it = obsVector.begin();
584 while (it != obsVector.end()) {
585 t_pppSatObs* satObs = *it;
586 t_irc modelSetup;
587 if (satObs->isValid()) {
588 modelSetup = satObs->cmpModel(station);
589 }
590 if (satObs->isValid() &&
591 satObs->eleSat() >= _opt->_minEle &&
592 modelSetup == success) {
593 ++it;
594 }
595 else {
596 delete satObs;
597 it = obsVector.erase(it);
598 }
599 }
600
601 return success;
602}
603
604//
605//////////////////////////////////////////////////////////////////////////////
606void t_pppClient::processEpoch(const vector<t_satObs*>& satObs, t_output* output) {
607
608 try {
609 initOutput(output);
610
611 // Prepare Observations of the Rover
612 // ---------------------------------
613 if (prepareObs(satObs, _obsRover, _epoTimeRover) != success) {
614 return finish(failure, 1);
615 }
616
617 for (int iter = 1; iter <= 2; iter++) {
618 ColumnVector xyzc(4); xyzc = 0.0;
619 bool print = (iter == 2);
620 if (cmpBancroft(_epoTimeRover, _obsRover, xyzc, print) != success) {
621 return finish(failure, 2);
622 }
623 if (cmpModel(_staRover, xyzc, _obsRover) != success) {
624 return finish(failure, 3);
625 }
626 }
627 // use observations only if satellite code biases are available
628 /* ------------------------------------------------------------
629 if (!_opt->_corrMount.empty() {
630 useObsWithCodeBiasesOnly(_obsRover);
631 }*/
632
633 if (int(_obsRover.size()) < _opt->_minObs) {
634 LOG << "t_pppClient::processEpoch not enough observations" << endl;
635 return finish(failure, 4);
636 }
637
638 _offGlo = cmpOffGlo(_obsRover);
639 _offGal = cmpOffGal(_obsRover);
640 _offBds = cmpOffBds(_obsRover);
641
642 // Prepare Pseudo Observations of the Rover
643 // ----------------------------------------
644 _pseudoObsIono = preparePseudoObs(_obsRover);
645
646 // Store last epoch of data
647 // ------------------------
648 _obsPool->putEpoch(_epoTimeRover, _obsRover, _pseudoObsIono);
649
650 // Process Epoch in Filter
651 // -----------------------
652 if (_filter->processEpoch(_obsPool) != success) {
653 LOG << "t_pppFilter::processEpoch() != success" << endl;
654 return finish(failure, 5);
655 }
656 }
657 catch (Exception& exc) {
658 LOG << exc.what() << endl;
659 return finish(failure, 6);
660 }
661 catch (t_except msg) {
662 LOG << msg.what() << endl;
663 return finish(failure, 7);
664 }
665 catch (const char* msg) {
666 LOG << msg << endl;
667 return finish(failure, 8);
668 }
669 catch (...) {
670 LOG << "unknown exception" << endl;
671 return finish(failure, 9);
672 }
673 return finish(success, 0);
674}
675
676//
677////////////////////////////////////////////////////////////////////////////
678double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
679 return aa[0]*bb[0] + aa[1]*bb[1] + aa[2]*bb[2] - aa[3]*bb[3];
680}
681
682//
683////////////////////////////////////////////////////////////////////////////
684t_irc t_pppClient::bancroft(const Matrix& BBpass, ColumnVector& pos) {
685
686 if (pos.Nrows() != 4) {
687 pos.ReSize(4);
688 }
689 pos = 0.0;
690
691 for (int iter = 1; iter <= 2; iter++) {
692 Matrix BB = BBpass;
693 int mm = BB.Nrows();
694 for (int ii = 1; ii <= mm; ii++) {
695 double xx = BB(ii,1);
696 double yy = BB(ii,2);
697 double traveltime = 0.072;
698 if (iter > 1) {
699 double zz = BB(ii,3);
700 double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
701 (yy-pos(2)) * (yy-pos(2)) +
702 (zz-pos(3)) * (zz-pos(3)) );
703 traveltime = rho / t_CST::c;
704 }
705 double angle = traveltime * t_CST::omega;
706 double cosa = cos(angle);
707 double sina = sin(angle);
708 BB(ii,1) = cosa * xx + sina * yy;
709 BB(ii,2) = -sina * xx + cosa * yy;
710 }
711
712 Matrix BBB;
713 if (mm > 4) {
714 SymmetricMatrix hlp; hlp << BB.t() * BB;
715 BBB = hlp.i() * BB.t();
716 }
717 else {
718 BBB = BB.i();
719 }
720 ColumnVector ee(mm); ee = 1.0;
721 ColumnVector alpha(mm); alpha = 0.0;
722 for (int ii = 1; ii <= mm; ii++) {
723 alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
724 }
725 ColumnVector BBBe = BBB * ee;
726 ColumnVector BBBalpha = BBB * alpha;
727 double aa = lorentz(BBBe, BBBe);
728 double bb = lorentz(BBBe, BBBalpha)-1;
729 double cc = lorentz(BBBalpha, BBBalpha);
730 double root = sqrt(bb*bb-aa*cc);
731
732 Matrix hlpPos(4,2);
733 hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
734 hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
735
736 ColumnVector omc(2);
737 for (int pp = 1; pp <= 2; pp++) {
738 hlpPos(4,pp) = -hlpPos(4,pp);
739 omc(pp) = BB(1,4) -
740 sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
741 (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
742 (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
743 hlpPos(4,pp);
744 }
745 if ( fabs(omc(1)) > fabs(omc(2)) ) {
746 pos = hlpPos.Column(2);
747 }
748 else {
749 pos = hlpPos.Column(1);
750 }
751 }
752 if (pos.size() != 4 ||
753 std::isnan(pos(1)) ||
754 std::isnan(pos(2)) ||
755 std::isnan(pos(3)) ||
756 std::isnan(pos(4))) {
757 return failure;
758 }
759
760 return success;
761}
762
763//
764//////////////////////////////////////////////////////////////////////////////
765void t_pppClient::reset() {
766
767 // to delete old orbit and clock corrections
768 delete _ephPool;
769 _ephPool = new t_pppEphPool();
770
771 // to delete old code biases
772 delete _obsPool;
773 _obsPool = new t_pppObsPool();
774
775 // to delete all parameters
776 delete _filter;
777 _filter = new t_pppFilter();
778
779}
Note: See TracBrowser for help on using the repository browser.