Ignore:
Timestamp:
01/30/14 15:55:42 (10 years ago)
Author:
ymipsl
Message:

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:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/functor/accumulate.cpp

    r443 r470  
    99 
    1010      CAccumulate::CAccumulate(CArray<double,1>& doutput) 
    11          : SuperClass(StdString("average"), doutput) 
     11         : SuperClass(StdString("accumulate"), doutput) 
     12      { /* Ne rien faire de plus */ } 
     13 
     14      CAccumulate::CAccumulate(CArray<double,1>& doutput, double missingValue) 
     15         : SuperClass(StdString("accumulate"), doutput, missingValue) 
    1216      { /* Ne rien faire de plus */ } 
    1317 
     
    2024                                 CArray<double,1>& _doutput) 
    2125      { 
    22 /* 
    23          const double * it1  = _dinput->data(), 
    24                       * end1 = _dinput->data() + _dinput->num_elements();  
    25                double * it   = _doutput->data(); 
    26          if (this->nbcall == 1) 
    27               for (; it1 != end1; it1++, it++) *it  = *it1; 
    28          else for (; it1 != end1; it1++, it++) *it += *it1;                
    29 */ 
    3026        if (this->nbcall == 1) _doutput=_dinput ; 
    31         else _doutput+=_dinput ; 
     27        else  
     28        { 
     29          if (hasMissingValue) 
     30          { 
     31            int i, n =_dinput.numElements() ; 
     32            const double * in=_dinput.dataFirst() ; 
     33            double* out=_doutput.dataFirst(); 
     34            for (i=0; i<n; ++i,++in,++out)  
     35              if (*in!=missingValue) 
     36              { 
     37                if(*out!=missingValue) *out  += *in; 
     38                else *out=*in ; 
     39              } 
     40          } 
     41          else _doutput+=_dinput ; 
     42        } 
     43      } 
    3244       
    33       } 
    3445       
    3546      void CAccumulate::final(void) 
    3647      { 
    37 /*          double * it1  = this->getDataOutput()->data(), 
    38                  * end1 = this->getDataOutput()->data() + this->getDataOutput()->num_elements(); 
    39           for (; it1 != end1; it1++) *it1 /= this->nbcall; 
    40           this->nbcall = 0;                                                    
    41 */ 
    42 //        doutput/=this->nbcall;  
    4348        this->nbcall = 0;  
    4449      } 
Note: See TracChangeset for help on using the changeset viewer.