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

Last change on this file since 11024 was 11019, checked in by stuerze, 3 weeks ago

added epoch/velocity fields to PPP coordinates file to allow BNC to propagate the reference coordinates related to a dedicated reference epoch to the current epoch

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