Changeset 1044


Ignore:
Timestamp:
02/01/17 22:11:39 (4 years ago)
Author:
ymipsl
Message:

New file attribute : time_units : second/day

  • In netcdf file switch between "seconds since " and "days since"
  • Change time axis value conforming to the defined unit.

YM

Location:
XIOS/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/config/file_attribute.conf

    r878 r1044  
    1919DECLARE_ENUM4(time_counter,  centered, instant, record, none) 
    2020DECLARE_ATTRIBUTE(StdString, time_counter_name) 
     21DECLARE_ENUM2(time_units, seconds, days) 
    2122DECLARE_ATTRIBUTE(int,       record_offset) 
    2223DECLARE_ATTRIBUTE(bool,       cyclic) 
  • XIOS/trunk/src/io/nc4_data_output.cpp

    r1012 r1044  
    19841984              field->getOperationTimeType() != func::CFunctor::once) 
    19851985          { 
    1986             field->resetNStep(getRecordFromTime(field->last_Write_srv) + 1); 
     1986                         double factorUnit; 
     1987                         if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) 
     1988                           factorUnit=context->getCalendar()->getDayLengthInSeconds() ;  
     1989                         else factorUnit=1 ; 
     1990            field->resetNStep(getRecordFromTime(field->last_Write_srv,factorUnit) + 1); 
    19871991          } 
    19881992 
     
    20472051          else if (field->file->time_counter == CFile::time_counter_attr::record) 
    20482052            time_counter_bound(0) = time_counter_bound(1) = field->getNStep() - 1; 
     2053 
     2054 
     2055 
     2056          if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) 
     2057          { 
     2058            double secByDay=context->getCalendar()->getDayLengthInSeconds() ; 
     2059            time_data/=secByDay; 
     2060            time_data_bound/=secByDay; 
     2061            time_counter/=secByDay; 
     2062            time_counter_bound/=secByDay; 
     2063          } 
    20492064        } 
    20502065 
     
    22712286         StdString timeid(getTimeCounterName()); 
    22722287         StdString timeBoundId("axis_nbounds"); 
     2288 
     2289         StdString strTimeUnits ; 
     2290         if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) strTimeUnits="days since " ; 
     2291         else  strTimeUnits="seconds since " ; 
    22732292  
    22742293         if (field->getOperationTimeType() == func::CFunctor::instant) 
     
    23002319              StdString strTimeOrigin=timeOrigin.toString() ; 
    23012320              this->writeTimeAxisAttributes 
    2302                  (axisid, cal->getType(), 
    2303                   StdString("seconds since ").append(strTimeOrigin), 
     2321                 (axisid, cal->getType(),strTimeUnits+strTimeOrigin, 
    23042322                  strTimeOrigin, axisBoundId); 
    23052323           } 
     
    23342352 
    23352353                  this->writeTimeAxisAttributes(axisid, cal->getType(), 
    2336                                                 StdString("seconds since ").append(strTimeOrigin), 
     2354                                                strTimeUnits+strTimeOrigin, 
    23372355                                                strTimeOrigin, axisBoundId); 
    23382356                } 
     
    25692587      ///-------------------------------------------------------------- 
    25702588 
    2571       StdSize CNc4DataOutput::getRecordFromTime(Time time) 
     2589      StdSize CNc4DataOutput::getRecordFromTime(Time time, double factorUnit) 
    25722590      { 
    25732591        std::map<Time, StdSize>::const_iterator it = timeToRecordCache.find(time); 
     
    25802598          CArray<double,2> timeAxisBounds; 
    25812599          SuperClassWriter::getTimeAxisBounds(timeAxisBounds, timeAxisBoundsId, isCollective); 
    2582  
     2600          timeAxisBounds*=factorUnit ; 
     2601           
    25832602          StdSize record = 0; 
    25842603          double dtime(time); 
  • XIOS/trunk/src/io/nc4_data_output.hpp

    r887 r1044  
    9696                                     const StdString & nav_model); 
    9797 
    98             StdSize getRecordFromTime(Time time); 
     98            StdSize getRecordFromTime(Time time, double factorUnit); 
    9999 
    100100         private : 
Note: See TracChangeset for help on using the changeset viewer.