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