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

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

minor changes

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