[Numpy-discussion] reshaping arrays

Bradley M. Froehle brad.froehle at gmail.com
Sat Mar 2 22:20:42 EST 2013

On Sat, Mar 2, 2013 at 6:03 PM, Sudheer Joseph <sudheer.joseph at yahoo.com>wrote:

> Hi all,
>         For a 3d array in matlab, I can do the below to reshape it before
> an eof analysis. Is there a way to do the same using numpy? Please help.
> [nlat,nlon,ntim ]=size(ssh);
> tssh=reshape(ssh,nlat*nlon,ntim);
> and afterwards
> eofout=[]
> eofout=reshape(eof1,nlat,nlon,ntime)

Yes, easy:

nlat, nlon, ntim = ssh.shape
tssh = ssh.reshape(nlat*nlon, ntim, order='F')
and afterwards
eofout = eofl.reshape(nlat, nlon, ntim, order='F')

You probably want to go read through

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130302/2a21adf4/attachment.html>

More information about the NumPy-Discussion mailing list