[Numpy-discussion] saving 3d array

Camilo Andrés Jimenez Cruz camilo.jimenezc@gmail....
Sun Jun 16 13:07:13 CDT 2013


Hi!

I know it is pretty much the same as you did before, but has been useful
for me in the past. Instead of saving each array separately, just create a
dictionary and save the it, something like

d= {put_all_your_arrays_here}
savez_compressed('file.npz', **d)


-- Camilo Jiménez


On Sat, Jun 15, 2013 at 2:11 PM, Eric Firing <efiring@hawaii.edu> wrote:

> On 2013/06/15 6:06 AM, Pierre GM wrote:
> >
> > On Jun 15, 2013, at 17:35 , Matthew Brett <matthew.brett@gmail.com>
> wrote:
> >
> >> Hi,
> >>
> >> On Sat, Jun 15, 2013 at 2:51 PM, Sudheer Joseph
> >> <sudheer.joseph@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)]`.
>
> For automated saving and restoring, try this:
>
>
> http://currents.soest.hawaii.edu/hgstage/pycurrents/file/686c2802a6c4/file/npzfile.py
>
> Eric
>
> _______________________________________________
> 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/20130616/a7e05170/attachment.html 


More information about the NumPy-Discussion mailing list