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