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
RevLine 
[7237]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"
[9386]10#include "pppClient.h"
[7237]11
12namespace BNC_PPP {
13
14class t_pppParlist;
15class t_pppObsPool;
16class t_pppSatObs;
17
18class t_pppFilter {
19 public:
[8905]20 t_pppFilter(t_pppObsPool* obsPool);
[7237]21 ~t_pppFilter();
22
[9386]23 t_irc processEpoch();
[7237]24
[9431]25 const ColumnVector& x() const {return _xFlt;}
26 const SymmetricMatrix& Q() const {return _QFlt;}
27
[9508]28 t_irc datumTransformation(const QMap<char, t_pppRefSat*>& refSatMap);
[9419]29 void initDatumTransformation(const std::vector<t_pppSatObs*>& allObs, bool pseudoObsIono);
30 unsigned setTrafoObs();
[10006]31 void restoreState(int num) {
32#ifdef BNC_DEBUG_PPP
33 LOG << "Restore parameter from last epoch : _parlist = _parlist_sav ("<< num << ")\n";
34#endif
[9526]35 _QFlt = _QFlt_sav;
36 _parlist = _parlist_sav;
37 }
[10006]38 void rememberState(int num) {
39#ifdef BNC_DEBUG_PPP
40 LOG << "Remember parameters from epoch before: _parlist_sav = _parlist ("<< num << ")\n";
41#endif
[9526]42 _QFlt_sav = _QFlt;
43 _parlist_sav = _parlist;
44 }
[8912]45
[7237]46 int numSat() const {return _numSat;}
[7928]47 double HDOP() const {return _dop.H;}
48 double HDOV() const {return _dop.V;}
[7237]49 double PDOP() const {return _dop.P;}
50 double GDOP() const {return _dop.G;}
51 double trp() const {
[9504]52 const std::vector<t_pppParam*>& par = _parlist.params();
[7237]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 {
[9504]61 const std::vector<t_pppParam*>& par = _parlist.params();
[7237]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();}
[7928]86 void reset() {H = V = P = T = G = 0.0;}
87 double H;
88 double V;
[7237]89 double P;
90 double T;
91 double G;
92 };
93
[8956]94 class t_datumTrafo {
[8915]95 public:
[9431]96 t_datumTrafo () {initIndices();}
97 ~t_datumTrafo (){}
[9419]98
[9431]99 void initIndices() {_firstRow = 1; _lastRow = 0;}
[9419]100 void updateIndices(char sys, int maxObsSys) {
101 if (firstSystem(sys)) {
[8915]102 initIndices();
103 }
104 else {
[9304]105 _firstRow = _lastRow + 1;
[8915]106 }
[10006]107 _lastRow += maxObsSys;
108#ifdef BNC_DEBUG_PPP
109 LOG << sys << " updateIndices: lastRow: " << _lastRow << "\n" ;
110#endif
[9419]111 };
[9386]112
[9431]113 void setFirstSystem(char firstSys) { _firstSys = firstSys;}
114 bool firstSystem(char sys) {
115 if (_firstSys == sys) {
116 return true;
117 }
118 return false;
119 }
[9419]120 void setNumObs(int maxObs) {_maxObs = maxObs;}
[9431]121 void setNumPar(int numPar) {_numPar = numPar;}
[9419]122 int numPar() {return _numPar;}
123 int numObs() {return _maxObs;}
[9431]124 void updateNumObs() {
125 _maxObs = _lastRow;
[9419]126 _AA1 = _AA1.SubMatrix(1, _lastRow, 1, _numPar);
127 _AA2 = _AA2.SubMatrix(1, _lastRow, 1, _numPar);
128 }
129
[9386]130 const Matrix& AA1() {return _AA1;}
131 const Matrix& AA2() {return _AA2;}
[9419]132 const Matrix& D21() {return _D21;}
[9386]133
[9431]134 void initAA() {
[9386]135 _AA1.ReSize(_maxObs, _numPar); _AA1 = 0.0;
136 _AA2.ReSize(_maxObs, _numPar); _AA2 = 0.0;
[9419]137 _D21.ReSize(_numPar, _numPar); _D21 = 0.0;
[8915]138 }
[10006]139 t_irc prepareAA(const Matrix& AA, int ind) {
140#ifdef BNC_DEBUG_PPP
141 LOG << "prepare AA" << ind << "\n";
142#endif
[8956]143 Matrix* Prep = &_AA2;
[9386]144 if (ind == 1) {
[8956]145 Prep = &_AA1;
[8915]146 }
[10006]147#ifdef BNC_DEBUG_PPP
[10003]148 LOG << "_firstRow: " << _firstRow << " _lastRow: " << _lastRow << " _numPar " << _numPar << std::endl;
[10006]149 LOG << "AA.Ncols() > _numPar? " << AA.Ncols() << " / " << _numPar << std::endl;
150#endif
[9508]151 if (AA.Ncols() > _numPar) {
152 LOG << "t_pppFilter::prepareAA: AA.Ncols() > _numPar: " << AA.Ncols() << " > " << _numPar << std::endl;
153 return failure;
154 }
[9386]155 Prep->SubMatrix(_firstRow, _lastRow, 1, _numPar) << AA;
[9508]156 return success;
[8915]157 }
[9386]158 void switchAA() {
159 _AA1 = _AA2;
160 }
[9419]161 t_irc computeTrafoMatrix() {
162 if (((_AA2.t() * _AA2)).Determinant() == 0.0) {
[9508]163 LOG << "t_pppFilter::computeTrafoMatrix: (_AA2.t() * _AA2).inv() is singular" << std::endl;
[9419]164 return failure;
[9386]165 }
[9419]166 _D21 = ((_AA2.t() * _AA2).i()) * _AA2.t() * _AA1;
167 return success;
[9386]168 }
[9419]169
[9386]170 void printMatrix(const Matrix& X, int nRow, int nCol) {
[8956]171 for (int rr = 0; rr < nRow; rr++) {
172 for (int cc = 0; cc < nCol; cc++) {
[9433]173 LOG << std::setw(6) << std::setprecision(3) << X[rr][cc] << " ;";
[8956]174 }
[9433]175 LOG << std::endl;
[9386]176 }
[9433]177 LOG << std::endl;
[8956]178 }
[9419]179 private:
[9386]180 int _firstRow;
181 int _lastRow;
182 Matrix _AA1;
183 Matrix _AA2;
[9419]184 Matrix _D21;
185 char _firstSys;
[9386]186 int _maxObs;
187 int _numPar;
188 QMap<char, t_prn> _refSatMapPseudoObs;
[8915]189 };
190
[7302]191 t_irc processSystem(const std::vector<t_lc::type>& LCs,
[8905]192 const std::vector<t_pppSatObs*>& obsVector,
193 const t_prn& refPrn,
194 bool pseudoObsIonoAvailable,
195 bool preProcessing);
[7237]196
[7302]197 t_irc detectCycleSlips(const std::vector<t_lc::type>& LCs,
[8905]198 const std::vector<t_pppSatObs*>& obsVector,
199 const t_prn& refPrn,
200 bool preProcessing);
[7237]201
202 t_irc resetAmb(t_prn prn, const std::vector<t_pppSatObs*>& obsVector,
203 SymmetricMatrix* QSav = 0, ColumnVector* xSav = 0);
204
[9508]205 void cmpDOP(const std::vector<t_pppSatObs*>& obsVector,
206 const QMap<char, t_pppRefSat*>& refSatMap);
[7237]207
[9526]208 void setStateVectorAndVarCovMatrix(const ColumnVector& xFltOld, const SymmetricMatrix& QFltOld);
209
[7237]210 void predictCovCrdPart(const SymmetricMatrix& QFltOld);
211
[9642]212 t_irc addNoiseToPar(t_pppParam::e_type parType, char sys);
[8956]213
[9508]214 bool resetRefSatellitesLastEpoch(std::vector<t_pppSatObs*>& obsVector,
215 const QMap<char, t_pppRefSat*>& refSatMap,
216 const QMap<char, t_pppRefSat*>& refSatMapLastEpoch);
[9386]217
[7237]218 bncTime _epoTime;
[9504]219 t_pppParlist _parlist;
220 t_pppParlist _parlist_sav;
[8905]221 t_pppObsPool* _obsPool;
[8915]222 t_datumTrafo* _datumTrafo;
[7237]223 SymmetricMatrix _QFlt;
[9526]224 SymmetricMatrix _QFlt_sav;
[7237]225 ColumnVector _xFlt;
226 ColumnVector _x0;
227 t_slip _slips[t_prn::MAXPRN+1];
228 int _numSat;
229 t_dop _dop;
230 bncTime _firstEpoTime;
[7302]231 bncTime _lastEpoTimeOK;
[8910]232 t_prn _refPrn;
[7237]233};
234
235}
236
237#endif
Note: See TracBrowser for help on using the repository browser.