Dear boost-users,

 

It’s my first time trying this and hope that someone may be able to enlighten me about which aspects of the Boost.DateTime library will help solve this problem…….

 

I have some time-series data which is time stamped with boost::posix_time::ptime values.  From this base-series I would like to synthesise higher interval time-series.  For example, a base-series of 1 second time-series data could be used to synthesise a time-series of any greater interval; 2 seconds, 5 seconds, 86400 seconds (1 day) etc.  Or 1 minute base-series data could be used to synthesise, 2 min, 15min, 60 min time-series etc.

 

It is entirely possible that any given base-series time point could be absent i.e. there could be time gaps in the base-series.

 

I have an idea to use boost::posix_time::time_period  to create regularly temporally spaced  ‘buckets’ of the required time interval; into which the base-series data elements would accumulate and thus allow the synthesising of the higher interval time-series.  Each ‘bucket’ represents one higher interval time-series data element.

 

It is important that the ‘buckets’ are aligned with natural multiples of the time interval for which they are accumulating. So for example a 10 second synthesised time-series would have boost::posix_time::time_period ‘buckets’ like so at: 1-10, 11-20, 21-30, 31-40, 41-50 & 51-60 seconds time_periods.

 

The first data element of the base-series could fall at any time, it could be on the 7th second of a minute, equally it could be on the 59th minute of an hour.  Somehow the first boost::posix_time::time_period ‘bucket’ for a particular synthesised interval must be set such that it spans the correct period of time and ends on a multiple of the time-series interval which is being synthesised.  Put simply, that first base-series data element needs to fall into a correctly aligned time_period ‘bucket’.

 

Using Boost.Date_Time how could the boost::posix_time::ptime of the first data element of the base-series be examined and the first time_period ‘bucket’ be correctly aligned to the relevant begin and end times for the synthesised time-series?  I envisage subsequent ‘buckets’ will be created by incrementing forward in time from the datum of the first.

 

With grateful thanks for any assistance,

 

Riskybiz.