[Numpy-discussion] saving 3d array

Sudheer Joseph sudheer.joseph at yahoo.com
Sat Jun 15 12:23:09 EDT 2013


Thanks a lot,
              Both suggestions helped me and I could save it as below.
np.savez('eof_output',eof=eof1.data,pcs=pc1,lags=lags,lons=lons,lats=lats,x=x,y=y,clevs=clevs,eof_mask=eof1.mask)

***************************************************************
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 at gmail.com;sudheer.joseph at yahoo.com
Web- http://oppamthadathil.tripod.com
***************************************************************


>________________________________
> From: Pierre GM <pgmdevlist at gmail.com>
>To: Discussion of Numerical Python <numpy-discussion at scipy.org> 
>Sent: Saturday, 15 June 2013 9:36 PM
>Subject: Re: [Numpy-discussion] saving 3d array
> 
>
>
>On Jun 15, 2013, at 17:35 , Matthew Brett <matthew.brett at gmail.com> wrote:
>
>> Hi,
>> 
>> On Sat, Jun 15, 2013 at 2:51 PM, Sudheer Joseph
>> <sudheer.joseph at yahoo.com> wrote:
>>> 
>>> Thank you very much for this tip.
>>> Is there a typical way to save masked and the rest separately?. Not much familiar with array handling in numpy.
>> 
>> I don't use masked array myself, but it looks like it would be something like:
>> 
>> eof1_unmasked = np.array(eof1)
>> eof1_mask = eof1.mask
>> 
>> then you could save those two.  Maybe a more maskey person could comment?
>
>Instead of `eof1_unmasked=np.array(eof1)`, you could do `eof1_unmasked = eof1.data`. The '.data' attribute points to  a view of the masked array as a simple ndarray.
>
>You may also wanna try `eof1.torecords()` that will return a structured array with dtype `[('_data',type_of_eof1),('_mask', bool)]`. 
>_______________________________________________
>NumPy-Discussion mailing list
>NumPy-Discussion at scipy.org
>http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130616/e6c96a29/attachment.html>


More information about the NumPy-Discussion mailing list