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/max_reduction.cpp

    r979 r1018  
    88 */ 
    99#include "max_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 
     37  if (hasMissingValue) 
    3738  { 
    38     currentlocalIndex = localIndex[idx].first; 
    39     currentWeight     = localIndex[idx].second; 
    40     if (flagInitial[currentlocalIndex]) 
     39    int nbLocalIndex = localIndex.size(); 
     40    int currentlocalIndex = 0;     
     41    for (int idx = 0; idx < nbLocalIndex; ++idx) 
    4142    { 
    42       dataOut(currentlocalIndex) = *(dataInput + idx); 
    43       flagInitial[currentlocalIndex] = false; 
     43      currentlocalIndex = localIndex[idx].first;       
     44      if (!NumTraits<double>::isnan(*(dataInput + idx))) 
     45      { 
     46        if (flagInitial[currentlocalIndex]) 
     47        { 
     48          dataOut(currentlocalIndex) = *(dataInput + idx); 
     49          flagInitial[currentlocalIndex] = false; 
     50        } 
     51        else 
     52        { 
     53          dataOut(currentlocalIndex) = std::max(*(dataInput + idx), dataOut(currentlocalIndex)); 
     54        } 
     55      } 
    4456    } 
    45     else 
     57  } 
     58  else 
     59  { 
     60    int nbLocalIndex = localIndex.size(); 
     61    int currentlocalIndex = 0;     
     62    for (int idx = 0; idx < nbLocalIndex; ++idx) 
    4663    { 
    47       dataOut(currentlocalIndex) = std::max(*(dataInput + idx), dataOut(currentlocalIndex)); 
     64      currentlocalIndex = localIndex[idx].first;       
     65      if (flagInitial[currentlocalIndex]) 
     66      { 
     67        dataOut(currentlocalIndex) = *(dataInput + idx); 
     68        flagInitial[currentlocalIndex] = false; 
     69      } 
     70      else 
     71      { 
     72        dataOut(currentlocalIndex) = std::max(*(dataInput + idx), dataOut(currentlocalIndex)); 
     73      } 
    4874    } 
    4975  } 
Note: See TracChangeset for help on using the changeset viewer.