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