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