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

Last change on this file since 10003 was 10003, 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.5 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
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 LOG << "t_pppFilter::prepareAA: AA.Ncols() > _numPar? " << AA.Ncols() << " / " << _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 addNoiseToPar(t_pppParam::e_type parType, 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.