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