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

Last change on this file since 10878 was 10791, checked in by mervart, 6 months ago

BNC Multifrequency and PPPAR Client (initial version)

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