Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.DateTime library to synthesise time-series data?
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2015-01-05 16:37:11


On 19/12/2014 23:40, Riskybiz wrote:
> 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 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 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.

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.


Boost-users 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