[SciPy-user] assignment of hours of day in time series

Tim Michelsen timmichelsen@gmx-topmail...
Sun Jan 13 18:08:09 CST 2008


Hi!

> sorry for not getting back to you earlier.
No problem. I am also only occasionally able to continue to explore 
further...

> Since the time "24:00" doesn't actually exist (as far as I
> am aware anyway),
I think different disciplines in science have different measurements and 
data. I think as far as geoscience and climate science is concerned this 
hour could exist, at least virtually.
Example:
A anemometer is connected to a logging device which is set to take one 
record every 10min. This can either be a punctual value or a average of 
the last 10min. before the value was recorded.
The raw data from the logger will contain:
23:00:00,		2
23:10:00,		2,3
23:20:00,		2,4
23:30:00,		2,6
23:40:00,		2,6
23:50:00,		2
00:00:00,		1,8

Some data providers use to attribute these measurements to the following 
hour when converted to hourly frequency: 24.
The data point 14.01.2008 24 would then contain all values from 23:00 to 
00:00.
The next data point would be 15.01.2008 01 which contains all values 
from 00:00 to 1:00.


To get such data well into a time series object I would have to define
start_dat = TS.Date(freq='HR', year=2008, month=1, day=14, hour=0)
and not
start_dat = TS.Date(freq='HR', year=2008, month=1, day=14, hour=1).

Is it now a little bit more understandable why I asked for the 1-24 format?

> you will have to rely on somewhat of a hack to get your
> desired output. Try this:
> 
>>>> import timeseries as ts
>>>> series = ts.time_series(range(400, 430), start_date=ts.now('hourly'))
>>>> hours = ts.time_series(series.hour + 1, dates=series.dates)
>>>> hour_fmtfunc = lambda x : '%i:00' % x
> ts.Report(hours, series, datefmt='%d-%b-%Y', delim='  ',
>           fmtfunc=[hour_fmtfunc, None])()
> 06-Jan-2008  23:00  400
> 06-Jan-2008  24:00  401
> 07-Jan-2008   1:00  402
> 07-Jan-2008   2:00  403
> 07-Jan-2008   3:00  404
> 07-Jan-2008   4:00  405
> 07-Jan-2008   5:00  406
> 07-Jan-2008   6:00  407
> 07-Jan-2008   7:00  408
> 07-Jan-2008   8:00  409
> 07-Jan-2008   9:00  410
> 07-Jan-2008  10:00  411
> 07-Jan-2008  11:00  412
> 07-Jan-2008  12:00  413
> 07-Jan-2008  13:00  414
> 07-Jan-2008  14:00  415
> 07-Jan-2008  15:00  416
> 07-Jan-2008  16:00  417
> 07-Jan-2008  17:00  418
> 07-Jan-2008  18:00  419
> 07-Jan-2008  19:00  420
> 07-Jan-2008  20:00  421
> 07-Jan-2008  21:00  422
> 07-Jan-2008  22:00  423
> 07-Jan-2008  23:00  424
> 07-Jan-2008  24:00  425
> 08-Jan-2008   1:00  426
> 08-Jan-2008   2:00  427
> 08-Jan-2008   3:00  428
> 08-Jan-2008   4:00  429
> 
> =================================
> 
> basically add one to the "hour" property of the series to get your desired
> output.
Thanks, I will do as you suggested.
Nevertheless, we should think if we you implement feature into the 
package that does take care for all this.
like a function that sets the hours of a day from 1 to 24 instead of 0 
to 23.

Kind regards,
Timmie

P.S.: Once I get my data in and these questions solved I'd like to add 
this to the wiki. Shall I then open a page Timeseries/FAQ or
Timeseries/Recipies?


More information about the SciPy-user mailing list