Re: [Numpy-discussion] Optimize speed of for loop using numpy

2008-02-27 Thread Trond Kristiansen
Hey all. I would just like to thank you all for extremely good feedback on my problem with optimizing loops. Thank you all for being so helpful. Cheers, Trond ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailma

Re: [Numpy-discussion] Optimize speed of for loop using numpy

2008-02-26 Thread Eric Firing
Trond, See if the attached file contains something close to what you need. It has no loops at all; I have not timed it, but it should be quite quick. I have given it only a cursory check, so I don't guarantee it works correctly. Depending on how your particular NetCDF interface works, you m

Re: [Numpy-discussion] Optimize speed of for loop using numpy

2008-02-26 Thread Anne Archibald
On 25/02/2008, Trond Kristiansen <[EMAIL PROTECTED]> wrote: > I have attached the function that the FOR loop is part of as a python file. > What I am trying to do is to create a set of functions that will read the > output files (NetCDF) from running the ROMS model (ocean model). The output >

Re: [Numpy-discussion] Optimize speed of for loop using numpy

2008-02-25 Thread Robert Kern
On Mon, Feb 25, 2008 at 8:32 PM, Trond Kristiansen <[EMAIL PROTECTED]> wrote: > Hi again. > > I have attached the function that the FOR loop is part of as a python file. > What I am trying to do is to create a set of functions that will read the > output files (NetCDF) from running the ROMS mode

Re: [Numpy-discussion] Optimize speed of for loop using numpy

2008-02-25 Thread Charles R Harris
On Mon, Feb 25, 2008 at 7:08 PM, Trond Kristiansen <[EMAIL PROTECTED]> wrote: > > > Hi all. > This is my first email to the discussion group. I have spent two days > trying > to get a particular loop to speed up, and the best result I got was this: > > tmp1=zeros((eta,xi),float) > > tmp2=zeros((et

Re: [Numpy-discussion] Optimize speed of for loop using numpy

2008-02-25 Thread Trond Kristiansen
Hi again. I have attached the function that the FOR loop is part of as a python file. What I am trying to do is to create a set of functions that will read the output files (NetCDF) from running the ROMS model (ocean model). The output file is organized in xi (x-direction), eta (y-direction), and

Re: [Numpy-discussion] Optimize speed of for loop using numpy

2008-02-25 Thread Hoyt Koepke
I would definitely suggest using scipy's weave.inline for this. It seems like this particular function can be translated into C code really easily, which would give you a HUGE speed up. Look at some of the examples in scipy/weave/examples to see how to do this. The numpy book also has a section

Re: [Numpy-discussion] Optimize speed of for loop using numpy

2008-02-25 Thread Robert Kern
On Mon, Feb 25, 2008 at 8:08 PM, Trond Kristiansen <[EMAIL PROTECTED]> wrote: > > > Hi all. > This is my first email to the discussion group. I have spent two days trying > to get a particular loop to speed up, and the best result I got was this: Can you try to repost this in such a way that th

[Numpy-discussion] Optimize speed of for loop using numpy

2008-02-25 Thread Trond Kristiansen
Hi all. This is my first email to the discussion group. I have spent two days trying to get a particular loop to speed up, and the best result I got was this: tmp1=zeros((eta,xi),float) tmp2=zeros((eta,xi),float) tmp1=tmp1+1 tmp2=tmp2+1 for i in range(xi): for j in range(eta):