StatsFilter_T.cpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
40 
41 #include <vector>
42 #include "FirstDiffFilter.hpp"
43 #include "FDiffFilter.hpp"
44 #include "WindowFilter.hpp"
45 #include "logstream.hpp"
46 
47 
48 
49 using namespace std;
50 using namespace gnsstk;
51 
52 
53 
54 int testFirstDiff(const vector<double>& xdata,
55  const vector<double>& data,
56  const double& ratlimit,
57  const string& label,
58  const bool& verbose,
59  vector< FilterHit<double> >& hit)
60 {
61  int iret;
62  unsigned int i,j,k;
63 
64  // fill flags
65  vector<int> flags;
66  flags = vector<int>(data.size(),0);
67 
68  // xdata and flags must exist but may be empty
69  FirstDiffFilter<double> fdf(xdata, data, flags);
70  fdf.setw(7);
71  fdf.setprecision(4);
72  fdf.setLimit(ratlimit);
73  iret = fdf.filter();
74  if (verbose)
75  {
76  cout << "# FD Filter returns " << iret << endl;
77  }
78  if (iret < 0)
79  {
80  cout << "# FD Filter failed (" << iret << ")" << endl;
81  }
82  else
83  {
84  iret = fdf.analyze();
85  if (iret < 0)
86  {
87  cout << "# FD Filter analysis failed (" << iret << ")" << endl;
88  }
89  else
90  {
91  iret=0;
92  }
93 
94  for (i=0; i<fdf.results.size(); i++)
95  {
96  fdf.getStats(fdf.results[i]);
97  }
98  fdf.setDumpNoAnal(false);
99  if (verbose)
100  {
101  fdf.dump(cout, label);
102  }
103 
104  hit = fdf.getResults();
105 
106  // clean the data based on results of filter
107  //vector< FilterHit<double> > hit=fdf.getResults();
108  for (j=0; j<hit.size(); j++)
109  {
110  cout << label << " " << hit[j].asString() << endl;
111 
112  //if (hit[j].type == FilterHit<double>::BOD) continue;
113  //else if (hit[j].type == FilterHit<double>::outlier) {
114  // for (k=0; k<hit[j].npts; k++)
115  // flags[hit[j].index+k] = -1; // flag for outlier
116  //}
117  //else if (hit[j].type == FilterHit<double>::slip) {
118  // for (k=hit[j].index; k<data.size(); k++)
119  // data[k] -= hit[j].step;
120  //}
121  }
122 
124  //ostream *pout = new ofstream("rstats.out");
125  //if (pout->fail()) {
126  // cout << "Unable to open file rstats.out - output to screen\n";
127  // pout = &cout;
128  //}
129 
130  //for (i=0; i<data.size(); i++)
131  // *pout << fixed << setprecision(prec) << i
132  // << " " << (xdata.size() ? xdata[i] : (double)(i))
133  // << " " << data[i] << " " << flags[i] << endl;
134  //if (pout != &cout) ((ofstream *)pout)->close();
135  }
136 
137  return iret;
138 }
139 
140 
141 
142 int testWindow(const vector<double>& xdata,
143  const vector<double>& data,
144  const bool& useTSS,
145  const double& window,
146  const double& steplimit,
147  const double& ratlimit,
148  const string& label,
149  const bool& verbose,
150  vector< FilterHit<double> >& hit)
151 {
152  int iret;
153  unsigned int i,j,k;
154 
155  // fill flags
156  vector<int> flags;
157  flags = vector<int>(data.size(),0);
158 
159  // one-sample stats
160  WindowFilter<double> wf(xdata, data, flags);
161  wf.setTwoSample(useTSS);
162  wf.setWidth(window);
163  if (ratlimit > 0.0)
164  {
165  wf.setMinRatio(ratlimit);
166  }
167  if (steplimit > 0.0)
168  {
169  wf.setMinStep(steplimit);
170  }
171  wf.setw(7);
172  wf.setprecision(4);
173  iret = wf.filter();
174  if (iret < 0)
175  {
176  cout << "# window filter failed (" << iret << ")" << endl;
177  }
178  else
179  {
180  if (verbose)
181  {
182  wf.setDebug(true);
183  }
184  wf.analyze(); // ignore return values
185  if (verbose)
186  {
187  wf.setDumpAnalMsg(true);
188  wf.dump(cout, label);
189  }
190 
191  hit = wf.getResults();
192  for (j=0; j<hit.size(); j++)
193  {
194  cout << label << " " << hit[j].asString() << endl;
195  }
196  }
197 
198  return iret;
199 }
200 
201 
202 
203 int testFDiff(const vector<double>& xdata,
204  const vector<double>& data,
205  const double& ratlimit,
206  const string& label,
207  const bool& verbose,
208  vector< FilterHit<double> >& hit)
209 {
210  int iret;
211  unsigned int i,j,k;
212 
213  // fill flags
214  vector<int> flags;
215  flags = vector<int>(data.size(),0);
216 
217  // xdata and flags must exist but may be empty
218  IterativeFDiffFilter<double> fdf(xdata, data, flags);
219  fdf.setw(7);
220  fdf.setprecision(4);
221 
222  fdf.setWidth(4);
223  fdf.setLimit(0.8);
224  fdf.setSigma(ratlimit);
225 
226  fdf.doVerbose(verbose);
227  fdf.doResetSigma(true);
228  fdf.doSmallSlips(false);
229 
230  iret = fdf.analysis();
231  if (iret < 0)
232  {
233  cout << "# FDiffFilter analysis failed (" << iret << ")" << endl;
234  }
235  else
236  {
237  iret=0;
238  }
239 
240  hit = fdf.getResults();
241 
242  // clean the data based on results of filter
243  //vector< FilterHit<double> > hit=fdf.getResults();
244  for (j=0; j<hit.size(); j++)
245  {
246  cout << label << " " << hit[j].asString() << endl;
247 
248  //if (hit[j].type == FilterHit<double>::BOD) continue;
249  //else if (hit[j].type == FilterHit<double>::outlier) {
250  // for (k=0; k<hit[j].npts; k++)
251  // flags[hit[j].index+k] = -1; // flag for outlier
252  //}
253  //else if (hit[j].type == FilterHit<double>::slip) {
254  // for (k=hit[j].index; k<data.size(); k++)
255  // data[k] -= hit[j].step;
256  //}
257  }
258 
260  //ostream *pout = new ofstream("rstats.out");
261  //if (pout->fail()) {
262  // cout << "Unable to open file rstats.out - output to screen\n";
263  // pout = &cout;
264  //}
265 
266  //for (i=0; i<data.size(); i++)
267  // *pout << fixed << setprecision(prec) << i
268  // << " " << (xdata.size() ? xdata[i] : (double)(i))
269  // << " " << data[i] << " " << flags[i] << endl;
270  //if (pout != &cout) ((ofstream *)pout)->close();
271 
272  return iret;
273 }
274 
275 
276 
277 int main(int argc, char **argv)
278 {
279  try
280  {
281  // datasets
282  //# Satellites G12
283  //# Linear combinations WLC:12 GF:P:12
284  //# RinDump output for file job4131.obs
285  //# Header ObsIDs GPS (4): C1C L1C C2W L2X
286  //# wk secs-of-wk sat WLC:12 GF:P:12
287  const unsigned int M1=243;
288  // sow WLC GF
289  double data1[3*M1] = {
290  485370.000, -0.642, 0.050, 485400.000, -0.586, 0.085, 485430.000, -0.415, 0.127,
291  485460.000, -0.374, 0.163, 485490.000, -0.426, 0.191, 485520.000, -0.567, 0.223,
292  485550.000, -0.855, 0.244, 485580.000, -1.151, 0.265, 485610.000, -1.329, 0.288,
293  485640.000, -1.369, 0.312, 485670.000, -1.270, 0.328, 485700.000, -0.956, 0.348,
294  485730.000, -0.585, 0.369, 485760.000, -0.368, 0.386, 485790.000, -0.324, 0.408,
295  485820.000, -0.374, 0.428, 485850.000, -0.487, 0.441, 485880.000, -0.631, 0.451,
296  485910.000, -0.754, 0.469, 485940.000, -0.884, 0.475, 485970.000, -0.974, 0.491,
297  486000.000, -1.103, 0.499, 486030.000, -1.142, 0.504, 486060.000, -0.872, 0.505,
298  486090.000, -0.414, 0.495, 486120.000, -0.006, 0.495, 486150.000, 0.300, 0.516,
299  486180.000, 0.335, 0.522, 486210.000, 0.156, 0.520, 486240.000, -0.106, 0.505,
300  486270.000, -0.313, 0.502, 486300.000, -0.651, 0.494, 486330.000, -1.062, 0.489,
301  486360.000, -1.381, 0.490, 486390.000, -1.552, 0.486, 486420.000, -1.427, 0.481,
302  486450.000, -0.992, 0.478, 486480.000, -0.536, 0.468, 486510.000, -0.211, 0.468,
303  486540.000, -0.212, 0.467, 486570.000, -0.436, 0.467, 486600.000, -0.803, 0.466,
304  486630.000, -1.141, 0.478, 486660.000, -1.488, 0.481, 486690.000, -1.708, 0.478,
305  486720.000, -1.685, 0.459, 486750.000, -1.529, 0.454, 486780.000, -1.521, 0.455,
306  486810.000, -1.540, 0.473, 486840.000, -1.509, 0.490, 486870.000, -1.422, 0.506,
307  486900.000, -1.459, 0.497, 487020.000, -1.860,-0.438, 487050.000, -2.144,-0.422,
308  487080.000, -1.880,-0.400, 487110.000, -1.442,-0.399, 487140.000, -1.077,-0.425,
309  487170.000, -0.669,-0.406, 487200.000, -0.653,-0.402, 487230.000, -0.626,-0.385,
310  487260.000, -0.523,-0.379, 487290.000, -0.456,-0.387, 487320.000, -0.555,-0.379,
311  487350.000, -0.821,-0.371, 487380.000, -1.135,-0.361, 487410.000, -1.237,-0.366,
312  487440.000, -1.019,-0.372, 487470.000, -0.807,-0.370, 487500.000, -0.879,-0.369,
313  487530.000, -1.109,-0.356, 487560.000, -1.390,-0.354, 487590.000, -1.524,-0.351,
314  487620.000, -1.403,-0.363, 487650.000, -1.240,-0.361, 487680.000, -1.309,-0.365,
315  487710.000, -1.449,-0.357, 487740.000, -1.613,-0.358, 487770.000, -1.677,-0.355,
316  487800.000, -1.598,-0.358, 487830.000, -1.395,-0.364, 487860.000, -1.180,-0.365,
317  487890.000, -1.048,-0.361, 487920.000, -1.040,-0.357, 487950.000, -1.101,-0.361,
318  487980.000, -1.105,-0.369, 488010.000, -0.993,-0.371, 488040.000, -0.747,-0.362,
319  488070.000, -0.558,-0.370, 488100.000, -0.392,-0.375, 488130.000, -0.321,-0.376,
320  488160.000, -0.363,-0.375, 488190.000, -0.399,-0.370, 488220.000, -0.406,-0.387,
321  488250.000, -0.277,-0.389, 488280.000, -0.324,-0.390, 488310.000, -0.473,-0.389,
322  488340.000, -0.613,-0.395, 488370.000, -0.660,-0.409, 488400.000, -0.504,-0.406,
323  488430.000, -0.406,-0.412, 488460.000, -0.448,-0.412, 488490.000, -0.606,-0.410,
324  488520.000, -0.813,-0.404, 488550.000, -1.005,-0.401, 488580.000, -1.078,-0.403,
325  488610.000, -1.022,-0.404, 488640.000, -1.110,-0.400, 488670.000, -1.251,-0.395,
326  488700.000, -1.387,-0.390, 488730.000, -1.354,-0.391, 488760.000, -1.197,-0.390,
327  488790.000, -0.946,-0.387, 488820.000, -0.788,-0.379, 488850.000, -0.795,-0.377,
328  488880.000, -0.830,-0.379, 488910.000, -0.864,-0.391, 488940.000, -0.816,-0.396,
329  488970.000, -0.799,-0.396, 489000.000, -0.833,-0.391, 489030.000, -0.918,-0.390,
330  489060.000, -0.976,-0.393, 489090.000, -0.962,-0.398, 489120.000, -0.943,-0.398,
331  489150.000, -0.961,-0.394, 489180.000, -0.948,-0.396, 489210.000, -0.809,-0.395,
332  489240.000, -0.670,-0.396, 489270.000, -0.586,-0.396, 489300.000, -0.581,-0.398,
333  489330.000, -0.534,-0.395, 489360.000, -0.466,-0.402, 489390.000, -0.253,-0.413,
334  489420.000, -0.122,-0.420, 489450.000, -0.144,-0.422, 489480.000, -0.339,-0.433,
335  489510.000, -0.546,-0.450, 489540.000, -0.683,-0.464, 489570.000, -0.921,-0.480,
336  489600.000, -1.244,-0.483, 489630.000, -1.742,-0.500, 489660.000, -2.081,-0.493,
337  489690.000, -2.116,-0.528, 489720.000, -1.982,-0.540, 489750.000, -1.991,-0.551,
338  489780.000, -2.158,-0.554, 490080.000,-17.714,-4.324, 490110.000,-17.941,-4.321,
339  490140.000,-18.259,-4.322, 490170.000,-18.417,-4.331, 490200.000,-18.211,-4.340,
340  490230.000,-17.821,-4.336, 490260.000,-17.523,-4.335, 490290.000,-17.407,-4.331,
341  490320.000,-17.387,-4.333, 490350.000,-17.302,-4.338, 490380.000,-17.090,-4.343,
342  490410.000,-16.902,-4.341, 490440.000,-16.835,-4.338, 490470.000,-16.856,-4.340,
343  490500.000,-16.888,-4.347, 490530.000,-16.886,-4.354, 490560.000,-16.933,-4.359,
344  490590.000,-17.009,-4.361, 490620.000,-17.093,-4.362, 490650.000,-17.066,-4.364,
345  490680.000,-16.985,-4.369, 490710.000,-16.935,-4.378, 490740.000,-17.007,-4.382,
346  490770.000,-17.151,-4.385, 490800.000,-17.268,-4.390, 490830.000,-17.289,-4.398,
347  490860.000,-17.241,-4.404, 490890.000,-17.193,-4.406, 490920.000,-17.230,-4.409,
348  490950.000,-17.261,-4.411, 490980.000,-17.250,-4.416, 491010.000,-17.185,-4.420,
349  491040.000,-17.089,-4.421, 491070.000,-17.046,-4.421, 491100.000,-17.057,-4.423,
350  491130.000,-17.062,-4.428, 491160.000,-17.036,-4.430, 491190.000,-17.039,-4.433,
351  491220.000,-17.058,-4.433, 491250.000,-17.119,-4.437, 491280.000,-17.171,-4.441,
352  491310.000,-17.171,-4.447, 491340.000,-17.141,-4.452, 491370.000,-17.122,-4.455,
353  491400.000,-17.143,-4.456, 491430.000,-17.157,-4.456, 491460.000,-17.143,-4.461,
354  491490.000,-17.098,-4.462, 491520.000,-17.105,-4.464, 491550.000,-17.160,-4.464,
355  491580.000,-17.221,-4.463, 491610.000,-17.250,-4.462, 491640.000,-17.196,-4.462,
356  491670.000,-17.143,-4.462, 491700.000,-17.101,-4.463, 491730.000,-17.047,-4.462,
357  491760.000,-17.004,-4.463, 491790.000,-16.961,-4.463, 491820.000,-16.931,-4.461,
358  491850.000,-16.929,-4.458, 491880.000,-16.937,-4.457, 491910.000,-16.945,-4.457,
359  491940.000,-16.996,-4.457, 491970.000,-17.078,-4.456, 492000.000,-17.160,-4.455,
360  492030.000,-17.219,-4.453, 492060.000,-17.244,-4.452, 492090.000,-17.249,-4.452,
361  492120.000,-17.256,-4.452, 492150.000,-17.276,-4.455, 492180.000,-17.289,-4.458,
362  492210.000,-17.269,-4.461, 492240.000,-17.238,-4.462, 492270.000,-17.195,-4.463,
363  492300.000,-17.184,-4.464, 492330.000,-17.214,-4.466, 492360.000,-17.242,-4.468,
364  492390.000,-17.248,-4.471, 492420.000,-17.232,-4.472, 492450.000,-17.195,-4.474,
365  492480.000,-17.183,-4.473, 492510.000,-17.217,-4.474, 492540.000,-17.278,-4.476,
366  492570.000,-17.346,-4.477, 492600.000,-17.409,-4.478, 492630.000,-17.453,-4.479,
367  492660.000,-17.501,-4.482, 492690.000,-17.515,-4.484, 492720.000,-17.487,-4.487,
368  492750.000,-17.416,-4.489, 492780.000,-17.336,-4.490, 492810.000,-17.268,-4.492,
369  492840.000,-17.229,-4.495, 492870.000,-17.188,-4.498, 492900.000,-17.160,-4.498,
370  492930.000,-17.163,-4.500, 492960.000,-17.180,-4.502, 492990.000,-17.206,-4.502
371  };
372 
373  const unsigned int M2=26;
374  //# secs-of-wk WLC:12 GF:P:12
375  double data2[2*M2] = {
376  489510.000, -8.546, 489540.000, 9.683, 489570.000, -7.921,
377  489600.000, -1.244, 489630.000, -1.742, 489660.000, -2.081,
378  489690.000, -2.116, 489720.000, -1.982, 489750.000, -1.991,
379  489780.000, -2.158, 489810.000, -11.723, 490080.000, -17.714,
380  490110.000, -17.941, 490140.000, -18.259, 490170.000, -18.417,
381  490200.000, -18.211, 490230.000, -17.821, 490260.000, -17.523,
382  490290.000, -17.407, 490320.000, -17.387, 490350.000, -17.302,
383  490380.000, -17.090, 490410.000, -16.902, 490440.000, -16.835,
384  490470.000, -16.856, 490500.000, -16.888
385  };
386 
387  //# RinDump output for file /local/Work/HFGeo/G10/G10_0180.14o.new
388  const unsigned int M3=245;
389  //# secs-of-wk WLC:12 GF:P:12
390  double data3[3*M3] = {
391  522000.000, 0.087, 522030.000, -0.039, 522060.000, 0.045, 522090.000, -0.246,
392  522120.000, -0.159, 522150.000, -0.006, 522180.000, -0.214, 522210.000, 0.051,
393  522240.000, 0.086, 522270.000, -0.019, 522300.000, -0.128, 522330.000, 0.141,
394  522360.000, -0.119, 522390.000, -0.216, 522420.000, 0.033, 522450.000, -0.172,
395  522480.000, 0.083, 522510.000, 0.022, 522540.000, -0.037, 522570.000, -0.052,
396  522600.000, -0.153, 522630.000, 0.114, 522660.000, 0.325, 522690.000, 0.015,
397  522720.000, -0.123, 522750.000, -0.054, 522780.000, -0.007, 522810.000, -0.072,
398  522840.000, -0.401, 522870.000, -0.098, 522900.000, 0.017, 522930.000, -0.147,
399  522960.000, -0.037, 522990.000, 0.027, 523020.000, -0.096, 523050.000, -0.088,
400  523080.000, 0.109, 523110.000, -0.115, 523140.000, 0.146, 523170.000, -0.340,
401  523200.000, -0.112, 523230.000, 0.219, 523260.000, -0.161, 523290.000, -0.179,
402  523320.000, 0.039, 523350.000, 0.037, 523380.000, 0.175, 523410.000, -0.265,
403  523440.000, -0.022, 523470.000, 0.204, 523500.000, 0.243, 523530.000, -0.107,
404  523560.000, -0.171, 523590.000, 0.334, 523620.000, 0.084, 523650.000, 0.100,
405  523680.000, -0.016, 523710.000, 0.035, 523740.000, 0.010, 523770.000, -0.113,
406  523800.000, -0.047, 523830.000, 0.179, 523860.000, 0.171, 523890.000, -0.279,
407  523920.000, -0.047, 523950.000, 0.405, 523980.000, 0.325, 524010.000, -0.068,
408  524040.000, 0.008, 524070.000, -2.719, 524100.000, -0.015, 524130.000, 0.272,
409  524160.000, 0.555, 524190.000, 0.300, 524220.000, 0.506, 524250.000, 0.084,
410  524280.000, 0.131, 524310.000, -0.109, 524340.000, -0.376, 524370.000, 0.372,
411  524400.000, 0.363, 524430.000, 0.063, 524460.000, 0.449, 524490.000, 0.078,
412  524520.000, 0.409, 524550.000, 0.128, 524580.000, 0.120, 524610.000, 0.324,
413  524640.000, 0.263, 524670.000, 0.123, 524700.000, 0.526, 524730.000, -0.591,
414  524760.000, 0.032, 524790.000, 2.959, 524820.000, 0.738, 524850.000, -0.020,
415  524880.000, 0.532, 524910.000, 0.783, 524940.000, 0.320, 524970.000, -0.004,
416  525000.000, 0.119, 525030.000, -0.641, 525060.000, -0.005, 525090.000, -0.045,
417  525120.000, 0.146, 525150.000, 0.202, 525180.000, 0.015, 525210.000, 0.072,
418  525240.000, 0.697, 525270.000, 0.885, 525300.000, 0.329, 525330.000, 0.618,
419  525360.000, -0.041, 525390.000, 0.072, 525420.000, 0.946, 525450.000, 0.204,
420  525480.000, 0.831, 525510.000, 0.257, 525540.000, 0.274, 525570.000, 0.612,
421  525600.000, 0.123, 525630.000, 0.107, 525660.000, 0.896, 525690.000, 0.083,
422  525720.000, 0.406, 525750.000, 0.398, 525780.000, 0.558, 525810.000, 0.577,
423  525840.000, -0.286, 525870.000, 0.226, 525900.000, 0.762, 525930.000, 0.873,
424  525960.000, 0.767, 525990.000, 0.865, 526020.000, 0.631, 526050.000, 0.771,
425  526080.000, 0.828, 526110.000, -0.308, 526140.000, 0.930, 526170.000, 0.817,
426  526200.000, 0.791, 526230.000, 0.048, 526260.000, 0.106, 526290.000, 0.249,
427  526320.000, 0.602, 526350.000, 0.099, 526380.000, 0.031, 526410.000, 0.145,
428  526440.000, 0.290, 526470.000, 0.635, 526500.000, 1.352, 526530.000, 1.048,
429  526560.000, 0.907, 526590.000, 0.743, 526620.000, 0.453, 526650.000, 0.860,
430  526680.000, 0.910, 526710.000, 0.483, 526740.000, 0.905, 526770.000, 0.535,
431  526800.000, -0.049, 526830.000, 0.308, 526860.000, 1.017, 526890.000, -0.278,
432  526920.000, 0.905, 526950.000, 0.373, 526980.000, 0.783, 527010.000, -0.020,
433  527040.000, 0.919, 527070.000, 0.503, 527100.000, 1.054, 527130.000, 0.775,
434  527160.000, 0.782, 527190.000, 0.236, 527220.000, 0.520, 527250.000, 0.641,
435  527280.000, 0.764, 527310.000, 0.264, 527340.000, 1.002, 527370.000, 0.764,
436  527400.000, 0.253, 527430.000, 1.204, 527460.000, 0.206, 527490.000, 1.109,
437  527520.000, 1.026, 527550.000, 0.501, 527580.000, 1.184, 527610.000, -0.042,
438  527640.000, 1.028, 527670.000, 1.123, 527700.000, 2.846, 527730.000, 1.678,
439  527760.000, 0.873, 527790.000, 0.908, 527820.000, 2.337, 527850.000, -0.664,
440  527880.000, 0.653, 527910.000, 0.200, 527940.000, 0.849, 527970.000, 0.606,
441  528000.000, -0.178, 528030.000, -0.046, 528060.000, 0.404, 528090.000, 0.378,
442  528120.000, 0.436, 528150.000, 0.146, 528180.000, -0.163, 528210.000, 0.046,
443  528240.000, -0.389, 528270.000, 0.566, 528300.000, -0.594, 528330.000, -0.312,
444  528360.000, -0.289, 528390.000, 0.694, 528420.000, -0.039, 528450.000, 0.809,
445  528480.000, 0.592, 528510.000, -0.687, 528540.000, 1.037, 528570.000, 0.608,
446  528600.000, 1.126, 528630.000, 0.736, 528660.000, -0.536, 528690.000, 0.318,
447  528720.000, 0.641, 528750.000, 0.223, 528780.000, 0.085, 528810.000, 1.703,
448  528840.000, 1.038, 528870.000, 0.572, 528900.000, 0.787, 528930.000, -0.765,
449  528960.000, -0.140, 528990.000, 0.712, 529020.000, 0.727, 529050.000, 0.027,
450  529080.000, 0.841, 529110.000, 0.568, 529140.000, 0.598, 529170.000, -0.638,
451  529200.000, 0.946, 529230.000, 1.173, 529260.000, -0.153, 529290.000, 0.125,
452  529320.000, 3.918
453  };
454 
455  bool verbose(false); // if true dump all data and results
456  int iret,count(0);
457  unsigned int i;
458  const double tol(0.001); // for comparing slip size
459  string label;
460  vector<double> xdata, data, dataB;
461  vector< FilterHit<double> > results;
462 
463  // dataset 1 ----------------------------------------------------------
464  data.clear(); dataB.clear(); xdata.clear();
465  for (i=0; i<M1; i++)
466  {
467  xdata.push_back(data1[3*i]);
468  data.push_back(data1[3*i+1]);
469  dataB.push_back(data1[3*i+2]);
470  }
471 
472  label = "Test1FDF";
473  iret = testFirstDiff(xdata, data, 2.0, label, verbose, results);
474  if (iret == 0)
475  {
476  if (results[0].type != FilterHit<double>::BOD ||
477  results[0].npts != 145 || results[0].ngood != 145)
478  {
479  cout << label << " first hit\n";
480  count++;
481  }
482  if (results[1].type != FilterHit<double>::slip ||
483  results[1].index != 145 || results[1].npts != 98 ||
484  results[1].ngood != 98 || ::fabs(results[1].step + 15.556) > tol)
485  {
486  cout << label << " second hit\n";
487  count++;
488  }
489  }
490  else
491  {
492  cout << label << " failed " << iret << "\n";
493  count++;
494  }
495 
496  label = "Test1Wind1";
497  iret = testWindow(xdata, data, false, 20, 0.08, 6, label, verbose,
498  results);
499  if (iret == 239)
500  {
501  if (results[0].type != FilterHit<double>::BOD ||
502  results[0].index != 2 ||
503  results[0].npts != 143 ||
504  results[0].ngood != 143)
505  {
506  cout << label << " first hit\n";
507  count++;
508  }
509  if (results[1].type != FilterHit<double>::slip ||
510  results[1].index != 145 ||
511  results[1].npts != 96 ||
512  results[1].ngood != 96 ||
513  ::fabs(results[1].step + 16.379) > tol)
514  {
515  cout << label << " second hit\n";
516  count++;
517  }
518  }
519  else
520  {
521  cout << label << " failed " << iret << "\n";
522  count++;
523  }
524 
525  label = "Test1Wind2";
526  iret = testWindow(xdata, data, true, 20, 0.08, 6, label, verbose,
527  results);
528  if (iret == 239)
529  {
530  if (results[0].type != FilterHit<double>::BOD ||
531  results[0].index != 2 ||
532  results[0].npts != 143 ||
533  results[0].ngood != 143)
534  {
535  cout << label << " first hit\n";
536  count++;
537  }
538  if (results[1].type != FilterHit<double>::slip ||
539  results[1].index != 145 ||
540  results[1].npts != 96 ||
541  results[1].ngood != 96 ||
542  ::fabs(results[1].step + 16.016) > tol)
543  {
544  cout << label << " second hit\n";
545  count++;
546  }
547  }
548  else
549  {
550  cout << label << " failed " << iret << "\n";
551  count++;
552  }
553 
554  label = "Test1Wind3";
555  iret = testWindow(xdata, dataB, true, 20, 0.08, 6, label, verbose,
556  results);
557  if (iret == 239)
558  {
559  if (results[0].type != FilterHit<double>::BOD ||
560  results[0].index != 2 ||
561  results[0].npts != 50 ||
562  results[0].ngood != 50)
563  {
564  cout << label << " first hit\n";
565  count++;
566  }
567  if (results[1].type != FilterHit<double>::slip ||
568  results[1].index != 52 ||
569  results[1].npts != 93 ||
570  results[1].ngood != 93 ||
571  ::fabs(results[1].step + 0.906) > tol)
572  {
573  cout << label << " second hit\n";
574  count++;
575  }
576  if (results[2].type != FilterHit<double>::slip ||
577  results[2].index != 145 ||
578  results[2].npts != 96 ||
579  results[2].ngood != 96 ||
580  ::fabs(results[2].step + 3.720) > tol)
581  {
582  cout << label << " third hit\n";
583  count++;
584  }
585  }
586  else
587  {
588  cout << label << " failed " << iret << "\n";
589  count++;
590  }
591 
592  // dataset 2 ----------------------------------------------------------
593  data.clear(); xdata.clear();
594  for (i=0; i<M2; i++)
595  {
596  xdata.push_back(data2[2*i]);
597  data.push_back(data2[2*i+1]);
598  }
599 
600  label = "Test2FDF";
601  iret = testFirstDiff(xdata, data, 2.0, label, verbose, results);
602  if (iret == 0)
603  {
604  if (results[0].type != FilterHit<double>::outlier ||
605  results[0].index != 0 ||
606  results[0].npts != 3 ||
607  results[0].ngood != 0)
608  {
609  count++;
610  }
611  if (results[1].type != FilterHit<double>::BOD ||
612  results[1].index != 3 ||
613  results[1].npts != 7 ||
614  results[1].ngood != 7)
615  {
616  count++;
617  }
618  if (results[2].type != FilterHit<double>::outlier ||
619  results[2].index != 10 ||
620  results[2].npts != 1 ||
621  results[2].ngood != 0)
622  {
623  count++;
624  }
625  if (results[3].type != FilterHit<double>::slip ||
626  results[3].index != 11 ||
627  results[3].npts != 15 ||
628  results[3].ngood != 15 ||
629  ::fabs(results[3].step + 15.556) > tol)
630  {
631  count++;
632  }
633  }
634  else
635  {
636  cout << label << " failed " << iret << "\n";
637  count++;
638  }
639 
640  label = "Test2Wind";
641  iret = testWindow(xdata, data, false, 10, 0.08, 6, label, verbose, results);
642  if (iret == 22)
643  {
644  if (results[0].type != FilterHit<double>::BOD ||
645  results[0].index != 2 ||
646  results[0].npts != 22 ||
647  results[0].ngood != 22)
648  {
649  cout << label << " first hit\n";
650  count++;
651  }
652  }
653  else
654  {
655  cout << label << " failed " << iret << "\n";
656  count++;
657  }
658 
659  // dataset 3 ----------------------------------------------------------
660  data.clear(); xdata.clear();
661  for (i=0; i<M3; i++)
662  {
663  xdata.push_back(data3[2*i]);
664  data.push_back(data3[2*i+1]);
665  }
666 
667  label = "Test3FDF";
668  iret = testFirstDiff(xdata, data, 2.5, label, verbose, results);
669  if (iret == 0)
670  {
671  if (results[0].type != FilterHit<double>::BOD ||
672  results[0].index != 0 ||
673  results[0].npts != 69 ||
674  results[0].ngood != 69)
675  {
676  cout << label << " first hit\n";
677  count++;
678  }
679  if (results[1].type != FilterHit<double>::outlier ||
680  results[1].index != 69 ||
681  results[1].npts != 1 ||
682  results[1].ngood != 0)
683  {
684  cout << label << " second hit\n";
685  count++;
686  }
687  if (results[2].type != FilterHit<double>::BOD ||
688  results[2].index != 70 ||
689  results[2].npts != 23 ||
690  results[2].ngood != 23)
691  {
692  cout << label << " third hit\n";
693  count++;
694  }
695  if (results[3].type != FilterHit<double>::slip ||
696  results[3].index != 93 ||
697  results[3].npts != 102 ||
698  results[3].ngood != 102 ||
699  ::fabs(results[3].step - 2.927) > tol)
700  {
701  cout << label << " fourth hit\n";
702  count++;
703  }
704  if (results[4].type != FilterHit<double>::slip ||
705  results[4].index != 195 ||
706  results[4].npts != 49 ||
707  results[4].ngood != 49 ||
708  ::fabs(results[4].step + 3.001) > tol)
709  {
710  cout << label << " fifth hit\n";
711  count++;
712  }
713  if (results[5].type != FilterHit<double>::outlier ||
714  results[5].index != 244 ||
715  results[5].npts != 1 ||
716  results[5].ngood != 0)
717  {
718  cout << label << " sixth hit\n";
719  count++;
720  }
721  }
722 
723  label = "Test3FDiffF";
724  iret = testFDiff(xdata, data, 0.4, label, verbose, results);
725  if (iret == 0)
726  {
727  if (results[0].type != FilterHit<double>::outlier ||
728  results[0].index != 69 ||
729  results[0].npts != 1 ||
730  results[0].dx != 30.0)
731  {
732  cout << label << " first hit\n";
733  count++;
734  }
735  if (results[1].type != FilterHit<double>::outlier ||
736  results[1].index != 93 ||
737  results[1].npts != 1 ||
738  results[1].dx != 30.0)
739  {
740  cout << label << " second hit\n";
741  count++;
742  }
743  if (results[2].type != FilterHit<double>::slip ||
744  results[2].index != 190 ||
745  results[2].npts != 1 ||
746  ::fabs(results[2].dx - 30.0) > 0.001 ||
747  ::fabs(results[2].step - 1.552) > 0.001 ||
748  ::fabs(results[2].sigma - 1.283) > 0.001)
749  {
750  cout << label << " third hit\n";
751  count++;
752  }
753  if (results[3].type != FilterHit<double>::slip ||
754  results[3].index != 195 ||
755  results[3].npts != 1 ||
756  ::fabs(results[3].dx - 30.0) > 0.001 ||
757  ::fabs(results[3].step + 3.172) > 0.001 ||
758  ::fabs(results[3].sigma - 1.855) > 0.001)
759  {
760  cout << label << " fourth hit\n";
761  count++;
762  }
763  if (results[4].type != FilterHit<double>::outlier ||
764  results[4].index != 244 ||
765  results[4].npts != 1 ||
766  results[4].dx != 0.0)
767  {
768  cout << label << " fifth hit\n";
769  count++;
770  }
771  }
772 
773  // --------------------------------------------------------------------
774  cout << "Error count is " << count << endl;
775  return count;
776  }
777  catch(Exception& e)
778  {
779  cout << "Threw " << e.what() << endl;
780  }
781 }
gnsstk::WindowFilter::setWidth
void setWidth(int w)
Definition: WindowFilter.hpp:367
testFDiff
int testFDiff(const vector< double > &xdata, const vector< double > &data, const double &ratlimit, const string &label, const bool &verbose, vector< FilterHit< double > > &hit)
Definition: StatsFilter_T.cpp:203
gnsstk::IterativeFDiffFilter::setw
void setw(int w)
set width for dump
Definition: FDiffFilter.hpp:855
gnsstk::FirstDiffFilter::getResults
std::vector< FilterHit< T > > getResults()
return a copy of the filter hit results
Definition: FirstDiffFilter.hpp:156
gnsstk::WindowFilter::dump
void dump(std::ostream &s, std::string tag=std::string())
Definition: WindowFilter.hpp:1341
gnsstk::FirstDiffFilter::dump
void dump(std::ostream &s, const std::string &tag=std::string())
Definition: FirstDiffFilter.hpp:682
gnsstk::IterativeFDiffFilter
forward declaration
Definition: FDiffFilter.hpp:113
gnsstk::WindowFilter::setw
void setw(int w)
Definition: WindowFilter.hpp:403
gnsstk::IterativeFDiffFilter::setprecision
void setprecision(int p)
set precision for dump
Definition: FDiffFilter.hpp:858
gnsstk::Exception::what
std::string what() const
Dump to a string.
Definition: Exception.cpp:193
logstream.hpp
gnsstk::WindowFilter::setDumpAnalMsg
void setDumpAnalMsg(bool b)
Definition: WindowFilter.hpp:394
gnsstk::FirstDiffFilter::filter
int filter(const size_t index=0, int npts=-1)
Definition: FirstDiffFilter.hpp:266
gnsstk::WindowFilter::filter
int filter(const size_t index=0, int npts=-1)
Definition: WindowFilter.hpp:506
gnsstk::IterativeFDiffFilter::setLimit
void setLimit(T val)
set limit
Definition: FDiffFilter.hpp:803
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::FirstDiffFilter::setDumpNoAnal
void setDumpNoAnal(bool b)
Definition: FirstDiffFilter.hpp:153
gnsstk::IterativeFDiffFilter::setSigma
void setSigma(T val)
set sigma limit
Definition: FDiffFilter.hpp:809
testFirstDiff
int testFirstDiff(const vector< double > &xdata, const vector< double > &data, const double &ratlimit, const string &label, const bool &verbose, vector< FilterHit< double > > &hit)
Definition: StatsFilter_T.cpp:54
gnsstk::IterativeFDiffFilter::doVerbose
bool doVerbose(bool doit)
make output verbose
Definition: FDiffFilter.hpp:842
gnsstk::Exception
Definition: Exception.hpp:151
gnsstk::WindowFilter::setMinRatio
void setMinRatio(T val)
Definition: WindowFilter.hpp:379
FDiffFilter.hpp
gnsstk::FirstDiffFilter
Definition: FirstDiffFilter.hpp:111
gnsstk::IterativeFDiffFilter::analysis
int analysis()
Definition: FDiffFilter.hpp:913
main
int main(int argc, char **argv)
Definition: StatsFilter_T.cpp:277
gnsstk::WindowFilter
Definition: WindowFilter.hpp:302
testWindow
int testWindow(const vector< double > &xdata, const vector< double > &data, const bool &useTSS, const double &window, const double &steplimit, const double &ratlimit, const string &label, const bool &verbose, vector< FilterHit< double > > &hit)
Definition: StatsFilter_T.cpp:142
gnsstk::FirstDiffFilter::setprecision
void setprecision(int p)
Definition: FirstDiffFilter.hpp:152
gnsstk::FirstDiffFilter::results
std::vector< FilterHit< T > > results
vector of FilterHit, generated by analyze(), also for use in dump()
Definition: FirstDiffFilter.hpp:250
gnsstk::FirstDiffFilter::setLimit
void setLimit(T val)
get and set
Definition: FirstDiffFilter.hpp:148
FirstDiffFilter.hpp
gnsstk::WindowFilter::setprecision
void setprecision(int p)
Definition: WindowFilter.hpp:404
example3.data
data
Definition: example3.py:22
gnsstk::WindowFilter::setTwoSample
void setTwoSample(bool b)
Definition: WindowFilter.hpp:369
WindowFilter.hpp
gnsstk::FirstDiffFilter::analyze
int analyze()
Definition: FirstDiffFilter.hpp:334
std
Definition: Angle.hpp:142
gnsstk::IterativeFDiffFilter::doSmallSlips
bool doSmallSlips(bool doit)
set flag to do small slips
Definition: FDiffFilter.hpp:815
gnsstk::WindowFilter::getResults
std::vector< FilterHit< T > > getResults()
get results vector of FilterHit
Definition: WindowFilter.hpp:407
gnsstk::WindowFilter::setMinStep
void setMinStep(T val)
Definition: WindowFilter.hpp:380
gnsstk::FilterHit
Definition: StatsFilterHit.hpp:68
gnsstk::WindowFilter::setDebug
void setDebug(bool b)
debug prints in analysis()
Definition: WindowFilter.hpp:400
gnsstk::IterativeFDiffFilter::getResults
std::vector< FilterHit< T > > getResults()
get results vector of FilterHit
Definition: FDiffFilter.hpp:867
gnsstk::IterativeFDiffFilter::doResetSigma
bool doResetSigma(bool doit)
(re)set sigma limit
Definition: FDiffFilter.hpp:825
gnsstk::IterativeFDiffFilter::setWidth
void setWidth(unsigned int w)
set window width
Definition: FDiffFilter.hpp:797
gnsstk::FirstDiffFilter::setw
void setw(int w)
get and set for dump
Definition: FirstDiffFilter.hpp:151
gnsstk::FirstDiffFilter::getStats
void getStats(FilterHit< T > &fe)
Definition: FirstDiffFilter.hpp:730
gnsstk::WindowFilter::analyze
int analyze()
Definition: WindowFilter.hpp:945


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:41