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