[SciPy-user] scikits.timeseries : how would Iplot (orcalculate) monthly statistics.
Dharhas Pothina
Dharhas.Pothina@twdb.state.tx...
Thu Mar 5 13:49:28 CST 2009
Thank you. This worked great and saved me a lot of time. I'm slowly getting the hang of this package. Sorry for the obvious question but I assume that ma.mean() etc automatically excludes masked values from the calculation.
- d
>>> Pierre GM <pgmdevlist@gmail.com> 3/4/2009 3:46 PM >>>
Dharhas,
On Mar 4, 2009, at 4:26 PM, Dharhas Pothina wrote:
> Original data is on an approximately two week frequency. I'll be
> reading them in as daily values and converting to monthly.
OK, you could try 'W', but 'D' is also OK.
> I eventually want to calculate plot monthly values in a particular
> year vs mean monthly values for all years (ie vs mean for each month
> irrespective of year)
Then, that's quite easy:
First, compute the means per month:
>>> mseries = series.convert('M', func=ma.mean)
You end up with a (n*12) series. Convert it to annual, but w/o
precising a function
>>> aseries = mseries.convert('A')
aseries is a (n, 12) series: years in rows, months in columns.
aseries[i,j] is the mean over month j for year i.
If you want the monthly values over all the years, just take the mean
along axis=0
>
>
>> If you have a monthly frequency: just use .convert('A') and compute
>> the stats for each column.
>
> Wouldn't this convert it to an Annual frequency, ie one value per
> year?
It does, but because you don't precise a func, you end up with a 2D
array
http://pytseries.sourceforge.net/generated/scikits.timeseries.TimeSeries.convert.html#scikits.timeseries.TimeSeries.convert
>> The generic idea is indeed to first convert to monthly. You end up
>> with a (12*n, 31) series that you have to reshape
>
> I get the 12*n , ie 12 months * number of years. Where does the 31
> come from. Does the series still contain the daily values after
> conversion to monthly?
I was talking about a 'D'aily series to convert to monthly, without
using a 'func' parameter. You then end up with a 2D series, with 12*n
rows and 31 columns (because there's at most 31 days per month). Note
that the last column (day 31) would be masked for Feb, Apr, Jun, Sep,
Nov.
_______________________________________________
SciPy-user mailing list
SciPy-user@scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user
More information about the SciPy-user
mailing list