Changeset 1186 for XIOS/trunk/src/filter
- Timestamp:
- 06/28/17 15:25:20 (7 years ago)
- Location:
- XIOS/trunk/src/filter
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/filter/file_writer_filter.cpp
r1119 r1186 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/trunk/src/filter/source_filter.cpp
r1018 r1186 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/trunk/src/filter/source_filter.hpp
r1018 r1186 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/trunk/src/filter/store_filter.cpp
r1119 r1186 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/trunk/src/filter/store_filter.hpp
r1119 r1186 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
Note: See TracChangeset
for help on using the changeset viewer.