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

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