Changeset 1018 for XIOS/trunk/src/filter
- Timestamp:
- 01/10/17 13:52:53 (7 years ago)
- Location:
- XIOS/trunk/src/filter
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/filter/file_writer_filter.cpp
r639 r1018 2 2 #include "exception.hpp" 3 3 #include "field.hpp" 4 #include "utils.hpp" 4 5 5 6 namespace xios … … 16 17 void CFileWriterFilter::onInputReady(std::vector<CDataPacketPtr> data) 17 18 { 19 bool ignoreMissingValue = (!field->detect_missing_value.isEmpty() && 20 !field->default_value.isEmpty() && 21 field->detect_missing_value == true); 22 if (ignoreMissingValue) 23 { 24 double missingValue = field->default_value; 25 size_t nbData = data[0]->data.numElements(); 26 for (size_t idx = 0; idx < nbData; ++idx) 27 { 28 if (NumTraits<double>::isnan(data[0]->data(idx))) 29 data[0]->data(idx) = missingValue; 30 } 31 } 32 18 33 field->sendUpdateData(data[0]->data); 19 34 } -
XIOS/trunk/src/filter/source_filter.cpp
r1006 r1018 3 3 #include "exception.hpp" 4 4 #include "calendar_util.hpp" 5 #include <limits> 5 6 6 7 namespace xios 7 8 { 8 9 CSourceFilter::CSourceFilter(CGarbageCollector& gc, CGrid* grid, 9 const CDuration offset /*= NoneDu*/, bool manualTrigger /*= false*/) 10 const CDuration offset /*= NoneDu*/, bool manualTrigger /*= false*/, 11 bool hasMissingValue /*= false*/, 12 double defaultValue /*= 0.0*/) 10 13 : COutputPin(gc, manualTrigger) 11 14 , grid(grid) 12 15 , offset(offset) 16 , hasMissingValue(hasMissingValue), defaultValue(defaultValue) 13 17 { 14 18 if (!grid) … … 29 33 packet->data.resize(grid->storeIndex_client.numElements()); 30 34 grid->inputField(data, packet->data); 35 36 // Convert missing values to NaN 37 if (hasMissingValue) 38 { 39 double nanValue = std::numeric_limits<double>::quiet_NaN(); 40 size_t nbData = packet->data.numElements(); 41 for (size_t idx = 0; idx < nbData; ++idx) 42 { 43 if (defaultValue == packet->data(idx)) 44 packet->data(idx) = nanValue; 45 } 46 } 31 47 32 48 onOutputReady(packet); -
XIOS/trunk/src/filter/source_filter.hpp
r1006 r1018 23 23 * \param offset the offset applied to the timestamp of all packets 24 24 * \param manualTrigger whether the output should be triggered manually 25 * \param hasMissingValue whether data has missing value 26 * \param defaultValue missing value to detect 25 27 */ 26 28 CSourceFilter(CGarbageCollector& gc, CGrid* grid, 27 const CDuration offset = NoneDu, bool manualTrigger = false); 29 const CDuration offset = NoneDu, bool manualTrigger = false, 30 bool hasMissingValue = false, 31 double defaultValue = 0.0); 28 32 29 33 /*! … … 58 62 CGrid* grid; //!< The grid attached to the data the filter can accept 59 63 const CDuration offset; //!< The offset applied to the timestamp of all packets 64 bool hasMissingValue; 65 double defaultValue; 60 66 }; // class CSourceFilter 61 67 } // namespace xios -
XIOS/trunk/src/filter/spatial_transform_filter.cpp
r1006 r1018 11 11 12 12 std::pair<boost::shared_ptr<CSpatialTransformFilter>, boost::shared_ptr<CSpatialTransformFilter> > 13 CSpatialTransformFilter::buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, double defaultValue)13 CSpatialTransformFilter::buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, bool hasMissingValue, double missingValue) 14 14 { 15 15 if (!srcGrid || !destGrid) … … 26 26 const std::vector<StdString>& auxInputs = gridTransformation->getAuxInputs(); 27 27 size_t inputCount = 1 + (auxInputs.empty() ? 0 : auxInputs.size()); 28 double defaultValue = (hasMissingValue) ? std::numeric_limits<double>::quiet_NaN() : missingValue; 28 29 boost::shared_ptr<CSpatialTransformFilter> filter(new CSpatialTransformFilter(gc, engine, defaultValue, inputCount)); 29 30 … … 103 104 } 104 105 packet->data.resize(gridTransformation->getGridDestination()->storeIndex_client.numElements()); 105 packet->data = defaultValue; 106 if (0 != packet->data.numElements()) 107 (packet->data)(0) = defaultValue; 106 108 apply(data[0]->data, packet->data); 107 109 } -
XIOS/trunk/src/filter/spatial_transform_filter.hpp
r873 r1018 32 32 * \param srcGrid the source grid 33 33 * \param destGrid the destination grid 34 * \param hasMissingValue whether field source has missing value 35 * \param defaultValue default value 34 36 * \return the first and the last filters of the filter graph 35 37 */ 36 38 static std::pair<boost::shared_ptr<CSpatialTransformFilter>, boost::shared_ptr<CSpatialTransformFilter> > 37 buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, double defaultValue);39 buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, bool hasMissingValue, double defaultValue); 38 40 39 41 protected: -
XIOS/trunk/src/filter/temporal_filter.cpp
r854 r1018 15 15 , isFirstOperation(true) 16 16 { 17 double defaultValue = ignoreMissingValue ? std::numeric_limits<double>::quiet_NaN() : missingValue; 18 17 19 #define DECLARE_FUNCTOR(MType, mtype) \ 18 20 if (opId.compare(#mtype) == 0) \ … … 20 22 if (ignoreMissingValue) \ 21 23 { \ 22 functor.reset(new func::C##MType(tmpData, missingValue)); \24 functor.reset(new func::C##MType(tmpData, defaultValue)); \ 23 25 } \ 24 26 else \
Note: See TracChangeset
for help on using the changeset viewer.