source: ntrip/trunk/BNC/src/PPP/pppParlist.cpp@ 9545

Last change on this file since 9545 was 9545, checked in by stuerze, 3 years ago

update 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: 27.3 KB
Line 
1/* -------------------------------------------------------------------------
2 * BKG NTRIP Client
3 * -------------------------------------------------------------------------
4 *
5 * Class: t_pppParlist
6 *
7 * Purpose: List of estimated parameters
8 *
9 * Author: L. Mervart
10 *
11 * Created: 29-Jul-2014
12 *
13 * Changes:
14 *
15 * -----------------------------------------------------------------------*/
16
17#include <cmath>
18#include <iostream>
19#include <sstream>
20#include <iomanip>
21#include <algorithm>
22#include <newmatio.h>
23
24#include "pppParlist.h"
25#include "pppSatObs.h"
26#include "pppStation.h"
27#include "bncutils.h"
28#include "bncconst.h"
29#include "pppClient.h"
30
31using namespace BNC_PPP;
32using namespace std;
33
34// Constructor
35////////////////////////////////////////////////////////////////////////////
36t_pppParam::t_pppParam(e_type type, const t_prn& prn, t_lc::type tLC,
37 const vector<t_pppSatObs*>* obsVector) {
38
39 _type = type;
40 _prn = prn;
41 _tLC = tLC;
42 _x0 = 0.0;
43 _indexOld = -1;
44 _indexNew = -1;
45 _noise = 0.0;
46 _ambInfo = 0;
47
48 switch (_type) {
49 case crdX:
50 _epoSpec = false;
51 _sigma0 = OPT->_aprSigCrd[0];
52 _noise = OPT->_noiseCrd[0];
53 break;
54 case crdY:
55 _epoSpec = false;
56 _sigma0 = OPT->_aprSigCrd[1];
57 _noise = OPT->_noiseCrd[1];
58 break;
59 case crdZ:
60 _epoSpec = false;
61 _sigma0 = OPT->_aprSigCrd[2];
62 _noise = OPT->_noiseCrd[2];
63 break;
64 case clkR:
65 _epoSpec = true;
66 _sigma0 = OPT->_aprSigClk;
67 break;
68 case amb:
69 _epoSpec = false;
70 _sigma0 = OPT->_aprSigAmb;
71 _ambInfo = new t_ambInfo();
72 if (obsVector) {
73 for (unsigned ii = 0; ii < obsVector->size(); ii++) {
74 const t_pppSatObs* obs = obsVector->at(ii);
75 if (obs->prn() == _prn) {
76 double offGR = 0;
77 if (_prn.system() == 'R' && tLC != t_lc::MW) {
78 offGR = PPP_CLIENT->offGR();
79 }
80 double offGE = 0;
81 if (_prn.system() == 'E' && tLC != t_lc::MW) {
82 offGE = PPP_CLIENT->offGE();
83 }
84 double offGC = 0;
85 if (_prn.system() == 'C' && tLC != t_lc::MW) {
86 offGC = PPP_CLIENT->offGC();
87 }
88 _x0 = floor((obs->obsValue(tLC) - offGR -offGE - offGC - obs->cmpValue(tLC)) / obs->lambda(tLC) + 0.5);
89 break;
90 }
91 }
92 }
93 break;
94 case offGR:
95 _epoSpec = true;
96 _sigma0 = OPT->_aprSigOGR;
97 _x0 = PPP_CLIENT->offGR();
98 break;
99 case offGE:
100 _epoSpec = true;
101 _sigma0 = OPT->_aprSigOGE;
102 _x0 = PPP_CLIENT->offGE();
103 break;
104 case offGC:
105 _epoSpec = true;
106 _sigma0 = OPT->_aprSigOGC;
107 _x0 = PPP_CLIENT->offGC();
108 break;
109 case trp:
110 _epoSpec = false;
111 _sigma0 = OPT->_aprSigTrp;
112 _noise = OPT->_noiseTrp;
113 break;
114 case ion:
115 _epoSpec = false;
116 _sigma0 = OPT->_aprSigIon;
117 _noise = OPT->_noiseIon;
118 break;
119 case cBiasG1: case cBiasR1: case cBiasE1: case cBiasC1:
120 case cBiasG2: case cBiasR2: case cBiasE2: case cBiasC2:
121 _epoSpec = false;
122 _sigma0 = OPT->_aprSigCodeBias;
123 _noise = OPT->_noiseCodeBias;
124 break;
125 case pBiasG1: case pBiasE1: case pBiasR1: case pBiasC1:
126 case pBiasG2: case pBiasE2: case pBiasR2: case pBiasC2:
127 _epoSpec = false;
128 _sigma0 = OPT->_aprSigPhaseBias;
129 _noise = OPT->_noisePhaseBias;
130 break;
131 }
132}
133
134//
135////////////////////////////////////////////////////////////////////////////
136t_pppParam::t_pppParam(const t_pppParam* old) {
137 _type = old->type();
138 _prn = old->prn();
139 _tLC = old->tLC();
140 _indexOld = old->indexOld();
141 _indexNew = old->indexNew();
142 _noise = old->noise();
143 _sigma0 = old->sigma0();
144 _epoSpec = old->epoSpec();
145 _x0 = old->x0();
146 setFirstObsTime(old->firstObsTime());
147 setLastObsTime(old->lastObsTime());
148 _ambInfo = 0;
149 if (_type == t_pppParam::amb) {
150 _ambInfo = new t_ambInfo();
151 _ambInfo->_resetCandidate = old->_ambInfo->_resetCandidate;
152 _ambInfo->_eleSat = old->_ambInfo->_eleSat;
153 _ambInfo->_numEpo = old->_ambInfo->_numEpo;
154 }
155}
156
157// Destructor
158////////////////////////////////////////////////////////////////////////////
159t_pppParam::~t_pppParam() {
160 if (_ambInfo) {
161 delete _ambInfo;
162 }
163}
164//
165////////////////////////////////////////////////////////////////////////////
166double t_pppParam::partial(const bncTime& /* epoTime */, const t_pppSatObs* obs,
167 const t_lc::type& tLC, const t_prn refPrn) const {
168
169 // Special Case - Melbourne-Wuebbena
170 // ---------------------------------
171 if (tLC == t_lc::MW && _type != amb) {
172 return 0.0;
173 }
174
175 const t_pppStation* sta = PPP_CLIENT->staRover();
176 ColumnVector rhoV = sta->xyzApr() - obs->xc().Rows(1,3);
177
178 map<t_frequency::type, double> codeCoeff;
179 map<t_frequency::type, double> phaseCoeff;
180 map<t_frequency::type, double> ionoCoeff;
181 obs->lcCoeff(tLC, codeCoeff, phaseCoeff, ionoCoeff);
182
183 switch (_type) {
184 case crdX:
185 if (tLC == t_lc::GIM || tLC == t_lc::Tz0) {return 0.0;}
186 return (sta->xyzApr()[0] - obs->xc()[0]) / rhoV.NormFrobenius();
187 case crdY:
188 if (tLC == t_lc::GIM || tLC == t_lc::Tz0) {return 0.0;}
189 return (sta->xyzApr()[1] - obs->xc()[1]) / rhoV.NormFrobenius();
190 case crdZ:
191 if (tLC == t_lc::GIM || tLC == t_lc::Tz0) {return 0.0;}
192 return (sta->xyzApr()[2] - obs->xc()[2]) / rhoV.NormFrobenius();
193 case clkR:
194 if (tLC == t_lc::GIM || tLC == t_lc::Tz0) {return 0.0;}
195 return 1.0;
196 case offGR:
197 if (tLC == t_lc::GIM || tLC == t_lc::Tz0) {return 0.0;}
198 return (obs->prn().system() == 'R') ? 1.0 : 0.0;
199 case offGE:
200 if (tLC == t_lc::GIM || tLC == t_lc::Tz0) {return 0.0;}
201 return (obs->prn().system() == 'E') ? 1.0 : 0.0;
202 case offGC:
203 if (tLC == t_lc::GIM || tLC == t_lc::Tz0) {return 0.0;}
204 return (obs->prn().system() == 'C') ? 1.0 : 0.0;
205 case amb:
206 if (tLC == t_lc::GIM || tLC == t_lc::Tz0) {return 0.0;}
207 else if ((OPT->_obsModelType == OPT->IF) ||
208 (OPT->_obsModelType == OPT->PPPRTK) ||
209 (OPT->_obsModelType == OPT->UncombPPP) ||
210 (OPT->_obsModelType == OPT->DCMcodeBias && !obs->isReference()) ||
211 (OPT->_obsModelType == OPT->DCMphaseBias && !obs->isReference()) ) {
212
213 if (obs->prn() == _prn) {
214 if (tLC == _tLC) {
215 return (obs->lambda(tLC));
216 }
217 else if (tLC == t_lc::lIF && _tLC == t_lc::MW) {
218 return obs->lambda(t_lc::lIF) * obs->lambda(t_lc::MW) / obs->lambda(t_lc::l2);
219 }
220 else {
221 if (_tLC == t_lc::l1) {
222 return obs->lambda(t_lc::l1) * phaseCoeff[t_lc::toFreq(obs->prn().system(),t_lc::l1)];
223 }
224 else if (_tLC == t_lc::l2) {
225 return obs->lambda(t_lc::l2) * phaseCoeff[t_lc::toFreq(obs->prn().system(),t_lc::l2)];
226 }
227 }
228 }
229 }
230 break;
231 case trp:
232 if (tLC == t_lc::GIM) {
233 return 0.0;
234 }
235 else if (tLC == t_lc::Tz0) {
236 return 1.0;
237 }
238 else {
239 return 1.0 / sin(obs->eleSat());
240 }
241 case ion:
242 if (obs->prn() == _prn) {
243 if (tLC == t_lc::c1) {
244 return ionoCoeff[t_lc::toFreq(obs->prn().system(),t_lc::c1)];
245 }
246 else if (tLC == t_lc::c2) {
247 return ionoCoeff[t_lc::toFreq(obs->prn().system(),t_lc::c2)];
248 }
249 else if (tLC == t_lc::l1) {
250 return ionoCoeff[t_lc::toFreq(obs->prn().system(),t_lc::l1)];
251 }
252 else if (tLC == t_lc::l2) {
253 return ionoCoeff[t_lc::toFreq(obs->prn().system(),t_lc::l2)];
254 }
255 else if (tLC == t_lc::GIM) {
256 return -1.0;
257 }
258 }
259 if (tLC == t_lc::GIM && _prn == refPrn) {
260 return 1.0;
261 }
262 break;
263 case cBiasG1:
264 if ((obs->prn().system() == 'G') && (tLC == t_lc::c1)) {return 1.0;} else {return 0.0;}
265 break;
266 case cBiasR1:
267 if ((obs->prn().system() == 'R') && (tLC == t_lc::c1)) {return 1.0;} else {return 0.0;}
268 break;
269 case cBiasE1:
270 if ((obs->prn().system() == 'E') && (tLC == t_lc::c1)) {return 1.0;} else {return 0.0;}
271 break;
272 case cBiasC1:
273 if ((obs->prn().system() == 'C') && (tLC == t_lc::c1)) {return 1.0;} else {return 0.0;}
274 break;
275 case cBiasG2:
276 if ((obs->prn().system() == 'G') && (tLC == t_lc::c2)) {return 1.0;} else {return 0.0;}
277 break;
278 case cBiasR2:
279 if ((obs->prn().system() == 'R') && (tLC == t_lc::c2)) {return 1.0;} else {return 0.0;}
280 break;
281 case cBiasE2:
282 if ((obs->prn().system() == 'E') && (tLC == t_lc::c2)) {return 1.0;} else {return 0.0;}
283 break;
284 case cBiasC2:
285 if ((obs->prn().system() == 'C') && (tLC == t_lc::c2)) {return 1.0;} else {return 0.0;}
286 break;
287 case pBiasG1:
288 if ((obs->prn().system() == 'G') && (tLC == t_lc::l1)) {return 1.0;} else {return 0.0;}
289 break;
290 case pBiasR1:
291 if ((obs->prn().system() == 'R') && (tLC == t_lc::l1)) {return 1.0;} else {return 0.0;}
292 break;
293 case pBiasE1:
294 if ((obs->prn().system() == 'E') && (tLC == t_lc::l1)) {return 1.0;} else {return 0.0;}
295 break;
296 case pBiasC1:
297 if ((obs->prn().system() == 'C') && (tLC == t_lc::l1)) {return 1.0;} else {return 0.0;}
298 break;
299 case pBiasG2:
300 if ((obs->prn().system() == 'G') && (tLC == t_lc::l2)) {return 1.0;} else {return 0.0;}
301 break;
302 case pBiasR2:
303 if ((obs->prn().system() == 'R') && (tLC == t_lc::l2)) {return 1.0;} else {return 0.0;}
304 break;
305 case pBiasE2:
306 if ((obs->prn().system() == 'E') && (tLC == t_lc::l2)) {return 1.0;} else {return 0.0;}
307 break;
308 case pBiasC2:
309 if ((obs->prn().system() == 'C') && (tLC == t_lc::l2)) {return 1.0;} else {return 0.0;}
310 break;
311
312 }
313 return 0.0;
314}
315
316//
317////////////////////////////////////////////////////////////////////////////
318string t_pppParam::toString() const {
319 stringstream ss;
320 switch (_type) {
321 case crdX:
322 ss << "CRD_X";
323 break;
324 case crdY:
325 ss << "CRD_Y";
326 break;
327 case crdZ:
328 ss << "CRD_Z";
329 break;
330 case clkR:
331 ss << "REC_CLK ";
332 break;
333 case offGR:
334 ss << "OGR ";
335 break;
336 case offGE:
337 ss << "OGE ";
338 break;
339 case offGC:
340 ss << "OGC ";
341 break;
342 case trp:
343 ss << "TRP ";
344 break;
345 case amb:
346 ss << "AMB " << left << setw(3) << t_lc::toString(_tLC) << right << ' ' << _prn.toString();
347 break;
348 case ion:
349 ss << "ION " << left << setw(3) << t_lc::toString(_tLC) << right << ' ' << _prn.toString();
350 break;
351 case cBiasG1: case pBiasG1:
352 case cBiasG2: case pBiasG2:
353 ss << "BIA " << left << setw(3) << t_lc::toString(_tLC) << right << " G ";
354 break;
355 case cBiasR1: case pBiasR1:
356 case cBiasR2: case pBiasR2:
357 ss << "BIA " << left << setw(3) << t_lc::toString(_tLC) << right << " R ";
358 break;
359 case cBiasE1: case pBiasE1:
360 case cBiasE2: case pBiasE2:
361 ss << "BIA " << left << setw(3) << t_lc::toString(_tLC) << right << " E ";
362 break;
363 case cBiasC1: case pBiasC1:
364 case cBiasC2: case pBiasC2:
365 ss << "BIA " << left << setw(3) << t_lc::toString(_tLC) << right << " C ";
366 break;
367 }
368 return ss.str();
369}
370
371// Constructor
372////////////////////////////////////////////////////////////////////////////
373t_pppParlist::t_pppParlist() {
374}
375
376// Destructor
377////////////////////////////////////////////////////////////////////////////
378t_pppParlist::~t_pppParlist() {
379 _usedSystems.clear();
380
381 vector<t_pppParam*>::iterator it = _params.begin();
382 while (it != _params.end()) {
383 t_pppParam* par = *it;
384 delete par;
385 it = _params.erase(it);
386 }
387}
388
389//
390////////////////////////////////////////////////////////////////////////////
391t_pppParlist::t_pppParlist(const t_pppParlist& old) {
392
393 _usedSystems = old._usedSystems;
394
395 vector<t_pppParam*>::const_iterator it = old.params().begin();
396 while (it != old.params().end()) {
397 const t_pppParam* oldParam = *it;
398 _params.push_back(new t_pppParam(oldParam));
399 }
400}
401
402//
403////////////////////////////////////////////////////////////////////////////
404const t_pppParlist& t_pppParlist::operator= (const t_pppParlist& p) {
405
406 _usedSystems.clear();
407
408 _usedSystems = p._usedSystems;
409
410 vector<t_pppParam*>::iterator it = _params.begin();
411 while (it != _params.end()) {
412 t_pppParam* par = *it;
413 delete par;
414 it = _params.erase(it);
415 }
416
417 for (unsigned jj = 0; jj < p.params().size(); jj++) {
418 t_pppParam* parFrom = p.params()[jj];
419 _params.push_back(new t_pppParam(parFrom));
420 }
421 return *this;
422}
423
424//
425////////////////////////////////////////////////////////////////////////////
426t_irc t_pppParlist::set(const bncTime& epoTime, const std::vector<t_pppSatObs*>& obsVector,
427 const QMap<char, t_pppRefSat*>& refSatMap) {
428
429 // Remove some Parameters
430 // ----------------------
431 vector<t_pppParam*>::iterator it = _params.begin();
432 while (it != _params.end()) {
433 t_pppParam* par = *it;
434
435 bool remove = false;
436
437 if (par->epoSpec()) {
438 remove = true;
439 }
440
441 else if (par->type() == t_pppParam::crdX ||
442 par->type() == t_pppParam::crdY ||
443 par->type() == t_pppParam::crdZ) {
444 if (par->lastObsTime().valid() && (epoTime - par->lastObsTime() > 60.0)) {
445 remove = true;
446 }
447 }
448
449 else if (par->type() == t_pppParam::amb) {
450 if (par->lastObsTime().valid() && (epoTime - par->lastObsTime() > 60.0)) {
451 remove = true;
452 }
453 if (OPT->_obsModelType == OPT->DCMcodeBias ||
454 OPT->_obsModelType == OPT->DCMphaseBias) {
455 char sys = par->prn().system();
456 t_prn refPrn = (refSatMap[sys])->prn();
457 if (par->lastObsTime().valid() && par->prn() == refPrn) {
458 remove = true;
459 }
460 }
461 }
462
463 else if (par->type() == t_pppParam::ion) {
464 if (par->lastObsTime().valid() && (epoTime - par->lastObsTime() > 60.0)) {
465 remove = true;
466 }
467 }
468 if (remove) {
469#ifdef BNC_DEBUG_PPP
470 LOG << "remove0 " << par->toString() << std::endl;
471#endif
472 delete par;
473 it = _params.erase(it);
474 }
475 else {
476 ++it;
477 }
478 }
479
480 // check which systems have observations
481 // -------------------------------------
482 _usedSystems.clear();
483 for (unsigned jj = 0; jj < obsVector.size(); jj++) {
484 const t_pppSatObs* satObs = obsVector[jj];
485 char sys = satObs->prn().system();
486 if (!_usedSystems.contains(sys)) {
487 _usedSystems.append(sys);
488 }
489 }
490
491 if (_usedSystems.size() > 1 &&
492 !_usedSystems.contains('G')) { // required to setup ISB w. r. t. GPS
493 return failure;
494 }
495
496
497
498 // Check whether parameters have observations
499 // ------------------------------------------
500 for (unsigned ii = 0; ii < _params.size(); ii++) {
501 t_pppParam* par = _params[ii];
502 if (par->prn() == 0) {
503 par->setLastObsTime(epoTime);
504 if (par->firstObsTime().undef()) {
505 par->setFirstObsTime(epoTime);
506 }
507 }
508 else {
509 for (unsigned jj = 0; jj < obsVector.size(); jj++) {
510 const t_pppSatObs* satObs = obsVector[jj];
511 if (satObs->prn() == par->prn()) {
512 par->setLastObsTime(epoTime);
513 if (par->firstObsTime().undef()) {
514 par->setFirstObsTime(epoTime);
515 }
516 break;
517 }
518 }
519 }
520 }
521
522
523 if (OPT->_obsModelType == OPT->DCMcodeBias ||
524 OPT->_obsModelType == OPT->DCMphaseBias) {
525 // Check if ambiguity parameters have observations
526 // -----------------------------------------------
527 vector<t_pppParam*>::iterator it = _params.begin();
528 QList<t_prn> lostSats;
529 while (it != _params.end()) {
530 t_pppParam* par = *it;
531 if ((par->type() == t_pppParam::amb) &&
532 (!par->lastObsTime().valid() || (epoTime - par->lastObsTime() > 0.0))) {
533#ifdef BNC_DEBUG_PPP
534 LOG << "remove1 " << par->toString() << std::endl;
535#endif
536 lostSats.append(par->prn());
537 delete par;
538 it = _params.erase(it);
539 }
540 // Check if systems have to be presented per biases
541 // ----------------------------------------------
542 else if ((par->type() == t_pppParam::cBiasG1 ||
543 par->type() == t_pppParam::cBiasG2 ||
544 par->type() == t_pppParam::pBiasG1 ||
545 par->type() == t_pppParam::pBiasG2) && !usedSystems().contains('G')) {
546 delete par;
547#ifdef BNC_DEBUG_PPP
548 LOG << "remove1 " << par->toString() << std::endl;
549#endif
550 it = _params.erase(it);
551 }
552 else if ((par->type() == t_pppParam::cBiasR1 ||
553 par->type() == t_pppParam::cBiasR2 ||
554 par->type() == t_pppParam::pBiasR1 ||
555 par->type() == t_pppParam::pBiasR2) && !usedSystems().contains('R')) {
556 delete par;
557#ifdef BNC_DEBUG_PPP
558 LOG << "remove1 " << par->toString() << std::endl;
559#endif
560 it = _params.erase(it);
561 }
562 else if ((par->type() == t_pppParam::cBiasE1 ||
563 par->type() == t_pppParam::cBiasE2 ||
564 par->type() == t_pppParam::pBiasE1 ||
565 par->type() == t_pppParam::pBiasE2) && !usedSystems().contains('E')) {
566 delete par;
567#ifdef BNC_DEBUG_PPP
568 LOG << "remove1 " << par->toString() << std::endl;
569#endif
570 it = _params.erase(it);
571 }
572 else if ((par->type() == t_pppParam::cBiasC1 ||
573 par->type() == t_pppParam::cBiasC2 ||
574 par->type() == t_pppParam::pBiasC1 ||
575 par->type() == t_pppParam::pBiasG2) && !usedSystems().contains('C')) {
576 delete par;
577#ifdef BNC_DEBUG_PPP
578 LOG << "remove1 " << par->toString() << std::endl;
579#endif
580 it = _params.erase(it);
581 }
582 else {
583 ++it;
584 }
585 }
586 // remove respective iono parameters
587 // ---------------------------------
588 it = _params.begin();
589 while (it != _params.end()) {
590 t_pppParam* par = *it;
591 if ((par->type() == t_pppParam::ion) &&
592 (lostSats.contains(par->prn()) || (epoTime - par->lastObsTime() > 0.0))) {
593 LOG << "remove1 " << par->toString() << std::endl;
594 delete par;
595 it = _params.erase(it);
596 }
597 else {
598 ++it;
599 }
600 }
601 }
602
603
604 // Required Set of Parameters
605 // --------------------------
606 vector<t_pppParam*> required;
607
608 // Coordinates
609 // -----------
610 required.push_back(new t_pppParam(t_pppParam::crdX, t_prn(), t_lc::dummy));
611 required.push_back(new t_pppParam(t_pppParam::crdY, t_prn(), t_lc::dummy));
612 required.push_back(new t_pppParam(t_pppParam::crdZ, t_prn(), t_lc::dummy));
613
614 // Receiver Code Biases
615 // --------------------
616 if (OPT->_obsModelType == OPT->DCMcodeBias) {
617 std::vector<t_lc::type> lc;
618 if (_usedSystems.contains('G')) {
619 lc = OPT->LCs('G');
620 if (std::find(lc.begin(), lc.end(), t_lc::c1) != lc.end()) {
621 required.push_back(new t_pppParam(t_pppParam::cBiasG1, t_prn(), t_lc::c1));
622 }
623 if (std::find(lc.begin(), lc.end(), t_lc::c2) != lc.end()) {
624 required.push_back(new t_pppParam(t_pppParam::cBiasG2, t_prn(), t_lc::c2));
625 }
626 }
627 if (_usedSystems.contains('R')) {
628 lc = OPT->LCs('R');
629 if (std::find(lc.begin(), lc.end(), t_lc::c1) != lc.end()) {
630 required.push_back(new t_pppParam(t_pppParam::cBiasR1, t_prn(), t_lc::c1));
631 }
632 if (std::find(lc.begin(), lc.end(), t_lc::c2) != lc.end()) {
633 required.push_back(new t_pppParam(t_pppParam::cBiasR2, t_prn(), t_lc::c2));
634 }
635 }
636 if (_usedSystems.contains('E')) {
637 lc = OPT->LCs('E');
638 if (std::find(lc.begin(), lc.end(), t_lc::c1) != lc.end()) {
639 required.push_back(new t_pppParam(t_pppParam::cBiasE1, t_prn(), t_lc::c1));
640 }
641 if (std::find(lc.begin(), lc.end(), t_lc::c2) != lc.end()) {
642 required.push_back(new t_pppParam(t_pppParam::cBiasE2, t_prn(), t_lc::c2));
643 }
644 }
645 if (_usedSystems.contains('C')) {
646 lc = OPT->LCs('C');
647 if (std::find(lc.begin(), lc.end(), t_lc::c1) != lc.end()) {
648 required.push_back(new t_pppParam(t_pppParam::cBiasC1, t_prn(), t_lc::c1));
649 }
650 if (std::find(lc.begin(), lc.end(), t_lc::c2) != lc.end()) {
651 required.push_back(new t_pppParam(t_pppParam::cBiasC2, t_prn(), t_lc::c2));
652 }
653 }
654 }
655
656 // Receiver Phase Biases
657 // ---------------------
658 if ((OPT->_obsModelType == OPT->DCMphaseBias) ||
659 (OPT->_obsModelType == OPT->PPPRTK) ) {
660 std::vector<t_lc::type> lc;
661 if (_usedSystems.contains('G')) {
662 lc = OPT->LCs('G');
663 if (std::find(lc.begin(), lc.end(), t_lc::l1) != lc.end()) {
664 required.push_back(new t_pppParam(t_pppParam::pBiasG1, t_prn(), t_lc::l1));
665 }
666 if (std::find(lc.begin(), lc.end(), t_lc::l2) != lc.end()) {
667 required.push_back(new t_pppParam(t_pppParam::pBiasG2, t_prn(), t_lc::l2));
668 }
669 }
670 if (_usedSystems.contains('R')) {
671 lc = OPT->LCs('R');
672 if (std::find(lc.begin(), lc.end(), t_lc::l1) != lc.end()) {
673 required.push_back(new t_pppParam(t_pppParam::pBiasR1, t_prn(), t_lc::l1));
674 }
675 if (std::find(lc.begin(), lc.end(), t_lc::l2) != lc.end()) {
676 required.push_back(new t_pppParam(t_pppParam::pBiasR2, t_prn(), t_lc::l2));
677 }
678
679 }
680 if (_usedSystems.contains('E')) {
681 lc = OPT->LCs('E');
682 if (std::find(lc.begin(), lc.end(), t_lc::l1) != lc.end()) {
683 required.push_back(new t_pppParam(t_pppParam::pBiasE1, t_prn(), t_lc::l1));
684 }
685 if (std::find(lc.begin(), lc.end(), t_lc::l2) != lc.end()) {
686 required.push_back(new t_pppParam(t_pppParam::pBiasE2, t_prn(), t_lc::l2));
687 }
688 }
689 if (_usedSystems.contains('C')) {
690 lc = OPT->LCs('C');
691 if (std::find(lc.begin(), lc.end(), t_lc::l1) != lc.end()) {
692 required.push_back(new t_pppParam(t_pppParam::pBiasC1, t_prn(), t_lc::l1));
693 }
694 if (std::find(lc.begin(), lc.end(), t_lc::l2) != lc.end()) {
695 required.push_back(new t_pppParam(t_pppParam::pBiasC2, t_prn(), t_lc::l2));
696 }
697 }
698 }
699
700 // Receiver Clock
701 // --------------
702 required.push_back(new t_pppParam(t_pppParam::clkR, t_prn(), t_lc::dummy));
703
704 // GPS-GLONASS Clock Offset
705 // ------------------------
706 if (_usedSystems.contains('G') && _usedSystems.contains('R')) {
707 required.push_back(new t_pppParam(t_pppParam::offGR, t_prn(), t_lc::dummy));
708 }
709
710 //GPS-Galileo Clock Offset
711 // ------------------------
712 if (_usedSystems.contains('G') && _usedSystems.contains('E')) {
713 required.push_back(new t_pppParam(t_pppParam::offGE, t_prn(), t_lc::dummy));
714 }
715
716 // GPS-BDS Clock Offset
717 // ------------------------
718 if (_usedSystems.contains('G') && _usedSystems.contains('C')) {
719 required.push_back(new t_pppParam(t_pppParam::offGC, t_prn(), t_lc::dummy));
720 }
721
722 // Troposphere
723 // -----------
724 if (OPT->estTrp()) {
725 required.push_back(new t_pppParam(t_pppParam::trp, t_prn(), t_lc::dummy));
726 }
727
728 // Ionosphere
729 // ----------
730 if (OPT->_obsModelType == OPT->UncombPPP ||
731 OPT->_obsModelType == OPT->DCMcodeBias ||
732 OPT->_obsModelType == OPT->DCMphaseBias ) {
733 for (unsigned jj = 0; jj < obsVector.size(); jj++) {
734 const t_pppSatObs* satObs = obsVector[jj];
735 required.push_back(new t_pppParam(t_pppParam::ion, satObs->prn(), t_lc::dummy));
736 }
737 }
738 // Ambiguities
739 // -----------
740 for (unsigned jj = 0; jj < obsVector.size(); jj++) {
741 const t_pppSatObs* satObs = obsVector[jj];
742 if ((OPT->_obsModelType == OPT->IF) ||
743 (OPT->_obsModelType == OPT->PPPRTK) ||
744 (OPT->_obsModelType == OPT->UncombPPP) ||
745 (OPT->_obsModelType == OPT->DCMcodeBias && !satObs->isReference()) ||
746 (OPT->_obsModelType == OPT->DCMphaseBias && !satObs->isReference()) ) {
747 const vector<t_lc::type>& ambLCs = OPT->ambLCs(satObs->prn().system());
748 for (unsigned ii = 0; ii < ambLCs.size(); ii++) {
749 required.push_back(new t_pppParam(t_pppParam::amb, satObs->prn(), ambLCs[ii], &obsVector));
750 }
751 }
752 }
753
754 // Check if all required parameters are present
755 // --------------------------------------------
756 for (unsigned ii = 0; ii < required.size(); ii++) {
757 t_pppParam* parReq = required[ii];
758
759 bool found = false;
760 for (unsigned jj = 0; jj < _params.size(); jj++) {
761 t_pppParam* parOld = _params[jj];
762 if (parOld->isEqual(parReq)) {
763 found = true;
764 break;
765 }
766 }
767 if (found) {
768 delete parReq;
769 }
770 else {
771#ifdef BNC_DEBUG_PPP
772 LOG << "push_back parReq " << parReq->toString() << std::endl;
773#endif
774 _params.push_back(parReq);
775 }
776 }
777
778 // Set Parameter Indices
779 // ---------------------
780 sort(_params.begin(), _params.end(), t_pppParam::sortFunction);
781
782 for (unsigned ii = 0; ii < _params.size(); ii++) {
783 t_pppParam* par = _params[ii];
784 par->setIndex(ii);
785 for (unsigned jj = 0; jj < obsVector.size(); jj++) {
786 const t_pppSatObs* satObs = obsVector[jj];
787 if (satObs->prn() == par->prn()) {
788 par->setAmbEleSat(satObs->eleSat());
789 par->stepAmbNumEpo();
790 }
791 }
792 }
793
794 return success;
795}
796
797//
798////////////////////////////////////////////////////////////////////////////
799void t_pppParlist::printResult(const bncTime& epoTime, const SymmetricMatrix& QQ,
800 const ColumnVector& xx) const {
801
802 string epoTimeStr = string(epoTime);
803 const t_pppStation* sta = PPP_CLIENT->staRover();
804
805 LOG << endl;
806
807 t_pppParam* parX = 0;
808 t_pppParam* parY = 0;
809 t_pppParam* parZ = 0;
810 vector<t_pppParam*>::const_iterator it = _params.begin();
811 while (it != _params.end()) {
812 t_pppParam* par = *it;
813 if (par->type() == t_pppParam::crdX) {
814 parX = par;
815 }
816 else if (par->type() == t_pppParam::crdY) {
817 parY = par;
818 }
819 else if (par->type() == t_pppParam::crdZ) {
820 parZ = par;
821 }
822 else {
823 int ind = par->indexNew();
824 double apr = (par->type() == t_pppParam::trp) ?
825 t_tropo::delay_saast(sta->xyzApr(), M_PI/2.0) : par->x0();
826 LOG << epoTimeStr << ' ' << par->toString() << ' '
827 << setw(10) << setprecision(4) << apr << ' '
828 << showpos << setw(10) << setprecision(4) << xx[ind] << noshowpos << " +- "
829 << setw(8) << setprecision(4) << sqrt(QQ[ind][ind]);
830 if (par->type() == t_pppParam::amb) {
831 LOG << " el = " << setw(6) << setprecision(2) << par->ambEleSat() * 180.0 / M_PI
832 << " epo = " << setw(4) << par->ambNumEpo();
833 }
834 LOG << endl;
835 }
836 ++it;
837 }
838
839 if (parX && parY && parZ) {
840
841 ColumnVector xyz(3);
842 xyz[0] = xx[parX->indexNew()];
843 xyz[1] = xx[parY->indexNew()];
844 xyz[2] = xx[parZ->indexNew()];
845
846 ColumnVector neu(3);
847 xyz2neu(sta->ellApr().data(), xyz.data(), neu.data());
848
849 SymmetricMatrix QQxyz = QQ.SymSubMatrix(1,3);
850
851 SymmetricMatrix QQneu(3);
852 covariXYZ_NEU(QQxyz, sta->ellApr().data(), QQneu);
853
854 LOG << epoTimeStr << ' ' << sta->name()
855 << " X = " << setprecision(4) << sta->xyzApr()[0] + xyz[0] << " +- "
856 << setprecision(4) << sqrt(QQxyz[0][0])
857
858 << " Y = " << setprecision(4) << sta->xyzApr()[1] + xyz[1] << " +- "
859 << setprecision(4) << sqrt(QQxyz[1][1])
860
861 << " Z = " << setprecision(4) << sta->xyzApr()[2] + xyz[2] << " +- "
862 << setprecision(4) << sqrt(QQxyz[2][2])
863
864 << " dN = " << setprecision(4) << neu[0] << " +- "
865 << setprecision(4) << sqrt(QQneu[0][0])
866
867 << " dE = " << setprecision(4) << neu[1] << " +- "
868 << setprecision(4) << sqrt(QQneu[1][1])
869
870 << " dU = " << setprecision(4) << neu[2] << " +- "
871 << setprecision(4) << sqrt(QQneu[2][2])
872
873 << endl;
874 }
875 return;
876}
877
878//
879////////////////////////////////////////////////////////////////////////////
880void t_pppParlist::printParams(const bncTime& epoTime) {
881
882 for (unsigned iPar = 0; iPar < _params.size(); iPar++) {
883 LOG << _params[iPar]->toString()
884 << "\t lastObsTime().valid() \t" << _params[iPar]->lastObsTime().valid()
885 << "\t epoTime - par->lastObsTime() \t" << (epoTime - _params[iPar]->lastObsTime())
886 << endl;
887 }
888}
889
Note: See TracBrowser for help on using the repository browser.