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

Last change on this file since 11067 was 11067, checked in by stuerze, 5 days ago

some more 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: 22.6 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 *_log << _antex->info().toStdString() << endl;
64 }
65 if (!_opt->_blqFileName.empty()) {
66 if (_tides->readBlqFile(_opt->_blqFileName.c_str()) == success) {
67 //_tides->printAllBlqSets();
68 }
69 }
70 CLIENTS.setLocalData(this); // CLIENTS takes ownership over "this"
71}
72
73// Destructor
74//////////////////////////////////////////////////////////////////////////////
75t_pppClient::~t_pppClient() {
76 _running = false;
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::putMetaData(const t_metaData* metaData) {
120 _obsPool->putMetaData(new t_metaData(*metaData));
121}
122
123//
124//////////////////////////////////////////////////////////////////////////////
125void t_pppClient::putOrbCorrections(const vector<t_orbCorr*>& corr) {
126 if (OPT->_logMode == t_pppOptions::normal && corr.size() > 0) {
127 LOG << "orbCorrections " << string(corr[0]->_time) << ' ' << corr.size() << endl;
128 }
129 for (unsigned ii = 0; ii < corr.size(); ii++) {
130 _ephPool->putOrbCorrection(new t_orbCorr(*corr[ii]));
131 }
132}
133
134//
135//////////////////////////////////////////////////////////////////////////////
136void t_pppClient::putClkCorrections(const vector<t_clkCorr*>& corr) {
137 if (OPT->_logMode == t_pppOptions::normal && corr.size() > 0) {
138 LOG << "clkCorrections " << string(corr[0]->_time) << ' ' << corr.size() << endl;
139 }
140 for (unsigned ii = 0; ii < corr.size(); ii++) {
141 _ephPool->putClkCorrection(new t_clkCorr(*corr[ii]));
142 }
143}
144
145//
146//////////////////////////////////////////////////////////////////////////////
147void t_pppClient::putCodeBiases(const vector<t_satCodeBias*>& biases) {
148 if (OPT->_logMode == t_pppOptions::normal && biases.size() > 0) {
149 LOG << "codeBiases " << string(biases[0]->_time) << ' ' << biases.size() << endl;
150 }
151 set<char> systems;
152 for (unsigned ii = 0; ii < biases.size(); ii++) {
153 t_satCodeBias* newBias = new t_satCodeBias(*biases[ii]);
154 char sys = newBias->_prn.system();
155 if (systems.find(sys) == systems.end()) {
156 _obsPool->clearCodeBiases(sys);
157 systems.insert(sys);
158 }
159 _obsPool->putCodeBias(newBias);
160 }
161}
162
163//
164//////////////////////////////////////////////////////////////////////////////
165void t_pppClient::putSatAntennas(const vector<t_satAntenna*>& satAntennas) {
166 if (OPT->_logMode == t_pppOptions::normal && satAntennas.size() > 0) {
167 LOG << "satAntennas " << string(satAntennas[0]->_time) << ' ' << satAntennas.size() << endl;
168 }
169 for (unsigned ii = 0; ii < satAntennas.size(); ii++) {
170 _obsPool->putSatAntenna(new t_satAntenna(*satAntennas[ii]));
171 }
172}
173
174//
175//////////////////////////////////////////////////////////////////////////////
176void t_pppClient::putPhaseBiases(const vector<t_satPhaseBias*>& biases) {
177 if (OPT->_logMode == t_pppOptions::normal && biases.size() > 0) {
178 LOG << "phaseBiases " << string(biases[0]->_time) << ' ' << biases.size() << endl;
179 }
180 set<char> systems;
181 for (unsigned ii = 0; ii < biases.size(); ii++) {
182 t_satPhaseBias* newBias = new t_satPhaseBias(*biases[ii]);
183 char sys = newBias->_prn.system();
184 if (systems.find(sys) == systems.end()) {
185 _obsPool->clearPhaseBiases(sys);
186 systems.insert(sys);
187 }
188 _obsPool->putPhaseBias(newBias);
189 }
190}
191
192//
193//////////////////////////////////////////////////////////////////////////////
194t_irc t_pppClient::prepareObs(const vector<t_satObs*>& satObs,
195 vector<t_pppSatObs*>& obsVector, bncTime& epoTime) {
196
197 // Default
198 // -------
199 epoTime.reset();
200 clearObs();
201
202 // Create vector of valid observations
203 // -----------------------------------
204 for (unsigned ii = 0; ii < satObs.size(); ii++) {
205 char sys = satObs[ii]->_prn.system();
206 if (_opt->useSystem(sys)) {
207 t_pppSatObs* pppSatObs = new t_pppSatObs(*satObs[ii]);
208 if (pppSatObs->isValid()) {
209 obsVector.push_back(pppSatObs);
210 }
211 else {
212 delete pppSatObs;
213 }
214 }
215 }
216
217 // Check whether data are synchronized, compute epoTime
218 // ----------------------------------------------------
219 const double MAXSYNC = 0.05; // synchronization limit
220 double meanDt = 0.0;
221 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
222 const t_pppSatObs* satObs = obsVector.at(ii);
223 if (epoTime.undef()) {
224 epoTime = satObs->time();
225 }
226 else {
227 double dt = satObs->time() - epoTime;
228 if (fabs(dt) > MAXSYNC) {
229 LOG << "t_pppClient::prepareObs asynchronous observations" << endl;
230 return failure;
231 }
232 meanDt += dt;
233 }
234 }
235
236 if (obsVector.size() > 0) {
237 epoTime += meanDt / obsVector.size();
238 }
239
240 return success;
241}
242
243//
244//////////////////////////////////////////////////////////////////////////////
245bool t_pppClient::preparePseudoObs(std::vector<t_pppSatObs*>& obsVector) {
246
247 bool pseudoObsIono = false;
248
249 if (_opt->_pseudoObsIono) {
250
251 // Select reference satellite per system: keep the current one if still
252 // visible; only switch to highest elevation when the current one disappears
253 // -------------------------------------------------------------------------
254 map<char, t_pppSatObs*> refSatMap;
255 map<char, t_pppSatObs*> bestEleMap;
256 for (t_pppSatObs* satObs : obsVector) {
257 satObs->resetReference();
258 double stec = satObs->getIonoCodeDelay(t_frequency::G1);
259 if (stec == 0.0) continue;
260 char sys = satObs->prn().system();
261 if (!bestEleMap.count(sys) || satObs->eleSat() > bestEleMap[sys]->eleSat()) {
262 bestEleMap[sys] = satObs;
263 }
264 if (_refPrnMap.count(sys) && satObs->prn() == _refPrnMap[sys]) {
265 refSatMap[sys] = satObs;
266 }
267 }
268 for (auto& kv : bestEleMap) {
269 if (!refSatMap.count(kv.first)) {
270 refSatMap[kv.first] = kv.second;
271 }
272 }
273 for (auto& kv : refSatMap) {
274 _refPrnMap[kv.first] = kv.second->prn();
275 kv.second->setAsReference();
276 }
277
278 if (bestEleMap.empty()) {
279 LOG << "GIM pseudo-obs unavailable: no valid STEC (vTec data missing?)" << endl;
280 }
281
282 // Set STEC pseudo-observations (single-differenced vs reference satellite)
283 // -------------------------------------------------------------------------
284 int nGIM = 0;
285 for (t_pppSatObs* satObs : obsVector) {
286 char sys = satObs->prn().system();
287 double stecRefSat = refSatMap.count(sys)
288 ? refSatMap[sys]->getIonoCodeDelay(t_frequency::G1)
289 : 0.0;
290 if (satObs->setPseudoObsIono(t_frequency::G1, stecRefSat)) {
291 pseudoObsIono = true;
292 nGIM++;
293 }
294 }
295 if (nGIM > 0) {
296 LOG << "GIM pseudo-obs: " << nGIM << " satellites, ref:";
297 for (auto& kv : refSatMap) {
298 LOG << ' ' << kv.second->prn().toString();
299 }
300 LOG << endl;
301 }
302 }
303
304 if (OPT->_logMode == t_pppOptions::all) {
305 vector<t_pppSatObs*>::iterator it = obsVector.begin();
306 while (it != obsVector.end()) {
307 t_pppSatObs* satObs = *it;
308 satObs->printObsMinusComputed();
309 it++;
310 }
311 }
312 return pseudoObsIono;
313}
314
315// Compute the Bancroft position, check for blunders
316//////////////////////////////////////////////////////////////////////////////
317t_irc t_pppClient::cmpBancroft(const bncTime& epoTime,
318 vector<t_pppSatObs*>& obsVector,
319 ColumnVector& xyzc, bool print) {
320
321 int numBancroft = obsVector.size();
322
323 while (_running) {
324 Matrix BB(numBancroft, 4);
325 int iObs = -1;
326 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
327 const t_pppSatObs* satObs = obsVector.at(ii);
328 t_lc LC = satObs->rangeLC();
329 if ( satObs->isValid(LC) &&
330 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
331 ++iObs;
332 BB[iObs][0] = satObs->xc()[0];
333 BB[iObs][1] = satObs->xc()[1];
334 BB[iObs][2] = satObs->xc()[2];
335 BB[iObs][3] = satObs->obsValue(LC) - satObs->cmpValueForBanc(LC);
336 }
337 }
338 if (iObs + 1 < _opt->_minObs) {
339 LOG << "t_pppClient::cmpBancroft not enough observations: " << iObs + 1 << endl;
340 return failure;
341 }
342 BB = BB.Rows(1,iObs+1);
343 if (bancroft(BB, xyzc) != success) {
344 return failure;
345 }
346
347 xyzc[3] /= t_CST::c;
348
349 // Check Blunders
350 // --------------
351 const double BLUNDER = 1500.0;
352 double maxRes = 0.0;
353 unsigned maxResIndex = 0;
354 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
355 const t_pppSatObs* satObs = obsVector.at(ii);
356 t_lc LC = satObs->rangeLC();
357 if (satObs->isValid(LC) &&
358 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
359 ColumnVector rr = satObs->xc().Rows(1,3) - xyzc.Rows(1,3);
360 double res = rr.NormFrobenius() - satObs->obsValue(LC)
361 - (satObs->xc()[3] - xyzc[3]) * t_CST::c;
362 if (fabs(res) > maxRes) {
363 maxRes = fabs(res);
364 maxResIndex = ii;
365 }
366 }
367 }
368 if (maxRes < BLUNDER) {
369 if (print) {
370 LOG.setf(ios::fixed);
371 LOG << "\nPPP of Epoch ";
372 if (!_epoTimeRover.undef()) LOG << string(_epoTimeRover);
373 LOG << " using " << _opt->_corrMount;
374 LOG << "\n---------------------------------------------------------------\n";
375 LOG << string(epoTime) << " BANCROFT: "
376 << setw(14) << setprecision(3) << xyzc[0] << ' '
377 << setw(14) << setprecision(3) << xyzc[1] << ' '
378 << setw(14) << setprecision(3) << xyzc[2] << ' '
379 << setw(14) << setprecision(3) << xyzc[3] * t_CST::c << endl << endl;
380 }
381 break;
382 }
383 else {
384 t_pppSatObs* satObs = obsVector.at(maxResIndex);
385 LOG << "t_pppClient::cmpBancroft Outlier " << satObs->prn().toString()
386 << " " << maxRes << endl;
387 delete satObs;
388 obsVector.erase(obsVector.begin() + maxResIndex);
389 }
390 }
391
392 return success;
393}
394
395//
396//////////////////////////////////////////////////////////////////////////////
397void t_pppClient::initOutput(t_output* output) {
398 _output = output;
399 _output->_numSat = 0;
400 _output->_hDop = 0.0;
401 _output->_error = false;
402}
403
404//
405//////////////////////////////////////////////////////////////////////////////
406void t_pppClient::clearObs() {
407 for (unsigned ii = 0; ii < _obsRover.size(); ii++) {
408 delete _obsRover.at(ii);
409 }
410 _obsRover.clear();
411}
412
413//
414//////////////////////////////////////////////////////////////////////////////
415void t_pppClient::finish(t_irc irc, int ind) {
416#ifdef BNC_DEBUG_PPP
417 LOG << "t_pppClient::finish(" << ind << "): " << irc << endl;
418#endif
419
420 clearObs();
421
422 _output->_epoTime = _epoTimeRover;
423
424 if (irc == success) {
425 _output->_xyzRover[0] = _staRover->xyzApr()[0] + _filter->x()[0];
426 _output->_xyzRover[1] = _staRover->xyzApr()[1] + _filter->x()[1];
427 _output->_xyzRover[2] = _staRover->xyzApr()[2] + _filter->x()[2];
428
429 xyz2neu(_staRover->ellApr().data(), _filter->x().data(), _output->_neu);
430
431 copy(&_filter->Q().data()[0], &_filter->Q().data()[6], _output->_covMatrix);
432
433 _output->_trp0 = t_tropo::delay_saast(_staRover->xyzApr(), M_PI/2.0);
434 _output->_trp = _filter->trp();
435 _output->_trpStdev = _filter->trpStdev();
436
437 _output->_fixRatio = _filter->fixRatio();
438
439 _output->_numSat = _filter->numSat();
440 _output->_hDop = _filter->HDOP();
441 _output->_error = false;
442 }
443 else {
444 _output->_error = true;
445 }
446
447 _output->_log = _log->str();
448 delete _log; _log = new ostringstream();
449
450 return;
451}
452
453//
454//////////////////////////////////////////////////////////////////////////////
455t_irc t_pppClient::cmpModel(t_pppStation* station, const ColumnVector& xyzc,
456 vector<t_pppSatObs*>& obsVector) {
457 bncTime time;
458 time = _epoTimeRover;
459 station->setName(_opt->_roverName);
460 station->setAntName(_opt->_antNameRover);
461 station->setEpochTime(time);
462
463 if (_opt->xyzAprRoverSet()) {
464 if (_opt->_refEpochRover != 0.0) {
465 double dt = decimalYear(time) - _opt->_refEpochRover;
466 station->setXyzApr(_opt->_xyzAprRover + dt * _opt->_velRover);
467 }
468 else {
469 station->setXyzApr(_opt->_xyzAprRover);
470 }
471 }
472 else {
473 station->setXyzApr(xyzc.Rows(1,3));
474 }
475 station->setNeuEcc(_opt->_neuEccRover);
476
477 // Receiver Clock
478 // --------------
479 station->setDClk(xyzc[3]);
480
481 // Tides
482 // -----
483 // RTCM-SSR Metadata (model correction type 3 = solid earth tides) tells us
484 // whether - and with which model - the correction stream's generation
485 // system already accounted for solid earth tides. To stay consistent with
486 // the orbit/clock corrections, mirror that choice here: skip our own
487 // correction if the provider applied none, apply our default model if the
488 // provider used its own default, and fall back to our default (with a
489 // warning) if the provider used some other, unsupported model - we have no
490 // way to reproduce an unknown model exactly. Absent any Metadata message
491 // (e.g. RTNET or older streams), keep today's unconditional behavior.
492 bool applyEarthTide = true;
493 const t_metaData* metaData = _obsPool->metaData();
494 if (metaData) {
495 for (unsigned ii = 0; ii < metaData->_entries.size(); ii++) {
496 const t_metaDataEntry& entry = metaData->_entries[ii];
497 if (entry._typeIndicator == 3) { // solid earth tides
498 if (!entry._applicationIndicator) {
499 applyEarthTide = false;
500 }
501 else if (entry._nonDefaultIndicator) {
502 LOG << "WARNING: SSR Metadata signals a non-default solid earth "
503 << "tide model (identifier " << entry._nonDefaultIdentifier
504 << "); applying BNC's default model anyway, results may be "
505 << "inconsistent" << endl;
506 }
507 break;
508 }
509 }
510 }
511 if (applyEarthTide) {
512 station->setTideDsplEarth(_tides->earth(time, station->xyzApr()));
513 }
514 else {
515 ColumnVector tideDsplEarth(3); tideDsplEarth = 0.0;
516 station->setTideDsplEarth(tideDsplEarth);
517 }
518 station->setTideDsplOcean(_tides->ocean(time, station->xyzApr(), station->name()));
519
520 // Observation model
521 // -----------------
522 vector<t_pppSatObs*>::iterator it = obsVector.begin();
523 while (it != obsVector.end()) {
524 t_pppSatObs* satObs = *it;
525 t_irc modelSetup;
526 if (satObs->isValid()) {
527 modelSetup = satObs->cmpModel(station);
528 }
529 if (satObs->isValid() &&
530 satObs->eleSat() >= _opt->_minEle &&
531 modelSetup == success) {
532 ++it;
533 }
534 else {
535 delete satObs;
536 it = obsVector.erase(it);
537 }
538 }
539
540 return success;
541}
542
543//
544//////////////////////////////////////////////////////////////////////////////
545void t_pppClient::processEpoch(const vector<t_satObs*>& satObs, t_output* output) {
546
547 try {
548 initOutput(output);
549
550 // Prepare Observations of the Rover
551 // ---------------------------------
552 if (prepareObs(satObs, _obsRover, _epoTimeRover) != success) {
553 return finish(failure, 1);
554 }
555
556 for (int iter = 1; iter <= 2; iter++) {
557 ColumnVector xyzc(4); xyzc = 0.0;
558 bool print = (iter == 2);
559 if (cmpBancroft(_epoTimeRover, _obsRover, xyzc, print) != success) {
560 return finish(failure, 2);
561 }
562 if (cmpModel(_staRover, xyzc, _obsRover) != success) {
563 return finish(failure, 3);
564 }
565 }
566
567 // Use observations only if satellite code biases are available
568 // ------------------------------------------------------------
569 if (_opt->ambRes()) {
570 useObsWithBiasesOnly(_obsRover);
571 }
572
573 if (int(_obsRover.size()) < _opt->_minObs) {
574 LOG << "t_pppClient::processEpoch not enough observations" << endl;
575 return finish(failure, 4);
576 }
577
578 // Prepare Pseudo Observations of the Rover
579 // ----------------------------------------
580 _pseudoObsIono = preparePseudoObs(_obsRover);
581
582 // Store last epoch of data
583 // ------------------------
584 _obsPool->putEpoch(_epoTimeRover, _obsRover, _pseudoObsIono);
585
586 // Process Epoch in Filter
587 // -----------------------
588 if (_filter->processEpoch(_obsPool) != success) {
589 LOG << "t_pppFilter::processEpoch() != success" << endl;
590 return finish(failure, 5);
591 }
592 }
593 catch (Exception& exc) {
594 LOG << exc.what() << endl;
595 // A failed Kalman update (e.g. non-positive-definite covariance) leaves
596 // the filter state unusable and would be carried into every subsequent
597 // epoch => restart the filter, keeping ephemerides and corrections
598 // ----------------------------------------------------------------------
599 LOG << string(_epoTimeRover) << " pppClient: filter reset after exception" << endl;
600 delete _filter;
601 _filter = new t_pppFilter();
602 return finish(failure, 6);
603 }
604 catch (t_except msg) {
605 LOG << msg.what() << endl;
606 return finish(failure, 7);
607 }
608 catch (const char* msg) {
609 LOG << msg << endl;
610 return finish(failure, 8);
611 }
612 catch (...) {
613 LOG << "unknown exception" << endl;
614 return finish(failure, 9);
615 }
616 return finish(success, 0);
617}
618
619//
620////////////////////////////////////////////////////////////////////////////
621double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
622 return aa[0]*bb[0] + aa[1]*bb[1] + aa[2]*bb[2] - aa[3]*bb[3];
623}
624
625//
626////////////////////////////////////////////////////////////////////////////
627t_irc t_pppClient::bancroft(const Matrix& BBpass, ColumnVector& pos) {
628
629 if (pos.Nrows() != 4) {
630 pos.ReSize(4);
631 }
632 pos = 0.0;
633
634 for (int iter = 1; iter <= 2; iter++) {
635 Matrix BB = BBpass;
636 int mm = BB.Nrows();
637 for (int ii = 1; ii <= mm; ii++) {
638 double xx = BB(ii,1);
639 double yy = BB(ii,2);
640 double traveltime = 0.072;
641 if (iter > 1) {
642 double zz = BB(ii,3);
643 double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
644 (yy-pos(2)) * (yy-pos(2)) +
645 (zz-pos(3)) * (zz-pos(3)) );
646 traveltime = rho / t_CST::c;
647 }
648 double angle = traveltime * t_CST::omega;
649 double cosa = cos(angle);
650 double sina = sin(angle);
651 BB(ii,1) = cosa * xx + sina * yy;
652 BB(ii,2) = -sina * xx + cosa * yy;
653 }
654
655 Matrix BBB;
656 if (mm > 4) {
657 SymmetricMatrix hlp; hlp << BB.t() * BB;
658 BBB = hlp.i() * BB.t();
659 }
660 else {
661 BBB = BB.i();
662 }
663 ColumnVector ee(mm); ee = 1.0;
664 ColumnVector alpha(mm); alpha = 0.0;
665 for (int ii = 1; ii <= mm; ii++) {
666 alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
667 }
668 ColumnVector BBBe = BBB * ee;
669 ColumnVector BBBalpha = BBB * alpha;
670 double aa = lorentz(BBBe, BBBe);
671 double bb = lorentz(BBBe, BBBalpha)-1;
672 double cc = lorentz(BBBalpha, BBBalpha);
673 double root = sqrt(bb*bb-aa*cc);
674
675 Matrix hlpPos(4,2);
676 hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
677 hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
678
679 ColumnVector omc(2);
680 for (int pp = 1; pp <= 2; pp++) {
681 hlpPos(4,pp) = -hlpPos(4,pp);
682 omc(pp) = BB(1,4) -
683 sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
684 (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
685 (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
686 hlpPos(4,pp);
687 }
688 if ( fabs(omc(1)) > fabs(omc(2)) ) {
689 pos = hlpPos.Column(2);
690 }
691 else {
692 pos = hlpPos.Column(1);
693 }
694 }
695 if (pos.size() != 4 ||
696 std::isnan(pos(1)) ||
697 std::isnan(pos(2)) ||
698 std::isnan(pos(3)) ||
699 std::isnan(pos(4))) {
700 return failure;
701 }
702
703 return success;
704}
705
706//
707//////////////////////////////////////////////////////////////////////////////
708void t_pppClient::reset() {
709
710 LOG << "pppClient: reset" << endl;
711 _refPrnMap.clear();
712 // to delete old orbit and clock corrections
713 delete _ephPool;
714 _ephPool = new t_pppEphPool();
715
716 // to delete old biases
717 delete _obsPool;
718 _obsPool = new t_pppObsPool();
719
720 // to delete all parameters
721 delete _filter;
722 _filter = new t_pppFilter();
723
724}
725
726//
727//////////////////////////////////////////////////////////////////////////////
728void t_pppClient::useObsWithBiasesOnly(vector<t_pppSatObs*>& obsVector) const {
729 vector<t_pppSatObs*>::iterator it = obsVector.begin();
730 while (it != obsVector.end()) {
731 t_pppSatObs* pppSatObs = *it;
732 if (pppSatObs->hasBiases()) {
733 ++it;
734 }
735 else {
736 LOG << "t_pppClient::useObsWithBiasesOnly: no biases: " << pppSatObs->prn().toString().c_str() << endl;
737 it = obsVector.erase(it);
738 delete pppSatObs;
739 }
740 }
741}
Note: See TracBrowser for help on using the repository browser.