Changeset 1264 for XIOS


Ignore:
Timestamp:
09/13/17 16:14:26 (7 years ago)
Author:
ymipsl
Message:
  • Add new attribute : detect_missing_value on "interpolate_domain" element. It will replace the standard detect_missing_value set on the field. It will be added progressively to all spatial transformation.
  • Now, when detecting missing value, horizontal interpolation do a correct renormalization.

YM

Location:
XIOS/dev/XIOS_DEV_CMIP6/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/config/interpolate_domain_attribute.conf

    r1158 r1264  
    33DECLARE_ATTRIBUTE(bool, renormalize) 
    44DECLARE_ATTRIBUTE(bool, quantity) 
     5DECLARE_ATTRIBUTE(bool, detect_missing_value) 
    56 
    67/* Write interpolation weights into file */ 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/interpolate_domain.cpp

    r1158 r1264  
    4848    } 
    4949 
     50    bool detect_missing_value=false ; 
     51    if (!this->detect_missing_value.isEmpty()) detect_missing_value = this->detect_missing_value.getValue(); 
     52    else this->detect_missing_value.setValue(detect_missing_value); 
     53 
     54    bool renormalize=false ; 
     55    if (!this->renormalize.isEmpty()) renormalize = this->renormalize.getValue(); 
     56    else this->renormalize.setValue(renormalize); 
     57 
     58    bool quantity=false ; 
     59    if (!this->quantity.isEmpty()) quantity = this->quantity.getValue(); 
     60    else this->quantity.setValue(quantity); 
     61 
    5062    if (this->mode.isEmpty()) this->mode.setValue(mode_attr::compute); 
    5163    if (this->write_weight.isEmpty()) this->write_weight.setValue(false); 
  • XIOS/dev/XIOS_DEV_CMIP6/src/transformation/domain_algorithm_interpolate.cpp

    r1173 r1264  
    5252  CContext* context = CContext::getCurrent(); 
    5353  interpDomain_->checkValid(domainSource); 
     54 
     55  detectMissingValue = interpDomain_->detect_missing_value ; 
     56  renormalize = interpDomain_->renormalize ; 
     57  quantity = interpDomain_->quantity ; 
     58   
    5459  fileToReadWrite_ = "xios_interpolation_weights_"; 
    5560 
     
    99104  std::vector<double> srcPole(3,0), dstPole(3,0); 
    100105  int orderInterp = interpDomain_->order.getValue(); 
    101   bool renormalize ; 
    102   bool quantity ; 
    103  
    104   if (interpDomain_->renormalize.isEmpty()) renormalize=true; 
    105   else renormalize = interpDomain_->renormalize; 
    106  
    107   if (interpDomain_->quantity.isEmpty()) quantity=false; 
    108   else quantity = interpDomain_->quantity; 
     106 
    109107 
    110108  const double poleValue = 90.0; 
     
    881879} 
    882880 
    883 } 
     881void CDomainAlgorithmInterpolate::apply(const std::vector<std::pair<int,double> >& localIndex, 
     882                                            const double* dataInput, 
     883                                            CArray<double,1>& dataOut, 
     884                                            std::vector<bool>& flagInitial, 
     885                                            bool ignoreMissingValue, bool firstPass  ) 
     886{ 
     887  int nbLocalIndex = localIndex.size();    
     888  double defaultValue = std::numeric_limits<double>::quiet_NaN(); 
     889    
     890  if (detectMissingValue) 
     891  { 
     892     if (firstPass && renormalize) 
     893     { 
     894       renormalizationFactor.resize(dataOut.numElements()) ; 
     895       renormalizationFactor=1 ; 
     896     } 
     897 
     898    for (int idx = 0; idx < nbLocalIndex; ++idx) 
     899    { 
     900      if (NumTraits<double>::isnan(*(dataInput + idx))) 
     901      { 
     902        flagInitial[localIndex[idx].first] = false; 
     903        if (renormalize) renormalizationFactor(localIndex[idx].first)-=localIndex[idx].second ; 
     904      } 
     905      else 
     906      { 
     907        dataOut(localIndex[idx].first) += *(dataInput + idx) * localIndex[idx].second; 
     908        flagInitial[localIndex[idx].first] = true; // Reset flag to indicate not all data source are nan 
     909      } 
     910    } 
     911 
     912    // If all data source are nan then data destination must be nan 
     913    for (int idx = 0; idx < nbLocalIndex; ++idx) 
     914    { 
     915      if (!flagInitial[localIndex[idx].first]) 
     916        dataOut(localIndex[idx].first) = defaultValue; 
     917    } 
     918  } 
     919  else 
     920  { 
     921    for (int idx = 0; idx < nbLocalIndex; ++idx) 
     922    { 
     923      dataOut(localIndex[idx].first) += *(dataInput + idx) * localIndex[idx].second; 
     924    } 
     925  } 
     926} 
     927 
     928void CDomainAlgorithmInterpolate::updateData(CArray<double,1>& dataOut) 
     929{ 
     930  if (detectMissingValue && renormalize) dataOut/=renormalizationFactor ; 
     931} 
     932 
     933} 
  • XIOS/dev/XIOS_DEV_CMIP6/src/transformation/domain_algorithm_interpolate.hpp

    r1173 r1264  
    3131  virtual ~CDomainAlgorithmInterpolate() {} 
    3232 
     33  virtual void apply(const std::vector<std::pair<int,double> >& localIndex, 
     34                     const double* dataInput, 
     35                     CArray<double,1>& dataOut, 
     36                     std::vector<bool>& flagInitial,                      
     37                     bool ignoreMissingValue, bool firstPass); 
     38  virtual void updateData(CArray<double,1>& dataOut); 
     39 
    3340  static bool registerTrans(); 
    3441protected: 
     
    4754 
    4855private: 
     56  CArray<double,1> renormalizationFactor ; 
     57  bool detectMissingValue ; 
     58  bool renormalize ; 
     59  bool quantity ; 
     60   
    4961  CInterpolateDomain* interpDomain_; 
    5062  bool writeToFile_; 
Note: See TracChangeset for help on using the changeset viewer.