Changeset 1251


Ignore:
Timestamp:
09/05/17 16:49:13 (3 years ago)
Author:
oabramkina
Message:

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/dev/XIOS_DEV_CMIP6/src/filter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/filter/file_writer_filter.cpp

    r1201 r1251  
    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/dev/XIOS_DEV_CMIP6/src/filter/store_filter.cpp

    r1246 r1251  
    7878  void CStoreFilter::onInputReady(std::vector<CDataPacketPtr> data) 
    7979  { 
    80     CDataPacketPtr packet = data[0]; 
     80 
     81    CDataPacketPtr packet; 
     82    if (detectMissingValues) 
     83    { 
     84      CArray<double, 1> dataArray = data[0]->data.copy(); 
     85 
     86      const size_t nbData = dataArray.numElements(); 
     87      for (size_t idx = 0; idx < nbData; ++idx) 
     88      { 
     89        if (NumTraits<double>::isnan(dataArray(idx))) 
     90          dataArray(idx) = missingValue; 
     91      } 
     92 
     93      packet = CDataPacketPtr(new CDataPacket); 
     94      packet->date = data[0]->date; 
     95      packet->timestamp = data[0]->timestamp; 
     96      packet->status = data[0]->status; 
     97      packet->data.resize(dataArray.numElements()); 
     98      packet->data = dataArray; 
     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.