source: ntrip/trunk/BNC/src/PPP/pppFilter.h@ 9551

Last change on this file since 9551 was 9551, checked in by stuerze, 2 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: 6.4 KB
Line 
1#ifndef FILTER_H
2#define FILTER_H
3
4#include <vector>
5#include <newmat.h>
6#include "pppInclude.h"
7#include "pppParlist.h"
8#include "bnctime.h"
9#include "t_prn.h"
10#include "pppClient.h"
11
12namespace BNC_PPP {
13
14class t_pppParlist;
15class t_pppObsPool;
16class t_pppSatObs;
17
18class t_pppFilter {
19 public:
20 t_pppFilter(t_pppObsPool* obsPool);
21 ~t_pppFilter();
22
23 t_irc processEpoch();
24
25 const ColumnVector& x() const {return _xFlt;}
26 const SymmetricMatrix& Q() const {return _QFlt;}
27
28 t_irc datumTransformation(const QMap<char, t_pppRefSat*>& refSatMap);
29 void initDatumTransformation(const std::vector<t_pppSatObs*>& allObs, bool pseudoObsIono);
30 unsigned setTrafoObs();
31 void restoreState(int num) { LOG << "Restore parameter from last epoch : _parlist = _parlist_sav ("<< num << ")\n";
32 _QFlt = _QFlt_sav;
33 _parlist = _parlist_sav;
34 }
35 void rememberState(int num) { LOG << "Remember parameters from epoch before: _parlist_sav = _parlist ("<< num << ")\n";
36 _QFlt_sav = _QFlt;
37 _parlist_sav = _parlist;
38 }
39
40 int numSat() const {return _numSat;}
41 double HDOP() const {return _dop.H;}
42 double HDOV() const {return _dop.V;}
43 double PDOP() const {return _dop.P;}
44 double GDOP() const {return _dop.G;}
45 double trp() const {
46 const std::vector<t_pppParam*>& par = _parlist.params();
47 for (unsigned ii = 0; ii < par.size(); ++ii) {
48 if (par[ii]->type() == t_pppParam::trp) {
49 return x()[ii];
50 }
51 }
52 return 0.0;
53 };
54 double trpStdev() const {
55 const std::vector<t_pppParam*>& par = _parlist.params();
56 for (unsigned ii = 0; ii < par.size(); ++ii) {
57 if (par[ii]->type() == t_pppParam::trp) {
58 return sqrt(Q()[ii][ii]);
59 }
60 }
61 return 0.0;
62 };
63 double ageOfLastSolutionOK() { return (_epoTime - _lastEpoTimeOK);}
64
65 private:
66 class t_slip {
67 public:
68 t_slip() {
69 _slip = false;
70 _obsSlipCounter = -1;
71 _biasJumpCounter = -1;
72 }
73 bool _slip;
74 int _obsSlipCounter;
75 int _biasJumpCounter;
76 };
77
78 class t_dop {
79 public:
80 t_dop() {reset();}
81 void reset() {H = V = P = T = G = 0.0;}
82 double H;
83 double V;
84 double P;
85 double T;
86 double G;
87 };
88
89 class t_datumTrafo {
90 public:
91 t_datumTrafo () {initIndices();}
92 ~t_datumTrafo (){}
93
94 void initIndices() {_firstRow = 1; _lastRow = 0;}
95 void updateIndices(char sys, int maxObsSys) {
96 if (firstSystem(sys)) {
97 initIndices();
98 }
99 else {
100 _firstRow = _lastRow + 1;
101 }
102 _lastRow += maxObsSys; //LOG << sys << " updateIndices: lastRow: " << _lastRow << "\n" ;
103 };
104
105 void setFirstSystem(char firstSys) { _firstSys = firstSys;}
106 bool firstSystem(char sys) {
107 if (_firstSys == sys) {
108 return true;
109 }
110 return false;
111 }
112 void setNumObs(int maxObs) {_maxObs = maxObs;}
113 void setNumPar(int numPar) {_numPar = numPar;}
114 int numPar() {return _numPar;}
115 int numObs() {return _maxObs;}
116 void updateNumObs() {
117 _maxObs = _lastRow;
118 _AA1 = _AA1.SubMatrix(1, _lastRow, 1, _numPar);
119 _AA2 = _AA2.SubMatrix(1, _lastRow, 1, _numPar);
120 }
121
122 const Matrix& AA1() {return _AA1;}
123 const Matrix& AA2() {return _AA2;}
124 const Matrix& D21() {return _D21;}
125
126 void initAA() {
127 _AA1.ReSize(_maxObs, _numPar); _AA1 = 0.0;
128 _AA2.ReSize(_maxObs, _numPar); _AA2 = 0.0;
129 _D21.ReSize(_numPar, _numPar); _D21 = 0.0;
130 }
131 t_irc prepareAA(const Matrix& AA, int ind) {//LOG << "prepare AA" << ind << "\n";
132 Matrix* Prep = &_AA2;
133 if (ind == 1) {
134 Prep = &_AA1;
135 }
136 //LOG << "_firstRow: " << _firstRow << " _lastRow: " << _lastRow << " _numPar " << _numPar << std::endl;
137 if (AA.Ncols() > _numPar) {
138 LOG << "t_pppFilter::prepareAA: AA.Ncols() > _numPar: " << AA.Ncols() << " > " << _numPar << std::endl;
139 return failure;
140 }
141 Prep->SubMatrix(_firstRow, _lastRow, 1, _numPar) << AA;
142 return success;
143 }
144 void switchAA() {
145 _AA1 = _AA2;
146 }
147 t_irc computeTrafoMatrix() {
148 if (((_AA2.t() * _AA2)).Determinant() == 0.0) {
149 LOG << "t_pppFilter::computeTrafoMatrix: (_AA2.t() * _AA2).inv() is singular" << std::endl;
150 return failure;
151 }
152 _D21 = ((_AA2.t() * _AA2).i()) * _AA2.t() * _AA1;
153 return success;
154 }
155
156 void printMatrix(const Matrix& X, int nRow, int nCol) {
157 for (int rr = 0; rr < nRow; rr++) {
158 for (int cc = 0; cc < nCol; cc++) {
159 LOG << std::setw(6) << std::setprecision(3) << X[rr][cc] << " ;";
160 }
161 LOG << std::endl;
162 }
163 LOG << std::endl;
164 }
165 private:
166 int _firstRow;
167 int _lastRow;
168 Matrix _AA1;
169 Matrix _AA2;
170 Matrix _D21;
171 char _firstSys;
172 int _maxObs;
173 int _numPar;
174 QMap<char, t_prn> _refSatMapPseudoObs;
175 };
176
177 t_irc processSystem(const std::vector<t_lc::type>& LCs,
178 const std::vector<t_pppSatObs*>& obsVector,
179 const t_prn& refPrn,
180 bool pseudoObsIonoAvailable,
181 bool preProcessing);
182
183 t_irc detectCycleSlips(const std::vector<t_lc::type>& LCs,
184 const std::vector<t_pppSatObs*>& obsVector,
185 const t_prn& refPrn,
186 bool preProcessing);
187
188 t_irc resetAmb(t_prn prn, const std::vector<t_pppSatObs*>& obsVector,
189 SymmetricMatrix* QSav = 0, ColumnVector* xSav = 0);
190
191 void cmpDOP(const std::vector<t_pppSatObs*>& obsVector,
192 const QMap<char, t_pppRefSat*>& refSatMap);
193
194 void setStateVectorAndVarCovMatrix(const ColumnVector& xFltOld, const SymmetricMatrix& QFltOld);
195
196 void predictCovCrdPart(const SymmetricMatrix& QFltOld);
197
198 t_irc addNoiseToIono(char sys);
199
200 bool resetRefSatellitesLastEpoch(std::vector<t_pppSatObs*>& obsVector,
201 const QMap<char, t_pppRefSat*>& refSatMap,
202 const QMap<char, t_pppRefSat*>& refSatMapLastEpoch);
203
204 bncTime _epoTime;
205 t_pppParlist _parlist;
206 t_pppParlist _parlist_sav;
207 t_pppObsPool* _obsPool;
208 t_datumTrafo* _datumTrafo;
209 SymmetricMatrix _QFlt;
210 SymmetricMatrix _QFlt_sav;
211 ColumnVector _xFlt;
212 ColumnVector _x0;
213 t_slip _slips[t_prn::MAXPRN+1];
214 int _numSat;
215 t_dop _dop;
216 bncTime _firstEpoTime;
217 bncTime _lastEpoTimeOK;
218 t_prn _refPrn;
219};
220
221}
222
223#endif
Note: See TracBrowser for help on using the repository browser.