Changeset 1282 for XIOS/dev


Ignore:
Timestamp:
09/26/17 17:41:03 (7 years ago)
Author:
oabramkina
Message:

Fixing a bug in case if freq_op is defined in months.

Location:
XIOS/dev/XIOS_DEV_CMIP6/src/filter
Files:
2 edited

Legend:

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

    r1278 r1282  
    1717    , samplingOffset(samplingOffset) 
    1818    , opFreq(opFreq) 
    19     , nextSamplingDate(initDate + this->samplingOffset + initDate.getRelCalendar().getTimeStep()) 
    20     , nextOperationDate(initDate + this->samplingOffset + opFreq) 
     19    , offsetMonth({0, this->samplingOffset.month, 0, 0, 0, 0, 0}) 
     20    , offsetAllButMonth({this->samplingOffset.year, 0 , this->samplingOffset.day, 
     21                         this->samplingOffset.hour, this->samplingOffset.minute, 
     22                         this->samplingOffset.second, this->samplingOffset.timestep}) 
     23    , initDate(initDate) 
    2124    , isFirstOperation(true) 
     25    , nextSamplingDate(initDate + initDate.getRelCalendar().getTimeStep() + this->samplingOffset) 
     26    , nextOperationDate(initDate + opFreq + this->samplingOffset) 
     27//    , nextOperationDate(initDate + opFreq + this->offsetMonth + this->offsetAllButMonth) 
     28    , nbSamplingDates(0) 
    2229  { 
     30    if (offsetMonth != NoneDu && offsetAllButMonth != NoneDu) 
     31    { 
     32      nextOperationDate = initDate + opFreq + this->offsetMonth; 
     33//      nextSamplingDate = initDate + initDate.getRelCalendar().getTimeStep() + this->samplingOffset; 
     34      nextSamplingDate = initDate + this->offsetMonth + this->offsetAllButMonth; 
     35    } 
    2336  } 
    2437 
     
    3548      { 
    3649        usePacket = (data[0]->date >= nextSamplingDate); 
    37         outputResult = (data[0]->date + samplingFreq > nextOperationDate); 
     50        outputResult = ((offsetMonth != NoneDu && offsetAllButMonth != NoneDu) 
     51                       ? (data[0]->date - offsetAllButMonth > nextOperationDate - samplingFreq) 
     52                       : (data[0]->date + samplingFreq > nextOperationDate)); 
     53//        outputResult = (data[0]->date  > nextOperationDate - samplingFreq); 
    3854        copyLess = (isInstantOperation && usePacket && outputResult); 
    3955      } 
     
    4965        } 
    5066 
    51         nextSamplingDate = nextSamplingDate + samplingFreq; 
     67        if (offsetMonth != NoneDu && offsetAllButMonth != NoneDu) 
     68        { 
     69          nextSamplingDate = initDate + samplingFreq; 
     70          for (int i=0; i<(nbSamplingDates+1); i++) 
     71          { 
     72            nextSamplingDate = nextSamplingDate + samplingFreq; 
     73          } 
     74          nextSamplingDate = nextSamplingDate + offsetAllButMonth; 
     75        } 
     76        else 
     77          nextSamplingDate = nextSamplingDate + samplingFreq; 
     78 
     79        nbSamplingDates++; 
     80 
    5281      } 
    5382 
     
    6897          packet = data[0]; 
    6998 
     99        nextOperationDate = nextOperationDate + samplingFreq + opFreq - samplingFreq; 
    70100        isFirstOperation = false; 
    71         nextOperationDate = nextOperationDate + samplingFreq + opFreq - samplingFreq; 
    72101      } 
    73102    } 
  • XIOS/dev/XIOS_DEV_CMIP6/src/filter/temporal_filter.hpp

    r1201 r1282  
    5656      const CDuration samplingOffset; //!< The sampling offset, i.e. the offset after which the input data will be used 
    5757      const CDuration opFreq; //!< The operation frequency, i.e. the frequency at which the output data will be computed 
     58      const CDuration offsetMonth; 
     59      const CDuration offsetAllButMonth; 
     60      const CDate initDate; 
     61      bool isFirstOperation; //!< True before the first operation was been computed 
    5862      CDate nextSamplingDate; //!< The date of the next sampling 
    5963      CDate nextOperationDate; //!< The date of the next operation 
    60       bool isFirstOperation; //!< True before the first operation was been computed 
     64      int nbSamplingDates; 
    6165  }; // class CTemporalFilter 
    6266} // namespace xios 
Note: See TracChangeset for help on using the changeset viewer.