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

Last change on this file since 10013 was 10013, checked in by stuerze, 12 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.3 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
109 };
110
111 void setFirstSystem(char firstSys) { _firstSys = firstSys;}
112 bool firstSystem(char sys) {
113 if (_firstSys == sys) {
114 return true;
115 }
116 return false;
117 }
118 void setNumObs(int maxObs) {_maxObs = maxObs;}
119 void setNumPar(int numPar) {_numPar = numPar;}
120 int numPar() {return _numPar;}
121 int numObs() {return _maxObs;}
122 void updateNumObs() {
123 _maxObs = _lastRow;
124 _AA1 = _AA1.SubMatrix(1, _lastRow, 1, _numPar);
125 _AA2 = _AA2.SubMatrix(1, _lastRow, 1, _numPar);
126 }
127
128 const Matrix& AA1() {return _AA1;}
129 const Matrix& AA2() {return _AA2;}
130 const Matrix& D21() {return _D21;}
131
132 void initAA() {
133 _AA1.ReSize(_maxObs, _numPar); _AA1 = 0.0;
134 _AA2.ReSize(_maxObs, _numPar); _AA2 = 0.0;
135 _D21.ReSize(_numPar, _numPar); _D21 = 0.0;
136 }
137 t_irc prepareAA(const Matrix& AA, int ind) {
138
139 Matrix* Prep = &_AA2;
140 if (ind == 1) {
141 Prep = &_AA1;
142 }
143
144 if (AA.Ncols() > _numPar) {
145 LOG << "t_pppFilter::prepareAA: AA.Ncols() > _numPar: " << AA.Ncols() << " > " << _numPar << std::endl;
146 return failure;
147 }
148 Prep->SubMatrix(_firstRow, _lastRow, 1, _numPar) << AA;
149 return success;
150 }
151 void switchAA() {
152 _AA1 = _AA2;
153 }
154 t_irc computeTrafoMatrix() {
155 if (((_AA2.t() * _AA2)).Determinant() == 0.0) {
156 LOG << "t_pppFilter::computeTrafoMatrix: (_AA2.t() * _AA2).inv() is singular" << std::endl;
157 return failure;
158 }
159 _D21 = ((_AA2.t() * _AA2).i()) * _AA2.t() * _AA1;
160 return success;
161 }
162
163 void printMatrix(const Matrix& X, int nRow, int nCol) {
164 for (int rr = 0; rr < nRow; rr++) {
165 for (int cc = 0; cc < nCol; cc++) {
166 LOG << std::setw(6) << std::setprecision(3) << X[rr][cc] << " ;";
167 }
168 LOG << std::endl;
169 }
170 LOG << std::endl;
171 }
172 private:
173 int _firstRow;
174 int _lastRow;
175 Matrix _AA1;
176 Matrix _AA2;
177 Matrix _D21;
178 char _firstSys;
179 int _maxObs;
180 int _numPar;
181 QMap<char, t_prn> _refSatMapPseudoObs;
182 };
183
184 t_irc processSystem(const std::vector<t_lc::type>& LCs,
185 const std::vector<t_pppSatObs*>& obsVector,
186 const t_prn& refPrn,
187 bool pseudoObsIonoAvailable,
188 bool preProcessing);
189
190 t_irc detectCycleSlips(const std::vector<t_lc::type>& LCs,
191 const std::vector<t_pppSatObs*>& obsVector,
192 const t_prn& refPrn,
193 bool preProcessing);
194
195 t_irc resetAmb(t_prn prn, const std::vector<t_pppSatObs*>& obsVector, t_lc::type lc,
196 SymmetricMatrix* QSav = 0, ColumnVector* xSav = 0);
197
198 void cmpDOP(const std::vector<t_pppSatObs*>& obsVector,
199 const QMap<char, t_pppRefSat*>& refSatMap);
200
201 void setStateVectorAndVarCovMatrix(const ColumnVector& xFltOld, const SymmetricMatrix& QFltOld,
202 bool setNeuNoiseToZero);
203
204 void predictCovCrdPart(const SymmetricMatrix& QFltOld, bool setNeuNoiseToZero);
205
206 t_irc addNoiseToPar(t_pppParam::e_type parType, char sys);
207
208 bool resetRefSatellitesLastEpoch(std::vector<t_pppSatObs*>& obsVector,
209 const QMap<char, t_pppRefSat*>& refSatMap,
210 const QMap<char, t_pppRefSat*>& refSatMapLastEpoch);
211
212 bncTime _epoTime;
213 t_pppParlist _parlist;
214 t_pppParlist _parlist_sav;
215 t_pppObsPool* _obsPool;
216 t_datumTrafo* _datumTrafo;
217 SymmetricMatrix _QFlt;
218 SymmetricMatrix _QFlt_sav;
219 ColumnVector _xFlt;
220 ColumnVector _x0;
221 t_slip _slips[t_prn::MAXPRN+1];
222 int _numSat;
223 t_dop _dop;
224 bncTime _firstEpoTime;
225 bncTime _lastEpoTimeOK;
226 t_prn _refPrn;
227};
228
229}
230
231#endif
Note: See TracBrowser for help on using the repository browser.