source: ntrip/trunk/BNC/src/PPP/pppSatObs.cpp@ 10230

Last change on this file since 10230 was 10222, checked in by stuerze, 13 months ago

minor changes regarding ppp

  • Property svn:keywords set to Author Date Id Rev URL;svn:eol-style=native
  • Property svn:mime-type set to text/plain
File size: 24.2 KB
RevLine 
[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
32using namespace BNC_PPP;
[9590]33using namespace std;
[7237]34
[10222]35const double GLO_WEIGHT_FACTOR = 3.0;
36const double BDS_WEIGHT_FACTOR = 3.0;
[9821]37
[7237]38// Constructor
39////////////////////////////////////////////////////////////////////////////
40t_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////////////////////////////////////////////////////////////////////////////
60t_pppSatObs::~t_pppSatObs() {
61 for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
62 delete _obs[iFreq];
63 }
64}
65
[7288]66//
[7237]67////////////////////////////////////////////////////////////////////////////
68void 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 &&
[10217]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]183void 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////////////////////////////////////////////////////////////////////////////
240bool 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////////////////////////////////////////////////////////////////////////////
248double 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) {
[10034]255 if (_stecSat == 0.0) {
[8905]256 if (valid) *valid = false;
257 return 0.0;
258 }
259 else {
[10034]260 return _stecSat;
[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////////////////////////////////////////////////////////////////////////////
298double 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////////////////////////////////////////////////////////////////////////////
324double 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) {
[10034]333 retVal = 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
[9821]347 // De-Weight GLO+BDS
348 // -----------------
[10010]349 if (_prn.system() == 'R' && t_lc::includesCode(tLC)) {
[9821]350 retVal *= GLO_WEIGHT_FACTOR;
351 }
[10010]352 if (_prn.system() == 'C' && t_lc::includesCode(tLC)){
[9821]353 retVal *= BDS_WEIGHT_FACTOR;
354 }
355
356
[7237]357 // Elevation-Dependent Weighting
358 // -----------------------------
359 double cEle = 1.0;
360 if ( (OPT->_eleWgtCode && t_lc::includesCode(tLC)) ||
361 (OPT->_eleWgtPhase && t_lc::includesPhase(tLC)) ) {
362 double eleD = eleSat()*180.0/M_PI;
363 double hlp = fabs(90.0 - eleD);
364 cEle = (1.0 + hlp*hlp*hlp*0.000004);
365 }
366
367 return cEle * retVal;
368}
369
[7288]370//
[7237]371////////////////////////////////////////////////////////////////////////////
[9386]372double t_pppSatObs::maxRes(t_lc::type tLC) const {
[8905]373 double retVal = 0.0;
[7237]374
375 map<t_frequency::type, double> codeCoeff;
376 map<t_frequency::type, double> phaseCoeff;
[8905]377 map<t_frequency::type, double> ionoCoeff;
378 lcCoeff(tLC, codeCoeff, phaseCoeff, ionoCoeff);
[7237]379
380 map<t_frequency::type, double>::const_iterator it;
[9473]381 for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
[7237]382 retVal += it->second * it->second * OPT->_maxResC1 * OPT->_maxResC1;
383 }
[9473]384 for (it = phaseCoeff.begin(); it != phaseCoeff.end(); it++) {
[7237]385 retVal += it->second * it->second * OPT->_maxResL1 * OPT->_maxResL1;
386 }
[8905]387 if (tLC == t_lc::GIM) {
[9553]388 retVal = OPT->_maxResGIM * OPT->_maxResGIM + OPT->_maxResGIM * OPT->_maxResGIM;
[8905]389 }
[9386]390
391 retVal = sqrt(retVal);
[9537]392
[10222]393
394 // Enlarge maxRes GLO+BDS
395 // ----------------------
396 if (_prn.system() == 'R' && t_lc::includesCode(tLC)) {
397 retVal *= GLO_WEIGHT_FACTOR;
398 }
399 if (_prn.system() == 'C' && t_lc::includesCode(tLC)){
400 retVal *= BDS_WEIGHT_FACTOR;
401 }
402
[9561]403 return retVal;
[7237]404}
405
406
[7288]407//
[7237]408////////////////////////////////////////////////////////////////////////////
409t_irc t_pppSatObs::cmpModel(const t_pppStation* station) {
410
411 // Reset all model values
412 // ----------------------
413 _model.reset();
414
415 // Topocentric Satellite Position
416 // ------------------------------
417 ColumnVector rSat = _xcSat.Rows(1,3);
[8905]418 ColumnVector rRec = station->xyzApr();
419 ColumnVector rhoV = rSat - rRec;
420 _model._rho = rhoV.NormFrobenius();
[7237]421
[8619]422 ColumnVector vSat = _vvSat;
423
[7237]424 ColumnVector neu(3);
425 xyz2neu(station->ellApr().data(), rhoV.data(), neu.data());
426
[8905]427 _model._eleSat = acos(sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / _model._rho);
[10219]428 if (neu[2] < 0.0) {
[7237]429 _model._eleSat *= -1.0;
430 }
431 _model._azSat = atan2(neu[1], neu[0]);
432
[9485]433 // Sun unit vector
434 ColumnVector xSun = t_astro::Sun(_time.mjddec());
435 xSun /= xSun.norm_Frobenius();
436
437 // Satellite unit vectors sz, sy, sx
438 ColumnVector sz = -rSat / rSat.norm_Frobenius();
439 ColumnVector sy = crossproduct(sz, xSun);
440 ColumnVector sx = crossproduct(sy, sz);
441
442 sx /= sx.norm_Frobenius();
443 sy /= sy.norm_Frobenius();
444
445 // LOS unit vector satellite --> receiver
446 ColumnVector rho = rRec - rSat;
447 rho /= rho.norm_Frobenius();
448
449 // LOS vector in satellite frame
450 ColumnVector u(3);
451 u(1) = dotproduct(sx, rho);
452 u(2) = dotproduct(sy, rho);
453 u(3) = dotproduct(sz, rho);
454
455 // Azimuth and elevation in satellite antenna frame
456 _model._elTx = atan2(u(3),sqrt(pow(u(2),2)+pow(u(1),2)));
457 _model._azTx = atan2(u(2),u(1));
458
459
[7237]460 // Satellite Clocks
461 // ----------------
462 _model._satClkM = _xcSat[3] * t_CST::c;
463
464 // Receiver Clocks
465 // ---------------
466 _model._recClkM = station->dClk() * t_CST::c;
467
468 // Sagnac Effect (correction due to Earth rotation)
469 // ------------------------------------------------
470 ColumnVector Omega(3);
471 Omega[0] = 0.0;
472 Omega[1] = 0.0;
473 Omega[2] = t_CST::omega / t_CST::c;
[8905]474 _model._sagnac = DotProduct(Omega, crossproduct(rSat, rRec));
[7237]475
476 // Antenna Eccentricity
477 // --------------------
478 _model._antEcc = -DotProduct(station->xyzEcc(), rhoV) / _model._rho;
479
480 // Antenna Phase Center Offsets and Variations
481 // -------------------------------------------
482 if (PPP_CLIENT->antex()) {
483 for (unsigned ii = 0; ii < t_frequency::max; ii++) {
484 t_frequency::type frqType = static_cast<t_frequency::type>(ii);
[9598]485 string frqStr = t_frequency::toString(frqType);
486 if (frqStr[0] != _prn.system()) {continue;}
[7237]487 bool found;
[9485]488 QString prn(_prn.toString().c_str());
489 _model._antPCO[ii] = PPP_CLIENT->antex()->rcvCorr(station->antName(), frqType, _model._eleSat, _model._azSat, found);
[9593]490 _model._antPCO[ii] += PPP_CLIENT->antex()->satCorr(prn, frqType, _model._elTx, _model._azTx, found);
[9560]491 if (OPT->_isAPC && found) {
[9485]492 // the PCOs as given in the satellite antenna correction for all frequencies
[9807]493 // have to be reduced by the PCO of the respective reference frequency
[9485]494 if (_prn.system() == 'G') {
495 _model._antPCO[ii] -= PPP_CLIENT->antex()->satCorr(prn, t_frequency::G1, _model._elTx, _model._azTx, found);
496 }
497 else if (_prn.system() == 'R') {
498 _model._antPCO[ii] -= PPP_CLIENT->antex()->satCorr(prn, t_frequency::R1, _model._elTx, _model._azTx, found);
499 }
500 else if (_prn.system() == 'E') {
501 _model._antPCO[ii] -= PPP_CLIENT->antex()->satCorr(prn, t_frequency::E1, _model._elTx, _model._azTx, found);
502 }
503 else if (_prn.system() == 'C') {
504 _model._antPCO[ii] -= PPP_CLIENT->antex()->satCorr(prn, t_frequency::C2, _model._elTx, _model._azTx, found);
505 }
506 }
[7237]507 }
508 }
509
510 // Tropospheric Delay
511 // ------------------
[8961]512 _model._tropo = t_tropo::delay_saast(rRec, _model._eleSat);
[7237]513
514 // Code Biases
515 // -----------
516 const t_satCodeBias* satCodeBias = PPP_CLIENT->obsPool()->satCodeBias(_prn);
[7288]517 if (satCodeBias) {
[7237]518 for (unsigned ii = 0; ii < satCodeBias->_bias.size(); ii++) {
519 const t_frqCodeBias& bias = satCodeBias->_bias[ii];
520 for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
[9598]521 string frqStr = t_frequency::toString(t_frequency::type(iFreq));
522 if (frqStr[0] != _prn.system()) {
523 continue;
524 }
[7237]525 const t_frqObs* obs = _obs[iFreq];
526 if (obs && obs->_rnxType2ch == bias._rnxType2ch) {
527 _model._codeBias[iFreq] = bias._value;
528 }
529 }
530 }
531 }
532
[7288]533 // Phase Biases
534 // -----------
535 const t_satPhaseBias* satPhaseBias = PPP_CLIENT->obsPool()->satPhaseBias(_prn);
[8619]536 double yaw = 0.0;
537 bool ssr = false;
[7288]538 if (satPhaseBias) {
[8905]539 double dt = station->epochTime() - satPhaseBias->_time;
540 if (satPhaseBias->_updateInt) {
541 dt -= (0.5 * ssrUpdateInt[satPhaseBias->_updateInt]);
542 }
543 yaw = satPhaseBias->_yaw + satPhaseBias->_yawRate * dt;
[8619]544 ssr = true;
[7288]545 for (unsigned ii = 0; ii < satPhaseBias->_bias.size(); ii++) {
546 const t_frqPhaseBias& bias = satPhaseBias->_bias[ii];
547 for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
[9598]548 string frqStr = t_frequency::toString(t_frequency::type(iFreq));
549 if (frqStr[0] != _prn.system()) {
550 continue;
551 }
[7288]552 const t_frqObs* obs = _obs[iFreq];
553 if (obs && obs->_rnxType2ch == bias._rnxType2ch) {
554 _model._phaseBias[iFreq] = bias._value;
555 }
556 }
557 }
558 }
559
[8619]560 // Phase Wind-Up
561 // -------------
562 _model._windUp = station->windUp(_time, _prn, rSat, ssr, yaw, vSat) ;
563
[8905]564 // Relativistic effect due to earth gravity
565 // ----------------------------------------
566 double a = rSat.NormFrobenius() + rRec.NormFrobenius();
567 double b = (rSat - rRec).NormFrobenius();
568 double gm = 3.986004418e14; // m3/s2
569 _model._rel = 2 * gm / t_CST::c / t_CST::c * log((a + b) / (a - b));
[8619]570
[7237]571 // Tidal Correction
572 // ----------------
[8905]573 _model._tideEarth = -DotProduct(station->tideDsplEarth(), rhoV) / _model._rho;
574 _model._tideOcean = -DotProduct(station->tideDsplOcean(), rhoV) / _model._rho;
[7237]575
576 // Ionospheric Delay
577 // -----------------
[7250]578 const t_vTec* vTec = PPP_CLIENT->obsPool()->vTec();
[7253]579 bool vTecUsage = true;
580 for (unsigned ii = 0; ii < OPT->LCs(_prn.system()).size(); ii++) {
581 t_lc::type tLC = OPT->LCs(_prn.system())[ii];
582 if (tLC == t_lc::cIF || tLC == t_lc::lIF) {
583 vTecUsage = false;
[7237]584 }
585 }
[8905]586
[7258]587 if (vTecUsage && vTec) {
[8905]588 double stec = station->stec(vTec, _signalPropagationTime, rSat);
589 double f1GPS = t_CST::freq(t_frequency::G1, 0);
[7258]590 for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
[10034]591 if (OPT->_pseudoObsIono) {
[8905]592 // For scaling the slant ionospheric delays the trick is to be consistent with units!
593 // The conversion of TECU into meters requires the frequency of the signal.
594 // Hence, GPS L1 frequency is used for all systems. The same is true for mu_i in lcCoeff().
595 _model._ionoCodeDelay[iFreq] = 40.3E16 / pow(f1GPS, 2) * stec;
596 }
597 else { // PPP-RTK
598 t_frequency::type frqType = static_cast<t_frequency::type>(iFreq);
599 _model._ionoCodeDelay[iFreq] = 40.3E16 / pow(t_CST::freq(frqType, _channel), 2) * stec;
600 }
[7253]601 }
602 }
[7237]603
604 // Set Model Set Flag
605 // ------------------
606 _model._set = true;
607
[8956]608 //printModel();
[7252]609
[7237]610 return success;
611}
612
[7288]613//
[7237]614////////////////////////////////////////////////////////////////////////////
615void t_pppSatObs::printModel() const {
[8956]616
617 LOG.setf(ios::fixed);
618 LOG << "\nMODEL for Satellite " << _prn.toString() << (isReference() ? " (Reference Satellite)" : "")
619
[9598]620 << "\n======================= " << endl
[9588]621 << "PPP STRATEGY : " << OPT->_obsmodelTypeStr.at((int)OPT->_obsModelType).toLocal8Bit().constData()
622 << ((OPT->_pseudoObsIono) ? " with pseudo-observations for STEC" : "") << endl
[8905]623 << "RHO : " << setw(12) << setprecision(3) << _model._rho << endl
624 << "ELE : " << setw(12) << setprecision(3) << _model._eleSat * RHO_DEG << endl
625 << "AZI : " << setw(12) << setprecision(3) << _model._azSat * RHO_DEG << endl
626 << "SATCLK : " << setw(12) << setprecision(3) << _model._satClkM << endl
627 << "RECCLK : " << setw(12) << setprecision(3) << _model._recClkM << endl
628 << "SAGNAC : " << setw(12) << setprecision(3) << _model._sagnac << endl
629 << "ANTECC : " << setw(12) << setprecision(3) << _model._antEcc << endl
630 << "TROPO : " << setw(12) << setprecision(3) << _model._tropo << endl
631 << "WINDUP : " << setw(12) << setprecision(3) << _model._windUp << endl
632 << "REL : " << setw(12) << setprecision(3) << _model._rel << endl
633 << "EARTH TIDES : " << setw(12) << setprecision(3) << _model._tideEarth << endl
634 << "OCEAN TIDES : " << setw(12) << setprecision(3) << _model._tideOcean << endl
635 << endl
636 << "FREQUENCY DEPENDENT CORRECTIONS:" << endl
637 << "-------------------------------" << endl;
[7237]638 for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
639 if (_obs[iFreq]) {
[7288]640 string frqStr = t_frequency::toString(t_frequency::type(iFreq));
641 if (_prn.system() == frqStr[0]) {
[8956]642 LOG << "PCO : " << frqStr << setw(12) << setprecision(3) << _model._antPCO[iFreq] << endl
[9598]643 << "BIAS CODE : " << frqStr << setw(12) << setprecision(3) << _model._codeBias[iFreq] << "\t(" << _obs[iFreq]->_rnxType2ch[1] << ") " << endl
644 << "BIAS PHASE : " << frqStr << setw(12) << setprecision(3) << _model._phaseBias[iFreq] << "\t(" << _obs[iFreq]->_rnxType2ch[1] << ") " << endl
[9588]645 << "IONO CODEDELAY: " << frqStr << setw(12) << setprecision(3) << _model._ionoCodeDelay[iFreq]<< endl;
[7288]646 }
[7237]647 }
648 }
[8905]649}
650
651//
652////////////////////////////////////////////////////////////////////////////
653void t_pppSatObs::printObsMinusComputed() const {
[9618]654// TODO: cout should be LOG
655 LOG.setf(ios::fixed);
656 LOG << "\nOBS-COMP for Satellite " << _prn.toString() << (isReference() ? " (Reference Satellite)" : "") << endl
[8905]657 << "========================== " << endl;
[7253]658 for (unsigned ii = 0; ii < OPT->LCs(_prn.system()).size(); ii++) {
659 t_lc::type tLC = OPT->LCs(_prn.system())[ii];
[9618]660 LOG << "OBS-CMP " << setw(4) << t_lc::toString(tLC) << ": " << _prn.toString() << " "
[7253]661 << setw(12) << setprecision(3) << obsValue(tLC) << " "
662 << setw(12) << setprecision(3) << cmpValue(tLC) << " "
663 << setw(12) << setprecision(3) << obsValue(tLC) - cmpValue(tLC) << endl;
664 }
[7237]665}
666
[7288]667//
[7237]668////////////////////////////////////////////////////////////////////////////
669double t_pppSatObs::cmpValueForBanc(t_lc::type tLC) const {
670 return cmpValue(tLC) - _model._rho - _model._sagnac - _model._recClkM;
671}
672
[7288]673//
[7237]674////////////////////////////////////////////////////////////////////////////
675double t_pppSatObs::cmpValue(t_lc::type tLC) const {
[8905]676 double cmpValue;
[7237]677
[8905]678 if (!isValid(tLC)) {
679 cmpValue = 0.0;
[7237]680 }
[8905]681 else if (tLC == t_lc::GIM) {
[8961]682 cmpValue = _stecSat;
[8905]683 }
684 else {
685 // Non-Dispersive Part
686 // -------------------
687 double nonDisp = _model._rho
688 + _model._recClkM - _model._satClkM
689 + _model._sagnac + _model._antEcc + _model._tropo
690 + _model._tideEarth + _model._tideOcean + _model._rel;
[7237]691
[8905]692 // Add Dispersive Part
693 // -------------------
694 double dispPart = 0.0;
695 map<t_frequency::type, double> codeCoeff;
696 map<t_frequency::type, double> phaseCoeff;
697 map<t_frequency::type, double> ionoCoeff;
698 lcCoeff(tLC, codeCoeff, phaseCoeff, ionoCoeff);
699 map<t_frequency::type, double>::const_iterator it;
700 for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
701 t_frequency::type tFreq = it->first;
702 dispPart += it->second * (_model._antPCO[tFreq] - _model._codeBias[tFreq]);
703 if (OPT->PPPRTK) {
704 dispPart += it->second * (_model._ionoCodeDelay[tFreq]);
705 }
706 }
707 for (it = phaseCoeff.begin(); it != phaseCoeff.end(); it++) {
708 t_frequency::type tFreq = it->first;
709 dispPart += it->second * (_model._antPCO[tFreq] - _model._phaseBias[tFreq] +
710 _model._windUp * t_CST::lambda(tFreq, _channel));
711 if (OPT->PPPRTK) {
712 dispPart += it->second * (- _model._ionoCodeDelay[tFreq]);
713 }
714 }
715 cmpValue = nonDisp + dispPart;
[7237]716 }
717
[8905]718 return cmpValue;
[7237]719}
720
[7288]721//
[7237]722////////////////////////////////////////////////////////////////////////////
723void t_pppSatObs::setRes(t_lc::type tLC, double res) {
724 _res[tLC] = res;
725}
726
[7288]727//
[7237]728////////////////////////////////////////////////////////////////////////////
729double t_pppSatObs::getRes(t_lc::type tLC) const {
730 map<t_lc::type, double>::const_iterator it = _res.find(tLC);
731 if (it != _res.end()) {
732 return it->second;
733 }
734 else {
735 return 0.0;
736 }
737}
[8905]738
739//
740////////////////////////////////////////////////////////////////////////////
[10034]741bool t_pppSatObs::setPseudoObsIono(t_frequency::type freq) {
742 bool pseudoObsIono = false;
[8905]743 _stecSat = _model._ionoCodeDelay[freq];
[10034]744 if (_stecSat) {
745 pseudoObsIono = true;
746 }
747 return pseudoObsIono;
[8905]748}
Note: See TracBrowser for help on using the repository browser.