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

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