| 1 | /* -------------------------------------------------------------------------
|
|---|
| 2 | * BKG NTRIP Client
|
|---|
| 3 | * -------------------------------------------------------------------------
|
|---|
| 4 | *
|
|---|
| 5 | * Class: t_pppSatObs
|
|---|
| 6 | *
|
|---|
| 7 | * Purpose: Satellite observations
|
|---|
| 8 | *
|
|---|
| 9 | * Author: L. Mervart
|
|---|
| 10 | *
|
|---|
| 11 | * Created: 29-Jul-2014
|
|---|
| 12 | *
|
|---|
| 13 | * Changes:
|
|---|
| 14 | *
|
|---|
| 15 | * -----------------------------------------------------------------------*/
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 | #include <iostream>
|
|---|
| 19 | #include <iomanip>
|
|---|
| 20 | #include <cmath>
|
|---|
| 21 | #include <newmatio.h>
|
|---|
| 22 |
|
|---|
| 23 | #include "pppSatObs.h"
|
|---|
| 24 | #include "bncconst.h"
|
|---|
| 25 | #include "pppEphPool.h"
|
|---|
| 26 | #include "pppStation.h"
|
|---|
| 27 | #include "bncutils.h"
|
|---|
| 28 | #include "bncantex.h"
|
|---|
| 29 | #include "pppObsPool.h"
|
|---|
| 30 | #include "pppClient.h"
|
|---|
| 31 |
|
|---|
| 32 | using namespace BNC_PPP;
|
|---|
| 33 | using namespace std;
|
|---|
| 34 |
|
|---|
| 35 | // Constructor
|
|---|
| 36 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 37 | t_pppSatObs::t_pppSatObs(const t_satObs& pppSatObs) {
|
|---|
| 38 | _prn = pppSatObs._prn;
|
|---|
| 39 | _time = pppSatObs._time;
|
|---|
| 40 | _outlier = false;
|
|---|
| 41 | _valid = true;
|
|---|
| 42 | _reference = false;
|
|---|
| 43 | _stecRefSat = 0.0;
|
|---|
| 44 | _stecSat = 0.0;
|
|---|
| 45 | for (unsigned ii = 0; ii < t_frequency::max; ii++) {
|
|---|
| 46 | _obs[ii] = 0;
|
|---|
| 47 | }
|
|---|
| 48 | prepareObs(pppSatObs);
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | // Destructor
|
|---|
| 52 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 53 | t_pppSatObs::~t_pppSatObs() {
|
|---|
| 54 | for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
|
|---|
| 55 | delete _obs[iFreq];
|
|---|
| 56 | }
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | //
|
|---|
| 60 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 61 | void t_pppSatObs::prepareObs(const t_satObs& pppSatObs) {
|
|---|
| 62 |
|
|---|
| 63 | _model.reset();
|
|---|
| 64 |
|
|---|
| 65 | // Select pseudo-ranges and phase observations
|
|---|
| 66 | // -------------------------------------------
|
|---|
| 67 | string preferredAttrib = "G:12&WCPSLX R:12&PC E:1&CBX E:5&QIX C:26&IQX";
|
|---|
| 68 | if (OPT->_obsModelType == OPT->DCMcodeBias ||
|
|---|
| 69 | OPT->_obsModelType == OPT->DCMphaseBias) {
|
|---|
| 70 | // at the moment only one code or phase bias per system (G,R,E,C)/modulation considered,
|
|---|
| 71 | preferredAttrib = "G:12&W R:12&P E:1&CX E:5&QX C:26&I";
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
|
|---|
| 75 | string frqNum = t_frequency::toString(t_frequency::type(iFreq)).substr(1);
|
|---|
| 76 | for (unsigned iPref = 0; iPref < preferredAttrib.length(); iPref++) {
|
|---|
| 77 | string obsType = (preferredAttrib[iPref] == '_') ? frqNum : frqNum + preferredAttrib[iPref];
|
|---|
| 78 | if (_obs[iFreq] == 0) {
|
|---|
| 79 | for (unsigned ii = 0; ii < pppSatObs._obs.size(); ii++) {
|
|---|
| 80 | const t_frqObs* obs = pppSatObs._obs[ii];
|
|---|
| 81 | if (obs->_rnxType2ch == obsType &&
|
|---|
| 82 | obs->_codeValid && obs->_code &&
|
|---|
| 83 | obs->_phaseValid && obs->_phase &&
|
|---|
| 84 | obs->_lockTimeValid && obs->_lockTime > 5.0) {
|
|---|
| 85 | _obs[iFreq] = new t_frqObs(*obs);
|
|---|
| 86 | }
|
|---|
| 87 | }
|
|---|
| 88 | }
|
|---|
| 89 | }
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | // Used frequency types
|
|---|
| 93 | // --------------------
|
|---|
| 94 | _fType1 = t_lc::toFreq(_prn.system(),t_lc::l1);
|
|---|
| 95 | _fType2 = t_lc::toFreq(_prn.system(),t_lc::l2);
|
|---|
| 96 |
|
|---|
| 97 | // Check whether all required frequencies available
|
|---|
| 98 | // ------------------------------------------------
|
|---|
| 99 | for (unsigned ii = 0; ii < OPT->LCs(_prn.system()).size(); ii++) {
|
|---|
| 100 | t_lc::type tLC = OPT->LCs(_prn.system())[ii];
|
|---|
| 101 | if (tLC == t_lc::GIM) {continue;}
|
|---|
| 102 | if (!isValid(tLC)) {
|
|---|
| 103 | _valid = false;
|
|---|
| 104 | return;
|
|---|
| 105 | }
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | // Find GLONASS Channel Number
|
|---|
| 109 | // ---------------------------
|
|---|
| 110 | if (_prn.system() == 'R') {
|
|---|
| 111 | _channel = PPP_CLIENT->ephPool()->getChannel(_prn);
|
|---|
| 112 | }
|
|---|
| 113 | else {
|
|---|
| 114 | _channel = 0;
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | // Compute Satellite Coordinates at Time of Transmission
|
|---|
| 118 | // -----------------------------------------------------
|
|---|
| 119 | _xcSat.ReSize(6); _xcSat = 0.0;
|
|---|
| 120 | _vvSat.ReSize(3); _vvSat = 0.0;
|
|---|
| 121 | bool totOK = false;
|
|---|
| 122 | ColumnVector satPosOld(6); satPosOld = 0.0;
|
|---|
| 123 | t_lc::type tLC = isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
|
|---|
| 124 | double prange = obsValue(tLC);
|
|---|
| 125 | for (int ii = 1; ii <= 10; ii++) {
|
|---|
| 126 | bncTime ToT = _time - prange / t_CST::c - _xcSat[3];
|
|---|
| 127 | if (PPP_CLIENT->ephPool()->getCrd(_prn, ToT, _xcSat, _vvSat) != success) {
|
|---|
| 128 | _valid = false;
|
|---|
| 129 | return;
|
|---|
| 130 | }
|
|---|
| 131 | ColumnVector dx = _xcSat - satPosOld;
|
|---|
| 132 | dx[3] *= t_CST::c;
|
|---|
| 133 | if (dx.NormFrobenius() < 1.e-4) {
|
|---|
| 134 | totOK = true;
|
|---|
| 135 | break;
|
|---|
| 136 | }
|
|---|
| 137 | satPosOld = _xcSat;
|
|---|
| 138 | }
|
|---|
| 139 | if (totOK) {
|
|---|
| 140 | _signalPropagationTime = prange / t_CST::c - _xcSat[3];
|
|---|
| 141 | _model._satClkM = _xcSat[3] * t_CST::c;
|
|---|
| 142 | }
|
|---|
| 143 | else {
|
|---|
| 144 | _valid = false;
|
|---|
| 145 | }
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | //
|
|---|
| 149 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 150 | void t_pppSatObs::lcCoeff(t_lc::type tLC,
|
|---|
| 151 | map<t_frequency::type, double>& codeCoeff,
|
|---|
| 152 | map<t_frequency::type, double>& phaseCoeff,
|
|---|
| 153 | map<t_frequency::type, double>& ionoCoeff) const {
|
|---|
| 154 |
|
|---|
| 155 | codeCoeff.clear();
|
|---|
| 156 | phaseCoeff.clear();
|
|---|
| 157 | ionoCoeff.clear();
|
|---|
| 158 |
|
|---|
| 159 | double f1 = t_CST::freq(_fType1, _channel);
|
|---|
| 160 | double f2 = t_CST::freq(_fType2, _channel);
|
|---|
| 161 | double f1GPS = t_CST::freq(t_frequency::G1, 0);
|
|---|
| 162 |
|
|---|
| 163 | switch (tLC) {
|
|---|
| 164 | case t_lc::l1:
|
|---|
| 165 | phaseCoeff[_fType1] = 1.0;
|
|---|
| 166 | ionoCoeff [_fType1] = -1.0 * pow(f1GPS, 2) / pow(f1, 2);
|
|---|
| 167 | return;
|
|---|
| 168 | case t_lc::l2:
|
|---|
| 169 | phaseCoeff[_fType2] = 1.0;
|
|---|
| 170 | ionoCoeff [_fType2] = -1.0 * pow(f1GPS, 2) / pow(f2, 2);
|
|---|
| 171 | return;
|
|---|
| 172 | case t_lc::lIF:
|
|---|
| 173 | phaseCoeff[_fType1] = f1 * f1 / (f1 * f1 - f2 * f2);
|
|---|
| 174 | phaseCoeff[_fType2] = -f2 * f2 / (f1 * f1 - f2 * f2);
|
|---|
| 175 | return;
|
|---|
| 176 | case t_lc::MW:
|
|---|
| 177 | phaseCoeff[_fType1] = f1 / (f1 - f2);
|
|---|
| 178 | phaseCoeff[_fType2] = -f2 / (f1 - f2);
|
|---|
| 179 | codeCoeff[_fType1] = -f1 / (f1 + f2);
|
|---|
| 180 | codeCoeff[_fType2] = -f2 / (f1 + f2);
|
|---|
| 181 | return;
|
|---|
| 182 | case t_lc::CL:
|
|---|
| 183 | phaseCoeff[_fType1] = 0.5;
|
|---|
| 184 | codeCoeff [_fType1] = 0.5;
|
|---|
| 185 | return;
|
|---|
| 186 | case t_lc::c1:
|
|---|
| 187 | codeCoeff[_fType1] = 1.0;
|
|---|
| 188 | ionoCoeff[_fType1] = pow(f1GPS, 2) / pow(f1, 2);
|
|---|
| 189 | return;
|
|---|
| 190 | case t_lc::c2:
|
|---|
| 191 | codeCoeff[_fType2] = 1.0;
|
|---|
| 192 | ionoCoeff[_fType2] = pow(f1GPS, 2) / pow(f2, 2);
|
|---|
| 193 | return;
|
|---|
| 194 | case t_lc::cIF:
|
|---|
| 195 | codeCoeff[_fType1] = f1 * f1 / (f1 * f1 - f2 * f2);
|
|---|
| 196 | codeCoeff[_fType2] = -f2 * f2 / (f1 * f1 - f2 * f2);
|
|---|
| 197 | return;
|
|---|
| 198 | case t_lc::GIM:
|
|---|
| 199 | case t_lc::dummy:
|
|---|
| 200 | case t_lc::maxLc:
|
|---|
| 201 | return;
|
|---|
| 202 | }
|
|---|
| 203 | }
|
|---|
| 204 |
|
|---|
| 205 | //
|
|---|
| 206 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 207 | bool t_pppSatObs::isValid(t_lc::type tLC) const {
|
|---|
| 208 | bool valid = true;
|
|---|
| 209 | obsValue(tLC, &valid);
|
|---|
| 210 |
|
|---|
| 211 | return valid;
|
|---|
| 212 | }
|
|---|
| 213 | //
|
|---|
| 214 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 215 | double t_pppSatObs::obsValue(t_lc::type tLC, bool* valid) const {
|
|---|
| 216 |
|
|---|
| 217 | double retVal = 0.0;
|
|---|
| 218 | if (valid) *valid = true;
|
|---|
| 219 |
|
|---|
| 220 | // Pseudo observations
|
|---|
| 221 | if (tLC == t_lc::GIM) {
|
|---|
| 222 | if (_stecRefSat == 0.0 || _stecSat == 0.0) {
|
|---|
| 223 | if (valid) *valid = false;
|
|---|
| 224 | return 0.0;
|
|---|
| 225 | }
|
|---|
| 226 | else {
|
|---|
| 227 | return _stecRefSat;
|
|---|
| 228 | }
|
|---|
| 229 | }
|
|---|
| 230 |
|
|---|
| 231 | map<t_frequency::type, double> codeCoeff;
|
|---|
| 232 | map<t_frequency::type, double> phaseCoeff;
|
|---|
| 233 | map<t_frequency::type, double> ionoCoeff;
|
|---|
| 234 | lcCoeff(tLC, codeCoeff, phaseCoeff, ionoCoeff);
|
|---|
| 235 |
|
|---|
| 236 | map<t_frequency::type, double>::const_iterator it;
|
|---|
| 237 |
|
|---|
| 238 | // Code observations
|
|---|
| 239 | for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
|
|---|
| 240 | t_frequency::type tFreq = it->first;
|
|---|
| 241 | if (_obs[tFreq] == 0) {
|
|---|
| 242 | if (valid) *valid = false;
|
|---|
| 243 | return 0.0;
|
|---|
| 244 | }
|
|---|
| 245 | else {
|
|---|
| 246 | retVal += it->second * _obs[tFreq]->_code;
|
|---|
| 247 | }
|
|---|
| 248 | }
|
|---|
| 249 | // Phase observations
|
|---|
| 250 | for (it = phaseCoeff.begin(); it != phaseCoeff.end(); it++) {
|
|---|
| 251 | t_frequency::type tFreq = it->first;
|
|---|
| 252 | if (_obs[tFreq] == 0) {
|
|---|
| 253 | if (valid) *valid = false;
|
|---|
| 254 | return 0.0;
|
|---|
| 255 | }
|
|---|
| 256 | else {
|
|---|
| 257 | retVal += it->second * _obs[tFreq]->_phase * t_CST::lambda(tFreq, _channel);
|
|---|
| 258 | }
|
|---|
| 259 | }
|
|---|
| 260 | return retVal;
|
|---|
| 261 | }
|
|---|
| 262 |
|
|---|
| 263 | //
|
|---|
| 264 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 265 | double t_pppSatObs::lambda(t_lc::type tLC) const {
|
|---|
| 266 |
|
|---|
| 267 | double f1 = t_CST::freq(_fType1, _channel);
|
|---|
| 268 | double f2 = t_CST::freq(_fType2, _channel);
|
|---|
| 269 |
|
|---|
| 270 | if (tLC == t_lc::l1) {
|
|---|
| 271 | return t_CST::c / f1;
|
|---|
| 272 | }
|
|---|
| 273 | else if (tLC == t_lc::l2) {
|
|---|
| 274 | return t_CST::c / f2;
|
|---|
| 275 | }
|
|---|
| 276 | else if (tLC == t_lc::lIF) {
|
|---|
| 277 | return t_CST::c / (f1 + f2);
|
|---|
| 278 | }
|
|---|
| 279 | else if (tLC == t_lc::MW) {
|
|---|
| 280 | return t_CST::c / (f1 - f2);
|
|---|
| 281 | }
|
|---|
| 282 | else if (tLC == t_lc::CL) {
|
|---|
| 283 | return t_CST::c / f1 / 2.0;
|
|---|
| 284 | }
|
|---|
| 285 |
|
|---|
| 286 | return 0.0;
|
|---|
| 287 | }
|
|---|
| 288 |
|
|---|
| 289 | //
|
|---|
| 290 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 291 | double t_pppSatObs::sigma(t_lc::type tLC) const {
|
|---|
| 292 |
|
|---|
| 293 | double retVal = 0.0;
|
|---|
| 294 | map<t_frequency::type, double> codeCoeff;
|
|---|
| 295 | map<t_frequency::type, double> phaseCoeff;
|
|---|
| 296 | map<t_frequency::type, double> ionoCoeff;
|
|---|
| 297 | lcCoeff(tLC, codeCoeff, phaseCoeff, ionoCoeff);
|
|---|
| 298 |
|
|---|
| 299 | if (tLC == t_lc::GIM) {
|
|---|
| 300 | retVal = OPT->_sigmaGIM * OPT->_sigmaGIM + OPT->_sigmaGIM * OPT->_sigmaGIM;
|
|---|
| 301 | }
|
|---|
| 302 |
|
|---|
| 303 | map<t_frequency::type, double>::const_iterator it;
|
|---|
| 304 | for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
|
|---|
| 305 | retVal += it->second * it->second * OPT->_sigmaC1 * OPT->_sigmaC1;
|
|---|
| 306 | }
|
|---|
| 307 |
|
|---|
| 308 | for (it = phaseCoeff.begin(); it != phaseCoeff.end(); it++) {
|
|---|
| 309 | retVal += it->second * it->second * OPT->_sigmaL1 * OPT->_sigmaL1;
|
|---|
| 310 | }
|
|---|
| 311 |
|
|---|
| 312 | retVal = sqrt(retVal);
|
|---|
| 313 |
|
|---|
| 314 | // De-Weight measurements
|
|---|
| 315 | // ----------------------
|
|---|
| 316 | if (_prn.system() == 'R' ) {
|
|---|
| 317 | if (t_lc::includesCode(tLC)) {
|
|---|
| 318 | retVal *= 100.0;
|
|---|
| 319 | }
|
|---|
| 320 | }
|
|---|
| 321 |
|
|---|
| 322 | // Elevation-Dependent Weighting
|
|---|
| 323 | // -----------------------------
|
|---|
| 324 | double cEle = 1.0;
|
|---|
| 325 | if ( (OPT->_eleWgtCode && t_lc::includesCode(tLC)) ||
|
|---|
| 326 | (OPT->_eleWgtPhase && t_lc::includesPhase(tLC)) ) {
|
|---|
| 327 | double eleD = eleSat()*180.0/M_PI;
|
|---|
| 328 | double hlp = fabs(90.0 - eleD);
|
|---|
| 329 | cEle = (1.0 + hlp*hlp*hlp*0.000004);
|
|---|
| 330 | }
|
|---|
| 331 |
|
|---|
| 332 | return cEle * retVal;
|
|---|
| 333 | }
|
|---|
| 334 |
|
|---|
| 335 | //
|
|---|
| 336 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 337 | double t_pppSatObs::maxRes(t_lc::type tLC) const {
|
|---|
| 338 | double retVal = 0.0;
|
|---|
| 339 |
|
|---|
| 340 | map<t_frequency::type, double> codeCoeff;
|
|---|
| 341 | map<t_frequency::type, double> phaseCoeff;
|
|---|
| 342 | map<t_frequency::type, double> ionoCoeff;
|
|---|
| 343 | lcCoeff(tLC, codeCoeff, phaseCoeff, ionoCoeff);
|
|---|
| 344 |
|
|---|
| 345 | map<t_frequency::type, double>::const_iterator it;
|
|---|
| 346 | for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
|
|---|
| 347 | retVal += it->second * it->second * OPT->_maxResC1 * OPT->_maxResC1;
|
|---|
| 348 | }
|
|---|
| 349 | for (it = phaseCoeff.begin(); it != phaseCoeff.end(); it++) {
|
|---|
| 350 | retVal += it->second * it->second * OPT->_maxResL1 * OPT->_maxResL1;
|
|---|
| 351 | }
|
|---|
| 352 | if (tLC == t_lc::GIM) {
|
|---|
| 353 | retVal = OPT->_maxResGIM * OPT->_maxResGIM + OPT->_maxResGIM * OPT->_maxResGIM;
|
|---|
| 354 | }
|
|---|
| 355 |
|
|---|
| 356 | retVal = sqrt(retVal);
|
|---|
| 357 |
|
|---|
| 358 | if (_prn.system() == 'R' && t_lc::includesCode(tLC)) {
|
|---|
| 359 | retVal *= 2.0;
|
|---|
| 360 | }
|
|---|
| 361 |
|
|---|
| 362 | return retVal;
|
|---|
| 363 | }
|
|---|
| 364 |
|
|---|
| 365 |
|
|---|
| 366 | //
|
|---|
| 367 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 368 | t_irc t_pppSatObs::cmpModel(const t_pppStation* station) {
|
|---|
| 369 |
|
|---|
| 370 | // Reset all model values
|
|---|
| 371 | // ----------------------
|
|---|
| 372 | _model.reset();
|
|---|
| 373 |
|
|---|
| 374 | // Topocentric Satellite Position
|
|---|
| 375 | // ------------------------------
|
|---|
| 376 | ColumnVector rSat = _xcSat.Rows(1,3);
|
|---|
| 377 | ColumnVector rRec = station->xyzApr();
|
|---|
| 378 | ColumnVector rhoV = rSat - rRec;
|
|---|
| 379 | _model._rho = rhoV.NormFrobenius();
|
|---|
| 380 |
|
|---|
| 381 | ColumnVector vSat = _vvSat;
|
|---|
| 382 |
|
|---|
| 383 | ColumnVector neu(3);
|
|---|
| 384 | xyz2neu(station->ellApr().data(), rhoV.data(), neu.data());
|
|---|
| 385 |
|
|---|
| 386 | _model._eleSat = acos(sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / _model._rho);
|
|---|
| 387 | if (neu[2] < 0) {
|
|---|
| 388 | _model._eleSat *= -1.0;
|
|---|
| 389 | }
|
|---|
| 390 | _model._azSat = atan2(neu[1], neu[0]);
|
|---|
| 391 |
|
|---|
| 392 | // Sun unit vector
|
|---|
| 393 | ColumnVector xSun = t_astro::Sun(_time.mjddec());
|
|---|
| 394 | xSun /= xSun.norm_Frobenius();
|
|---|
| 395 |
|
|---|
| 396 | // Satellite unit vectors sz, sy, sx
|
|---|
| 397 | ColumnVector sz = -rSat / rSat.norm_Frobenius();
|
|---|
| 398 | ColumnVector sy = crossproduct(sz, xSun);
|
|---|
| 399 | ColumnVector sx = crossproduct(sy, sz);
|
|---|
| 400 |
|
|---|
| 401 | sx /= sx.norm_Frobenius();
|
|---|
| 402 | sy /= sy.norm_Frobenius();
|
|---|
| 403 |
|
|---|
| 404 | // LOS unit vector satellite --> receiver
|
|---|
| 405 | ColumnVector rho = rRec - rSat;
|
|---|
| 406 | rho /= rho.norm_Frobenius();
|
|---|
| 407 |
|
|---|
| 408 | // LOS vector in satellite frame
|
|---|
| 409 | ColumnVector u(3);
|
|---|
| 410 | u(1) = dotproduct(sx, rho);
|
|---|
| 411 | u(2) = dotproduct(sy, rho);
|
|---|
| 412 | u(3) = dotproduct(sz, rho);
|
|---|
| 413 |
|
|---|
| 414 | // Azimuth and elevation in satellite antenna frame
|
|---|
| 415 | _model._elTx = atan2(u(3),sqrt(pow(u(2),2)+pow(u(1),2)));
|
|---|
| 416 | _model._azTx = atan2(u(2),u(1));
|
|---|
| 417 |
|
|---|
| 418 |
|
|---|
| 419 | // Satellite Clocks
|
|---|
| 420 | // ----------------
|
|---|
| 421 | _model._satClkM = _xcSat[3] * t_CST::c;
|
|---|
| 422 |
|
|---|
| 423 | // Receiver Clocks
|
|---|
| 424 | // ---------------
|
|---|
| 425 | _model._recClkM = station->dClk() * t_CST::c;
|
|---|
| 426 |
|
|---|
| 427 | // Sagnac Effect (correction due to Earth rotation)
|
|---|
| 428 | // ------------------------------------------------
|
|---|
| 429 | ColumnVector Omega(3);
|
|---|
| 430 | Omega[0] = 0.0;
|
|---|
| 431 | Omega[1] = 0.0;
|
|---|
| 432 | Omega[2] = t_CST::omega / t_CST::c;
|
|---|
| 433 | _model._sagnac = DotProduct(Omega, crossproduct(rSat, rRec));
|
|---|
| 434 |
|
|---|
| 435 | // Antenna Eccentricity
|
|---|
| 436 | // --------------------
|
|---|
| 437 | _model._antEcc = -DotProduct(station->xyzEcc(), rhoV) / _model._rho;
|
|---|
| 438 |
|
|---|
| 439 | // Antenna Phase Center Offsets and Variations
|
|---|
| 440 | // -------------------------------------------
|
|---|
| 441 | if (PPP_CLIENT->antex()) {
|
|---|
| 442 | for (unsigned ii = 0; ii < t_frequency::max; ii++) {
|
|---|
| 443 | t_frequency::type frqType = static_cast<t_frequency::type>(ii);
|
|---|
| 444 | bool found;
|
|---|
| 445 | QString prn(_prn.toString().c_str());
|
|---|
| 446 | _model._antPCO[ii] = PPP_CLIENT->antex()->rcvCorr(station->antName(), frqType, _model._eleSat, _model._azSat, found);
|
|---|
| 447 | _model._antPCO[ii] += PPP_CLIENT->antex()->satCorr(prn, frqType, _model._elTx, _model._azTx, found);
|
|---|
| 448 | if (OPT->_isAPC && found) {
|
|---|
| 449 | // the PCOs as given in the satellite antenna correction for all frequencies
|
|---|
| 450 | // have to be reduced by the PCO of the reference frequency
|
|---|
| 451 | if (_prn.system() == 'G') {
|
|---|
| 452 | _model._antPCO[ii] -= PPP_CLIENT->antex()->satCorr(prn, t_frequency::G1, _model._elTx, _model._azTx, found);
|
|---|
| 453 | }
|
|---|
| 454 | else if (_prn.system() == 'R') {
|
|---|
| 455 | _model._antPCO[ii] -= PPP_CLIENT->antex()->satCorr(prn, t_frequency::R1, _model._elTx, _model._azTx, found);
|
|---|
| 456 | }
|
|---|
| 457 | else if (_prn.system() == 'E') {
|
|---|
| 458 | _model._antPCO[ii] -= PPP_CLIENT->antex()->satCorr(prn, t_frequency::E1, _model._elTx, _model._azTx, found);
|
|---|
| 459 | }
|
|---|
| 460 | else if (_prn.system() == 'C') {
|
|---|
| 461 | _model._antPCO[ii] -= PPP_CLIENT->antex()->satCorr(prn, t_frequency::C2, _model._elTx, _model._azTx, found);
|
|---|
| 462 | }
|
|---|
| 463 | }
|
|---|
| 464 | }
|
|---|
| 465 | }
|
|---|
| 466 |
|
|---|
| 467 | // Tropospheric Delay
|
|---|
| 468 | // ------------------
|
|---|
| 469 | _model._tropo = t_tropo::delay_saast(rRec, _model._eleSat);
|
|---|
| 470 |
|
|---|
| 471 | // Code Biases
|
|---|
| 472 | // -----------
|
|---|
| 473 | const t_satCodeBias* satCodeBias = PPP_CLIENT->obsPool()->satCodeBias(_prn);
|
|---|
| 474 | if (satCodeBias) {
|
|---|
| 475 | for (unsigned ii = 0; ii < satCodeBias->_bias.size(); ii++) {
|
|---|
| 476 | const t_frqCodeBias& bias = satCodeBias->_bias[ii];
|
|---|
| 477 | for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
|
|---|
| 478 | const t_frqObs* obs = _obs[iFreq];
|
|---|
| 479 | if (obs && obs->_rnxType2ch == bias._rnxType2ch) {
|
|---|
| 480 | _model._codeBias[iFreq] = bias._value;
|
|---|
| 481 | }
|
|---|
| 482 | }
|
|---|
| 483 | }
|
|---|
| 484 | }
|
|---|
| 485 |
|
|---|
| 486 | // Phase Biases
|
|---|
| 487 | // -----------
|
|---|
| 488 | const t_satPhaseBias* satPhaseBias = PPP_CLIENT->obsPool()->satPhaseBias(_prn);
|
|---|
| 489 | double yaw = 0.0;
|
|---|
| 490 | bool ssr = false;
|
|---|
| 491 | if (satPhaseBias) {
|
|---|
| 492 | double dt = station->epochTime() - satPhaseBias->_time;
|
|---|
| 493 | if (satPhaseBias->_updateInt) {
|
|---|
| 494 | dt -= (0.5 * ssrUpdateInt[satPhaseBias->_updateInt]);
|
|---|
| 495 | }
|
|---|
| 496 | yaw = satPhaseBias->_yaw + satPhaseBias->_yawRate * dt;
|
|---|
| 497 | ssr = true;
|
|---|
| 498 | for (unsigned ii = 0; ii < satPhaseBias->_bias.size(); ii++) {
|
|---|
| 499 | const t_frqPhaseBias& bias = satPhaseBias->_bias[ii];
|
|---|
| 500 | for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
|
|---|
| 501 | const t_frqObs* obs = _obs[iFreq];
|
|---|
| 502 | if (obs && obs->_rnxType2ch == bias._rnxType2ch) {
|
|---|
| 503 | _model._phaseBias[iFreq] = bias._value;
|
|---|
| 504 | }
|
|---|
| 505 | }
|
|---|
| 506 | }
|
|---|
| 507 | }
|
|---|
| 508 |
|
|---|
| 509 | // Phase Wind-Up
|
|---|
| 510 | // -------------
|
|---|
| 511 | _model._windUp = station->windUp(_time, _prn, rSat, ssr, yaw, vSat) ;
|
|---|
| 512 |
|
|---|
| 513 | // Relativistic effect due to earth gravity
|
|---|
| 514 | // ----------------------------------------
|
|---|
| 515 | double a = rSat.NormFrobenius() + rRec.NormFrobenius();
|
|---|
| 516 | double b = (rSat - rRec).NormFrobenius();
|
|---|
| 517 | double gm = 3.986004418e14; // m3/s2
|
|---|
| 518 | _model._rel = 2 * gm / t_CST::c / t_CST::c * log((a + b) / (a - b));
|
|---|
| 519 |
|
|---|
| 520 | // Tidal Correction
|
|---|
| 521 | // ----------------
|
|---|
| 522 | _model._tideEarth = -DotProduct(station->tideDsplEarth(), rhoV) / _model._rho;
|
|---|
| 523 | _model._tideOcean = -DotProduct(station->tideDsplOcean(), rhoV) / _model._rho;
|
|---|
| 524 |
|
|---|
| 525 | // Ionospheric Delay
|
|---|
| 526 | // -----------------
|
|---|
| 527 | const t_vTec* vTec = PPP_CLIENT->obsPool()->vTec();
|
|---|
| 528 | bool vTecUsage = true;
|
|---|
| 529 | for (unsigned ii = 0; ii < OPT->LCs(_prn.system()).size(); ii++) {
|
|---|
| 530 | t_lc::type tLC = OPT->LCs(_prn.system())[ii];
|
|---|
| 531 | if (tLC == t_lc::cIF || tLC == t_lc::lIF) {
|
|---|
| 532 | vTecUsage = false;
|
|---|
| 533 | }
|
|---|
| 534 | }
|
|---|
| 535 |
|
|---|
| 536 | if (vTecUsage && vTec) {
|
|---|
| 537 | double stec = station->stec(vTec, _signalPropagationTime, rSat);
|
|---|
| 538 | double f1GPS = t_CST::freq(t_frequency::G1, 0);
|
|---|
| 539 | for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
|
|---|
| 540 | if (OPT->_pseudoObsIono) { // DCMcodeBias, DCMphaseBias
|
|---|
| 541 | // For scaling the slant ionospheric delays the trick is to be consistent with units!
|
|---|
| 542 | // The conversion of TECU into meters requires the frequency of the signal.
|
|---|
| 543 | // Hence, GPS L1 frequency is used for all systems. The same is true for mu_i in lcCoeff().
|
|---|
| 544 | _model._ionoCodeDelay[iFreq] = 40.3E16 / pow(f1GPS, 2) * stec;
|
|---|
| 545 | }
|
|---|
| 546 | else { // PPP-RTK
|
|---|
| 547 | t_frequency::type frqType = static_cast<t_frequency::type>(iFreq);
|
|---|
| 548 | _model._ionoCodeDelay[iFreq] = 40.3E16 / pow(t_CST::freq(frqType, _channel), 2) * stec;
|
|---|
| 549 | }
|
|---|
| 550 | }
|
|---|
| 551 | }
|
|---|
| 552 |
|
|---|
| 553 | // Set Model Set Flag
|
|---|
| 554 | // ------------------
|
|---|
| 555 | _model._set = true;
|
|---|
| 556 |
|
|---|
| 557 | //printModel();
|
|---|
| 558 |
|
|---|
| 559 | return success;
|
|---|
| 560 | }
|
|---|
| 561 |
|
|---|
| 562 | //
|
|---|
| 563 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 564 | void t_pppSatObs::printModel() const {
|
|---|
| 565 |
|
|---|
| 566 | LOG.setf(ios::fixed);
|
|---|
| 567 | LOG << "\nMODEL for Satellite " << _prn.toString() << (isReference() ? " (Reference Satellite)" : "")
|
|---|
| 568 |
|
|---|
| 569 | << "======================= " << endl
|
|---|
| 570 | << "PPP STRATEGY : " << OPT->_obsmodelTypeStr.at((int)OPT->_obsModelType).toLocal8Bit().constData()
|
|---|
| 571 | << ((OPT->_pseudoObsIono) ? " with pseudo-observations for STEC" : "") << endl
|
|---|
| 572 | << "RHO : " << setw(12) << setprecision(3) << _model._rho << endl
|
|---|
| 573 | << "ELE : " << setw(12) << setprecision(3) << _model._eleSat * RHO_DEG << endl
|
|---|
| 574 | << "AZI : " << setw(12) << setprecision(3) << _model._azSat * RHO_DEG << endl
|
|---|
| 575 | << "SATCLK : " << setw(12) << setprecision(3) << _model._satClkM << endl
|
|---|
| 576 | << "RECCLK : " << setw(12) << setprecision(3) << _model._recClkM << endl
|
|---|
| 577 | << "SAGNAC : " << setw(12) << setprecision(3) << _model._sagnac << endl
|
|---|
| 578 | << "ANTECC : " << setw(12) << setprecision(3) << _model._antEcc << endl
|
|---|
| 579 | << "TROPO : " << setw(12) << setprecision(3) << _model._tropo << endl
|
|---|
| 580 | << "WINDUP : " << setw(12) << setprecision(3) << _model._windUp << endl
|
|---|
| 581 | << "REL : " << setw(12) << setprecision(3) << _model._rel << endl
|
|---|
| 582 | << "EARTH TIDES : " << setw(12) << setprecision(3) << _model._tideEarth << endl
|
|---|
| 583 | << "OCEAN TIDES : " << setw(12) << setprecision(3) << _model._tideOcean << endl
|
|---|
| 584 | << endl
|
|---|
| 585 | << "FREQUENCY DEPENDENT CORRECTIONS:" << endl
|
|---|
| 586 | << "-------------------------------" << endl;
|
|---|
| 587 | for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
|
|---|
| 588 | if (_obs[iFreq]) {
|
|---|
| 589 | string frqStr = t_frequency::toString(t_frequency::type(iFreq));
|
|---|
| 590 | if (_prn.system() == frqStr[0]) {
|
|---|
| 591 | LOG << "PCO : " << frqStr << setw(12) << setprecision(3) << _model._antPCO[iFreq] << endl
|
|---|
| 592 | << "BIAS CODE : " << frqStr << setw(12) << setprecision(3) << _model._codeBias[iFreq] << endl
|
|---|
| 593 | << "BIAS PHASE : " << frqStr << setw(12) << setprecision(3) << _model._phaseBias[iFreq] << endl
|
|---|
| 594 | << "IONO CODEDELAY: " << frqStr << setw(12) << setprecision(3) << _model._ionoCodeDelay[iFreq]<< endl;
|
|---|
| 595 | }
|
|---|
| 596 | }
|
|---|
| 597 | }
|
|---|
| 598 | }
|
|---|
| 599 |
|
|---|
| 600 | //
|
|---|
| 601 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 602 | void t_pppSatObs::printObsMinusComputed() const {
|
|---|
| 603 | // TODO: cout should be LOG
|
|---|
| 604 | cout.setf(ios::fixed);
|
|---|
| 605 | cout << "\nOBS-COMP for Satellite " << _prn.toString() << (isReference() ? " (Reference Satellite)" : "") << endl
|
|---|
| 606 | << "========================== " << endl;
|
|---|
| 607 | for (unsigned ii = 0; ii < OPT->LCs(_prn.system()).size(); ii++) {
|
|---|
| 608 | t_lc::type tLC = OPT->LCs(_prn.system())[ii];
|
|---|
| 609 | cout << "OBS-CMP " << setw(4) << t_lc::toString(tLC) << ": " << _prn.toString() << " "
|
|---|
| 610 | << setw(12) << setprecision(3) << obsValue(tLC) << " "
|
|---|
| 611 | << setw(12) << setprecision(3) << cmpValue(tLC) << " "
|
|---|
| 612 | << setw(12) << setprecision(3) << obsValue(tLC) - cmpValue(tLC) << endl;
|
|---|
| 613 | }
|
|---|
| 614 | }
|
|---|
| 615 |
|
|---|
| 616 |
|
|---|
| 617 | //
|
|---|
| 618 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 619 | double t_pppSatObs::cmpValueForBanc(t_lc::type tLC) const {
|
|---|
| 620 | return cmpValue(tLC) - _model._rho - _model._sagnac - _model._recClkM;
|
|---|
| 621 | }
|
|---|
| 622 |
|
|---|
| 623 | //
|
|---|
| 624 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 625 | double t_pppSatObs::cmpValue(t_lc::type tLC) const {
|
|---|
| 626 | double cmpValue;
|
|---|
| 627 |
|
|---|
| 628 | if (!isValid(tLC)) {
|
|---|
| 629 | cmpValue = 0.0;
|
|---|
| 630 | }
|
|---|
| 631 | else if (tLC == t_lc::GIM) {
|
|---|
| 632 | cmpValue = _stecSat;
|
|---|
| 633 | }
|
|---|
| 634 | else {
|
|---|
| 635 | // Non-Dispersive Part
|
|---|
| 636 | // -------------------
|
|---|
| 637 | double nonDisp = _model._rho
|
|---|
| 638 | + _model._recClkM - _model._satClkM
|
|---|
| 639 | + _model._sagnac + _model._antEcc + _model._tropo
|
|---|
| 640 | + _model._tideEarth + _model._tideOcean + _model._rel;
|
|---|
| 641 |
|
|---|
| 642 | // Add Dispersive Part
|
|---|
| 643 | // -------------------
|
|---|
| 644 | double dispPart = 0.0;
|
|---|
| 645 | map<t_frequency::type, double> codeCoeff;
|
|---|
| 646 | map<t_frequency::type, double> phaseCoeff;
|
|---|
| 647 | map<t_frequency::type, double> ionoCoeff;
|
|---|
| 648 | lcCoeff(tLC, codeCoeff, phaseCoeff, ionoCoeff);
|
|---|
| 649 | map<t_frequency::type, double>::const_iterator it;
|
|---|
| 650 | for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
|
|---|
| 651 | t_frequency::type tFreq = it->first;
|
|---|
| 652 | dispPart += it->second * (_model._antPCO[tFreq] - _model._codeBias[tFreq]);
|
|---|
| 653 | if (OPT->PPPRTK) {
|
|---|
| 654 | dispPart += it->second * (_model._ionoCodeDelay[tFreq]);
|
|---|
| 655 | }
|
|---|
| 656 | }
|
|---|
| 657 | for (it = phaseCoeff.begin(); it != phaseCoeff.end(); it++) {
|
|---|
| 658 | t_frequency::type tFreq = it->first;
|
|---|
| 659 | dispPart += it->second * (_model._antPCO[tFreq] - _model._phaseBias[tFreq] +
|
|---|
| 660 | _model._windUp * t_CST::lambda(tFreq, _channel));
|
|---|
| 661 | if (OPT->PPPRTK) {
|
|---|
| 662 | dispPart += it->second * (- _model._ionoCodeDelay[tFreq]);
|
|---|
| 663 | }
|
|---|
| 664 | }
|
|---|
| 665 | cmpValue = nonDisp + dispPart;
|
|---|
| 666 | }
|
|---|
| 667 |
|
|---|
| 668 | return cmpValue;
|
|---|
| 669 | }
|
|---|
| 670 |
|
|---|
| 671 | //
|
|---|
| 672 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 673 | void t_pppSatObs::setRes(t_lc::type tLC, double res) {
|
|---|
| 674 | _res[tLC] = res;
|
|---|
| 675 | }
|
|---|
| 676 |
|
|---|
| 677 | //
|
|---|
| 678 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 679 | double t_pppSatObs::getRes(t_lc::type tLC) const {
|
|---|
| 680 | map<t_lc::type, double>::const_iterator it = _res.find(tLC);
|
|---|
| 681 | if (it != _res.end()) {
|
|---|
| 682 | return it->second;
|
|---|
| 683 | }
|
|---|
| 684 | else {
|
|---|
| 685 | return 0.0;
|
|---|
| 686 | }
|
|---|
| 687 | }
|
|---|
| 688 |
|
|---|
| 689 | //
|
|---|
| 690 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 691 | void t_pppSatObs::setPseudoObsIono(t_frequency::type freq, double stecRefSat) {
|
|---|
| 692 | _stecSat = _model._ionoCodeDelay[freq];
|
|---|
| 693 | _stecRefSat = stecRefSat;
|
|---|
| 694 | }
|
|---|