[Numpy-discussion] insert 1D to a 2D array and change it to 3D

Matthieu Brucher matthieu.brucher@gmail....
Fri Apr 25 05:09:42 CDT 2008


2008/4/25, tournesol <tournesol33@gmail.com>:
>
> Hi All.
>
>
> I just want to conver Fortran 77 source to
> Python.
>
> Here is my F77 source.
>
>         DIMENSION A(25,60,13),B(25,60,13)
>
>         open(15,file='data.dat')
>         DO 60 K=1,2
>         READ(15,1602) ((B(I,J),J=1,60),I=1,25)
>     60 CONTINUE
>   1602 FORMAT(15I4)
>
>         DO 63 K=1,10
>         DO 62 I=1,25
>         DO 62 J=1,60
>         A(I,J,K)=B(I,J)
>     62 CONTINUE
>     63 CONTINUE
>         END
>
> Q1: Fortran-contiguous is ARRAY(row,colum,depth).
>      How about the Python-contiguous ? array(depth,row,colum) ?



Default is C-contiguous, but you can you Fortran contiguous arrays.


Q2: How can I insert 1D to a 2D array and make it to
>      3D array. ex:) B:25x60 ==> A: 10X25X60
>

I don't understand what you want to do, but broadcasting allows copying
several instances of an array into another one.

Matthieu
-- 
French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080425/b76a4c3e/attachment.html 


More information about the Numpy-discussion mailing list