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