[SciPy-user] time series plotting (slightly off topic)

Pierre GM pgmdevlist at gmail.com
Tue Jan 2 12:22:43 CST 2007

Ciao Matt,
Happy New Year !
I've been quite busy during Xmas and NYD with your TimeSeries module. Please 
have a look in the mtimeseries subfolder. You'll find the basic code along 
with an updated version of your example and some unittests.

As I had told you last year, my implmntation of TimeSeries relies on 
maskedarray. That means that TimeSeries object are basically subclasses of 
MaskedArray, and in fine of ndarray. Support of non-regular time series, with 
gaps in dates, is operational. The trick is to store the dates along the 
data, in a new DateArray object. That's a bit of an overload when you have 
regular time series, but that's the only way. 

The DateArray objects are described in the tsdate.py file. I put some 
creation/conversion tests: you can convert a DateArray to another frequency, 
to strings, or even to Gregorian proleptic ordinals, which means that 
plotting is as simple as:
plot_date(series._dates.toordinal(), series._series) 
I had already written some subclasses of MPL.SubPlot to simplify that. I'll 
have to clean my code a bit and will post it latter.

The nice thing is that you can select items directly by their date, entered as 
a DateObject, or even a string, without having to convert them to indices 

Conversion to other frequencies works as expected.  Using basic arithmetic 
functions works also (a nice side effect of working with maskedarray).

A couple of comments:
- Do we still need dateOf ? cseries.convert seems to do the work. dateOf could 
then just be a python wrapper.
- It'd be cool if cseries.convert could accept arrays instead of only scalars. 
That way, we wouldn't have to loop over a DateArray for the conversion.

Now I intend to work on the full support of multi-timeseries, viz, one 
TimeSeries object where each row corresponds to a particular series. In 
particular, I'd want to be able to access data by names, a bit like records. 
I want also to work on supporting other frequencies, such as weekly, hourly 
and minutely. There's already some basic implementation in tsdate, but I 
haven't tried to modify the C code yet.

I  didn't really try to support the regular numpy.core.ma: I can try to work a 
bit on that, but that's not my main objective.

Let me know what you think.


More information about the SciPy-user mailing list