Ignore:
Timestamp:
01/10/17 13:52:53 (7 years ago)
Author:
mhnguyen
Message:

Improving missing-value processing
If detect_missing_value is activated, then all missing value will be converted to
NaN (Not-a-number) in input of data flow then they will be reconverted to missing value on output

+) Update SourceFilter?, TemporalFilter? and SpatialTransformFilter? with new processing
+) Update all transformations with new processing

Test
+) On Curie
+) Work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/transformation/Functions/sum_reduction.cpp

    r979 r1018  
    33   \author Ha NGUYEN 
    44   \since 27 June 2016 
    5    \date 27 June 2016 
     5   \date 9 Jan 2017 
    66 
    77   \brief sum reduction 
    88 */ 
    99#include "sum_reduction.hpp" 
     10#include "utils.hpp" 
    1011 
    1112namespace xios { 
     
    2930                                   const double* dataInput, 
    3031                                   CArray<double,1>& dataOut, 
    31                                    std::vector<bool>& flagInitial) 
     32                                   std::vector<bool>& flagInitial, 
     33                                   const double& defaultValue) 
    3234{ 
    33   int nbLocalIndex = localIndex.size(); 
    34   int currentlocalIndex = 0; 
    35   double currentWeight  = 0.0; 
    36   for (int idx = 0; idx < nbLocalIndex; ++idx) 
     35  bool hasMissingValue = NumTraits<double>::isnan(defaultValue); 
     36  if (hasMissingValue) 
    3737  { 
    38     currentlocalIndex = localIndex[idx].first; 
    39     currentWeight     = localIndex[idx].second; 
    40     if (flagInitial[currentlocalIndex]) 
     38    int nbLocalIndex = localIndex.size(); 
     39    int currentlocalIndex = 0;     
     40    for (int idx = 0; idx < nbLocalIndex; ++idx) 
    4141    { 
    42       dataOut(currentlocalIndex) = *(dataInput + idx); 
    43       flagInitial[currentlocalIndex] = false; 
    44     } 
    45     else 
     42      currentlocalIndex = localIndex[idx].first;    
     43      if (!NumTraits<double>::isnan(*(dataInput + idx))) 
     44      {    
     45        if (flagInitial[currentlocalIndex]) 
     46        { 
     47          dataOut(currentlocalIndex) = *(dataInput + idx); 
     48          flagInitial[currentlocalIndex] = false; 
     49        } 
     50        else 
     51        { 
     52          dataOut(currentlocalIndex) += *(dataInput + idx); 
     53        } 
     54      } 
     55    }     
     56  } 
     57  else 
     58  { 
     59    int nbLocalIndex = localIndex.size(); 
     60    int currentlocalIndex = 0;     
     61    for (int idx = 0; idx < nbLocalIndex; ++idx) 
    4662    { 
    47       dataOut(currentlocalIndex) += *(dataInput + idx); 
     63      currentlocalIndex = localIndex[idx].first;       
     64      if (flagInitial[currentlocalIndex]) 
     65      { 
     66        dataOut(currentlocalIndex) = *(dataInput + idx); 
     67        flagInitial[currentlocalIndex] = false; 
     68      } 
     69      else 
     70      { 
     71        dataOut(currentlocalIndex) += *(dataInput + idx); 
     72      } 
    4873    } 
    4974  } 
Note: See TracChangeset for help on using the changeset viewer.