[SciPy-user] Generating a 4D array from a set of 3D arrays
Wed May 21 13:07:26 CDT 2008
Perfect. Thanks I knew there must be something simple I was missing.
>>> "Robert Kern" <firstname.lastname@example.org> 5/21/2008 12:45 PM >>>
On Wed, May 21, 2008 at 12:05 PM, Dharhas Pothina
> I'm trying to read 3 dimensional time series data from a file and store it in a numpy array so I can analyze the data. I'm having problems working out how to append the 3D array from each timestep to make a 4D array. I worked out that I could make a list of 3D arrays but if I do that I'm having issues slicing it the way I need to.
Keep appending to the list to build it up. Then make an array from
that list using array().
from numpy import array
a = array([[[ 1, 2],[ 3, 4],[ 5, 6]],[[101, 102],[103,
104],[105, 106]],[[201, 202],[203, 204],[205, 206]]])
newdata = a
for i in arange(5):
data_list.append(newdata) # This is the idiomatic way to append to a list.
newdata = newdata + 1000
data_array = array(data_list)
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
SciPy-user mailing list
More information about the SciPy-user