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

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