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