[Numpy-discussion] ToyFDTDpython on Freshmeat yesterday

Travis Oliphant oliphant at ee.byu.edu
Thu Sep 6 10:14:02 EDT 2001

> Rob wrote:
> > Only slowdown was dumping the E fields into a file every few
> > ticks to generate the movie.  I know there must be better ways to dump
> > an array than use indexing-
> If you want to dump the binary data, you can use:
> file.write(array.tostring)
> If you need an ASCI representation, you can use various forms of:
> format_string = '%f '* A.shape[1] + '\n'
> for r in range(A.shape[0]):
> 	file.write(format_string%(tuple(A[r,:])))
> You could probably use map to speed it up a little as well.
> I'd love to see an array-oreinted version of fscanf and fprintf to make
> this faster and easier, but I have yet to get around to writing one.

Check out the IO secion of SciPy.  Numpyio along with a flexible
ASCII_file reader are there.


More information about the NumPy-Discussion mailing list