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
RevLine 
[7237]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 *
[7271]13 * Changes:
[7237]14 *
15 * -----------------------------------------------------------------------*/
16
17#include <QThreadStorage>
18
19#include <iostream>
20#include <iomanip>
[8451]21#include <cmath>
[10034]22#include <stdlib.h>
[7237]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) {
[10259]51 _running = true;
[7237]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();
[10034]58 _filter = new t_pppFilter();
[7237]59 _tides = new t_tides();
[8905]60 _antex = 0;
[7237]61 if (!_opt->_antexFileName.empty()) {
62 _antex = new bncAntex(_opt->_antexFileName.c_str());
63 }
[8905]64 if (!_opt->_blqFileName.empty()) {
65 if (_tides->readBlqFile(_opt->_blqFileName.c_str()) == success) {
66 //_tides->printAllBlqSets();
67 }
[7237]68 }
[10256]69 _offGlo = 0.0;
70 _offGal = 0.0;
71 _offBds = 0.0;
[7237]72 CLIENTS.setLocalData(this); // CLIENTS takes ownership over "this"
73}
74
75// Destructor
76//////////////////////////////////////////////////////////////////////////////
77t_pppClient::~t_pppClient() {
[10259]78 _running = false;
[7237]79 delete _log;
80 delete _opt;
81 delete _ephPool;
82 delete _obsPool;
83 delete _staRover;
[7866]84 if (_antex) {
85 delete _antex;
86 }
[10034]87 delete _filter;
[7237]88 delete _tides;
89 clearObs();
90}
91
[7271]92//
[7237]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);
[7271]98 const t_ephBDS* ephBDS = dynamic_cast<const t_ephBDS*>(eph);
[7237]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 }
[7271]108 else if (ephBDS) {
109 _ephPool->putEphemeris(new t_ephBDS(*ephBDS));
110 }
[7237]111}
112
113//
114//////////////////////////////////////////////////////////////////////////////
115void t_pppClient::putTec(const t_vTec* vTec) {
[7248]116 _obsPool->putTec(new t_vTec(*vTec));
[7237]117}
118
[7271]119//
[7237]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
[7271]127//
[7237]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
[7271]135//
[7237]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//////////////////////////////////////////////////////////////////////////////
[7288]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//////////////////////////////////////////////////////////////////////////////
[7237]153t_irc t_pppClient::prepareObs(const vector<t_satObs*>& satObs,
154 vector<t_pppSatObs*>& obsVector, bncTime& epoTime) {
[8905]155
[7271]156 // Default
[7237]157 // -------
158 epoTime.reset();
[10038]159 clearObs();
[7237]160
161 // Create vector of valid observations
162 // -----------------------------------
163 for (unsigned ii = 0; ii < satObs.size(); ii++) {
[9567]164 char sys = satObs[ii]->_prn.system();
165 if (_opt->useSystem(sys)) {
[7237]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
[8905]202//
203//////////////////////////////////////////////////////////////////////////////
204bool t_pppClient::preparePseudoObs(std::vector<t_pppSatObs*>& obsVector) {
205
206 bool pseudoObsIono = false;
207
[8912]208 if (_opt->_pseudoObsIono) {
[8905]209 vector<t_pppSatObs*>::iterator it = obsVector.begin();
210 while (it != obsVector.end()) {
211 t_pppSatObs* satObs = *it;
[10034]212 pseudoObsIono = satObs->setPseudoObsIono(t_frequency::G1);
[8905]213 it++;
214 }
215 }
[10256]216/*
[10217]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*/
[8905]224 return pseudoObsIono;
225}
226
[9560]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;
[10251]235 if (pppSatObs->getCodeBias(pppSatObs->fType1()) &&
236 pppSatObs->getCodeBias(pppSatObs->fType2())) {
237 codeBiasesAvailable = true;
[9560]238 }
239 if (codeBiasesAvailable) {
240 ++it;
241 }
242 else {
243 it = obsVector.erase(it);
244 delete pppSatObs;
245 }
246 }
[10251]247 return;
[9560]248}
249
250
[7237]251// Compute the Bancroft position, check for blunders
252//////////////////////////////////////////////////////////////////////////////
[7271]253t_irc t_pppClient::cmpBancroft(const bncTime& epoTime,
[7237]254 vector<t_pppSatObs*>& obsVector,
255 ColumnVector& xyzc, bool print) {
256 t_lc::type tLC = t_lc::dummy;
[10256]257 int numBancroft = obsVector.size();
[7237]258
[10259]259 while (_running) {
[10256]260 Matrix BB(numBancroft, 4);
[7237]261 int iObs = -1;
262 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
263 const t_pppSatObs* satObs = obsVector.at(ii);
[10356]264 if (tLC == t_lc::dummy) {
265 if (satObs->isValid(t_lc::cIF)) {
266 tLC = t_lc::cIF;
[7237]267 }
[10356]268 else if (satObs->isValid(t_lc::c1)) {
269 tLC = t_lc::c1;
[7237]270 }
[10356]271 else if (satObs->isValid(t_lc::c2)) {
272 tLC = t_lc::c2;
273 }
[7237]274 }
[10356]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 }
[7237]283 }
[8912]284 if (iObs + 1 < _opt->_minObs) {
[9943]285 LOG << "t_pppClient::cmpBancroft not enough observations: " << iObs + 1 << endl;
[7237]286 return failure;
287 }
288 BB = BB.Rows(1,iObs+1);
[9600]289 if (bancroft(BB, xyzc) != success) {
290 return failure;
291 }
[7237]292
293 xyzc[3] /= t_CST::c;
294
295 // Check Blunders
296 // --------------
[10259]297 const double BLUNDER = 100.0;
[7237]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);
[10373]302 char sys = satObs->prn().system();
[10384]303 if (satObs->isValid() &&
[10373]304 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
[7237]305 ColumnVector rr = satObs->xc().Rows(1,3) - xyzc.Rows(1,3);
[8905]306 double res = rr.NormFrobenius() - satObs->obsValue(tLC)
[8453]307 - (satObs->xc()[3] - xyzc[3]) * t_CST::c;
[9600]308 if (fabs(res) > maxRes) {
309 maxRes = fabs(res);
[7237]310 maxResIndex = ii;
311 }
312 }
313 }
[9600]314 if (maxRes < BLUNDER) {
[10034]315 if (print) {
[7237]316 LOG.setf(ios::fixed);
[9783]317 LOG << "\nPPP of Epoch ";
318 if (!_epoTimeRover.undef()) LOG << string(_epoTimeRover);
319 LOG << "\n---------------------------------------------------------------\n";
[10384]320 LOG << string(epoTime) << " BANCROFT: "
[7237]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);
[10165]330 LOG << "t_pppClient::cmpBancroft Outlier " << satObs->prn().toString()
[7237]331 << " " << maxRes << endl;
332 delete satObs;
333 obsVector.erase(obsVector.begin() + maxResIndex);
334 }
335 }
336
337 return success;
338}
339
[10256]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;
[10319]352 unsigned nObs = 0;
[10256]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 }
[10259]380 if (fabs(maxRes) > 100.0) {
381 LOG << "t_pppClient::cmpOffGlo outlier " << maxResPrn.toString() << " " << maxRes << endl;
[10256]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;
[10319]405 unsigned nObs = 0;
[10256]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
[10259]433 if (fabs(maxRes) > 100.0) {
434 LOG << "t_pppClient::cmpOffGal outlier " << maxResPrn.toString() << " " << maxRes << endl;
[10256]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;
[10319]458 unsigned nObs = 0;
[10256]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
[10259]487 if (fabs(maxRes) > 100.0) {
488 LOG << "t_pppClient::cmpOffBDS outlier " << maxResPrn.toString() << " " << maxRes << endl;
[10256]489 delete obsVector.at(maxResIndex);
490 obsVector.erase(obsVector.begin() + maxResIndex);
491 }
492 else {
493 break;
494 }
495 }
496 }
497 return offBds;
498}
499
[7271]500//
[7237]501//////////////////////////////////////////////////////////////////////////////
502void t_pppClient::initOutput(t_output* output) {
503 _output = output;
504 _output->_numSat = 0;
[7927]505 _output->_hDop = 0.0;
[7237]506 _output->_error = false;
507}
508
[7271]509//
[7237]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
[7271]518//
[7237]519//////////////////////////////////////////////////////////////////////////////
[9585]520void t_pppClient::finish(t_irc irc, int ind) {
[9783]521#ifdef BNC_DEBUG_PPP
[9585]522 LOG << "t_pppClient::finish(" << ind << "): " << irc << endl;
[9783]523#endif
[9585]524
[7237]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
[9386]542 _output->_numSat = _filter->numSat();
543 _output->_hDop = _filter->HDOP();
[7237]544 _output->_error = false;
545 }
546 else {
547 _output->_error = true;
548 }
[10034]549
[7237]550 _output->_log = _log->str();
551 delete _log; _log = new ostringstream();
[9545]552
553 return;
[7237]554}
555
[7271]556//
[7237]557//////////////////////////////////////////////////////////////////////////////
558t_irc t_pppClient::cmpModel(t_pppStation* station, const ColumnVector& xyzc,
559 vector<t_pppSatObs*>& obsVector) {
560 bncTime time;
561 time = _epoTimeRover;
[8912]562 station->setName(_opt->_roverName);
563 station->setAntName(_opt->_antNameRover);
[8905]564 station->setEpochTime(time);
[10034]565
[8912]566 if (_opt->xyzAprRoverSet()) {
567 station->setXyzApr(_opt->_xyzAprRover);
[7237]568 }
569 else {
570 station->setXyzApr(xyzc.Rows(1,3));
571 }
[8912]572 station->setNeuEcc(_opt->_neuEccRover);
[7237]573
574 // Receiver Clock
575 // --------------
576 station->setDClk(xyzc[3]);
577
578 // Tides
579 // -----
[8905]580 station->setTideDsplEarth(_tides->earth(time, station->xyzApr()));
581 station->setTideDsplOcean(_tides->ocean(time, station->xyzApr(), station->name()));
[7271]582
[7237]583 // Observation model
584 // -----------------
585 vector<t_pppSatObs*>::iterator it = obsVector.begin();
586 while (it != obsVector.end()) {
587 t_pppSatObs* satObs = *it;
[7254]588 t_irc modelSetup;
[7237]589 if (satObs->isValid()) {
[7254]590 modelSetup = satObs->cmpModel(station);
[7237]591 }
[7254]592 if (satObs->isValid() &&
[8912]593 satObs->eleSat() >= _opt->_minEle &&
[7254]594 modelSetup == success) {
[7237]595 ++it;
596 }
597 else {
598 delete satObs;
599 it = obsVector.erase(it);
600 }
601 }
602
603 return success;
604}
605
[7271]606//
[7237]607//////////////////////////////////////////////////////////////////////////////
608void t_pppClient::processEpoch(const vector<t_satObs*>& satObs, t_output* output) {
609
610 try {
611 initOutput(output);
[10034]612
613 // Prepare Observations of the Rover
614 // ---------------------------------
615 if (prepareObs(satObs, _obsRover, _epoTimeRover) != success) {
616 return finish(failure, 1);
[10031]617 }
[9419]618
[10034]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);
[10031]624 }
[10034]625 if (cmpModel(_staRover, xyzc, _obsRover) != success) {
626 return finish(failure, 3);
[8956]627 }
[10034]628 }
629 // use observations only if satellite code biases are available
630 /* ------------------------------------------------------------
631 if (!_opt->_corrMount.empty() {
[10015]632 useObsWithCodeBiasesOnly(_obsRover);
[10034]633 }*/
[8905]634
[10034]635 if (int(_obsRover.size()) < _opt->_minObs) {
636 LOG << "t_pppClient::processEpoch not enough observations" << endl;
637 return finish(failure, 4);
638 }
[10038]639
[10256]640 _offGlo = cmpOffGlo(_obsRover);
641 _offGal = cmpOffGal(_obsRover);
642 _offBds = cmpOffBds(_obsRover);
643
[10034]644 // Prepare Pseudo Observations of the Rover
645 // ----------------------------------------
646 _pseudoObsIono = preparePseudoObs(_obsRover);
[10018]647
[10034]648 // Store last epoch of data
649 // ------------------------
650 _obsPool->putEpoch(_epoTimeRover, _obsRover, _pseudoObsIono);
[7237]651
[10034]652 // Process Epoch in Filter
653 // -----------------------
654 if (_filter->processEpoch(_obsPool) != success) {
[10220]655 LOG << "t_pppFilter::processEpoch() != success" << endl;
[10034]656 return finish(failure, 5);
657 }
[7237]658 }
659 catch (Exception& exc) {
660 LOG << exc.what() << endl;
[10034]661 return finish(failure, 6);
[7237]662 }
663 catch (t_except msg) {
664 LOG << msg.what() << endl;
[10034]665 return finish(failure, 7);
[7237]666 }
667 catch (const char* msg) {
668 LOG << msg << endl;
[10034]669 return finish(failure, 8);
[7237]670 }
671 catch (...) {
672 LOG << "unknown exception" << endl;
[10034]673 return finish(failure, 9);
[7237]674 }
[10034]675 return finish(success, 0);
[7237]676}
677
[7271]678//
[7237]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
[7271]684//
[7237]685////////////////////////////////////////////////////////////////////////////
[9600]686t_irc t_pppClient::bancroft(const Matrix& BBpass, ColumnVector& pos) {
[7237]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);
[7271]702 double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
703 (yy-pos(2)) * (yy-pos(2)) +
[7237]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 }
[7271]713
[7237]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++) {
[7271]725 alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
[7237]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
[7271]734 Matrix hlpPos(4,2);
[7237]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);
[7271]741 omc(pp) = BB(1,4) -
[7237]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)) +
[7271]744 (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
[7237]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 }
[9600]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;
[7237]763}
764
[7972]765//
766//////////////////////////////////////////////////////////////////////////////
[10256]767void t_pppClient::reset() {
[9490]768
[7972]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();
[8905]776
777 // to delete all parameters
778 delete _filter;
[10034]779 _filter = new t_pppFilter();
[8905]780
[7996]781}
Note: See TracBrowser for help on using the repository browser.