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 |
|
---|
35 | using namespace BNC_PPP;
|
---|
36 | using namespace std;
|
---|
37 |
|
---|
38 | // Global variable holding thread-specific pointers
|
---|
39 | //////////////////////////////////////////////////////////////////////////////
|
---|
40 | QThreadStorage<t_pppClient*> CLIENTS;
|
---|
41 |
|
---|
42 | // Static function returning thread-specific pointer
|
---|
43 | //////////////////////////////////////////////////////////////////////////////
|
---|
44 | t_pppClient* t_pppClient::instance() {
|
---|
45 | return CLIENTS.localData();
|
---|
46 | }
|
---|
47 |
|
---|
48 | // Constructor
|
---|
49 | //////////////////////////////////////////////////////////////////////////////
|
---|
50 | t_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 |
|
---|
72 | CLIENTS.setLocalData(this); // CLIENTS takes ownership over "this"
|
---|
73 | }
|
---|
74 |
|
---|
75 | // Destructor
|
---|
76 | //////////////////////////////////////////////////////////////////////////////
|
---|
77 | t_pppClient::~t_pppClient() {
|
---|
78 | delete _log;
|
---|
79 | delete _opt;
|
---|
80 | delete _ephPool;
|
---|
81 | delete _obsPool;
|
---|
82 | delete _staRover;
|
---|
83 | if (_antex) {
|
---|
84 | delete _antex;
|
---|
85 | }
|
---|
86 | delete _filter;
|
---|
87 | delete _tides;
|
---|
88 | clearObs();
|
---|
89 | }
|
---|
90 |
|
---|
91 | //
|
---|
92 | //////////////////////////////////////////////////////////////////////////////
|
---|
93 | void t_pppClient::putEphemeris(const t_eph* eph) {
|
---|
94 | const t_ephGPS* ephGPS = dynamic_cast<const t_ephGPS*>(eph);
|
---|
95 | const t_ephGlo* ephGlo = dynamic_cast<const t_ephGlo*>(eph);
|
---|
96 | const t_ephGal* ephGal = dynamic_cast<const t_ephGal*>(eph);
|
---|
97 | const t_ephBDS* ephBDS = dynamic_cast<const t_ephBDS*>(eph);
|
---|
98 | if (ephGPS) {
|
---|
99 | _ephPool->putEphemeris(new t_ephGPS(*ephGPS));
|
---|
100 | }
|
---|
101 | else if (ephGlo) {
|
---|
102 | _ephPool->putEphemeris(new t_ephGlo(*ephGlo));
|
---|
103 | }
|
---|
104 | else if (ephGal) {
|
---|
105 | _ephPool->putEphemeris(new t_ephGal(*ephGal));
|
---|
106 | }
|
---|
107 | else if (ephBDS) {
|
---|
108 | _ephPool->putEphemeris(new t_ephBDS(*ephBDS));
|
---|
109 | }
|
---|
110 | }
|
---|
111 |
|
---|
112 | //
|
---|
113 | //////////////////////////////////////////////////////////////////////////////
|
---|
114 | void t_pppClient::putTec(const t_vTec* vTec) {
|
---|
115 | _obsPool->putTec(new t_vTec(*vTec));
|
---|
116 | }
|
---|
117 |
|
---|
118 | //
|
---|
119 | //////////////////////////////////////////////////////////////////////////////
|
---|
120 | void t_pppClient::putOrbCorrections(const vector<t_orbCorr*>& corr) {
|
---|
121 | for (unsigned ii = 0; ii < corr.size(); ii++) {
|
---|
122 | _ephPool->putOrbCorrection(new t_orbCorr(*corr[ii]));
|
---|
123 | }
|
---|
124 | }
|
---|
125 |
|
---|
126 | //
|
---|
127 | //////////////////////////////////////////////////////////////////////////////
|
---|
128 | void t_pppClient::putClkCorrections(const vector<t_clkCorr*>& corr) {
|
---|
129 | for (unsigned ii = 0; ii < corr.size(); ii++) {
|
---|
130 | _ephPool->putClkCorrection(new t_clkCorr(*corr[ii]));
|
---|
131 | }
|
---|
132 | }
|
---|
133 |
|
---|
134 | //
|
---|
135 | //////////////////////////////////////////////////////////////////////////////
|
---|
136 | void t_pppClient::putCodeBiases(const vector<t_satCodeBias*>& biases) {
|
---|
137 | for (unsigned ii = 0; ii < biases.size(); ii++) {
|
---|
138 | _obsPool->putCodeBias(new t_satCodeBias(*biases[ii]));
|
---|
139 | }
|
---|
140 | }
|
---|
141 |
|
---|
142 | //
|
---|
143 | //////////////////////////////////////////////////////////////////////////////
|
---|
144 | void t_pppClient::putPhaseBiases(const vector<t_satPhaseBias*>& biases) {
|
---|
145 | for (unsigned ii = 0; ii < biases.size(); ii++) {
|
---|
146 | _obsPool->putPhaseBias(new t_satPhaseBias(*biases[ii]));
|
---|
147 | }
|
---|
148 | }
|
---|
149 |
|
---|
150 | //
|
---|
151 | //////////////////////////////////////////////////////////////////////////////
|
---|
152 | t_irc t_pppClient::prepareObs(const vector<t_satObs*>& satObs,
|
---|
153 | vector<t_pppSatObs*>& obsVector, bncTime& epoTime) {
|
---|
154 |
|
---|
155 | // Default
|
---|
156 | // -------
|
---|
157 | epoTime.reset();
|
---|
158 | clearObs();
|
---|
159 |
|
---|
160 | // Create vector of valid observations
|
---|
161 | // -----------------------------------
|
---|
162 | for (unsigned ii = 0; ii < satObs.size(); ii++) {
|
---|
163 | char sys = satObs[ii]->_prn.system();
|
---|
164 | if (_opt->useSystem(sys)) {
|
---|
165 | t_pppSatObs* pppSatObs = new t_pppSatObs(*satObs[ii]);
|
---|
166 | if (pppSatObs->isValid()) {
|
---|
167 | obsVector.push_back(pppSatObs);
|
---|
168 | }
|
---|
169 | else {
|
---|
170 | delete pppSatObs;
|
---|
171 | }
|
---|
172 | }
|
---|
173 | }
|
---|
174 |
|
---|
175 | // Check whether data are synchronized, compute epoTime
|
---|
176 | // ----------------------------------------------------
|
---|
177 | const double MAXSYNC = 0.05; // synchronization limit
|
---|
178 | double meanDt = 0.0;
|
---|
179 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
180 | const t_pppSatObs* satObs = obsVector.at(ii);
|
---|
181 | if (epoTime.undef()) {
|
---|
182 | epoTime = satObs->time();
|
---|
183 | }
|
---|
184 | else {
|
---|
185 | double dt = satObs->time() - epoTime;
|
---|
186 | if (fabs(dt) > MAXSYNC) {
|
---|
187 | LOG << "t_pppClient::prepareObs asynchronous observations" << endl;
|
---|
188 | return failure;
|
---|
189 | }
|
---|
190 | meanDt += dt;
|
---|
191 | }
|
---|
192 | }
|
---|
193 |
|
---|
194 | if (obsVector.size() > 0) {
|
---|
195 | epoTime += meanDt / obsVector.size();
|
---|
196 | }
|
---|
197 |
|
---|
198 | return success;
|
---|
199 | }
|
---|
200 |
|
---|
201 | //
|
---|
202 | //////////////////////////////////////////////////////////////////////////////
|
---|
203 | bool t_pppClient::preparePseudoObs(std::vector<t_pppSatObs*>& obsVector) {
|
---|
204 |
|
---|
205 | bool pseudoObsIono = false;
|
---|
206 |
|
---|
207 | if (_opt->_pseudoObsIono) {
|
---|
208 | vector<t_pppSatObs*>::iterator it = obsVector.begin();
|
---|
209 | while (it != obsVector.end()) {
|
---|
210 | t_pppSatObs* satObs = *it;
|
---|
211 | pseudoObsIono = satObs->setPseudoObsIono(t_frequency::G1);
|
---|
212 | it++;
|
---|
213 | }
|
---|
214 | }
|
---|
215 | /*
|
---|
216 | vector<t_pppSatObs*>::iterator it = obsVector.begin();
|
---|
217 | while (it != obsVector.end()) {
|
---|
218 | t_pppSatObs* satObs = *it;
|
---|
219 | satObs->printObsMinusComputed();
|
---|
220 | it++;
|
---|
221 | }
|
---|
222 | */
|
---|
223 | return pseudoObsIono;
|
---|
224 | }
|
---|
225 |
|
---|
226 | //
|
---|
227 | //////////////////////////////////////////////////////////////////////////////
|
---|
228 | void t_pppClient::useObsWithCodeBiasesOnly(std::vector<t_pppSatObs*>& obsVector) {
|
---|
229 |
|
---|
230 | vector<t_pppSatObs*>::iterator it = obsVector.begin();
|
---|
231 | while (it != obsVector.end()) {
|
---|
232 | t_pppSatObs* pppSatObs = *it;
|
---|
233 | char sys = pppSatObs->prn().system();
|
---|
234 | bool codeBiasesAvailable = false;
|
---|
235 | t_frequency::type fType1 = t_lc::toFreq(sys,t_lc::c1);
|
---|
236 | t_frequency::type fType2 = t_lc::toFreq(sys,t_lc::c2);
|
---|
237 | if (pppSatObs->getCodeBias(fType1) &&
|
---|
238 | pppSatObs->getCodeBias(fType2)) {
|
---|
239 | codeBiasesAvailable = true;
|
---|
240 | }
|
---|
241 | if (codeBiasesAvailable) {
|
---|
242 | ++it;
|
---|
243 | }
|
---|
244 | else {
|
---|
245 | it = obsVector.erase(it);
|
---|
246 | delete pppSatObs;
|
---|
247 | }
|
---|
248 | }
|
---|
249 |
|
---|
250 | }
|
---|
251 |
|
---|
252 |
|
---|
253 | // Compute the Bancroft position, check for blunders
|
---|
254 | //////////////////////////////////////////////////////////////////////////////
|
---|
255 | t_irc t_pppClient::cmpBancroft(const bncTime& epoTime,
|
---|
256 | vector<t_pppSatObs*>& obsVector,
|
---|
257 | ColumnVector& xyzc, bool print) {
|
---|
258 |
|
---|
259 | t_lc::type tLC = t_lc::dummy;
|
---|
260 |
|
---|
261 | while (true) {
|
---|
262 | Matrix BB(obsVector.size(), 4);
|
---|
263 | int iObs = -1;
|
---|
264 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
265 | const t_pppSatObs* satObs = obsVector.at(ii);
|
---|
266 | if (tLC == t_lc::dummy) {
|
---|
267 | if (satObs->isValid(t_lc::cIF)) {
|
---|
268 | tLC = t_lc::cIF;
|
---|
269 | }
|
---|
270 | else if (satObs->isValid(t_lc::c1)) {
|
---|
271 | tLC = t_lc::c1;
|
---|
272 | }
|
---|
273 | else if (satObs->isValid(t_lc::c2)) {
|
---|
274 | tLC = t_lc::c2;
|
---|
275 | }
|
---|
276 | }
|
---|
277 | if ( satObs->isValid(tLC) &&
|
---|
278 | (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
|
---|
279 | ++iObs;
|
---|
280 | BB[iObs][0] = satObs->xc()[0];
|
---|
281 | BB[iObs][1] = satObs->xc()[1];
|
---|
282 | BB[iObs][2] = satObs->xc()[2];
|
---|
283 | BB[iObs][3] = satObs->obsValue(tLC) - satObs->cmpValueForBanc(tLC);
|
---|
284 | }
|
---|
285 | }
|
---|
286 | if (iObs + 1 < _opt->_minObs) {
|
---|
287 | LOG << "t_pppClient::cmpBancroft not enough observations: " << iObs + 1 << endl;
|
---|
288 | return failure;
|
---|
289 | }
|
---|
290 | BB = BB.Rows(1,iObs+1);
|
---|
291 | if (bancroft(BB, xyzc) != success) {
|
---|
292 | return failure;
|
---|
293 | }
|
---|
294 |
|
---|
295 | xyzc[3] /= t_CST::c;
|
---|
296 |
|
---|
297 | // Check Blunders
|
---|
298 | // --------------
|
---|
299 | const double BLUNDER = 100.0;
|
---|
300 | double maxRes = 0.0;
|
---|
301 | unsigned maxResIndex = 0;
|
---|
302 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
303 | const t_pppSatObs* satObs = obsVector.at(ii);
|
---|
304 | if (satObs->isValid() &&
|
---|
305 | (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
|
---|
306 | ColumnVector rr = satObs->xc().Rows(1,3) - xyzc.Rows(1,3);
|
---|
307 | double res = rr.NormFrobenius() - satObs->obsValue(tLC)
|
---|
308 | - (satObs->xc()[3] - xyzc[3]) * t_CST::c;
|
---|
309 | if (fabs(res) > maxRes) {
|
---|
310 | maxRes = fabs(res);
|
---|
311 | maxResIndex = ii;
|
---|
312 | }
|
---|
313 | }
|
---|
314 | }
|
---|
315 | if (maxRes < BLUNDER) {
|
---|
316 | if (print) {
|
---|
317 | LOG.setf(ios::fixed);
|
---|
318 | LOG << "\nPPP of Epoch ";
|
---|
319 | if (!_epoTimeRover.undef()) LOG << string(_epoTimeRover);
|
---|
320 | LOG << "\n---------------------------------------------------------------\n";
|
---|
321 | LOG << string(epoTime) << " BANCROFT:" << ' '
|
---|
322 | << setw(14) << setprecision(3) << xyzc[0] << ' '
|
---|
323 | << setw(14) << setprecision(3) << xyzc[1] << ' '
|
---|
324 | << setw(14) << setprecision(3) << xyzc[2] << ' '
|
---|
325 | << setw(14) << setprecision(3) << xyzc[3] * t_CST::c << endl << endl;
|
---|
326 | }
|
---|
327 | break;
|
---|
328 | }
|
---|
329 | else {
|
---|
330 | t_pppSatObs* satObs = obsVector.at(maxResIndex);
|
---|
331 | LOG << "t_pppClient::cmpBancroft Outlier " << satObs->prn().toString()
|
---|
332 | << " " << maxRes << endl;
|
---|
333 | delete satObs;
|
---|
334 | obsVector.erase(obsVector.begin() + maxResIndex);
|
---|
335 | }
|
---|
336 | }
|
---|
337 |
|
---|
338 | return success;
|
---|
339 | }
|
---|
340 |
|
---|
341 | //
|
---|
342 | //////////////////////////////////////////////////////////////////////////////
|
---|
343 | void t_pppClient::initOutput(t_output* output) {
|
---|
344 | _output = output;
|
---|
345 | _output->_numSat = 0;
|
---|
346 | _output->_hDop = 0.0;
|
---|
347 | _output->_error = false;
|
---|
348 | }
|
---|
349 |
|
---|
350 | //
|
---|
351 | //////////////////////////////////////////////////////////////////////////////
|
---|
352 | void t_pppClient::clearObs() {
|
---|
353 | for (unsigned ii = 0; ii < _obsRover.size(); ii++) {
|
---|
354 | delete _obsRover.at(ii);
|
---|
355 | }
|
---|
356 | _obsRover.clear();
|
---|
357 | }
|
---|
358 |
|
---|
359 | //
|
---|
360 | //////////////////////////////////////////////////////////////////////////////
|
---|
361 | void t_pppClient::finish(t_irc irc, int ind) {
|
---|
362 | #ifdef BNC_DEBUG_PPP
|
---|
363 | LOG << "t_pppClient::finish(" << ind << "): " << irc << endl;
|
---|
364 | #endif
|
---|
365 |
|
---|
366 | clearObs();
|
---|
367 |
|
---|
368 | _output->_epoTime = _epoTimeRover;
|
---|
369 |
|
---|
370 | if (irc == success) {
|
---|
371 | _output->_xyzRover[0] = _staRover->xyzApr()[0] + _filter->x()[0];
|
---|
372 | _output->_xyzRover[1] = _staRover->xyzApr()[1] + _filter->x()[1];
|
---|
373 | _output->_xyzRover[2] = _staRover->xyzApr()[2] + _filter->x()[2];
|
---|
374 |
|
---|
375 | xyz2neu(_staRover->ellApr().data(), _filter->x().data(), _output->_neu);
|
---|
376 |
|
---|
377 | copy(&_filter->Q().data()[0], &_filter->Q().data()[6], _output->_covMatrix);
|
---|
378 |
|
---|
379 | _output->_trp0 = t_tropo::delay_saast(_staRover->xyzApr(), M_PI/2.0);
|
---|
380 | _output->_trp = _filter->trp();
|
---|
381 | _output->_trpStdev = _filter->trpStdev();
|
---|
382 |
|
---|
383 | _output->_numSat = _filter->numSat();
|
---|
384 | _output->_hDop = _filter->HDOP();
|
---|
385 | _output->_error = false;
|
---|
386 | }
|
---|
387 | else {
|
---|
388 | _output->_error = true;
|
---|
389 | }
|
---|
390 |
|
---|
391 | _output->_log = _log->str();
|
---|
392 | delete _log; _log = new ostringstream();
|
---|
393 |
|
---|
394 | return;
|
---|
395 | }
|
---|
396 |
|
---|
397 | //
|
---|
398 | //////////////////////////////////////////////////////////////////////////////
|
---|
399 | t_irc t_pppClient::cmpModel(t_pppStation* station, const ColumnVector& xyzc,
|
---|
400 | vector<t_pppSatObs*>& obsVector) {
|
---|
401 | bncTime time;
|
---|
402 | time = _epoTimeRover;
|
---|
403 | station->setName(_opt->_roverName);
|
---|
404 | station->setAntName(_opt->_antNameRover);
|
---|
405 | station->setEpochTime(time);
|
---|
406 |
|
---|
407 | if (_opt->xyzAprRoverSet()) {
|
---|
408 | station->setXyzApr(_opt->_xyzAprRover);
|
---|
409 | }
|
---|
410 | else {
|
---|
411 | station->setXyzApr(xyzc.Rows(1,3));
|
---|
412 | }
|
---|
413 | station->setNeuEcc(_opt->_neuEccRover);
|
---|
414 |
|
---|
415 | // Receiver Clock
|
---|
416 | // --------------
|
---|
417 | station->setDClk(xyzc[3]);
|
---|
418 |
|
---|
419 | // Tides
|
---|
420 | // -----
|
---|
421 | station->setTideDsplEarth(_tides->earth(time, station->xyzApr()));
|
---|
422 | station->setTideDsplOcean(_tides->ocean(time, station->xyzApr(), station->name()));
|
---|
423 |
|
---|
424 | // Observation model
|
---|
425 | // -----------------
|
---|
426 | vector<t_pppSatObs*>::iterator it = obsVector.begin();
|
---|
427 | while (it != obsVector.end()) {
|
---|
428 | t_pppSatObs* satObs = *it;
|
---|
429 | t_irc modelSetup;
|
---|
430 | if (satObs->isValid()) {
|
---|
431 | modelSetup = satObs->cmpModel(station);
|
---|
432 | }
|
---|
433 | if (satObs->isValid() &&
|
---|
434 | satObs->eleSat() >= _opt->_minEle &&
|
---|
435 | modelSetup == success) {
|
---|
436 | ++it;
|
---|
437 | }
|
---|
438 | else {
|
---|
439 | delete satObs;
|
---|
440 | it = obsVector.erase(it);
|
---|
441 | }
|
---|
442 | }
|
---|
443 |
|
---|
444 | return success;
|
---|
445 | }
|
---|
446 |
|
---|
447 | //
|
---|
448 | //////////////////////////////////////////////////////////////////////////////
|
---|
449 | void t_pppClient::processEpoch(const vector<t_satObs*>& satObs, t_output* output) {
|
---|
450 |
|
---|
451 | try {
|
---|
452 | initOutput(output);
|
---|
453 |
|
---|
454 | // Prepare Observations of the Rover
|
---|
455 | // ---------------------------------
|
---|
456 | if (prepareObs(satObs, _obsRover, _epoTimeRover) != success) {
|
---|
457 | return finish(failure, 1);
|
---|
458 | }
|
---|
459 |
|
---|
460 | for (int iter = 1; iter <= 2; iter++) {
|
---|
461 | ColumnVector xyzc(4); xyzc = 0.0;
|
---|
462 | bool print = (iter == 2);
|
---|
463 | if (cmpBancroft(_epoTimeRover, _obsRover, xyzc, print) != success) {
|
---|
464 | return finish(failure, 2);
|
---|
465 | }
|
---|
466 | if (cmpModel(_staRover, xyzc, _obsRover) != success) {
|
---|
467 | return finish(failure, 3);
|
---|
468 | }
|
---|
469 | }
|
---|
470 | // use observations only if satellite code biases are available
|
---|
471 | /* ------------------------------------------------------------
|
---|
472 | if (!_opt->_corrMount.empty() {
|
---|
473 | useObsWithCodeBiasesOnly(_obsRover);
|
---|
474 | }*/
|
---|
475 |
|
---|
476 | if (int(_obsRover.size()) < _opt->_minObs) {
|
---|
477 | LOG << "t_pppClient::processEpoch not enough observations" << endl;
|
---|
478 | return finish(failure, 4);
|
---|
479 | }
|
---|
480 |
|
---|
481 | // Prepare Pseudo Observations of the Rover
|
---|
482 | // ----------------------------------------
|
---|
483 | _pseudoObsIono = preparePseudoObs(_obsRover);
|
---|
484 |
|
---|
485 | // Store last epoch of data
|
---|
486 | // ------------------------
|
---|
487 | _obsPool->putEpoch(_epoTimeRover, _obsRover, _pseudoObsIono);
|
---|
488 |
|
---|
489 | // Process Epoch in Filter
|
---|
490 | // -----------------------
|
---|
491 | if (_filter->processEpoch(_obsPool) != success) {
|
---|
492 | LOG << "t_pppFilter::processEpoch() != success" << endl;
|
---|
493 | return finish(failure, 5);
|
---|
494 | }
|
---|
495 | }
|
---|
496 | catch (Exception& exc) {
|
---|
497 | LOG << exc.what() << endl;
|
---|
498 | return finish(failure, 6);
|
---|
499 | }
|
---|
500 | catch (t_except msg) {
|
---|
501 | LOG << msg.what() << endl;
|
---|
502 | return finish(failure, 7);
|
---|
503 | }
|
---|
504 | catch (const char* msg) {
|
---|
505 | LOG << msg << endl;
|
---|
506 | return finish(failure, 8);
|
---|
507 | }
|
---|
508 | catch (...) {
|
---|
509 | LOG << "unknown exception" << endl;
|
---|
510 | return finish(failure, 9);
|
---|
511 | }
|
---|
512 | return finish(success, 0);
|
---|
513 | }
|
---|
514 |
|
---|
515 | //
|
---|
516 | ////////////////////////////////////////////////////////////////////////////
|
---|
517 | double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
|
---|
518 | return aa[0]*bb[0] + aa[1]*bb[1] + aa[2]*bb[2] - aa[3]*bb[3];
|
---|
519 | }
|
---|
520 |
|
---|
521 | //
|
---|
522 | ////////////////////////////////////////////////////////////////////////////
|
---|
523 | t_irc t_pppClient::bancroft(const Matrix& BBpass, ColumnVector& pos) {
|
---|
524 |
|
---|
525 | if (pos.Nrows() != 4) {
|
---|
526 | pos.ReSize(4);
|
---|
527 | }
|
---|
528 | pos = 0.0;
|
---|
529 |
|
---|
530 | for (int iter = 1; iter <= 2; iter++) {
|
---|
531 | Matrix BB = BBpass;
|
---|
532 | int mm = BB.Nrows();
|
---|
533 | for (int ii = 1; ii <= mm; ii++) {
|
---|
534 | double xx = BB(ii,1);
|
---|
535 | double yy = BB(ii,2);
|
---|
536 | double traveltime = 0.072;
|
---|
537 | if (iter > 1) {
|
---|
538 | double zz = BB(ii,3);
|
---|
539 | double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
|
---|
540 | (yy-pos(2)) * (yy-pos(2)) +
|
---|
541 | (zz-pos(3)) * (zz-pos(3)) );
|
---|
542 | traveltime = rho / t_CST::c;
|
---|
543 | }
|
---|
544 | double angle = traveltime * t_CST::omega;
|
---|
545 | double cosa = cos(angle);
|
---|
546 | double sina = sin(angle);
|
---|
547 | BB(ii,1) = cosa * xx + sina * yy;
|
---|
548 | BB(ii,2) = -sina * xx + cosa * yy;
|
---|
549 | }
|
---|
550 |
|
---|
551 | Matrix BBB;
|
---|
552 | if (mm > 4) {
|
---|
553 | SymmetricMatrix hlp; hlp << BB.t() * BB;
|
---|
554 | BBB = hlp.i() * BB.t();
|
---|
555 | }
|
---|
556 | else {
|
---|
557 | BBB = BB.i();
|
---|
558 | }
|
---|
559 | ColumnVector ee(mm); ee = 1.0;
|
---|
560 | ColumnVector alpha(mm); alpha = 0.0;
|
---|
561 | for (int ii = 1; ii <= mm; ii++) {
|
---|
562 | alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
|
---|
563 | }
|
---|
564 | ColumnVector BBBe = BBB * ee;
|
---|
565 | ColumnVector BBBalpha = BBB * alpha;
|
---|
566 | double aa = lorentz(BBBe, BBBe);
|
---|
567 | double bb = lorentz(BBBe, BBBalpha)-1;
|
---|
568 | double cc = lorentz(BBBalpha, BBBalpha);
|
---|
569 | double root = sqrt(bb*bb-aa*cc);
|
---|
570 |
|
---|
571 | Matrix hlpPos(4,2);
|
---|
572 | hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
|
---|
573 | hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
|
---|
574 |
|
---|
575 | ColumnVector omc(2);
|
---|
576 | for (int pp = 1; pp <= 2; pp++) {
|
---|
577 | hlpPos(4,pp) = -hlpPos(4,pp);
|
---|
578 | omc(pp) = BB(1,4) -
|
---|
579 | sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
|
---|
580 | (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
|
---|
581 | (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
|
---|
582 | hlpPos(4,pp);
|
---|
583 | }
|
---|
584 | if ( fabs(omc(1)) > fabs(omc(2)) ) {
|
---|
585 | pos = hlpPos.Column(2);
|
---|
586 | }
|
---|
587 | else {
|
---|
588 | pos = hlpPos.Column(1);
|
---|
589 | }
|
---|
590 | }
|
---|
591 | if (pos.size() != 4 ||
|
---|
592 | std::isnan(pos(1)) ||
|
---|
593 | std::isnan(pos(2)) ||
|
---|
594 | std::isnan(pos(3)) ||
|
---|
595 | std::isnan(pos(4))) {
|
---|
596 | return failure;
|
---|
597 | }
|
---|
598 |
|
---|
599 | return success;
|
---|
600 | }
|
---|
601 |
|
---|
602 | //
|
---|
603 | //////////////////////////////////////////////////////////////////////////////
|
---|
604 | void t_pppClient::reset() {cout << "t_pppClient::reset()" << endl;
|
---|
605 |
|
---|
606 | // to delete old orbit and clock corrections
|
---|
607 | delete _ephPool;
|
---|
608 | _ephPool = new t_pppEphPool();
|
---|
609 |
|
---|
610 | // to delete old code biases
|
---|
611 | delete _obsPool;
|
---|
612 | _obsPool = new t_pppObsPool();
|
---|
613 |
|
---|
614 | // to delete all parameters
|
---|
615 | delete _filter;
|
---|
616 | _filter = new t_pppFilter();
|
---|
617 |
|
---|
618 | }
|
---|