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

Last change on this file since 10793 was 10791, checked in by mervart, 5 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
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 <algorithm>
22#include <set>
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;
35using namespace std;
36
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 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
61//
62////////////////////////////////////////////////////////////////////////////
63bool t_pppSatObs::isBetter(const t_frqObs* aa, t_frqObs* bb, const string& trkModes) const {
64
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;
84
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;
91 }
92
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;
110 }
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;
118 }
119 }
120 if (_obs[frq] == 0 || isBetter(obs, _obs[frq], trkModes)) {
121 delete _obs[frq];
122 _obs[frq] = new t_frqObs(*obs);
123 }
124 }
125 }
126
127 // Check whether all required frequencies available
128 // ------------------------------------------------
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)) {
136 _valid = false;
137 return;
138 }
139 }
140
141 // Find GLONASS Channel Number
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 // -----------------------------------------------------
152 _xcSat.ReSize(6); _xcSat = 0.0;
153 _vvSat.ReSize(3); _vvSat = 0.0;
154 bool totOK = false;
155 ColumnVector satPosOld(6); satPosOld = 0.0;
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 }
174 }
175 if (!_valid) {
176 return;
177 }
178
179 double prange = obsValue(_rangeLC);
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;
188 if (dx.NormFrobenius() < 1.e-4) {
189 totOK = true;
190 break;
191 }
192 satPosOld = _xcSat;
193 }
194 if (totOK) {
195 _signalPropagationTime = prange / t_CST::c - _xcSat[3];
196 _model._satClkM = _xcSat[3] * t_CST::c;
197 }
198 else {
199 _valid = false;
200 }
201}
202
203//
204////////////////////////////////////////////////////////////////////////////
205void t_pppSatObs::lcCoeff(t_lc LC,
206 map<t_frequency::type, double>& codeCoeff,
207 map<t_frequency::type, double>& phaseCoeff,
208 map<t_frequency::type, double>& ionoCoeff) const {
209
210 codeCoeff.clear();
211 phaseCoeff.clear();
212 ionoCoeff.clear();
213
214 double f1 = t_CST::freq(LC._frq1, _channel);
215 double f2 = t_CST::freq(LC._frq2, _channel);
216 double f1GPS = t_CST::freq(t_frequency::G1, 0);
217
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);
222 return;
223 case t_lc::code:
224 codeCoeff[LC._frq1] = 1.0;
225 ionoCoeff[LC._frq1] = pow(f1GPS, 2) / pow(f1, 2);
226 return;
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);
230 return;
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;
235 case t_lc::MW:
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);
240 return;
241 case t_lc::CL:
242 phaseCoeff[LC._frq1] = 0.5;
243 codeCoeff [LC._frq1] = 0.5;
244 return;
245 case t_lc::GIM:
246 case t_lc::dummy:
247 case t_lc::maxLc:
248 return;
249 }
250}
251
252//
253////////////////////////////////////////////////////////////////////////////
254bool t_pppSatObs::isValid(t_lc LC) const {
255 bool valid = true;
256 obsValue(LC, &valid);
257
258 return valid;
259}
260//
261////////////////////////////////////////////////////////////////////////////
262double t_pppSatObs::obsValue(t_lc LC, bool* valid) const {
263
264 double retVal = 0.0;
265 if (valid) *valid = true;
266
267 // Pseudo observations
268 if (LC._type == t_lc::GIM) {
269 if (_stecSat == 0.0) {
270 if (valid) *valid = false;
271 return 0.0;
272 }
273 else {
274 return _stecSat;
275 }
276 }
277
278 map<t_frequency::type, double> codeCoeff;
279 map<t_frequency::type, double> phaseCoeff;
280 map<t_frequency::type, double> ionoCoeff;
281 lcCoeff(LC, codeCoeff, phaseCoeff, ionoCoeff);
282
283 map<t_frequency::type, double>::const_iterator it;
284
285 // Code observations
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 }
296 // Phase observations
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
310//
311////////////////////////////////////////////////////////////////////////////
312double t_pppSatObs::lambda(t_lc LC) const {
313
314 double f1 = t_CST::freq(LC._frq1, _channel);
315 double f2 = t_CST::freq(LC._frq2, _channel);
316
317 if (LC._type == t_lc::phase) {
318 return t_CST::c / f1;
319 }
320 else if (LC._type == t_lc::phaseIF) {
321 return t_CST::c / (f1 + f2);
322 }
323 else if (LC._type == t_lc::MW) {
324 return t_CST::c / (f1 - f2);
325 }
326 else if (LC._type == t_lc::CL) {
327 return t_CST::c / f1 / 2.0;
328 }
329
330 return 0.0;
331}
332
333//
334////////////////////////////////////////////////////////////////////////////
335double t_pppSatObs::sigma(t_lc LC) const {
336
337 double retVal = 0.0;
338 map<t_frequency::type, double> codeCoeff;
339 map<t_frequency::type, double> phaseCoeff;
340 map<t_frequency::type, double> ionoCoeff;
341 lcCoeff(LC, codeCoeff, phaseCoeff, ionoCoeff);
342
343 if (LC._type == t_lc::GIM) {
344 retVal = OPT->_sigmaGIM * OPT->_sigmaGIM;
345 }
346
347 map<t_frequency::type, double>::const_iterator it;
348 for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
349 retVal += it->second * it->second * OPT->_sigmaC1 * OPT->_sigmaC1;
350 }
351
352 for (it = phaseCoeff.begin(); it != phaseCoeff.end(); it++) {
353 retVal += it->second * it->second * OPT->_sigmaL1 * OPT->_sigmaL1;
354 }
355
356 retVal = sqrt(retVal);
357
358 // De-Weight R
359 // -----------
360 if (_prn.system() == 'R'&& LC.includesCode()) {
361 retVal *= 5.0;
362 }
363
364 // Elevation-Dependent Weighting
365 // -----------------------------
366 double cEle = 1.0;
367 if ( (OPT->_eleWgtCode && LC.includesCode()) ||
368 (OPT->_eleWgtPhase && LC.includesPhase()) ) {
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
377//
378////////////////////////////////////////////////////////////////////////////
379double t_pppSatObs::maxRes(t_lc LC) const {
380 double retVal = 0.0;
381
382 map<t_frequency::type, double> codeCoeff;
383 map<t_frequency::type, double> phaseCoeff;
384 map<t_frequency::type, double> ionoCoeff;
385 lcCoeff(LC, codeCoeff, phaseCoeff, ionoCoeff);
386
387 map<t_frequency::type, double>::const_iterator it;
388 for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
389 retVal += it->second * it->second * OPT->_maxResC1 * OPT->_maxResC1;
390 }
391 for (it = phaseCoeff.begin(); it != phaseCoeff.end(); it++) {
392 retVal += it->second * it->second * OPT->_maxResL1 * OPT->_maxResL1;
393 }
394 if (LC._type == t_lc::GIM) {
395 retVal = OPT->_maxResGIM * OPT->_maxResGIM + OPT->_maxResGIM * OPT->_maxResGIM;
396 }
397
398 retVal = sqrt(retVal);
399
400 return retVal;
401}
402
403
404//
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);
415 ColumnVector rRec = station->xyzApr();
416 ColumnVector rhoV = rSat - rRec;
417 _model._rho = rhoV.NormFrobenius();
418
419 ColumnVector vSat = _vvSat;
420
421 ColumnVector neu(3);
422 xyz2neu(station->ellApr().data(), rhoV.data(), neu.data());
423
424 _model._eleSat = acos(sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / _model._rho);
425 if (neu[2] < 0.0) {
426 _model._eleSat *= -1.0;
427 }
428 _model._azSat = atan2(neu[1], neu[0]);
429
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
457 // Satellite Clocks
458 // ----------------
459 _model._satClkM = _xcSat[3] * t_CST::c; // satellite system specific
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;
471 _model._sagnac = DotProduct(Omega, crossproduct(rSat, rRec));
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);
482 string frqStr = t_frequency::toString(frqType);
483 if (frqStr[0] != _prn.system()) {continue;}
484 bool found;
485 QString prn(_prn.toString().c_str());
486 _model._antPCO[ii] = PPP_CLIENT->antex()->rcvCorr(station->antName(), frqType, _model._eleSat, _model._azSat, found);
487 _model._antPCO[ii] += PPP_CLIENT->antex()->satCorr(prn, frqType, _model._elTx, _model._azTx, found);
488 if (OPT->_isAPC && found) {
489 // the PCOs as given in the satellite antenna correction for all frequencies
490 // have to be reduced by the PCO of the respective reference frequency
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 }
504 }
505 }
506
507 // Tropospheric Delay
508 // ------------------
509 _model._tropo = t_tropo::delay_saast(rRec, _model._eleSat);
510
511 // Code Biases
512 // -----------
513 const t_satCodeBias* satCodeBias = PPP_CLIENT->obsPool()->satCodeBias(_prn);
514 if (satCodeBias) {
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++) {
518 string frqStr = t_frequency::toString(t_frequency::type(iFreq));
519 if (frqStr[0] != _prn.system()) {
520 continue;
521 }
522 const t_frqObs* obs = _obs[iFreq];
523 if (obs && obs->_rnxType2ch == bias._rnxType2ch) {
524 _model._codeBias[iFreq] = (bias._value != 0.0 ? bias._value : ZEROVALUE);
525 }
526 }
527 }
528 }
529
530 // Phase Biases
531 // -----------
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]);
541 }
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 }
559 }
560 }
561 }
562 }
563
564 // Phase Wind-Up
565 // -------------
566 _model._windUp = station->windUp(_time, _prn, rSat, useYaw, yaw, vSat) ;
567
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));
574
575 // Tidal Correction
576 // ----------------
577 _model._tideEarth = -DotProduct(station->tideDsplEarth(), rhoV) / _model._rho;
578 _model._tideOcean = -DotProduct(station->tideDsplOcean(), rhoV) / _model._rho;
579
580 // Ionospheric Delay
581 // -----------------
582 const t_vTec* vTec = PPP_CLIENT->obsPool()->vTec();
583 bool vTecUsage = true;
584 for (unsigned ii = 0; ii < OPT->LCs(_prn.system()).size(); ii++) {
585 t_lc LC = OPT->LCs(_prn.system())[ii];
586 if (LC._type == t_lc::codeIF || LC._type == t_lc::phaseIF) {
587 vTecUsage = false;
588 }
589 }
590
591 if (vTecUsage && vTec) {
592 double stec = station->stec(vTec, _signalPropagationTime, rSat);
593 double f1GPS = t_CST::freq(t_frequency::G1, 0);
594 for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
595 if (OPT->_pseudoObsIono) {
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 }
605 }
606 }
607
608 // Set Model Set Flag
609 // ------------------
610 _model._set = true;
611
612 if (OPT->_logMode == t_pppOptions::all) {
613 printModel();
614 }
615
616 return success;
617}
618
619//
620////////////////////////////////////////////////////////////////////////////
621void t_pppSatObs::printModel() const {
622
623 LOG.setf(ios::fixed);
624 LOG << "\nMODEL for Satellite " << _prn.toString() << (isReference() ? " (Reference Satellite)" : "")
625
626 << "\n======================= " << endl
627 << "PPP "
628 << ((OPT->_pseudoObsIono) ? " with pseudo-observations for STEC" : "") << endl
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;
644 for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
645 if (_obs[iFreq]) {
646 string frqStr = t_frequency::toString(t_frequency::type(iFreq));
647 if (_prn.system() == frqStr[0]) {
648 LOG << "PCO : " << frqStr << setw(12) << setprecision(3) << _model._antPCO[iFreq] << endl
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
651 << "IONO CODEDELAY: " << frqStr << setw(12) << setprecision(3) << _model._ionoCodeDelay[iFreq]<< endl;
652 }
653 }
654 }
655}
656
657//
658////////////////////////////////////////////////////////////////////////////
659void t_pppSatObs::printObsMinusComputed() const {
660 LOG.setf(ios::fixed);
661 LOG << "\nOBS-COMP for Satellite " << _prn.toString() << (isReference() ? " (Reference Satellite)" : "") << endl
662 << "========================== " << endl;
663 char sys = _prn.system();
664 for (unsigned ii = 0; ii < OPT->LCs(sys).size(); ii++) {
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;
670 }
671}
672
673//
674////////////////////////////////////////////////////////////////////////////
675double t_pppSatObs::cmpValueForBanc(t_lc LC) const {
676 return cmpValue(LC) - _model._rho - _model._sagnac - _model._recClkM;
677}
678
679//
680////////////////////////////////////////////////////////////////////////////
681double t_pppSatObs::cmpValue(t_lc LC) const {
682 double cmpValue;
683
684 if (!isValid(LC)) {
685 cmpValue = 0.0;
686 }
687 else if (LC._type == t_lc::GIM) {
688 cmpValue = _stecSat;
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;
697
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;
704 lcCoeff(LC, codeCoeff, phaseCoeff, ionoCoeff);
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;
716 }
717
718 return cmpValue;
719}
720
721//
722////////////////////////////////////////////////////////////////////////////
723void t_pppSatObs::setRes(t_lc LC, double res) {
724 _res[LC] = res;
725}
726
727//
728////////////////////////////////////////////////////////////////////////////
729double t_pppSatObs::getRes(t_lc LC) const {
730 map<t_lc, double>::const_iterator it = _res.find(LC);
731 if (it != _res.end()) {
732 return it->second;
733 }
734 else {
735 return 0.0;
736 }
737}
738
739//
740////////////////////////////////////////////////////////////////////////////
741bool t_pppSatObs::setPseudoObsIono(t_frequency::type freq) {
742 bool pseudoObsIono = false;
743 _stecSat = _model._ionoCodeDelay[freq];
744 if (_stecSat) {
745 pseudoObsIono = true;
746 }
747 return pseudoObsIono;
748}
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.