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

Last change on this file since 9527 was 9527, checked in by stuerze, 2 years ago

update regarding PPP

  • 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
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 }
[9527]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 }
[9508]135 //LOG << "_firstRow: " << _firstRow << " _lastRow: " << _lastRow << " _numPar " << _numPar << std::endl;
136 if (AA.Ncols() > _numPar) {
137 LOG << "t_pppFilter::prepareAA: AA.Ncols() > _numPar: " << AA.Ncols() << " > " << _numPar << std::endl;
138 return failure;
139 }
[9386]140 Prep->SubMatrix(_firstRow, _lastRow, 1, _numPar) << AA;
[9508]141 return success;
[8915]142 }
[9386]143 void switchAA() {
144 _AA1 = _AA2;
145 }
[9419]146 t_irc computeTrafoMatrix() {
147 if (((_AA2.t() * _AA2)).Determinant() == 0.0) {
[9508]148 LOG << "t_pppFilter::computeTrafoMatrix: (_AA2.t() * _AA2).inv() is singular" << std::endl;
[9419]149 return failure;
[9386]150 }
[9419]151 _D21 = ((_AA2.t() * _AA2).i()) * _AA2.t() * _AA1;
152 return success;
[9386]153 }
[9419]154
[9386]155 void printMatrix(const Matrix& X, int nRow, int nCol) {
[8956]156 for (int rr = 0; rr < nRow; rr++) {
157 for (int cc = 0; cc < nCol; cc++) {
[9433]158 LOG << std::setw(6) << std::setprecision(3) << X[rr][cc] << " ;";
[8956]159 }
[9433]160 LOG << std::endl;
[9386]161 }
[9433]162 LOG << std::endl;
[8956]163 }
[9419]164 private:
[9386]165 int _firstRow;
166 int _lastRow;
167 Matrix _AA1;
168 Matrix _AA2;
[9419]169 Matrix _D21;
170 char _firstSys;
[9386]171 int _maxObs;
172 int _numPar;
173 QMap<char, t_prn> _refSatMapPseudoObs;
[8915]174 };
175
[7302]176 t_irc processSystem(const std::vector<t_lc::type>& LCs,
[8905]177 const std::vector<t_pppSatObs*>& obsVector,
178 const t_prn& refPrn,
179 bool pseudoObsIonoAvailable,
180 bool preProcessing);
[7237]181
[7302]182 t_irc detectCycleSlips(const std::vector<t_lc::type>& LCs,
[8905]183 const std::vector<t_pppSatObs*>& obsVector,
184 const t_prn& refPrn,
185 bool preProcessing);
[7237]186
187 t_irc resetAmb(t_prn prn, const std::vector<t_pppSatObs*>& obsVector,
188 SymmetricMatrix* QSav = 0, ColumnVector* xSav = 0);
189
[9508]190 void cmpDOP(const std::vector<t_pppSatObs*>& obsVector,
191 const QMap<char, t_pppRefSat*>& refSatMap);
[7237]192
[9526]193 void setStateVectorAndVarCovMatrix(const ColumnVector& xFltOld, const SymmetricMatrix& QFltOld);
194
[7237]195 void predictCovCrdPart(const SymmetricMatrix& QFltOld);
196
[9386]197 t_irc addNoiseToIono(char sys);
[8956]198
[9508]199 bool resetRefSatellitesLastEpoch(std::vector<t_pppSatObs*>& obsVector,
200 const QMap<char, t_pppRefSat*>& refSatMap,
201 const QMap<char, t_pppRefSat*>& refSatMapLastEpoch);
[9386]202
[7237]203 bncTime _epoTime;
[9504]204 t_pppParlist _parlist;
205 t_pppParlist _parlist_sav;
[8905]206 t_pppObsPool* _obsPool;
[8915]207 t_datumTrafo* _datumTrafo;
[7237]208 SymmetricMatrix _QFlt;
[9526]209 SymmetricMatrix _QFlt_sav;
[7237]210 ColumnVector _xFlt;
211 ColumnVector _x0;
212 t_slip _slips[t_prn::MAXPRN+1];
213 int _numSat;
214 t_dop _dop;
215 bncTime _firstEpoTime;
[7302]216 bncTime _lastEpoTimeOK;
[8910]217 t_prn _refPrn;
[7237]218};
219
220}
221
222#endif
Note: See TracBrowser for help on using the repository browser.