Changeset 1037 for XIOS/dev/branch_yushan/src/filter/source_filter.cpp
- Timestamp:
- 01/25/17 16:25:17 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_yushan/src/filter/source_filter.cpp
r1018 r1037 3 3 #include "exception.hpp" 4 4 #include "calendar_util.hpp" 5 #include <limits>6 5 7 6 namespace xios 8 7 { 9 CSourceFilter::CSourceFilter(CGarbageCollector& gc, CGrid* grid, 10 const CDuration offset /*= NoneDu*/, bool manualTrigger /*= false*/, 11 bool hasMissingValue /*= false*/, 12 double defaultValue /*= 0.0*/) 13 : COutputPin(gc, manualTrigger) 14 , grid(grid) 8 CSourceFilter::CSourceFilter(CGrid* grid, const CDuration offset /*= NoneDu*/) 9 : grid(grid) 15 10 , offset(offset) 16 , hasMissingValue(hasMissingValue), defaultValue(defaultValue)17 11 { 18 12 if (!grid) … … 32 26 33 27 packet->data.resize(grid->storeIndex_client.numElements()); 28 34 29 grid->inputField(data, packet->data); 35 30 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 } 47 48 onOutputReady(packet); 31 deliverOuput(packet); 49 32 } 50 33 … … 66 49 packet->status = CDataPacket::NO_ERROR; 67 50 68 // if (data.size() != grid->storeIndex_toSrv.size()) 69 if (data.size() != grid->storeIndex_fromSrv.size()) 51 if (data.size() != grid->storeIndex_toSrv.size()) 70 52 ERROR("CSourceFilter::streamDataFromServer(CDate date, const std::map<int, CArray<double, 1> >& data)", 71 53 << "Incoherent data received from servers," 72 << " expected " << grid->storeIndex_ fromSrv.size() << " chunks but " << data.size() << " were given.");54 << " expected " << grid->storeIndex_toSrv.size() << " chunks but " << data.size() << " were given."); 73 55 74 56 packet->data.resize(grid->storeIndex_client.numElements()); … … 76 58 for (it = data.begin(); it != itEnd; it++) 77 59 { 78 //CArray<int,1>& index = grid->storeIndex_toSrv[it->first];79 CArray<int,1>& index = grid->storeIndex_fromSrv[it->first]; 60 CArray<int,1>& index = grid->storeIndex_toSrv[it->first]; 61 80 62 for (int n = 0; n < index.numElements(); n++) 81 63 packet->data(index(n)) = it->second(n); 82 64 } 83 65 84 onOutputReady(packet);66 deliverOuput(packet); 85 67 } 86 68 … … 91 73 packet->timestamp = date; 92 74 packet->status = CDataPacket::END_OF_STREAM; 93 onOutputReady(packet);75 deliverOuput(packet); 94 76 } 95 77 } // namespace xios
Note: See TracChangeset
for help on using the changeset viewer.