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