source: XIOS/trunk/src/functor/minimum.cpp @ 470

Last change on this file since 470 was 470, checked in by ymipsl, 10 years ago

Enhancement : using new field attribute "detect_missing_value=true" adn defining a default value, the temporal operator (average, minimum, maximum, accumulate ...) detect missing value in the field and don't take them into account to perform the operation.

YM

File size: 1.5 KB
Line 
1#include "minimum.hpp"
2#include "array_new.hpp"
3#include <algorithm>
4
5namespace xios
6{
7   namespace func
8   {
9      /// ////////////////////// Définitions ////////////////////// ///
10
11      CMinimum::CMinimum(CArray<double,1>& doutput)
12         : SuperClass(StdString("minimum"), doutput)
13      { /* Ne rien faire de plus */ }
14
15      CMinimum::CMinimum(CArray<double,1>& doutput, double missingValue)
16         : SuperClass(StdString("minimum"), doutput, missingValue)
17      { /* Ne rien faire de plus */ }
18
19      CMinimum::~CMinimum(void)
20      { /* Ne rien faire de plus */ }
21
22      //---------------------------------------------------------------
23
24      void CMinimum::apply(const CArray<double,1>& _dinput,
25                                 CArray<double,1>& _doutput)
26      {
27        const double * it1  = _dinput.dataFirst(),
28                      * end1 = _dinput.dataFirst() + _dinput.numElements();
29        double * it   = _doutput.dataFirst();
30       
31        if (this->nbcall == 1)  for (; it1 != end1; it1++, it++) *it = *it1;
32        else 
33        {
34          if (hasMissingValue) 
35          { 
36            for (; it1 != end1; it1++, it++) 
37              if (*it1!=missingValue)
38              {
39                if (*it != missingValue) *it = std::min(*it1, *it);
40                else *it=*it1 ;
41              }
42          }
43          else for (; it1 != end1; it1++, it++) *it = std::min(*it1, *it);
44        }
45
46      }
47
48      //---------------------------------------------------------------
49
50   } // namespace func
51} // namespace xmlioserver
Note: See TracBrowser for help on using the repository browser.