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

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