[SciPy-user] sorting timeseries data.

Dharhas Pothina Dharhas.Pothina at twdb.state.tx.us
Fri May 2 12:11:04 EDT 2008


Hi,

I have some field data with unequal spacing and some duplicate values that I am trying to plot a spline through. It seems that the splrep and splev functions require a unique monotonically increasing series of values.

Say I have an unordered dataset with some duplicate values like :

seconds = array([1,3,2,5,4,1,6,9,8])
data = array([100, 101, 102, 103, 104, 105, 106, 107, 108])

I want to sort the data to be monotonically increasing by the variable seconds and filter out duplicate values (say by deleting the second occurrence). 

I've tried combining the arrays : a = array([seconds,data]) and then using sort and argsort with various options but instead of sorting by the first column it sorts *every* column. I've also tried a=zip(x,y) followed by sort() / unique()

my final sorted array needs to look like

newseconds = array([1,1,2,3,4,5,6,8,9])
newdata = array([100,105,102,101,104,103,106,108,107])

and then removing duplicates should look like

finalseconds = array([1,2,3,4,5,6,8,9])
finaldata = array([100,102,101,104,103,106,108,107])

Any help is appreciated.

thanks

- dharhas






More information about the SciPy-User mailing list