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 |
|
---|
12 | namespace BNC_PPP {
|
---|
13 |
|
---|
14 | class t_pppParlist;
|
---|
15 | class t_pppObsPool;
|
---|
16 | class t_pppSatObs;
|
---|
17 |
|
---|
18 | class 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 |
|
---|
64 | private:
|
---|
65 | class t_slip {
|
---|
66 | public:
|
---|
67 | t_slip() {
|
---|
68 | _slip = false;
|
---|
69 | _obsSlipCounter = -1;
|
---|
70 | _biasJumpCounter = -1;
|
---|
71 | }
|
---|
72 | bool _slip;
|
---|
73 | int _obsSlipCounter;
|
---|
74 | int _biasJumpCounter;
|
---|
75 | };
|
---|
76 |
|
---|
77 | class t_dop {
|
---|
78 | public:
|
---|
79 | t_dop() {reset();}
|
---|
80 | void reset() {H = V = P = T = G = 0.0;}
|
---|
81 | double H;
|
---|
82 | double V;
|
---|
83 | double P;
|
---|
84 | double T;
|
---|
85 | double G;
|
---|
86 | };
|
---|
87 |
|
---|
88 | class t_datumTrafo {
|
---|
89 | public:
|
---|
90 | t_datumTrafo () {initIndices();}
|
---|
91 | ~t_datumTrafo (){}
|
---|
92 |
|
---|
93 | void initIndices() {_firstRow = 1; _lastRow = 0;}
|
---|
94 | void updateIndices(char sys, int maxObsSys) {
|
---|
95 | if (firstSystem(sys)) {
|
---|
96 | initIndices();
|
---|
97 | }
|
---|
98 | else {
|
---|
99 | _firstRow = _lastRow + 1;
|
---|
100 | }
|
---|
101 | _lastRow += maxObsSys; //LOG << sys << " updateIndices: lastRow: " << _lastRow << "\n" ;
|
---|
102 | };
|
---|
103 |
|
---|
104 | void setFirstSystem(char firstSys) { _firstSys = firstSys;}
|
---|
105 | bool firstSystem(char sys) {
|
---|
106 | if (_firstSys == sys) {
|
---|
107 | return true;
|
---|
108 | }
|
---|
109 | return false;
|
---|
110 | }
|
---|
111 | void setNumObs(int maxObs) {_maxObs = maxObs;}
|
---|
112 | void setNumPar(int numPar) {_numPar = numPar;}
|
---|
113 | int numPar() {return _numPar;}
|
---|
114 | int numObs() {return _maxObs;}
|
---|
115 | void updateNumObs() {
|
---|
116 | _maxObs = _lastRow;
|
---|
117 | _AA1 = _AA1.SubMatrix(1, _lastRow, 1, _numPar);
|
---|
118 | _AA2 = _AA2.SubMatrix(1, _lastRow, 1, _numPar);
|
---|
119 | }
|
---|
120 |
|
---|
121 | const Matrix& AA1() {return _AA1;}
|
---|
122 | const Matrix& AA2() {return _AA2;}
|
---|
123 | const Matrix& D21() {return _D21;}
|
---|
124 |
|
---|
125 | void initAA() {
|
---|
126 | _AA1.ReSize(_maxObs, _numPar); _AA1 = 0.0;
|
---|
127 | _AA2.ReSize(_maxObs, _numPar); _AA2 = 0.0;
|
---|
128 | _D21.ReSize(_numPar, _numPar); _D21 = 0.0;
|
---|
129 | }
|
---|
130 | t_irc prepareAA(const Matrix& AA, int ind) {//LOG << "prepare AA" << ind << "\n";
|
---|
131 | Matrix* Prep = &_AA2;
|
---|
132 | if (ind == 1) {
|
---|
133 | Prep = &_AA1;
|
---|
134 | }
|
---|
135 | //LOG << "_firstRow: " << _firstRow << " _lastRow: " << _lastRow << " _numPar " << _numPar << std::endl;
|
---|
136 | if (AA.Ncols() > _numPar) {
|
---|
137 | LOG << "t_pppFilter::prepareAA: AA.Ncols() > _numPar: " << AA.Ncols() << " > " << _numPar << std::endl;
|
---|
138 | return failure;
|
---|
139 | }
|
---|
140 | Prep->SubMatrix(_firstRow, _lastRow, 1, _numPar) << AA;
|
---|
141 | return success;
|
---|
142 | }
|
---|
143 | void switchAA() {
|
---|
144 | _AA1 = _AA2;
|
---|
145 | }
|
---|
146 | t_irc computeTrafoMatrix() {
|
---|
147 | if (((_AA2.t() * _AA2)).Determinant() == 0.0) {
|
---|
148 | LOG << "t_pppFilter::computeTrafoMatrix: (_AA2.t() * _AA2).inv() is singular" << std::endl;
|
---|
149 | return failure;
|
---|
150 | }
|
---|
151 | _D21 = ((_AA2.t() * _AA2).i()) * _AA2.t() * _AA1;
|
---|
152 | return success;
|
---|
153 | }
|
---|
154 |
|
---|
155 | void printMatrix(const Matrix& X, int nRow, int nCol) {
|
---|
156 | for (int rr = 0; rr < nRow; rr++) {
|
---|
157 | for (int cc = 0; cc < nCol; cc++) {
|
---|
158 | LOG << std::setw(6) << std::setprecision(3) << X[rr][cc] << " ;";
|
---|
159 | }
|
---|
160 | LOG << std::endl;
|
---|
161 | }
|
---|
162 | LOG << std::endl;
|
---|
163 | }
|
---|
164 | private:
|
---|
165 | int _firstRow;
|
---|
166 | int _lastRow;
|
---|
167 | Matrix _AA1;
|
---|
168 | Matrix _AA2;
|
---|
169 | Matrix _D21;
|
---|
170 | char _firstSys;
|
---|
171 | int _maxObs;
|
---|
172 | int _numPar;
|
---|
173 | QMap<char, t_prn> _refSatMapPseudoObs;
|
---|
174 | };
|
---|
175 |
|
---|
176 | t_irc processSystem(const std::vector<t_lc::type>& LCs,
|
---|
177 | const std::vector<t_pppSatObs*>& obsVector,
|
---|
178 | const t_prn& refPrn,
|
---|
179 | bool pseudoObsIonoAvailable,
|
---|
180 | bool preProcessing);
|
---|
181 |
|
---|
182 | t_irc detectCycleSlips(const std::vector<t_lc::type>& LCs,
|
---|
183 | const std::vector<t_pppSatObs*>& obsVector,
|
---|
184 | const t_prn& refPrn,
|
---|
185 | bool preProcessing);
|
---|
186 |
|
---|
187 | t_irc resetAmb(t_prn prn, const std::vector<t_pppSatObs*>& obsVector,
|
---|
188 | SymmetricMatrix* QSav = 0, ColumnVector* xSav = 0);
|
---|
189 |
|
---|
190 | void cmpDOP(const std::vector<t_pppSatObs*>& obsVector,
|
---|
191 | const QMap<char, t_pppRefSat*>& refSatMap);
|
---|
192 |
|
---|
193 | void setStateVectorAndVarCovMatrix(const ColumnVector& xFltOld, const SymmetricMatrix& QFltOld);
|
---|
194 |
|
---|
195 | void predictCovCrdPart(const SymmetricMatrix& QFltOld);
|
---|
196 |
|
---|
197 | t_irc addNoiseToIono(char sys);
|
---|
198 |
|
---|
199 | bool resetRefSatellitesLastEpoch(std::vector<t_pppSatObs*>& obsVector,
|
---|
200 | const QMap<char, t_pppRefSat*>& refSatMap,
|
---|
201 | const QMap<char, t_pppRefSat*>& refSatMapLastEpoch);
|
---|
202 |
|
---|
203 | bncTime _epoTime;
|
---|
204 | t_pppParlist _parlist;
|
---|
205 | t_pppParlist _parlist_sav;
|
---|
206 | t_pppObsPool* _obsPool;
|
---|
207 | t_datumTrafo* _datumTrafo;
|
---|
208 | SymmetricMatrix _QFlt;
|
---|
209 | SymmetricMatrix _QFlt_sav;
|
---|
210 | ColumnVector _xFlt;
|
---|
211 | ColumnVector _x0;
|
---|
212 | t_slip _slips[t_prn::MAXPRN+1];
|
---|
213 | int _numSat;
|
---|
214 | t_dop _dop;
|
---|
215 | bncTime _firstEpoTime;
|
---|
216 | bncTime _lastEpoTimeOK;
|
---|
217 | t_prn _refPrn;
|
---|
218 | };
|
---|
219 |
|
---|
220 | }
|
---|
221 |
|
---|
222 | #endif
|
---|