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