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