Commit 79c1e322941870fc8ee23abe2272e3d31270e529

Authored by Hacene SI HADJ MOHAND
1 parent 1aae861e

grom zero

src/ExternLib/DataFiltering/DataFiltering.hh
... ... @@ -190,167 +190,7 @@ namespace AMDA {
190 190  
191 191 };
192 192  
193   - template <typename ElemType>
194   - class DataFiltering1D : public Operation {
195   - public:
196   - // constructor
197   -
198   - DataFiltering1D(Process& pProcess, ParamDataSpec<std::vector<ElemType> >& paramInput, double factor = Default::_factor, int nPoints = Default::_nPoints) :
199   - Operation(pProcess),
200   - _paramInput(paramInput),
201   - _paramOutput(new ParamDataSpec<std::vector<ElemType> >()),
202   - _factor(factor),
203   - _nPoints(nPoints),
204   - _container(new FilteringContainer1D<ElemType> ()){
205   - _paramDataOutput = _paramOutput;
206   - }
207   -
208   - virtual ~DataFiltering1D() {
209   - }
210   -
211   - void write(ParamDataIndexInfo &pParamDataIndexInfo) {
212   -
213   - // init container
214   -
215   - int size = _paramInput.get(pParamDataIndexInfo._startIndex).size();
216   - std::vector<int> vectInt(size,0);
217   - _container->_size = vectInt;
218   - /**
219   - _container->_nFilteredPoints.resize(size,0);
220   - _container->_ave.resize(size,0);
221   - _container->_sum.resize(size,0);
222   - _container->_sumsq.resize(size,0);
223   - _container->_sig.resize(size,0);
224   - */
225   - for (unsigned int _index = pParamDataIndexInfo._startIndex;
226   - _index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess;
227   - ++_index) {
228   - double crtTime = _paramInput.getTime(_index);
229   - std::vector<ElemType> inputElt = _paramInput.get(_index);
230   -
231   - _paramOutput->pushTime(crtTime);
232   - _paramOutput->getDataList().push_back(inputElt);
233   - /**
234   -
235   - // initialiser et remplir container
236   - if (*std::min_element(std::begin(_container._size), std::end(_container._size)) < _nPoints) {
237   -
238   - _container._values.push_back(inputElt);
239   - _container._times.push_back(crtTime);
240   - for (int i = 0; i < size; i++) {
241   - if (!isNAN(inputElt[i])) {
242   - _container._sum[i] += inputElt[i];
243   - _container._sumsq[i] += inputElt[i]*inputElt[i];
244   - _container._size[i] += 1;
245   - }
246   - }
247   - } else {
248   - for (int i = 0; i < size; i++) {
249   - _container._ave[i] = (ElemType) _container._sum[i] / _container._size[i];
250   - _container._sig[i] = std::sqrt((_container._sumsq[i] - _container._sum[i] * _container._sum[i] / _container._size[i]) / _container._size[i]);
251   - }
252   -
253   - // filter Elements
254   - for (auto elt = _container._values.begin(); elt != _container._values.end(); ++elt) {
255   - int i;
256   - for (auto it = elt->begin(); it != elt->end(); ++it) {
257   - i = it - elt->begin();
258   - ElemType crt_val = *it;
259   - if (isNAN(crt_val)) {
260   - continue;
261   - }
262   -
263   - if (std::abs(crt_val - _container._ave[i]) > _factor * _container._sig[i]) {
264   - _container._sum[i] -= crt_val;
265   - _container._sumsq[i] -= crt_val*crt_val;
266   - _container._size[i] -= 1;
267   - _container._nFilteredPoints[i] += 1;
268   - *it << NotANumber();
269   - }
270   - }
271   - }
272   - _paramOutput->pushTime(_container._times.front());
273   - _paramOutput->getDataList().push_back(_container._values.front());
274   - _container._values.pop_front();
275   - _container._times.pop_front();
276   - for (int i = 0; i < size; i++) {
277   - if (!isNAN(_container._values.front()[i])) {
278   - _container._size[i] -= 1;
279   - _container._sum[i] -= _container._values.front()[i];
280   - _container._sumsq[i] -= _container._values.front()[i] * _container._values.front()[i];
281   - }
282   - if (!isNAN(inputElt[i])) {
283   - _container._sum[i] += inputElt[i];
284   - _container._sumsq[i] += inputElt[i] * inputElt[i];
285   - _container._size[i] += 1;
286   - }
287   - }
288   - _container._values.push_back(inputElt);
289   - _container._times.push_back(crtTime);
290   - }
291   - // last value filter and write
292   - if (_index == pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess - 1) {
293   - for (int i = 0; i < size; i++) {
294   - _container._ave[i] = (ElemType) _container._sum[i] / _container._size[i];
295   - _container._sig[i] = std::sqrt((_container._sumsq[i] - _container._sum[i] * _container._sum[i] / _container._size[i]) / _container._size[i]);
296   - }
297   - for (auto elt = _container._values.begin(); elt != _container._values.end(); ++elt) {
298   - int i;
299   - for (auto it = elt->begin(); it != elt->end(); ++it) {
300   - i = it - elt->begin();
301   - ElemType crt_val = *it;
302   - if (isNAN(crt_val)) {
303   - continue;
304   - }
305   -
306   - if (std::abs(crt_val - _container._ave[i]) > _factor * _container._sig[i]) {
307   - _container._sum[i] -= crt_val;
308   - _container._sumsq[i] -= crt_val*crt_val;
309   - _container._size[i] -= 1;
310   - _container._nFilteredPoints[i] += 1;
311   - *it << NotANumber();
312   - }
313   - }
314   - }
315   -
316   - std::list<double>::iterator itTimes = _container._times.begin();
317   - for (auto elt : _container._values) {
318   - _paramOutput->pushTime(*itTimes);
319   - _paramOutput->getDataList().push_back(elt);
320   - ++itTimes;
321   - }
322   - }
323   - * */
324   - }
325   - }
326   -
327   - private:
328   - /**
329   - * input data
330   - */
331   - ParamDataSpec<std::vector<ElemType> >& _paramInput;
332   -
333   - /**
334   - * oupout filtered data
335   - */
336   - ParamDataSpec<std::vector<ElemType> >* _paramOutput;
337   -
338   - /**
339   - * factor in term of sigma used in the filtering
340   - */
341   - double _factor;
342   -
343   - /**
344   - Number of point used in the fitering algorithm
345   - */
346   - int _nPoints;
347   -
348   - /**
349   - * Data container used during filtering
350   - */
351   - FilteringContainer1D<ElemType>* _container;
352   -
353   - };
  193 +
354 194 }
355 195 }
356 196 }
... ...
src/ExternLib/DataFiltering/DataFilteringCreator.hh
... ... @@ -173,7 +173,7 @@ namespace AMDA {
173 173 }
174 174 template <typename Type>
175 175 void create1DOperation() {
176   - _operation = new DataFiltering::DataFiltering1D<Type>(_process, dynamic_cast<ParamDataSpec<std::vector<Type>>&> (_paramData), _factor, _nPoints);
  176 +
177 177 }
178 178  
179 179 Process &_process;
... ...