Changeset 1201 for XIOS/dev/dev_olga/src/filter
- Timestamp:
- 07/07/17 18:17:49 (7 years ago)
- Location:
- XIOS/dev/dev_olga/src/filter
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/filter/file_writer_filter.cpp
r1158 r1201 17 17 void CFileWriterFilter::onInputReady(std::vector<CDataPacketPtr> data) 18 18 { 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) 23 25 { 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(); 26 28 for (size_t idx = 0; idx < nbData; ++idx) 27 29 { 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; 30 32 } 31 } 33 } 32 34 33 field->sendUpdateData( data[0]->data);35 field->sendUpdateData(packet->data); 34 36 } 35 37 -
XIOS/dev/dev_olga/src/filter/source_filter.cpp
r1158 r1201 37 37 if (hasMissingValue) 38 38 { 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(); 41 41 for (size_t idx = 0; idx < nbData; ++idx) 42 42 { … … 82 82 } 83 83 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 84 96 onOutputReady(packet); 85 97 } -
XIOS/dev/dev_olga/src/filter/source_filter.hpp
r1158 r1201 62 62 CGrid* grid; //!< The grid attached to the data the filter can accept 63 63 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; 66 66 }; // class CSourceFilter 67 67 } // namespace xios -
XIOS/dev/dev_olga/src/filter/store_filter.cpp
r1158 r1201 6 6 namespace xios 7 7 { 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*/) 9 10 : CInputPin(gc, 1) 10 11 , gc(gc) 11 12 , context(context) 12 13 , grid(grid) 14 , detectMissingValues(detectMissingValues) 15 , missingValue(missingValue) 13 16 { 14 17 if (!context) … … 75 78 void CStoreFilter::onInputReady(std::vector<CDataPacketPtr> data) 76 79 { 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)); 78 83 // The packet is always destroyed by the garbage collector 79 84 // 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 } 81 96 } 82 97 -
XIOS/dev/dev_olga/src/filter/store_filter.hpp
r1158 r1201 22 22 * \param context the context to which the data belongs 23 23 * \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 24 26 */ 25 CStoreFilter(CGarbageCollector& gc, CContext* context, CGrid* grid); 27 CStoreFilter(CGarbageCollector& gc, CContext* context, CGrid* grid, 28 bool detectMissingValues = false, double missingValue = 0.0); 26 29 27 30 /*! … … 75 78 CContext* context; //!< The context to which the data belongs 76 79 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 77 82 std::map<Time, CDataPacketPtr> packets; //<! The stored packets 78 83 }; // class CStoreFilter -
XIOS/dev/dev_olga/src/filter/temporal_filter.hpp
r1158 r1201 48 48 49 49 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 50 52 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 52 55 const CDuration samplingFreq; //!< The sampling frequency, i.e. the frequency at which the input data will be used 53 56 const CDuration samplingOffset; //!< The sampling offset, i.e. the offset after which the input data will be used … … 56 59 CDate nextOperationDate; //!< The date of the next operation 57 60 bool isFirstOperation; //!< True before the first operation was been computed 58 const bool isOnceOperation; //!< True if the operation should be computed just once59 const bool isInstantOperation; //!< True if the operation is instant60 61 }; // class CTemporalFilter 61 62 } // namespace xios
Note: See TracChangeset
for help on using the changeset viewer.