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

Last change on this file since 10386 was 10384, checked in by stuerze, 6 months ago

changes regarding PPP

  • Property svn:keywords set to Author Date Id Rev URL;svn:eol-style=native
  • Property svn:mime-type set to text/plain
File size: 22.0 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 char sys = satObs->prn().system();
303 if (satObs->isValid() &&
304 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
305 ColumnVector rr = satObs->xc().Rows(1,3) - xyzc.Rows(1,3);
306 double res = rr.NormFrobenius() - satObs->obsValue(tLC)
307 - (satObs->xc()[3] - xyzc[3]) * t_CST::c;
308 if (fabs(res) > maxRes) {
309 maxRes = fabs(res);
310 maxResIndex = ii;
311 }
312 }
313 }
314 if (maxRes < BLUNDER) {
315 if (print) {
316 LOG.setf(ios::fixed);
317 LOG << "\nPPP of Epoch ";
318 if (!_epoTimeRover.undef()) LOG << string(_epoTimeRover);
319 LOG << "\n---------------------------------------------------------------\n";
320 LOG << string(epoTime) << " BANCROFT: "
321 << setw(14) << setprecision(3) << xyzc[0] << ' '
322 << setw(14) << setprecision(3) << xyzc[1] << ' '
323 << setw(14) << setprecision(3) << xyzc[2] << ' '
324 << setw(14) << setprecision(3) << xyzc[3] * t_CST::c << endl << endl;
325 }
326 break;
327 }
328 else {
329 t_pppSatObs* satObs = obsVector.at(maxResIndex);
330 LOG << "t_pppClient::cmpBancroft Outlier " << satObs->prn().toString()
331 << " " << maxRes << endl;
332 delete satObs;
333 obsVector.erase(obsVector.begin() + maxResIndex);
334 }
335 }
336
337 return success;
338}
339
340// Compute A Priori Glonass Clock Offset
341//////////////////////////////////////////////////////////////////////////////
342double t_pppClient::cmpOffGlo(vector<t_pppSatObs*>& obsVector) {
343
344 t_lc::type tLC = t_lc::dummy;
345 double offGlo = 0.0;
346
347 if (_opt->useSystem('R')) {
348 while (obsVector.size() > 0) {
349 offGlo = 0.0;
350 double maxRes = 0.0;
351 int maxResIndex = -1;
352 unsigned nObs = 0;
353 t_prn maxResPrn;
354 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
355 const t_pppSatObs* satObs = obsVector.at(ii);
356 if (satObs->prn().system() == 'R') {
357 if (tLC == t_lc::dummy) {
358 tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
359 }
360 if (satObs->isValid(tLC) &&
361 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
362 double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
363 ++nObs;
364 offGlo += ll;
365 if (fabs(ll) > fabs(maxRes)) {
366 maxRes = ll;
367 maxResIndex = ii;
368 maxResPrn = satObs->prn();
369 }
370 }
371 }
372 }
373
374 if (nObs > 0) {
375 offGlo = offGlo / nObs;
376 }
377 else {
378 offGlo = 0.0;
379 }
380 if (fabs(maxRes) > 100.0) {
381 LOG << "t_pppClient::cmpOffGlo outlier " << maxResPrn.toString() << " " << maxRes << endl;
382 delete obsVector.at(maxResIndex);
383 obsVector.erase(obsVector.begin() + maxResIndex);
384 }
385 else {
386 break;
387 }
388 }
389 }
390 return offGlo;
391}
392
393// Compute A Priori Galileo Clock Offset
394//////////////////////////////////////////////////////////////////////////////
395double t_pppClient::cmpOffGal(vector<t_pppSatObs*>& obsVector) {
396
397 t_lc::type tLC = t_lc::dummy;
398 double offGal = 0.0;
399
400 if (_opt->useSystem('E')) {
401 while (obsVector.size() > 0) {
402 offGal = 0.0;
403 double maxRes = 0.0;
404 int maxResIndex = -1;
405 unsigned nObs = 0;
406 t_prn maxResPrn;
407 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
408 const t_pppSatObs* satObs = obsVector.at(ii);
409 if (satObs->prn().system() == 'E') {
410 if (tLC == t_lc::dummy) {
411 tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
412 }
413 if (satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
414 double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
415 ++nObs;
416 offGal += ll;
417 if (fabs(ll) > fabs(maxRes)) {
418 maxRes = ll;
419 maxResIndex = ii;
420 maxResPrn = satObs->prn();
421 }
422 }
423 }
424 }
425
426 if (nObs > 0) {
427 offGal = offGal / nObs;
428 }
429 else {
430 offGal = 0.0;
431 }
432
433 if (fabs(maxRes) > 100.0) {
434 LOG << "t_pppClient::cmpOffGal outlier " << maxResPrn.toString() << " " << maxRes << endl;
435 delete obsVector.at(maxResIndex);
436 obsVector.erase(obsVector.begin() + maxResIndex);
437 }
438 else {
439 break;
440 }
441 }
442 }
443 return offGal;
444}
445
446// Compute A Priori BDS Clock Offset
447//////////////////////////////////////////////////////////////////////////////
448double t_pppClient::cmpOffBds(vector<t_pppSatObs*>& obsVector) {
449
450 t_lc::type tLC = t_lc::dummy;
451 double offBds = 0.0;
452
453 if (_opt->useSystem('C')) {
454 while (obsVector.size() > 0) {
455 offBds = 0.0;
456 double maxRes = 0.0;
457 int maxResIndex = -1;
458 unsigned nObs = 0;
459 t_prn maxResPrn;
460 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
461 const t_pppSatObs* satObs = obsVector.at(ii);
462 if (satObs->prn().system() == 'C') {
463 if (tLC == t_lc::dummy) {
464 tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
465 }
466 if (satObs->isValid(tLC) &&
467 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
468 double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
469 ++nObs;
470 offBds += ll;
471 if (fabs(ll) > fabs(maxRes)) {
472 maxRes = ll;
473 maxResIndex = ii;
474 maxResPrn = satObs->prn();
475 }
476 }
477 }
478 }
479
480 if (nObs > 0) {
481 offBds = offBds / nObs;
482 }
483 else {
484 offBds = 0.0;
485 }
486
487 if (fabs(maxRes) > 100.0) {
488 LOG << "t_pppClient::cmpOffBDS outlier " << maxResPrn.toString() << " " << maxRes << endl;
489 delete obsVector.at(maxResIndex);
490 obsVector.erase(obsVector.begin() + maxResIndex);
491 }
492 else {
493 break;
494 }
495 }
496 }
497 return offBds;
498}
499
500//
501//////////////////////////////////////////////////////////////////////////////
502void t_pppClient::initOutput(t_output* output) {
503 _output = output;
504 _output->_numSat = 0;
505 _output->_hDop = 0.0;
506 _output->_error = false;
507}
508
509//
510//////////////////////////////////////////////////////////////////////////////
511void t_pppClient::clearObs() {
512 for (unsigned ii = 0; ii < _obsRover.size(); ii++) {
513 delete _obsRover.at(ii);
514 }
515 _obsRover.clear();
516}
517
518//
519//////////////////////////////////////////////////////////////////////////////
520void t_pppClient::finish(t_irc irc, int ind) {
521#ifdef BNC_DEBUG_PPP
522 LOG << "t_pppClient::finish(" << ind << "): " << irc << endl;
523#endif
524
525 clearObs();
526
527 _output->_epoTime = _epoTimeRover;
528
529 if (irc == success) {
530 _output->_xyzRover[0] = _staRover->xyzApr()[0] + _filter->x()[0];
531 _output->_xyzRover[1] = _staRover->xyzApr()[1] + _filter->x()[1];
532 _output->_xyzRover[2] = _staRover->xyzApr()[2] + _filter->x()[2];
533
534 xyz2neu(_staRover->ellApr().data(), _filter->x().data(), _output->_neu);
535
536 copy(&_filter->Q().data()[0], &_filter->Q().data()[6], _output->_covMatrix);
537
538 _output->_trp0 = t_tropo::delay_saast(_staRover->xyzApr(), M_PI/2.0);
539 _output->_trp = _filter->trp();
540 _output->_trpStdev = _filter->trpStdev();
541
542 _output->_numSat = _filter->numSat();
543 _output->_hDop = _filter->HDOP();
544 _output->_error = false;
545 }
546 else {
547 _output->_error = true;
548 }
549
550 _output->_log = _log->str();
551 delete _log; _log = new ostringstream();
552
553 return;
554}
555
556//
557//////////////////////////////////////////////////////////////////////////////
558t_irc t_pppClient::cmpModel(t_pppStation* station, const ColumnVector& xyzc,
559 vector<t_pppSatObs*>& obsVector) {
560 bncTime time;
561 time = _epoTimeRover;
562 station->setName(_opt->_roverName);
563 station->setAntName(_opt->_antNameRover);
564 station->setEpochTime(time);
565
566 if (_opt->xyzAprRoverSet()) {
567 station->setXyzApr(_opt->_xyzAprRover);
568 }
569 else {
570 station->setXyzApr(xyzc.Rows(1,3));
571 }
572 station->setNeuEcc(_opt->_neuEccRover);
573
574 // Receiver Clock
575 // --------------
576 station->setDClk(xyzc[3]);
577
578 // Tides
579 // -----
580 station->setTideDsplEarth(_tides->earth(time, station->xyzApr()));
581 station->setTideDsplOcean(_tides->ocean(time, station->xyzApr(), station->name()));
582
583 // Observation model
584 // -----------------
585 vector<t_pppSatObs*>::iterator it = obsVector.begin();
586 while (it != obsVector.end()) {
587 t_pppSatObs* satObs = *it;
588 t_irc modelSetup;
589 if (satObs->isValid()) {
590 modelSetup = satObs->cmpModel(station);
591 }
592 if (satObs->isValid() &&
593 satObs->eleSat() >= _opt->_minEle &&
594 modelSetup == success) {
595 ++it;
596 }
597 else {
598 delete satObs;
599 it = obsVector.erase(it);
600 }
601 }
602
603 return success;
604}
605
606//
607//////////////////////////////////////////////////////////////////////////////
608void t_pppClient::processEpoch(const vector<t_satObs*>& satObs, t_output* output) {
609
610 try {
611 initOutput(output);
612
613 // Prepare Observations of the Rover
614 // ---------------------------------
615 if (prepareObs(satObs, _obsRover, _epoTimeRover) != success) {
616 return finish(failure, 1);
617 }
618
619 for (int iter = 1; iter <= 2; iter++) {
620 ColumnVector xyzc(4); xyzc = 0.0;
621 bool print = (iter == 2);
622 if (cmpBancroft(_epoTimeRover, _obsRover, xyzc, print) != success) {
623 return finish(failure, 2);
624 }
625 if (cmpModel(_staRover, xyzc, _obsRover) != success) {
626 return finish(failure, 3);
627 }
628 }
629 // use observations only if satellite code biases are available
630 /* ------------------------------------------------------------
631 if (!_opt->_corrMount.empty() {
632 useObsWithCodeBiasesOnly(_obsRover);
633 }*/
634
635 if (int(_obsRover.size()) < _opt->_minObs) {
636 LOG << "t_pppClient::processEpoch not enough observations" << endl;
637 return finish(failure, 4);
638 }
639
640 _offGlo = cmpOffGlo(_obsRover);
641 _offGal = cmpOffGal(_obsRover);
642 _offBds = cmpOffBds(_obsRover);
643
644 // Prepare Pseudo Observations of the Rover
645 // ----------------------------------------
646 _pseudoObsIono = preparePseudoObs(_obsRover);
647
648 // Store last epoch of data
649 // ------------------------
650 _obsPool->putEpoch(_epoTimeRover, _obsRover, _pseudoObsIono);
651
652 // Process Epoch in Filter
653 // -----------------------
654 if (_filter->processEpoch(_obsPool) != success) {
655 LOG << "t_pppFilter::processEpoch() != success" << endl;
656 return finish(failure, 5);
657 }
658 }
659 catch (Exception& exc) {
660 LOG << exc.what() << endl;
661 return finish(failure, 6);
662 }
663 catch (t_except msg) {
664 LOG << msg.what() << endl;
665 return finish(failure, 7);
666 }
667 catch (const char* msg) {
668 LOG << msg << endl;
669 return finish(failure, 8);
670 }
671 catch (...) {
672 LOG << "unknown exception" << endl;
673 return finish(failure, 9);
674 }
675 return finish(success, 0);
676}
677
678//
679////////////////////////////////////////////////////////////////////////////
680double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
681 return aa[0]*bb[0] + aa[1]*bb[1] + aa[2]*bb[2] - aa[3]*bb[3];
682}
683
684//
685////////////////////////////////////////////////////////////////////////////
686t_irc t_pppClient::bancroft(const Matrix& BBpass, ColumnVector& pos) {
687
688 if (pos.Nrows() != 4) {
689 pos.ReSize(4);
690 }
691 pos = 0.0;
692
693 for (int iter = 1; iter <= 2; iter++) {
694 Matrix BB = BBpass;
695 int mm = BB.Nrows();
696 for (int ii = 1; ii <= mm; ii++) {
697 double xx = BB(ii,1);
698 double yy = BB(ii,2);
699 double traveltime = 0.072;
700 if (iter > 1) {
701 double zz = BB(ii,3);
702 double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
703 (yy-pos(2)) * (yy-pos(2)) +
704 (zz-pos(3)) * (zz-pos(3)) );
705 traveltime = rho / t_CST::c;
706 }
707 double angle = traveltime * t_CST::omega;
708 double cosa = cos(angle);
709 double sina = sin(angle);
710 BB(ii,1) = cosa * xx + sina * yy;
711 BB(ii,2) = -sina * xx + cosa * yy;
712 }
713
714 Matrix BBB;
715 if (mm > 4) {
716 SymmetricMatrix hlp; hlp << BB.t() * BB;
717 BBB = hlp.i() * BB.t();
718 }
719 else {
720 BBB = BB.i();
721 }
722 ColumnVector ee(mm); ee = 1.0;
723 ColumnVector alpha(mm); alpha = 0.0;
724 for (int ii = 1; ii <= mm; ii++) {
725 alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
726 }
727 ColumnVector BBBe = BBB * ee;
728 ColumnVector BBBalpha = BBB * alpha;
729 double aa = lorentz(BBBe, BBBe);
730 double bb = lorentz(BBBe, BBBalpha)-1;
731 double cc = lorentz(BBBalpha, BBBalpha);
732 double root = sqrt(bb*bb-aa*cc);
733
734 Matrix hlpPos(4,2);
735 hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
736 hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
737
738 ColumnVector omc(2);
739 for (int pp = 1; pp <= 2; pp++) {
740 hlpPos(4,pp) = -hlpPos(4,pp);
741 omc(pp) = BB(1,4) -
742 sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
743 (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
744 (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
745 hlpPos(4,pp);
746 }
747 if ( fabs(omc(1)) > fabs(omc(2)) ) {
748 pos = hlpPos.Column(2);
749 }
750 else {
751 pos = hlpPos.Column(1);
752 }
753 }
754 if (pos.size() != 4 ||
755 std::isnan(pos(1)) ||
756 std::isnan(pos(2)) ||
757 std::isnan(pos(3)) ||
758 std::isnan(pos(4))) {
759 return failure;
760 }
761
762 return success;
763}
764
765//
766//////////////////////////////////////////////////////////////////////////////
767void t_pppClient::reset() {
768
769 // to delete old orbit and clock corrections
770 delete _ephPool;
771 _ephPool = new t_pppEphPool();
772
773 // to delete old code biases
774 delete _obsPool;
775 _obsPool = new t_pppObsPool();
776
777 // to delete all parameters
778 delete _filter;
779 _filter = new t_pppFilter();
780
781}
Note: See TracBrowser for help on using the repository browser.