
Boost Users : 
Subject: Re: [Boostusers] Boost.DateTime library to synthesise timeseries data?
From: Gavin Lambert (gavinl_at_[hidden])
Date: 20150105 16:37:11
On 19/12/2014 23:40, Riskybiz wrote:
> I have some timeseries data which is time stamped with
> boost::posix_time::ptime values. From this baseseries I would like to
> synthesise higher interval timeseries. For example, a baseseries of 1
> second timeseries data could be used to synthesise a timeseries of any
> greater interval; 2 seconds, 5 seconds, 86400 seconds (1 day) etc. Or 1
> minute baseseries data could be used to synthesise, 2 min, 15min, 60
> min timeseries etc.
>
> It is entirely possible that any given baseseries time point could be
> absent i.e. there could be time gaps in the baseseries.
>
> 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 baseseries data elements would accumulate and thus allow
> the synthesising of the higher interval timeseries. Each ‘bucket’
> represents one higher interval timeseries 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 timeseries would have boost::posix_time::time_period
> ‘buckets’ like so at: 110, 1120, 2130, 3140, 4150 & 5160 seconds
> time_periods.
>
> The first data element of the baseseries could fall at any time, it
> could be on the 7^th second of a minute, equally it could be on the
> 59^th 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 timeseries interval which is being
> synthesised. Put simply, that first baseseries 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 baseseries be examined and the first
> time_period ‘bucket’ be correctly aligned to the relevant begin and end
> times for the synthesised timeseries? I envisage subsequent ‘buckets’
> will be created by incrementing forward in time from the datum of the first.
I'm not really sure from the above what your actual problem is  you
should be able to write all of that fairly easily.
Having said that, you might want to consider storing an "origin" ptime
separately (a copy of the earliest sample's time) and then storing
samples in your data structure based on offsets from that origin time.
It should greatly simplify a lot of code.
Boostusers list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net