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

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