Best way for rotating a matrix of data?

Nobody nobody at
Wed Sep 22 18:50:21 CEST 2010

On Tue, 21 Sep 2010 19:38:06 -0700, Raphaël Plasson wrote:

> Actually, I more precisely extract my 2D array from much higher
> dimensions data (i.e. 10-20 fields of different data in 3 dimensions
> of space+1 dimension of time), contained in a hdf5 file. I typically
> would like to extract arbitrary slices of any of the fields from the
> 3+1D space... and I don't really know how this can be simply done. I
> can only extract an "orthogonal" 2D space from this space, and rotate
> it with the above method.
> Is there a more direct way to extract arbitrary slices directly from
> 2/3/4D arrays? Which python modules would be able to do the job?

You can use arrays as indices, so applying a transformation to a set of
index arrays (e.g. np.indices) then using those as indices is equivalent
to applying a spatial transform to the data.

Also: scipy.ndimage.

More information about the Python-list mailing list