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

Last change on this file since 9548 was 9548, checked in by stuerze, 9 months 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.1 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) {return 0.0;}
186 return (sta->xyzApr()[0] - obs->xc()[0]) / rhoV.NormFrobenius();
187 case crdY:
188 if (tLC == t_lc::GIM) {return 0.0;}
189 return (sta->xyzApr()[1] - obs->xc()[1]) / rhoV.NormFrobenius();
190 case crdZ:
191 if (tLC == t_lc::GIM) {return 0.0;}
192 return (sta->xyzApr()[2] - obs->xc()[2]) / rhoV.NormFrobenius();
193 case clkR:
194 if (tLC == t_lc::GIM) {return 0.0;}
195 return 1.0;
196 case offGR:
197 if (tLC == t_lc::GIM) {return 0.0;}
198 return (obs->prn().system() == 'R') ? 1.0 : 0.0;
199 case offGE:
200 if (tLC == t_lc::GIM) {return 0.0;}
201 return (obs->prn().system() == 'E') ? 1.0 : 0.0;
202 case offGC:
203 if (tLC == t_lc::GIM) {return 0.0;}
204 return (obs->prn().system() == 'C') ? 1.0 : 0.0;
205 case amb:
206 if (tLC == t_lc::GIM) {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 {
236 return 1.0 / sin(obs->eleSat());
237 }
238 case ion:
239 if (obs->prn() == _prn) {
240 if (tLC == t_lc::c1) {
241 return ionoCoeff[t_lc::toFreq(obs->prn().system(),t_lc::c1)];
242 }
243 else if (tLC == t_lc::c2) {
244 return ionoCoeff[t_lc::toFreq(obs->prn().system(),t_lc::c2)];
245 }
246 else if (tLC == t_lc::l1) {
247 return ionoCoeff[t_lc::toFreq(obs->prn().system(),t_lc::l1)];
248 }
249 else if (tLC == t_lc::l2) {
250 return ionoCoeff[t_lc::toFreq(obs->prn().system(),t_lc::l2)];
251 }
252 else if (tLC == t_lc::GIM) {
253 return -1.0;
254 }
255 }
256 if (tLC == t_lc::GIM && _prn == refPrn) {
257 return 1.0;
258 }
259 break;
260 case cBiasG1:
261 if ((obs->prn().system() == 'G') && (tLC == t_lc::c1)) {return 1.0;} else {return 0.0;}
262 break;
263 case cBiasR1:
264 if ((obs->prn().system() == 'R') && (tLC == t_lc::c1)) {return 1.0;} else {return 0.0;}
265 break;
266 case cBiasE1:
267 if ((obs->prn().system() == 'E') && (tLC == t_lc::c1)) {return 1.0;} else {return 0.0;}
268 break;
269 case cBiasC1:
270 if ((obs->prn().system() == 'C') && (tLC == t_lc::c1)) {return 1.0;} else {return 0.0;}
271 break;
272 case cBiasG2:
273 if ((obs->prn().system() == 'G') && (tLC == t_lc::c2)) {return 1.0;} else {return 0.0;}
274 break;
275 case cBiasR2:
276 if ((obs->prn().system() == 'R') && (tLC == t_lc::c2)) {return 1.0;} else {return 0.0;}
277 break;
278 case cBiasE2:
279 if ((obs->prn().system() == 'E') && (tLC == t_lc::c2)) {return 1.0;} else {return 0.0;}
280 break;
281 case cBiasC2:
282 if ((obs->prn().system() == 'C') && (tLC == t_lc::c2)) {return 1.0;} else {return 0.0;}
283 break;
284 case pBiasG1:
285 if ((obs->prn().system() == 'G') && (tLC == t_lc::l1)) {return 1.0;} else {return 0.0;}
286 break;
287 case pBiasR1:
288 if ((obs->prn().system() == 'R') && (tLC == t_lc::l1)) {return 1.0;} else {return 0.0;}
289 break;
290 case pBiasE1:
291 if ((obs->prn().system() == 'E') && (tLC == t_lc::l1)) {return 1.0;} else {return 0.0;}
292 break;
293 case pBiasC1:
294 if ((obs->prn().system() == 'C') && (tLC == t_lc::l1)) {return 1.0;} else {return 0.0;}
295 break;
296 case pBiasG2:
297 if ((obs->prn().system() == 'G') && (tLC == t_lc::l2)) {return 1.0;} else {return 0.0;}
298 break;
299 case pBiasR2:
300 if ((obs->prn().system() == 'R') && (tLC == t_lc::l2)) {return 1.0;} else {return 0.0;}
301 break;
302 case pBiasE2:
303 if ((obs->prn().system() == 'E') && (tLC == t_lc::l2)) {return 1.0;} else {return 0.0;}
304 break;
305 case pBiasC2:
306 if ((obs->prn().system() == 'C') && (tLC == t_lc::l2)) {return 1.0;} else {return 0.0;}
307 break;
308
309 }
310 return 0.0;
311}
312
313//
314////////////////////////////////////////////////////////////////////////////
315string t_pppParam::toString() const {
316 stringstream ss;
317 switch (_type) {
318 case crdX:
319 ss << "CRD_X";
320 break;
321 case crdY:
322 ss << "CRD_Y";
323 break;
324 case crdZ:
325 ss << "CRD_Z";
326 break;
327 case clkR:
328 ss << "REC_CLK ";
329 break;
330 case offGR:
331 ss << "OGR ";
332 break;
333 case offGE:
334 ss << "OGE ";
335 break;
336 case offGC:
337 ss << "OGC ";
338 break;
339 case trp:
340 ss << "TRP ";
341 break;
342 case amb:
343 ss << "AMB " << left << setw(3) << t_lc::toString(_tLC) << right << ' ' << _prn.toString();
344 break;
345 case ion:
346 ss << "ION " << left << setw(3) << t_lc::toString(_tLC) << right << ' ' << _prn.toString();
347 break;
348 case cBiasG1: case pBiasG1:
349 case cBiasG2: case pBiasG2:
350 ss << "BIA " << left << setw(3) << t_lc::toString(_tLC) << right << " G ";
351 break;
352 case cBiasR1: case pBiasR1:
353 case cBiasR2: case pBiasR2:
354 ss << "BIA " << left << setw(3) << t_lc::toString(_tLC) << right << " R ";
355 break;
356 case cBiasE1: case pBiasE1:
357 case cBiasE2: case pBiasE2:
358 ss << "BIA " << left << setw(3) << t_lc::toString(_tLC) << right << " E ";
359 break;
360 case cBiasC1: case pBiasC1:
361 case cBiasC2: case pBiasC2:
362 ss << "BIA " << left << setw(3) << t_lc::toString(_tLC) << right << " C ";
363 break;
364 }
365 return ss.str();
366}
367
368// Constructor
369////////////////////////////////////////////////////////////////////////////
370t_pppParlist::t_pppParlist() {
371}
372
373// Destructor
374////////////////////////////////////////////////////////////////////////////
375t_pppParlist::~t_pppParlist() {
376 _usedSystems.clear();
377
378 vector<t_pppParam*>::iterator it = _params.begin();
379 while (it != _params.end()) {
380 t_pppParam* par = *it;
381 delete par;
382 it = _params.erase(it);
383 }
384}
385
386//
387////////////////////////////////////////////////////////////////////////////
388t_pppParlist::t_pppParlist(const t_pppParlist& old) {
389
390 _usedSystems = old._usedSystems;
391
392 vector<t_pppParam*>::const_iterator it = old.params().begin();
393 while (it != old.params().end()) {
394 const t_pppParam* oldParam = *it;
395 _params.push_back(new t_pppParam(oldParam));
396 }
397}
398
399//
400////////////////////////////////////////////////////////////////////////////
401const t_pppParlist& t_pppParlist::operator= (const t_pppParlist& p) {
402
403 _usedSystems.clear();
404
405 _usedSystems = p._usedSystems;
406
407 vector<t_pppParam*>::iterator it = _params.begin();
408 while (it != _params.end()) {
409 t_pppParam* par = *it;
410 delete par;
411 it = _params.erase(it);
412 }
413
414 for (unsigned jj = 0; jj < p.params().size(); jj++) {
415 t_pppParam* parFrom = p.params()[jj];
416 _params.push_back(new t_pppParam(parFrom));
417 }
418 return *this;
419}
420
421//
422////////////////////////////////////////////////////////////////////////////
423t_irc t_pppParlist::set(const bncTime& epoTime, const std::vector<t_pppSatObs*>& obsVector,
424 const QMap<char, t_pppRefSat*>& refSatMap) {
425
426 // Remove some Parameters
427 // ----------------------
428 vector<t_pppParam*>::iterator it = _params.begin();
429 while (it != _params.end()) {
430 t_pppParam* par = *it;
431
432 bool remove = false;
433
434 if (par->epoSpec()) {
435 remove = true;
436 }
437
438 else if (par->type() == t_pppParam::crdX ||
439 par->type() == t_pppParam::crdY ||
440 par->type() == t_pppParam::crdZ) {
441 if (par->lastObsTime().valid() && (epoTime - par->lastObsTime() > 60.0)) {
442 remove = true;
443 }
444 }
445
446 else if (par->type() == t_pppParam::amb) {
447 if (par->lastObsTime().valid() && (epoTime - par->lastObsTime() > 60.0)) {
448 remove = true;
449 }
450 if (OPT->_obsModelType == OPT->DCMcodeBias ||
451 OPT->_obsModelType == OPT->DCMphaseBias) {
452 char sys = par->prn().system();
453 t_prn refPrn = (refSatMap[sys])->prn();
454 if (par->lastObsTime().valid() && par->prn() == refPrn) {
455 remove = true;
456 }
457 }
458 }
459
460 else if (par->type() == t_pppParam::ion) {
461 if (par->lastObsTime().valid() && (epoTime - par->lastObsTime() > 60.0)) {
462 remove = true;
463 }
464 }
465 if (remove) {
466#ifdef BNC_DEBUG_PPP
467 LOG << "remove0 " << par->toString() << std::endl;
468#endif
469 delete par;
470 it = _params.erase(it);
471 }
472 else {
473 ++it;
474 }
475 }
476
477 // check which systems have observations
478 // -------------------------------------
479 _usedSystems.clear();
480 for (unsigned jj = 0; jj < obsVector.size(); jj++) {
481 const t_pppSatObs* satObs = obsVector[jj];
482 char sys = satObs->prn().system();
483 if (!_usedSystems.contains(sys)) {
484 _usedSystems.append(sys);
485 }
486 }
487
488 if (_usedSystems.size() > 1 &&
489 !_usedSystems.contains('G')) { // required to setup ISB w. r. t. GPS
490 return failure;
491 }
492
493
494
495 // Check whether parameters have observations
496 // ------------------------------------------
497 for (unsigned ii = 0; ii < _params.size(); ii++) {
498 t_pppParam* par = _params[ii];
499 if (par->prn() == 0) {
500 par->setLastObsTime(epoTime);
501 if (par->firstObsTime().undef()) {
502 par->setFirstObsTime(epoTime);
503 }
504 }
505 else {
506 for (unsigned jj = 0; jj < obsVector.size(); jj++) {
507 const t_pppSatObs* satObs = obsVector[jj];
508 if (satObs->prn() == par->prn()) {
509 par->setLastObsTime(epoTime);
510 if (par->firstObsTime().undef()) {
511 par->setFirstObsTime(epoTime);
512 }
513 break;
514 }
515 }
516 }
517 }
518
519
520 if (OPT->_obsModelType == OPT->DCMcodeBias ||
521 OPT->_obsModelType == OPT->DCMphaseBias) {
522 // Check if ambiguity parameters have observations
523 // -----------------------------------------------
524 vector<t_pppParam*>::iterator it = _params.begin();
525 QList<t_prn> lostSats;
526 while (it != _params.end()) {
527 t_pppParam* par = *it;
528 if ((par->type() == t_pppParam::amb) &&
529 (!par->lastObsTime().valid() || (epoTime - par->lastObsTime() > 0.0))) {
530#ifdef BNC_DEBUG_PPP
531 LOG << "remove1 " << par->toString() << std::endl;
532#endif
533 lostSats.append(par->prn());
534 delete par;
535 it = _params.erase(it);
536 }
537 // Check if systems have to be presented per biases
538 // ----------------------------------------------
539 else if ((par->type() == t_pppParam::cBiasG1 ||
540 par->type() == t_pppParam::cBiasG2 ||
541 par->type() == t_pppParam::pBiasG1 ||
542 par->type() == t_pppParam::pBiasG2) && !usedSystems().contains('G')) {
543#ifdef BNC_DEBUG_PPP
544 LOG << "remove1 " << par->toString() << std::endl;
545#endif
546 delete par;
547 it = _params.erase(it);
548 }
549 else if ((par->type() == t_pppParam::cBiasR1 ||
550 par->type() == t_pppParam::cBiasR2 ||
551 par->type() == t_pppParam::pBiasR1 ||
552 par->type() == t_pppParam::pBiasR2) && !usedSystems().contains('R')) {
553#ifdef BNC_DEBUG_PPP
554 LOG << "remove1 " << par->toString() << std::endl;
555#endif
556 delete par;
557 it = _params.erase(it);
558 }
559 else if ((par->type() == t_pppParam::cBiasE1 ||
560 par->type() == t_pppParam::cBiasE2 ||
561 par->type() == t_pppParam::pBiasE1 ||
562 par->type() == t_pppParam::pBiasE2) && !usedSystems().contains('E')) {
563#ifdef BNC_DEBUG_PPP
564 LOG << "remove1 " << par->toString() << std::endl;
565#endif
566 delete par;
567 it = _params.erase(it);
568 }
569 else if ((par->type() == t_pppParam::cBiasC1 ||
570 par->type() == t_pppParam::cBiasC2 ||
571 par->type() == t_pppParam::pBiasC1 ||
572 par->type() == t_pppParam::pBiasC2) && !usedSystems().contains('C')) {
573#ifdef BNC_DEBUG_PPP
574 LOG << "remove1 " << par->toString() << std::endl;
575#endif
576 delete par;
577 it = _params.erase(it);
578 }
579 else {
580 ++it;
581 }
582 }
583 // remove respective iono parameters
584 // ---------------------------------
585 it = _params.begin();
586 while (it != _params.end()) {
587 t_pppParam* par = *it;
588 if ((par->type() == t_pppParam::ion) &&
589 (lostSats.contains(par->prn()) || (epoTime - par->lastObsTime() > 0.0))) {
590 LOG << "remove1 " << par->toString() << std::endl;
591 delete par;
592 it = _params.erase(it);
593 }
594 else {
595 ++it;
596 }
597 }
598 }
599
600
601 // Required Set of Parameters
602 // --------------------------
603 vector<t_pppParam*> required;
604
605 // Coordinates
606 // -----------
607 required.push_back(new t_pppParam(t_pppParam::crdX, t_prn(), t_lc::dummy));
608 required.push_back(new t_pppParam(t_pppParam::crdY, t_prn(), t_lc::dummy));
609 required.push_back(new t_pppParam(t_pppParam::crdZ, t_prn(), t_lc::dummy));
610
611 // Receiver Code Biases
612 // --------------------
613 if (OPT->_obsModelType == OPT->DCMcodeBias) {
614 std::vector<t_lc::type> lc;
615 if (_usedSystems.contains('G')) {
616 lc = OPT->LCs('G');
617 if (std::find(lc.begin(), lc.end(), t_lc::c1) != lc.end()) {
618 required.push_back(new t_pppParam(t_pppParam::cBiasG1, t_prn(), t_lc::c1));
619 }
620 if (std::find(lc.begin(), lc.end(), t_lc::c2) != lc.end()) {
621 required.push_back(new t_pppParam(t_pppParam::cBiasG2, t_prn(), t_lc::c2));
622 }
623 }
624 if (_usedSystems.contains('R')) {
625 lc = OPT->LCs('R');
626 if (std::find(lc.begin(), lc.end(), t_lc::c1) != lc.end()) {
627 required.push_back(new t_pppParam(t_pppParam::cBiasR1, t_prn(), t_lc::c1));
628 }
629 if (std::find(lc.begin(), lc.end(), t_lc::c2) != lc.end()) {
630 required.push_back(new t_pppParam(t_pppParam::cBiasR2, t_prn(), t_lc::c2));
631 }
632 }
633 if (_usedSystems.contains('E')) {
634 lc = OPT->LCs('E');
635 if (std::find(lc.begin(), lc.end(), t_lc::c1) != lc.end()) {
636 required.push_back(new t_pppParam(t_pppParam::cBiasE1, t_prn(), t_lc::c1));
637 }
638 if (std::find(lc.begin(), lc.end(), t_lc::c2) != lc.end()) {
639 required.push_back(new t_pppParam(t_pppParam::cBiasE2, t_prn(), t_lc::c2));
640 }
641 }
642 if (_usedSystems.contains('C')) {
643 lc = OPT->LCs('C');
644 if (std::find(lc.begin(), lc.end(), t_lc::c1) != lc.end()) {
645 required.push_back(new t_pppParam(t_pppParam::cBiasC1, t_prn(), t_lc::c1));
646 }
647 if (std::find(lc.begin(), lc.end(), t_lc::c2) != lc.end()) {
648 required.push_back(new t_pppParam(t_pppParam::cBiasC2, t_prn(), t_lc::c2));
649 }
650 }
651 }
652
653 // Receiver Phase Biases
654 // ---------------------
655 if ((OPT->_obsModelType == OPT->DCMphaseBias) ||
656 (OPT->_obsModelType == OPT->PPPRTK) ) {
657 std::vector<t_lc::type> lc;
658 if (_usedSystems.contains('G')) {
659 lc = OPT->LCs('G');
660 if (std::find(lc.begin(), lc.end(), t_lc::l1) != lc.end()) {
661 required.push_back(new t_pppParam(t_pppParam::pBiasG1, t_prn(), t_lc::l1));
662 }
663 if (std::find(lc.begin(), lc.end(), t_lc::l2) != lc.end()) {
664 required.push_back(new t_pppParam(t_pppParam::pBiasG2, t_prn(), t_lc::l2));
665 }
666 }
667 if (_usedSystems.contains('R')) {
668 lc = OPT->LCs('R');
669 if (std::find(lc.begin(), lc.end(), t_lc::l1) != lc.end()) {
670 required.push_back(new t_pppParam(t_pppParam::pBiasR1, t_prn(), t_lc::l1));
671 }
672 if (std::find(lc.begin(), lc.end(), t_lc::l2) != lc.end()) {
673 required.push_back(new t_pppParam(t_pppParam::pBiasR2, t_prn(), t_lc::l2));
674 }
675
676 }
677 if (_usedSystems.contains('E')) {
678 lc = OPT->LCs('E');
679 if (std::find(lc.begin(), lc.end(), t_lc::l1) != lc.end()) {
680 required.push_back(new t_pppParam(t_pppParam::pBiasE1, t_prn(), t_lc::l1));
681 }
682 if (std::find(lc.begin(), lc.end(), t_lc::l2) != lc.end()) {
683 required.push_back(new t_pppParam(t_pppParam::pBiasE2, t_prn(), t_lc::l2));
684 }
685 }
686 if (_usedSystems.contains('C')) {
687 lc = OPT->LCs('C');
688 if (std::find(lc.begin(), lc.end(), t_lc::l1) != lc.end()) {
689 required.push_back(new t_pppParam(t_pppParam::pBiasC1, t_prn(), t_lc::l1));
690 }
691 if (std::find(lc.begin(), lc.end(), t_lc::l2) != lc.end()) {
692 required.push_back(new t_pppParam(t_pppParam::pBiasC2, t_prn(), t_lc::l2));
693 }
694 }
695 }
696
697 // Receiver Clock
698 // --------------
699 required.push_back(new t_pppParam(t_pppParam::clkR, t_prn(), t_lc::dummy));
700
701 // GPS-GLONASS Clock Offset
702 // ------------------------
703 if (_usedSystems.contains('G') && _usedSystems.contains('R')) {
704 required.push_back(new t_pppParam(t_pppParam::offGR, t_prn(), t_lc::dummy));
705 }
706
707 //GPS-Galileo Clock Offset
708 // ------------------------
709 if (_usedSystems.contains('G') && _usedSystems.contains('E')) {
710 required.push_back(new t_pppParam(t_pppParam::offGE, t_prn(), t_lc::dummy));
711 }
712
713 // GPS-BDS Clock Offset
714 // ------------------------
715 if (_usedSystems.contains('G') && _usedSystems.contains('C')) {
716 required.push_back(new t_pppParam(t_pppParam::offGC, t_prn(), t_lc::dummy));
717 }
718
719 // Troposphere
720 // -----------
721 if (OPT->estTrp()) {
722 required.push_back(new t_pppParam(t_pppParam::trp, t_prn(), t_lc::dummy));
723 }
724
725 // Ionosphere
726 // ----------
727 if (OPT->_obsModelType == OPT->UncombPPP ||
728 OPT->_obsModelType == OPT->DCMcodeBias ||
729 OPT->_obsModelType == OPT->DCMphaseBias ) {
730 for (unsigned jj = 0; jj < obsVector.size(); jj++) {
731 const t_pppSatObs* satObs = obsVector[jj];
732 required.push_back(new t_pppParam(t_pppParam::ion, satObs->prn(), t_lc::dummy));
733 }
734 }
735 // Ambiguities
736 // -----------
737 for (unsigned jj = 0; jj < obsVector.size(); jj++) {
738 const t_pppSatObs* satObs = obsVector[jj];
739 if ((OPT->_obsModelType == OPT->IF) ||
740 (OPT->_obsModelType == OPT->PPPRTK) ||
741 (OPT->_obsModelType == OPT->UncombPPP) ||
742 (OPT->_obsModelType == OPT->DCMcodeBias && !satObs->isReference()) ||
743 (OPT->_obsModelType == OPT->DCMphaseBias && !satObs->isReference()) ) {
744 const vector<t_lc::type>& ambLCs = OPT->ambLCs(satObs->prn().system());
745 for (unsigned ii = 0; ii < ambLCs.size(); ii++) {
746 required.push_back(new t_pppParam(t_pppParam::amb, satObs->prn(), ambLCs[ii], &obsVector));
747 }
748 }
749 }
750
751 // Check if all required parameters are present
752 // --------------------------------------------
753 for (unsigned ii = 0; ii < required.size(); ii++) {
754 t_pppParam* parReq = required[ii];
755
756 bool found = false;
757 for (unsigned jj = 0; jj < _params.size(); jj++) {
758 t_pppParam* parOld = _params[jj];
759 if (parOld->isEqual(parReq)) {
760 found = true;
761 break;
762 }
763 }
764 if (found) {
765 delete parReq;
766 }
767 else {
768#ifdef BNC_DEBUG_PPP
769 LOG << "push_back parReq " << parReq->toString() << std::endl;
770#endif
771 _params.push_back(parReq);
772 }
773 }
774
775 // Set Parameter Indices
776 // ---------------------
777 sort(_params.begin(), _params.end(), t_pppParam::sortFunction);
778
779 for (unsigned ii = 0; ii < _params.size(); ii++) {
780 t_pppParam* par = _params[ii];
781 par->setIndex(ii);
782 for (unsigned jj = 0; jj < obsVector.size(); jj++) {
783 const t_pppSatObs* satObs = obsVector[jj];
784 if (satObs->prn() == par->prn()) {
785 par->setAmbEleSat(satObs->eleSat());
786 par->stepAmbNumEpo();
787 }
788 }
789 }
790
791 return success;
792}
793
794//
795////////////////////////////////////////////////////////////////////////////
796void t_pppParlist::printResult(const bncTime& epoTime, const SymmetricMatrix& QQ,
797 const ColumnVector& xx) const {
798
799 string epoTimeStr = string(epoTime);
800 const t_pppStation* sta = PPP_CLIENT->staRover();
801
802 LOG << endl;
803
804 t_pppParam* parX = 0;
805 t_pppParam* parY = 0;
806 t_pppParam* parZ = 0;
807 vector<t_pppParam*>::const_iterator it = _params.begin();
808 while (it != _params.end()) {
809 t_pppParam* par = *it;
810 if (par->type() == t_pppParam::crdX) {
811 parX = par;
812 }
813 else if (par->type() == t_pppParam::crdY) {
814 parY = par;
815 }
816 else if (par->type() == t_pppParam::crdZ) {
817 parZ = par;
818 }
819 else {
820 int ind = par->indexNew();
821 double apr = (par->type() == t_pppParam::trp) ?
822 t_tropo::delay_saast(sta->xyzApr(), M_PI/2.0) : par->x0();
823 LOG << epoTimeStr << ' ' << par->toString() << ' '
824 << setw(10) << setprecision(4) << apr << ' '
825 << showpos << setw(10) << setprecision(4) << xx[ind] << noshowpos << " +- "
826 << setw(8) << setprecision(4) << sqrt(QQ[ind][ind]);
827 if (par->type() == t_pppParam::amb) {
828 LOG << " el = " << setw(6) << setprecision(2) << par->ambEleSat() * 180.0 / M_PI
829 << " epo = " << setw(4) << par->ambNumEpo();
830 }
831 LOG << endl;
832 }
833 ++it;
834 }
835
836 if (parX && parY && parZ) {
837
838 ColumnVector xyz(3);
839 xyz[0] = xx[parX->indexNew()];
840 xyz[1] = xx[parY->indexNew()];
841 xyz[2] = xx[parZ->indexNew()];
842
843 ColumnVector neu(3);
844 xyz2neu(sta->ellApr().data(), xyz.data(), neu.data());
845
846 SymmetricMatrix QQxyz = QQ.SymSubMatrix(1,3);
847
848 SymmetricMatrix QQneu(3);
849 covariXYZ_NEU(QQxyz, sta->ellApr().data(), QQneu);
850
851 LOG << epoTimeStr << ' ' << sta->name()
852 << " X = " << setprecision(4) << sta->xyzApr()[0] + xyz[0] << " +- "
853 << setprecision(4) << sqrt(QQxyz[0][0])
854
855 << " Y = " << setprecision(4) << sta->xyzApr()[1] + xyz[1] << " +- "
856 << setprecision(4) << sqrt(QQxyz[1][1])
857
858 << " Z = " << setprecision(4) << sta->xyzApr()[2] + xyz[2] << " +- "
859 << setprecision(4) << sqrt(QQxyz[2][2])
860
861 << " dN = " << setprecision(4) << neu[0] << " +- "
862 << setprecision(4) << sqrt(QQneu[0][0])
863
864 << " dE = " << setprecision(4) << neu[1] << " +- "
865 << setprecision(4) << sqrt(QQneu[1][1])
866
867 << " dU = " << setprecision(4) << neu[2] << " +- "
868 << setprecision(4) << sqrt(QQneu[2][2])
869
870 << endl;
871 }
872 return;
873}
874
875//
876////////////////////////////////////////////////////////////////////////////
877void t_pppParlist::printParams(const bncTime& epoTime) {
878
879 for (unsigned iPar = 0; iPar < _params.size(); iPar++) {
880 LOG << _params[iPar]->toString()
881 << "\t lastObsTime().valid() \t" << _params[iPar]->lastObsTime().valid()
882 << "\t epoTime - par->lastObsTime() \t" << (epoTime - _params[iPar]->lastObsTime())
883 << endl;
884 }
885}
886
Note: See TracBrowser for help on using the repository browser.