[5683] | 1 |
|
---|
[5740] | 2 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 3 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
| 4 | //
|
---|
| 5 | // Copyright (C) 2007
|
---|
| 6 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 7 | // http://www.bkg.bund.de
|
---|
| 8 | // Czech Technical University Prague, Department of Geodesy
|
---|
| 9 | // http://www.fsv.cvut.cz
|
---|
| 10 | //
|
---|
| 11 | // Email: euref-ip@bkg.bund.de
|
---|
| 12 | //
|
---|
| 13 | // This program is free software; you can redistribute it and/or
|
---|
| 14 | // modify it under the terms of the GNU General Public License
|
---|
| 15 | // as published by the Free Software Foundation, version 2.
|
---|
| 16 | //
|
---|
| 17 | // This program is distributed in the hope that it will be useful,
|
---|
| 18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | // GNU General Public License for more details.
|
---|
| 21 | //
|
---|
| 22 | // You should have received a copy of the GNU General Public License
|
---|
| 23 | // along with this program; if not, write to the Free Software
|
---|
| 24 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 25 |
|
---|
| 26 | /* -------------------------------------------------------------------------
|
---|
| 27 | * BKG NTRIP Client
|
---|
| 28 | * -------------------------------------------------------------------------
|
---|
| 29 | *
|
---|
| 30 | * Class: t_pppClient
|
---|
| 31 | *
|
---|
| 32 | * Purpose: PPP Client processing starts here
|
---|
| 33 | *
|
---|
| 34 | * Author: L. Mervart
|
---|
| 35 | *
|
---|
| 36 | * Created: 29-Jul-2014
|
---|
| 37 | *
|
---|
| 38 | * Changes:
|
---|
| 39 | *
|
---|
| 40 | * -----------------------------------------------------------------------*/
|
---|
| 41 |
|
---|
[5758] | 42 | #include <QThreadStorage>
|
---|
[5740] | 43 |
|
---|
[5683] | 44 | #include <iostream>
|
---|
| 45 | #include <iomanip>
|
---|
| 46 | #include <stdlib.h>
|
---|
| 47 | #include <string.h>
|
---|
| 48 | #include <stdexcept>
|
---|
| 49 |
|
---|
[5734] | 50 | #include "pppClient.h"
|
---|
[5683] | 51 | #include "ephpool.h"
|
---|
| 52 | #include "obspool.h"
|
---|
| 53 | #include "satbias.h"
|
---|
[5740] | 54 | #include "bncconst.h"
|
---|
| 55 | #include "bncutils.h"
|
---|
[5683] | 56 | #include "station.h"
|
---|
[5740] | 57 | #include "bnctides.h"
|
---|
| 58 | #include "bncantex.h"
|
---|
[5683] | 59 | #include "filter.h"
|
---|
| 60 |
|
---|
| 61 | using namespace BNC;
|
---|
| 62 | using namespace std;
|
---|
| 63 |
|
---|
[5758] | 64 | // Global variable holding thread-specific pointers
|
---|
[5683] | 65 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5758] | 66 | QThreadStorage<t_pppClient*> CLIENTS;
|
---|
[5683] | 67 |
|
---|
[5758] | 68 | // Static function returning thread-specific pointer
|
---|
| 69 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 70 | t_pppClient* t_pppClient::instance() {
|
---|
| 71 | return CLIENTS.localData();
|
---|
| 72 | }
|
---|
| 73 |
|
---|
[5683] | 74 | // Constructor
|
---|
| 75 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5761] | 76 | t_pppClient::t_pppClient(const t_options* opt) {
|
---|
[5683] | 77 | _output = 0;
|
---|
[5761] | 78 | _opt = new t_options(*opt);
|
---|
[5683] | 79 | _log = new ostringstream();
|
---|
| 80 | _ephPool = new t_ephPool();
|
---|
| 81 | _obsPool = new t_obsPool();
|
---|
[5740] | 82 | _staRover = new t_station();
|
---|
[5683] | 83 | _filter = new t_filter();
|
---|
[5761] | 84 |
|
---|
| 85 | if (!_opt->_antexFile.empty()) {
|
---|
| 86 | _antex = new bncAntex(_opt->_antexFile.c_str());
|
---|
| 87 | }
|
---|
| 88 | else {
|
---|
| 89 | _antex = 0;
|
---|
| 90 | }
|
---|
| 91 |
|
---|
[5759] | 92 | CLIENTS.setLocalData(this); // CLIENTS takes ownership over "this"
|
---|
[5683] | 93 | }
|
---|
| 94 |
|
---|
| 95 | // Destructor
|
---|
| 96 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5734] | 97 | t_pppClient::~t_pppClient() {
|
---|
[5683] | 98 | delete _log;
|
---|
| 99 | delete _opt;
|
---|
| 100 | delete _ephPool;
|
---|
| 101 | delete _obsPool;
|
---|
| 102 | delete _staRover;
|
---|
| 103 | delete _antex;
|
---|
| 104 | delete _filter;
|
---|
| 105 | clearObs();
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | //
|
---|
| 109 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5734] | 110 | void t_pppClient::putGPSEphemeris(const t_ephGPS* eph) {
|
---|
[5683] | 111 | _ephPool->putEphemeris(new t_ephGPS(*eph));
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | //
|
---|
| 115 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5734] | 116 | void t_pppClient::putGloEphemeris(const t_ephGlo* eph) {
|
---|
[5683] | 117 | _ephPool->putEphemeris(new t_ephGlo(*eph));
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | //
|
---|
| 121 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5769] | 122 | void t_pppClient::putGalEphemeris(const t_ephGal* eph) {
|
---|
| 123 | _ephPool->putEphemeris(new t_ephGal(*eph));
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | //
|
---|
| 127 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5740] | 128 | void t_pppClient::putOrbCorrections(int numCorr, const t_orbCorr* corr) {
|
---|
[5683] | 129 | for (int ii = 0; ii < numCorr; ii++) {
|
---|
| 130 | _ephPool->putOrbCorrection(new t_orbCorr(corr[ii]));
|
---|
| 131 | }
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | //
|
---|
| 135 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5740] | 136 | void t_pppClient::putClkCorrections(int numCorr, const t_clkCorr* corr) {
|
---|
[5683] | 137 | for (int ii = 0; ii < numCorr; ii++) {
|
---|
| 138 | _ephPool->putClkCorrection(new t_clkCorr(corr[ii]));
|
---|
| 139 | }
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | //
|
---|
| 143 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5740] | 144 | void t_pppClient::putBiases(int numBiases, const t_satBiases* biases) {
|
---|
[5683] | 145 | for (int ii = 0; ii < numBiases; ii++) {
|
---|
| 146 | _obsPool->putBiases(new t_satBias(biases[ii]));
|
---|
| 147 | }
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | //
|
---|
| 151 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5740] | 152 | t_irc t_pppClient::prepareObs(int numSat, const t_pppSatObs* satObs,
|
---|
| 153 | vector<t_satObs*>& obsVector, bncTime& epoTime) {
|
---|
[5683] | 154 | // Default
|
---|
| 155 | // -------
|
---|
| 156 | epoTime.reset();
|
---|
| 157 |
|
---|
| 158 | // Create vector of valid observations
|
---|
| 159 | // -----------------------------------
|
---|
| 160 | int numValidGPS = 0;
|
---|
| 161 | for (int ii = 0; ii < numSat; ii++) {
|
---|
[5740] | 162 | char system = satObs[ii]._prn.system();
|
---|
[5683] | 163 | if (system == 'G' || (system == 'R' && OPT->useGlonass())) {
|
---|
| 164 | t_satObs* satObs = new t_satObs(satObs[ii]);
|
---|
| 165 | if (satObs->isValid()) {
|
---|
| 166 | obsVector.push_back(satObs);
|
---|
| 167 | if (satObs->prn().system() == 'G') {
|
---|
| 168 | ++numValidGPS;
|
---|
| 169 | }
|
---|
| 170 | }
|
---|
| 171 | else {
|
---|
| 172 | delete satObs;
|
---|
| 173 | }
|
---|
| 174 | }
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | // Check whether data are synchronized, compute epoTime
|
---|
| 178 | // ----------------------------------------------------
|
---|
| 179 | const double MAXSYNC = 0.05; // synchronization limit
|
---|
| 180 | double meanDt = 0.0;
|
---|
| 181 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
| 182 | const t_satObs* satObs = obsVector.at(ii);
|
---|
| 183 | if (epoTime.undef()) {
|
---|
| 184 | epoTime = satObs->time();
|
---|
| 185 | }
|
---|
| 186 | else {
|
---|
| 187 | double dt = satObs->time() - epoTime;
|
---|
| 188 | if (fabs(dt) > MAXSYNC) {
|
---|
[5734] | 189 | LOG << "t_pppClient::prepareObs asynchronous observations" << endl;
|
---|
[5740] | 190 | return failure;
|
---|
[5683] | 191 | }
|
---|
| 192 | meanDt += dt;
|
---|
| 193 | }
|
---|
| 194 | }
|
---|
| 195 | epoTime += meanDt / obsVector.size();
|
---|
| 196 |
|
---|
[5740] | 197 | return success;
|
---|
[5683] | 198 | }
|
---|
| 199 |
|
---|
| 200 | // Compute the Bancroft position, check for blunders
|
---|
| 201 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5740] | 202 | t_irc t_pppClient::cmpBancroft(const bncTime& epoTime,
|
---|
[5683] | 203 | vector<t_satObs*>& obsVector,
|
---|
| 204 | ColumnVector& xyzc, bool print) {
|
---|
| 205 |
|
---|
| 206 | t_lc::type tLC = (OPT->dualFreqRequired() ? t_lc::cIF : t_lc::c1);
|
---|
| 207 |
|
---|
| 208 | while (true) {
|
---|
| 209 | Matrix BB(obsVector.size(), 4);
|
---|
| 210 | int iObs = -1;
|
---|
| 211 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
| 212 | const t_satObs* satObs = obsVector.at(ii);
|
---|
| 213 | if ( satObs->isValid() && satObs->prn().system() == 'G' &&
|
---|
[5740] | 214 | (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle) ) {
|
---|
[5683] | 215 | ++iObs;
|
---|
| 216 | BB[iObs][0] = satObs->xc()[0];
|
---|
| 217 | BB[iObs][1] = satObs->xc()[1];
|
---|
| 218 | BB[iObs][2] = satObs->xc()[2];
|
---|
| 219 | BB[iObs][3] = satObs->obsValue(tLC) - satObs->cmpValueForBanc(tLC);
|
---|
| 220 | }
|
---|
| 221 | }
|
---|
[5740] | 222 | if (iObs + 1 < OPT->_minObs) {
|
---|
[5734] | 223 | LOG << "t_pppClient::cmpBancroft not enough observations" << endl;
|
---|
[5740] | 224 | return failure;
|
---|
[5683] | 225 | }
|
---|
| 226 | BB = BB.Rows(1,iObs+1);
|
---|
| 227 | bancroft(BB, xyzc);
|
---|
| 228 |
|
---|
[5740] | 229 | xyzc[3] /= t_CST::c;
|
---|
[5683] | 230 |
|
---|
| 231 | // Check Blunders
|
---|
| 232 | // --------------
|
---|
| 233 | const double BLUNDER = 100.0;
|
---|
| 234 | double maxRes = 0.0;
|
---|
| 235 | unsigned maxResIndex = 0;
|
---|
| 236 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
| 237 | const t_satObs* satObs = obsVector.at(ii);
|
---|
| 238 | if ( satObs->isValid() && satObs->prn().system() == 'G' &&
|
---|
[5740] | 239 | (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle) ) {
|
---|
[5683] | 240 | ColumnVector rr = satObs->xc().Rows(1,3) - xyzc.Rows(1,3);
|
---|
| 241 | double res = rr.norm_Frobenius() - satObs->obsValue(tLC)
|
---|
[5740] | 242 | - (satObs->xc()[3] - xyzc[3]) * t_CST::c;
|
---|
[5683] | 243 | if (fabs(res) > maxRes) {
|
---|
| 244 | maxRes = fabs(res);
|
---|
| 245 | maxResIndex = ii;
|
---|
| 246 | }
|
---|
| 247 | }
|
---|
| 248 | }
|
---|
| 249 | if (maxRes < BLUNDER) {
|
---|
| 250 | if (print) {
|
---|
| 251 | LOG.setf(ios::fixed);
|
---|
| 252 | LOG << string(epoTime) << " BANCROFT:" << ' '
|
---|
| 253 | << setw(14) << setprecision(3) << xyzc[0] << ' '
|
---|
| 254 | << setw(14) << setprecision(3) << xyzc[1] << ' '
|
---|
| 255 | << setw(14) << setprecision(3) << xyzc[2] << ' '
|
---|
[5740] | 256 | << setw(14) << setprecision(3) << xyzc[3] * t_CST::c << endl << endl;
|
---|
[5683] | 257 | }
|
---|
| 258 | break;
|
---|
| 259 | }
|
---|
| 260 | else {
|
---|
| 261 | t_satObs* satObs = obsVector.at(maxResIndex);
|
---|
[5734] | 262 | LOG << "t_pppClient::cmpBancroft outlier " << satObs->prn().toString()
|
---|
[5683] | 263 | << " " << maxRes << endl;
|
---|
| 264 | delete satObs;
|
---|
| 265 | obsVector.erase(obsVector.begin() + maxResIndex);
|
---|
| 266 | }
|
---|
| 267 | }
|
---|
| 268 |
|
---|
[5740] | 269 | return success;
|
---|
[5683] | 270 | }
|
---|
| 271 |
|
---|
| 272 | // Compute A Priori GPS-Glonass Offset
|
---|
| 273 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5734] | 274 | double t_pppClient::cmpOffGG(vector<t_satObs*>& obsVector) {
|
---|
[5683] | 275 |
|
---|
| 276 | t_lc::type tLC = (OPT->dualFreqRequired() ? t_lc::cIF : t_lc::c1);
|
---|
| 277 | double offGG = 0.0;
|
---|
| 278 |
|
---|
| 279 | if (OPT->useGlonass()) {
|
---|
| 280 | while (true) {
|
---|
| 281 | offGG = 0.0;
|
---|
| 282 | bool outlierFound = false;
|
---|
| 283 | unsigned nObs = 0;
|
---|
| 284 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
| 285 | t_satObs* satObs = obsVector.at(ii);
|
---|
| 286 | if ( !satObs->outlier() && satObs->isValid() && satObs->prn().system() == 'R' &&
|
---|
[5740] | 287 | (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle) ) {
|
---|
[5683] | 288 | ++nObs;
|
---|
| 289 | double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
|
---|
| 290 | if (fabs(ll) > 1000.0) {
|
---|
| 291 | satObs->setOutlier();
|
---|
| 292 | outlierFound = true;
|
---|
[5734] | 293 | LOG << "t_pppClient::cmpOffGG outlier " << satObs->prn().toString()
|
---|
[5683] | 294 | << " " << ll << endl;
|
---|
| 295 | }
|
---|
| 296 | offGG += ll;
|
---|
| 297 | }
|
---|
| 298 | }
|
---|
| 299 | if (nObs > 0) {
|
---|
| 300 | offGG = offGG / nObs;
|
---|
| 301 | }
|
---|
| 302 | else {
|
---|
| 303 | offGG = 0.0;
|
---|
| 304 | }
|
---|
| 305 | if (!outlierFound) {
|
---|
| 306 | break;
|
---|
| 307 | }
|
---|
| 308 | }
|
---|
| 309 | }
|
---|
| 310 |
|
---|
| 311 | return offGG;
|
---|
| 312 | }
|
---|
| 313 |
|
---|
| 314 | //
|
---|
| 315 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5744] | 316 | void t_pppClient::initOutput(t_output* output) {
|
---|
[5683] | 317 | _output = output;
|
---|
[5740] | 318 | _output->_numSat = 0;
|
---|
| 319 | _output->_pDop = 0.0;
|
---|
| 320 | _output->_error = false;
|
---|
[5683] | 321 | }
|
---|
| 322 |
|
---|
| 323 | //
|
---|
| 324 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5734] | 325 | void t_pppClient::clearObs() {
|
---|
[5683] | 326 | for (unsigned ii = 0; ii < _obsRover.size(); ii++) {
|
---|
| 327 | delete _obsRover.at(ii);
|
---|
| 328 | }
|
---|
| 329 | _obsRover.clear();
|
---|
| 330 | }
|
---|
| 331 |
|
---|
| 332 | //
|
---|
| 333 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5740] | 334 | void t_pppClient::finish(t_irc irc) {
|
---|
[5683] | 335 |
|
---|
| 336 | clearObs();
|
---|
| 337 |
|
---|
[5740] | 338 | _output->_epoTime = _epoTimeRover;
|
---|
[5683] | 339 |
|
---|
[5740] | 340 | if (irc == success) {
|
---|
[5683] | 341 | _output->_xyzRover[0] = _staRover->xyzApr()[0] + _filter->x()[0];
|
---|
| 342 | _output->_xyzRover[1] = _staRover->xyzApr()[1] + _filter->x()[1];
|
---|
| 343 | _output->_xyzRover[2] = _staRover->xyzApr()[2] + _filter->x()[2];
|
---|
| 344 | copy(&_filter->Q().data()[0], &_filter->Q().data()[6], _output->_covMatrix);
|
---|
| 345 | _output->_numSat = _filter->numSat();
|
---|
| 346 | _output->_pDop = _filter->PDOP();
|
---|
| 347 | _output->_error = false;
|
---|
| 348 | }
|
---|
| 349 | else {
|
---|
| 350 | _output->_error = true;
|
---|
| 351 | }
|
---|
[5740] | 352 | _output->_log = _log->str();
|
---|
[5683] | 353 | delete _log; _log = new ostringstream();
|
---|
| 354 | }
|
---|
| 355 |
|
---|
| 356 | //
|
---|
| 357 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5740] | 358 | t_irc t_pppClient::cmpModel(t_station* station, const ColumnVector& xyzc,
|
---|
[5683] | 359 | vector<t_satObs*>& obsVector) {
|
---|
| 360 |
|
---|
[5740] | 361 | bncTime time;
|
---|
| 362 | time = _epoTimeRover;
|
---|
| 363 | station->setName(OPT->_roverName);
|
---|
| 364 | station->setAntName(OPT->_antNameRover);
|
---|
| 365 | if (OPT->xyzAprRoverSet()) {
|
---|
| 366 | station->setXyzApr(OPT->_xyzAprRover);
|
---|
[5683] | 367 | }
|
---|
| 368 | else {
|
---|
[5740] | 369 | station->setXyzApr(xyzc.Rows(1,3));
|
---|
[5683] | 370 | }
|
---|
[5740] | 371 | station->setNeuEcc(OPT->_neuEccRover);
|
---|
[5683] | 372 |
|
---|
| 373 | // Receiver Clock
|
---|
| 374 | // --------------
|
---|
| 375 | station->setDClk(xyzc[3]);
|
---|
| 376 |
|
---|
| 377 | // Tides
|
---|
| 378 | // -----
|
---|
[5740] | 379 | ColumnVector hlp = station->xyzApr();
|
---|
| 380 | tides(time, hlp);
|
---|
| 381 | station->setTideDspl(hlp - station->xyzApr());
|
---|
[5683] | 382 |
|
---|
| 383 | // Observation model
|
---|
| 384 | // -----------------
|
---|
| 385 | vector<t_satObs*>::iterator it = obsVector.begin();
|
---|
| 386 | while (it != obsVector.end()) {
|
---|
| 387 | t_satObs* satObs = *it;
|
---|
| 388 | satObs->cmpModel(station);
|
---|
[5740] | 389 | if (satObs->isValid() && satObs->eleSat() >= OPT->_minEle) {
|
---|
[5683] | 390 | ++it;
|
---|
| 391 | }
|
---|
| 392 | else {
|
---|
| 393 | delete satObs;
|
---|
| 394 | it = obsVector.erase(it);
|
---|
| 395 | }
|
---|
| 396 | }
|
---|
| 397 |
|
---|
[5740] | 398 | return success;
|
---|
[5683] | 399 | }
|
---|
| 400 |
|
---|
| 401 | //
|
---|
| 402 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5734] | 403 | void t_pppClient::processEpoch(int numSatRover, const t_pppSatObs* satObsRover,
|
---|
[5744] | 404 | t_output* output) {
|
---|
[5683] | 405 |
|
---|
| 406 | try {
|
---|
| 407 | initOutput(output);
|
---|
| 408 |
|
---|
| 409 | // Prepare Observations of the Rover
|
---|
| 410 | // ---------------------------------
|
---|
| 411 | if (prepareObs(numSatRover, satObsRover, _obsRover,
|
---|
[5740] | 412 | _epoTimeRover) != success) {
|
---|
| 413 | return finish(failure);
|
---|
[5683] | 414 | }
|
---|
| 415 |
|
---|
| 416 | LOG << "\nResults of Epoch ";
|
---|
| 417 | if (!_epoTimeRover.undef()) LOG << string(_epoTimeRover);
|
---|
| 418 | LOG << "\n--------------------------------------\n";
|
---|
| 419 |
|
---|
| 420 | for (int iter = 1; iter <= 2; iter++) {
|
---|
| 421 | ColumnVector xyzc(4); xyzc = 0.0;
|
---|
| 422 | bool print = (iter == 2);
|
---|
[5740] | 423 | if (cmpBancroft(_epoTimeRover, _obsRover, xyzc, print) != success) {
|
---|
| 424 | return finish(failure);
|
---|
[5683] | 425 | }
|
---|
[5740] | 426 | if (cmpModel(_staRover, xyzc, _obsRover) != success) {
|
---|
| 427 | return finish(failure);
|
---|
[5683] | 428 | }
|
---|
| 429 | }
|
---|
| 430 |
|
---|
| 431 | _offGG = cmpOffGG(_obsRover);
|
---|
| 432 |
|
---|
| 433 | // Store last epoch of data
|
---|
| 434 | // ------------------------
|
---|
| 435 | _obsPool->putEpoch(_epoTimeRover, _obsRover);
|
---|
| 436 |
|
---|
| 437 | // Process Epoch in Filter
|
---|
| 438 | // -----------------------
|
---|
[5740] | 439 | if (_filter->processEpoch(_obsPool) != success) {
|
---|
| 440 | return finish(failure);
|
---|
[5683] | 441 | }
|
---|
| 442 | }
|
---|
| 443 | catch (Exception& exc) {
|
---|
| 444 | LOG << exc.what() << endl;
|
---|
[5740] | 445 | return finish(failure);
|
---|
[5683] | 446 | }
|
---|
[5763] | 447 | catch (pppExcept msg) {
|
---|
| 448 | LOG << msg.what() << endl;
|
---|
[5740] | 449 | return finish(failure);
|
---|
[5683] | 450 | }
|
---|
| 451 | catch (...) {
|
---|
| 452 | LOG << "unknown exception" << endl;
|
---|
[5740] | 453 | return finish(failure);
|
---|
[5683] | 454 | }
|
---|
| 455 |
|
---|
[5740] | 456 | return finish(success);
|
---|
[5683] | 457 | }
|
---|
[5740] | 458 |
|
---|
| 459 | //
|
---|
| 460 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 461 | double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
|
---|
| 462 | return aa[0]*bb[0] + aa[1]*bb[1] + aa[2]*bb[2] - aa[3]*bb[3];
|
---|
| 463 | }
|
---|
| 464 |
|
---|
| 465 | //
|
---|
| 466 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 467 | void t_pppClient::bancroft(const Matrix& BBpass, ColumnVector& pos) {
|
---|
| 468 |
|
---|
| 469 | if (pos.Nrows() != 4) {
|
---|
| 470 | pos.ReSize(4);
|
---|
| 471 | }
|
---|
| 472 | pos = 0.0;
|
---|
| 473 |
|
---|
| 474 | for (int iter = 1; iter <= 2; iter++) {
|
---|
| 475 | Matrix BB = BBpass;
|
---|
| 476 | int mm = BB.Nrows();
|
---|
| 477 | for (int ii = 1; ii <= mm; ii++) {
|
---|
| 478 | double xx = BB(ii,1);
|
---|
| 479 | double yy = BB(ii,2);
|
---|
| 480 | double traveltime = 0.072;
|
---|
| 481 | if (iter > 1) {
|
---|
| 482 | double zz = BB(ii,3);
|
---|
| 483 | double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
|
---|
| 484 | (yy-pos(2)) * (yy-pos(2)) +
|
---|
| 485 | (zz-pos(3)) * (zz-pos(3)) );
|
---|
| 486 | traveltime = rho / t_CST::c;
|
---|
| 487 | }
|
---|
| 488 | double angle = traveltime * t_CST::omega;
|
---|
| 489 | double cosa = cos(angle);
|
---|
| 490 | double sina = sin(angle);
|
---|
| 491 | BB(ii,1) = cosa * xx + sina * yy;
|
---|
| 492 | BB(ii,2) = -sina * xx + cosa * yy;
|
---|
| 493 | }
|
---|
| 494 |
|
---|
| 495 | Matrix BBB;
|
---|
| 496 | if (mm > 4) {
|
---|
| 497 | SymmetricMatrix hlp; hlp << BB.t() * BB;
|
---|
| 498 | BBB = hlp.i() * BB.t();
|
---|
| 499 | }
|
---|
| 500 | else {
|
---|
| 501 | BBB = BB.i();
|
---|
| 502 | }
|
---|
| 503 | ColumnVector ee(mm); ee = 1.0;
|
---|
| 504 | ColumnVector alpha(mm); alpha = 0.0;
|
---|
| 505 | for (int ii = 1; ii <= mm; ii++) {
|
---|
| 506 | alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
|
---|
| 507 | }
|
---|
| 508 | ColumnVector BBBe = BBB * ee;
|
---|
| 509 | ColumnVector BBBalpha = BBB * alpha;
|
---|
| 510 | double aa = lorentz(BBBe, BBBe);
|
---|
| 511 | double bb = lorentz(BBBe, BBBalpha)-1;
|
---|
| 512 | double cc = lorentz(BBBalpha, BBBalpha);
|
---|
| 513 | double root = sqrt(bb*bb-aa*cc);
|
---|
| 514 |
|
---|
| 515 | Matrix hlpPos(4,2);
|
---|
| 516 | hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
|
---|
| 517 | hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
|
---|
| 518 |
|
---|
| 519 | ColumnVector omc(2);
|
---|
| 520 | for (int pp = 1; pp <= 2; pp++) {
|
---|
| 521 | hlpPos(4,pp) = -hlpPos(4,pp);
|
---|
| 522 | omc(pp) = BB(1,4) -
|
---|
| 523 | sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
|
---|
| 524 | (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
|
---|
| 525 | (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
|
---|
| 526 | hlpPos(4,pp);
|
---|
| 527 | }
|
---|
| 528 | if ( fabs(omc(1)) > fabs(omc(2)) ) {
|
---|
| 529 | pos = hlpPos.Column(2);
|
---|
| 530 | }
|
---|
| 531 | else {
|
---|
| 532 | pos = hlpPos.Column(1);
|
---|
| 533 | }
|
---|
| 534 | }
|
---|
| 535 | }
|
---|
| 536 |
|
---|