Changeset 1253


Ignore:
Timestamp:
09/06/17 11:03:04 (3 years ago)
Author:
oabramkina
Message:

Trunk: fixing a bug in case of activated missing values. If nan values are replaced by default values or vice versa data package (or data) is copied.

Location:
XIOS/trunk/src/filter
Files:
2 edited

Legend:

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

    r1186 r1253  
    1717  void CFileWriterFilter::onInputReady(std::vector<CDataPacketPtr> data) 
    1818  { 
    19     CDataPacketPtr packet = data[0]; 
    20  
    2119    const bool detectMissingValue = (!field->detect_missing_value.isEmpty() 
    2220                                      && !field->default_value.isEmpty() 
    2321                                      && field->detect_missing_value == true); 
     22 
     23    CArray<double, 1> dataArray = (detectMissingValue) ? data[0]->data.copy() : data[0]->data; 
     24 
    2425    if (detectMissingValue) 
    2526    { 
    2627      const double missingValue = field->default_value; 
    27       const size_t nbData = packet->data.numElements(); 
     28      const size_t nbData = dataArray.numElements(); 
    2829      for (size_t idx = 0; idx < nbData; ++idx) 
    2930      { 
    30         if (NumTraits<double>::isnan(packet->data(idx))) 
    31           packet->data(idx) = missingValue; 
     31        if (NumTraits<double>::isnan(dataArray(idx))) 
     32          dataArray(idx) = missingValue; 
    3233      } 
    3334    } 
    3435 
    35     field->sendUpdateData(packet->data); 
     36    field->sendUpdateData(dataArray); 
    3637  } 
    3738 
  • XIOS/trunk/src/filter/store_filter.cpp

    r1247 r1253  
    7878  void CStoreFilter::onInputReady(std::vector<CDataPacketPtr> data) 
    7979  { 
    80     CDataPacketPtr packet = data[0]; 
     80 
     81    CDataPacketPtr packet; 
     82    if (detectMissingValues) 
     83    { 
     84      const size_t nbData = data[0]->data.numElements(); 
     85 
     86      packet = CDataPacketPtr(new CDataPacket); 
     87      packet->date = data[0]->date; 
     88      packet->timestamp = data[0]->timestamp; 
     89      packet->status = data[0]->status; 
     90      packet->data.resize(nbData); 
     91      packet->data = data[0]->data; 
     92 
     93      for (size_t idx = 0; idx < nbData; ++idx) 
     94      { 
     95        if (NumTraits<double>::isnan(packet->data(idx))) 
     96          packet->data(idx) = missingValue; 
     97      } 
     98 
     99    } 
     100 
     101    else 
     102    { 
     103      packet = data[0]; 
     104    } 
    81105 
    82106    packets.insert(std::make_pair(packet->timestamp, packet)); 
     
    85109    gc.registerObject(this, packet->timestamp); 
    86110 
    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     } 
    96111  } 
    97112 
Note: See TracChangeset for help on using the changeset viewer.