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