writing efficiently a numpy array
Emile van Sebille
emile at fenx.com
Thu Feb 28 10:19:51 EST 2002
"Stephan" <stephan.schumacher at andra.fr> wrote in message
news:fc905aec.0202280020.738f55db at posting.google.com...
> > In what area are you looking to be more efficient? Memory, time, or
> > something else? Do you need it in ascii form for another program,
or
> > are you saving it to be read back in?
>
> in Time !!!
>
> I need it in ascii file because this file will be the input file of
> another program. The numpy arrays store fields of velocity, pressure,
> saturation... The fields are computed on a mesh with about 300000
> nodes. Then another program read the fields and compute the migration
> of several species.
Take advantage of Numeric's output formatting, using:
<untested>
for ii in range(0,len(a),N):
file.write(str(a[ii:ii+N])[1:-1]+"\n")
HTH,
--
Emile van Sebille
emile at fenx.com
---------
More information about the Python-list
mailing list