[SciPy-user] incompatible sizes when correlating two timeseries

Pierre GM pgmdevlist@gmail....
Fri Dec 19 13:35:04 CST 2008


On Dec 18, 2008, at 1:33 PM, Matt Knox wrote:

> Timmie <timmichelsen <at> gmx-topmail.de> writes:
>
>>
>> Hello,
>> I try to correlate two timeseries.
>>
>> I don not understand, why I get an error for incompatile size.
>
> I would say this is a bug. Although I am not 100% certain the cause  
> of it at the
> moment. I think it happens when the correlate function tries to  
> create a new
> TimeSeries to store the result in and somehow the dates of the input  
> TimeSeries
> get passed along to create the resulting TimeSeries (which will be  
> of size 1).
>

np.correlate(x,y) returns a 1D array of size 1. Because x and y are  
TimeSeries, it tries to create a new series, but don't know what to do  
w/ the dates, so it chokes.


> A simple work around for now is to just call np.correlate on the  
> underlying raw
> array (using the .data attribute of the TimeSeries). Note that  
> np.correlate will
> NOT work properly with MaskedArray's that contain masked value. In  
> general you
> should assume functions from the top level numpy namespace will not  
> work
> properly with masked values.

Indeed: when manipulating time series, if you don't need to keep track  
of the dates, just drop them by using .series (better than .data, as  
'masked values shouldn't be trusted anyway'(TM)...)


> Pierre, I think we should probably up-cast the TimeSeries to a plain  
> MaskedArray
> when _update_from is called with dates of a different size than the  
> data. I'm
> sure other functions in numpy crash on TimeSeries objects for the  
> same reason.
> What do you think?

Right now, nothing. I need to see a better example. Here, yes, we  
could drop the dates and return a MaskedArray. In other cases, there's  
a legitimate reason for trying to output a TimeSeries.


More information about the SciPy-user mailing list