Ignore:
Timestamp:
07/10/17 18:17:04 (7 years ago)
Author:
yushan
Message:

branch merged with trunk @1200

Location:
XIOS/dev/branch_yushan_merged/src/filter
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_yushan_merged/src/filter/file_writer_filter.cpp

    r1119 r1205  
    1717  void CFileWriterFilter::onInputReady(std::vector<CDataPacketPtr> data) 
    1818  { 
    19     bool ignoreMissingValue = (!field->detect_missing_value.isEmpty() &&  
    20                                !field->default_value.isEmpty() &&  
    21                                field->detect_missing_value == true); 
    22     if (ignoreMissingValue) 
     19    CDataPacketPtr packet = data[0]; 
     20 
     21    const bool detectMissingValue = (!field->detect_missing_value.isEmpty() 
     22                                      && !field->default_value.isEmpty() 
     23                                      && field->detect_missing_value == true); 
     24    if (detectMissingValue) 
    2325    { 
    24       double missingValue = field->default_value; 
    25       size_t nbData = data[0]->data.numElements(); 
     26      const double missingValue = field->default_value; 
     27      const size_t nbData = packet->data.numElements(); 
    2628      for (size_t idx = 0; idx < nbData; ++idx) 
    2729      { 
    28         if (NumTraits<double>::isnan(data[0]->data(idx))) 
    29           data[0]->data(idx) = missingValue; 
     30        if (NumTraits<double>::isnan(packet->data(idx))) 
     31          packet->data(idx) = missingValue; 
    3032      } 
    31     }     
     33    } 
    3234 
    33     field->sendUpdateData(data[0]->data); 
     35    field->sendUpdateData(packet->data); 
    3436  } 
    3537 
  • XIOS/dev/branch_yushan_merged/src/filter/source_filter.cpp

    r1018 r1205  
    3737    if (hasMissingValue) 
    3838    { 
    39       double nanValue = std::numeric_limits<double>::quiet_NaN(); 
    40       size_t nbData = packet->data.numElements(); 
     39      const double nanValue = std::numeric_limits<double>::quiet_NaN(); 
     40      const size_t nbData = packet->data.numElements(); 
    4141      for (size_t idx = 0; idx < nbData; ++idx) 
    4242      { 
     
    8282    } 
    8383 
     84    // Convert missing values to NaN 
     85    if (hasMissingValue) 
     86    { 
     87      const double nanValue = std::numeric_limits<double>::quiet_NaN(); 
     88      const size_t nbData = packet->data.numElements(); 
     89      for (size_t idx = 0; idx < nbData; ++idx) 
     90      { 
     91        if (defaultValue == packet->data(idx)) 
     92          packet->data(idx) = nanValue; 
     93      } 
     94    } 
     95 
    8496    onOutputReady(packet); 
    8597  } 
  • XIOS/dev/branch_yushan_merged/src/filter/source_filter.hpp

    r1018 r1205  
    6262      CGrid* grid; //!< The grid attached to the data the filter can accept 
    6363      const CDuration offset; //!< The offset applied to the timestamp of all packets 
    64       bool hasMissingValue; 
    65       double defaultValue; 
     64      const bool hasMissingValue; 
     65      const double defaultValue; 
    6666  }; // class CSourceFilter 
    6767} // namespace xios 
  • XIOS/dev/branch_yushan_merged/src/filter/store_filter.cpp

    r1119 r1205  
    66namespace xios 
    77{ 
    8   CStoreFilter::CStoreFilter(CGarbageCollector& gc, CContext* context, CGrid* grid) 
     8  CStoreFilter::CStoreFilter(CGarbageCollector& gc, CContext* context, CGrid* grid, 
     9                             bool detectMissingValues /*= false*/, double missingValue /*= 0.0*/) 
    910    : CInputPin(gc, 1) 
    1011    , gc(gc) 
    1112    , context(context) 
    1213    , grid(grid) 
     14    , detectMissingValues(detectMissingValues) 
     15    , missingValue(missingValue) 
    1316  { 
    1417    if (!context) 
     
    7578  void CStoreFilter::onInputReady(std::vector<CDataPacketPtr> data) 
    7679  { 
    77     packets.insert(std::make_pair(data[0]->timestamp, data[0])); 
     80    CDataPacketPtr packet = data[0]; 
     81 
     82    packets.insert(std::make_pair(packet->timestamp, packet)); 
    7883    // The packet is always destroyed by the garbage collector 
    7984    // so we register but never unregister 
    80     gc.registerObject(this, data[0]->timestamp); 
     85    gc.registerObject(this, packet->timestamp); 
     86 
     87    if (detectMissingValues) 
     88    { 
     89      const size_t nbData = packet->data.numElements(); 
     90      for (size_t idx = 0; idx < nbData; ++idx) 
     91      { 
     92        if (NumTraits<double>::isnan(packet->data(idx))) 
     93          packet->data(idx) = missingValue; 
     94      } 
     95    } 
    8196  } 
    8297 
  • XIOS/dev/branch_yushan_merged/src/filter/store_filter.hpp

    r1119 r1205  
    2222       * \param context the context to which the data belongs 
    2323       * \param grid the grid to which the data is attached 
     24       * \param detectMissingValues whether missing values should be detected 
     25       * \param missingValue the value to use to replace missing values 
    2426       */ 
    25       CStoreFilter(CGarbageCollector& gc, CContext* context, CGrid* grid); 
     27      CStoreFilter(CGarbageCollector& gc, CContext* context, CGrid* grid, 
     28                   bool detectMissingValues = false, double missingValue = 0.0); 
    2629 
    2730      /*! 
     
    7578      CContext* context; //!< The context to which the data belongs 
    7679      CGrid* grid; //!< The grid attached to the data the filter can accept 
     80      const bool detectMissingValues; //!< Whether missing values should be detected 
     81      const double missingValue; //!< The value to use to replace missing values 
    7782      std::map<Time, CDataPacketPtr> packets; //<! The stored packets 
    7883  }; // class CStoreFilter 
  • XIOS/dev/branch_yushan_merged/src/filter/temporal_filter.hpp

    r1124 r1205  
    4848 
    4949    private: 
     50      // Warning the declaration order matters here, double-check the constructor before changing it 
     51      CArray<double, 1> tmpData; //!< The array of data used for temporary storage 
    5052      const boost::scoped_ptr<func::CFunctor> functor; //!< The functor corresponding to the temporal operation 
    51       CArray<double, 1> tmpData; //!< The array of data used for temporary storage 
     53      const bool isOnceOperation; //!< True if the operation should be computed just once 
     54      const bool isInstantOperation; //!< True if the operation is instant 
    5255      const CDuration samplingFreq; //!< The sampling frequency, i.e. the frequency at which the input data will be used 
    5356      const CDuration samplingOffset; //!< The sampling offset, i.e. the offset after which the input data will be used 
     
    5659      CDate nextOperationDate; //!< The date of the next operation 
    5760      bool isFirstOperation; //!< True before the first operation was been computed 
    58       const bool isOnceOperation; //!< True if the operation should be computed just once 
    59       const bool isInstantOperation; //!< True if the operation is instant 
    6061  }; // class CTemporalFilter 
    6162} // namespace xios 
Note: See TracChangeset for help on using the changeset viewer.