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