Timeseries can be resampled to any arbitrary timestep through the use of resampling algorithms. The user defines for each parameter which algorithm should be used and whenever a requested timestep can not be found in the original data, the user-defined resampling algorithms will be called for every parameter available in MeteoData.
Please keep in mind that the input sampling rate can be anything (including variable) as well as the output sampling rate!
When a specific timestep is requested and can not be found in the original data (but lies within the time range of the original data), the TimeSeriesManager calls the MeteoProcessor and requests a temporal interpolation. The request is forwarded to a Meteo1DInterpolator that computes what should be the index of the element just after the one that needs to be computed as well as some flags to know if is the first or the last element in the timeseries. Then the Meteo1DInterpolator calls for each meteorological parameters the algorithm that is responsible for temporally interpolating this parameter with the above computed information. Depending on the user configuration for the algorithm (that is parsed and setup in the constructor of the algorithm), the requested point is computed (or the algorithm simply returns if it can not compute a value). Some helper functions are defined in the ResamplingAlgorithms class that is inherited by every algorithm.
Using the template.cc and template.h files in meteoio/meteoResampling, build your own algorithm:
In order to debug and test your implementation, it is recommended to use a very small buffer (keys BUFFER_SIZE and BUFF_BEFORE) so it is easy to follow what is going on. You can also always switch back and forth between Enable_Resampling = true and false in the [Interpolations1D] section to see what your algorithm is doing. Please keep in mind that you can not make any assumption regarding the sampling rate, so each neighbouring point has to be checked for validity.
The newly added resampling algorithm must be added to the list of available algorithms in ResamplingAlgorithms.cc with a proper description and a link to its documentation. Please feel free to add necessary bibliographic references to the bibliographic section!