[SciPy-User] scikits.timeseries question
Mon Nov 30 18:53:56 CST 2009
On Nov 30, 2009, at 5:23 PM, Christopher Barker wrote:
> Pierre GM wrote:
>> On Nov 30, 2009, at 6:58 PM, Christopher Barker wrote:
>> I guess you're confusing DateArrays and TimeSeries.
>> DateArrays are just arrays of dates (think a ndarray of datetime
>> objects, or a ndarray with a datetime64 dtype). TimeSeries are like
>> MaskedArrays, the combination of a ndarray of values with 2 others
>> ndarrays: one array of booleans (the mask), one DateArray.
> Actually, I think I got that.
>>> In : sd = ts.Date(freq='D', year=2001, month=1, day=1)
>>> In : sd
>>> Out: <D : 01-Jan-2001>
>> All is well here.
>>> In : da = ts.date_array((1,2,3,4), start_date=sd)
>> Check the doc for date_array: the first argument can be
>> * a sequence of integers corresponding to the representation
>> :class:`Date` objects.
> That's what I'm trying to give it.
>> So, what you're trying to do is to build a an array of four dates
>> Instead, use that:
>> timeseries([1 2 3 4],
>> dates = [01-Jan-2001 ... 04-Jan-2001],
>> freq = D)
> Ah, but what I am trying to do is build that "dates" array -- in teh
> real case, I have 1212 pieces of data, associated with time, in
> terms of
> "days since Jan 1, 2001). So I need to construct that dates array to
> associate with the time_series data.
> So I want:
> dates = what_to_put_here?
I may be misunderstanding what you are trying to do, but here's what I
In : sd = ts.Date('d', '2001-01-01')
In : dates = ts.date_array(cumsum(ones(4)) + sd)
In : dates
DateArray([02-Jan-2001, 03-Jan-2001, 04-Jan-2001, 05-Jan-2001],
If the dates aren't consecutive, you can always just use the known
In : days_since_beginning = array([1, 3, 4, 8])
In : dates = ts.date_array(days_since_beginning + sd)
In : dates
DateArray([02-Jan-2001, 04-Jan-2001, 05-Jan-2001, 09-Jan-2001],
There's probably an easier way...
If this happens to be what you are trying to do, be careful of the
counting of days (0 based, vs 1 based).
> timeseries([1 2 3 4],
> dates = dates],
> freq = D)
> While I'm at it -- what I really have is a big 'ol 3-d array, which is
> gridded model output, of shape: (time, lat, lon). Time is expressed in
> days since...
> I need to do a moving average of the while grid over time. Can a
> time_series be n-d, with time as one of the axis?
> Christopher Barker, Ph.D.
> Emergency Response Division
> NOAA/NOS/OR&R (206) 526-6959 voice
> 7600 Sand Point Way NE (206) 526-6329 fax
> Seattle, WA 98115 (206) 526-6317 main reception
> SciPy-User mailing list
More information about the SciPy-User