[Numpy-discussion] reshaping arrays

Sudheer Joseph sudheer.joseph@yahoo....
Sat Mar 2 22:35:43 CST 2013


Hi Brad,
                I am not getting the attribute reshape for the array, are you having a different version of numpy than mine?

I have 
In [55]: np.__version__
Out[55]: '1.7.0'
and detail of the shape

details of variable 

In [57]: ssh??
Type:       NetCDFVariable
String Form:<NetCDFVariable object at 0x492d3d8>
Namespace:  Interactive
Length:     75
Docstring:  NetCDF Variable

In [58]: ssh.shape
Out[58]: (75, 140, 180)

ssh??
Type:       NetCDFVariable
String Form:<NetCDFVariable object at 0x492d3d8>
Namespace:  Interactive
Length:     75
Docstring:  NetCDF Variable

In [66]: ssh.shape
Out[66]: (75, 140, 180)

In [67]: ssh.reshape(75,140*180)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/home/sjo/RAMA_20120807/adcp/<ipython-input-67-1a21dae1d18d> in <module>()
----> 1 ssh.reshape(75,140*180)

AttributeError: reshape

 
***************************************************************
Sudheer Joseph 
Indian National Centre for Ocean Information Services
Ministry of Earth Sciences, Govt. of India
POST BOX NO: 21, IDA Jeedeemetla P.O.
Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000 55
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile)
E-mail:sjo.India@gmail.com;sudheer.joseph@yahoo.com
Web- http://oppamthadathil.tripod.com
***************************************************************


________________________________
 From: Sudheer Joseph <sudheer.joseph@yahoo.com>
To: Discussion of Numerical Python <numpy-discussion@scipy.org> 
Sent: Sunday, 3 March 2013 9:19 AM
Subject: Re: [Numpy-discussion] reshaping arrays
 

Thank you Brad,
for the quick reply with solution, special thanks to the link for matlab users.
with best regards,
Sudheer
 
***************************************************************
Sudheer Joseph 
Indian National Centre for Ocean Information Services
Ministry of Earth Sciences, Govt. of India
POST BOX NO: 21, IDA Jeedeemetla P.O.
Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000 55
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile)
E-mail:sjo.India@gmail.com;sudheer.joseph@yahoo.com
Web- http://oppamthadathil.tripod.com
***************************************************************


________________________________
 From: Bradley M. Froehle <brad.froehle@gmail.com>
To: Discussion of Numerical Python <numpy-discussion@scipy.org> 
Sent: Sunday, 3 March 2013 8:50 AM
Subject: Re: [Numpy-discussion] reshaping arrays
 

On Sat, Mar 2, 2013 at 6:03 PM, Sudheer Joseph <sudheer.joseph@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 http://www.scipy.org/NumPy_for_Matlab_Users.

Cheers,
Brad
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion



_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130303/3461810e/attachment-0001.html 


More information about the NumPy-Discussion mailing list