Changeset 1264
- Timestamp:
- 09/13/17 16:14:26 (7 years ago)
- 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 3 3 DECLARE_ATTRIBUTE(bool, renormalize) 4 4 DECLARE_ATTRIBUTE(bool, quantity) 5 DECLARE_ATTRIBUTE(bool, detect_missing_value) 5 6 6 7 /* Write interpolation weights into file */ -
XIOS/dev/XIOS_DEV_CMIP6/src/node/interpolate_domain.cpp
r1158 r1264 48 48 } 49 49 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 50 62 if (this->mode.isEmpty()) this->mode.setValue(mode_attr::compute); 51 63 if (this->write_weight.isEmpty()) this->write_weight.setValue(false); -
XIOS/dev/XIOS_DEV_CMIP6/src/transformation/domain_algorithm_interpolate.cpp
r1173 r1264 52 52 CContext* context = CContext::getCurrent(); 53 53 interpDomain_->checkValid(domainSource); 54 55 detectMissingValue = interpDomain_->detect_missing_value ; 56 renormalize = interpDomain_->renormalize ; 57 quantity = interpDomain_->quantity ; 58 54 59 fileToReadWrite_ = "xios_interpolation_weights_"; 55 60 … … 99 104 std::vector<double> srcPole(3,0), dstPole(3,0); 100 105 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 109 107 110 108 const double poleValue = 90.0; … … 881 879 } 882 880 883 } 881 void 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 928 void 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 31 31 virtual ~CDomainAlgorithmInterpolate() {} 32 32 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 33 40 static bool registerTrans(); 34 41 protected: … … 47 54 48 55 private: 56 CArray<double,1> renormalizationFactor ; 57 bool detectMissingValue ; 58 bool renormalize ; 59 bool quantity ; 60 49 61 CInterpolateDomain* interpDomain_; 50 62 bool writeToFile_;
Note: See TracChangeset
for help on using the changeset viewer.