Ignore:
Timestamp:
06/28/17 15:25:20 (7 years ago)
Author:
rlacroix
Message:

Fix: Ensure "detect_missing_value" is always applied.

Missing values are know handled as expected for input fields (both from file or from model).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/filter/store_filter.cpp

    r1119 r1186  
    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 
Note: See TracChangeset for help on using the changeset viewer.