Ignore:
Timestamp:
01/07/22 12:17:18 (3 years ago)
Author:
ymipsl
Message:

Improve file reading reading

  • add_offset and scaling_factor attributes are set when present in reading file
  • Add new attribute for axis to scale axis_value when read from file : convert_from_factor
  • fix bugs when time dimension in reading file is not unlimited

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/io/nc4_data_input.cpp

    r1639 r2280  
    3535    if (SuperClassWriter::isTemporal(fieldId)) 
    3636    { 
    37 //      return SuperClassWriter::getDimensions(&fieldId)[SuperClassWriter::getUnlimitedDimensionName()]; 
    3837      return SuperClassWriter::getDimensions(&fieldId)[SuperClassWriter::getTimeCounterName()]; 
    3938    } 
     
    159158    if (SuperClassWriter::isTemporal(fieldId)) 
    160159    { 
    161       dimSizeMap.erase(SuperClassWriter::getUnlimitedDimensionName()); 
     160      dimSizeMap.erase(SuperClassWriter::getTimeCounterName()); 
    162161      dimList.pop_front() ;  // assume time dimension is first 
    163162    } 
     
    195194        listDimSize.push_front(*dimSizeMap.find(*it)); 
    196195    } 
     196     
     197    // read specific field attribute 
     198    if (field->add_offset.isEmpty()) 
     199    { 
     200      if (SuperClassWriter::hasAttribute<float>("add_offset",&fieldId))  
     201        field->add_offset =  SuperClassWriter::getAttributeValue<float>("add_offset",&fieldId)[0] ; 
     202      else if (SuperClassWriter::hasAttribute<double>("add_offset",&fieldId)) 
     203        field->add_offset =  SuperClassWriter::getAttributeValue<double>("add_offset",&fieldId)[0] ; 
     204    } 
     205 
     206    if (field->scale_factor.isEmpty()) 
     207    { 
     208      if (SuperClassWriter::hasAttribute<float>("scale_factor",&fieldId))  
     209        field->scale_factor =  SuperClassWriter::getAttributeValue<float>("scale_factor",&fieldId)[0] ; 
     210      else if (SuperClassWriter::hasAttribute<double>("scale_factor",&fieldId)) 
     211        field->scale_factor =  SuperClassWriter::getAttributeValue<double>("scale_factor",&fieldId)[0] ; 
     212    } 
    197213 
    198214    // Now process domain and axis 
     
    579595        if (!axis->n.isEmpty()) n = axis->n.getValue(); 
    580596        axis->value.resize(n); 
    581         for (int i = 0; i < n; ++i) axis->value(i) = readAxisValue(begin + i); 
     597        double convertFromFactor=1.0 ; 
     598        if (!axis->convert_from_factor.isEmpty()) convertFromFactor = axis->convert_from_factor ; 
     599        for (int i = 0; i < n; ++i) axis->value(i) = readAxisValue(begin + i)*convertFromFactor; 
    582600      } 
    583601    } 
Note: See TracChangeset for help on using the changeset viewer.