Re: Use of Python with GDAL. How to speed up ?

2006-03-24 Thread Serge Orlov
Julien Fiore wrote: Thank you Serge for this generous reply, Vectorized code seems a great choice to compute the distance. If I understand well, vectorized code can only work when you don't need to access the values of the array, but only need to know the indices. You can access array

Re: Use of Python with GDAL. How to speed up ?

2006-03-23 Thread Julien Fiore
Thank you Serge for this generous reply, Vectorized code seems a great choice to compute the distance. If I understand well, vectorized code can only work when you don't need to access the values of the array, but only need to know the indices. This works well for the distance, but I need to

Re: Use of Python with GDAL. How to speed up ?

2006-03-22 Thread Julien Fiore
Thanks for the psyco information, Serge. 2) Rewrite the code to be vectorized (don't use psyco) Right now your code *doesn't* get any speed benefit from numpy I do not understand this point. How to rewrite the code ? Do you mean in C ? Julien --

Re: Use of Python with GDAL. How to speed up ?

2006-03-22 Thread Julien Fiore
Thanks Caleb for the advice, I profiled my code with the following lines: import profile, pstats profile.runctx('openness(infile,outfile,R)',globals(),locals(),'profile.log') p = pstats.Stats('profile.log') p.sort_stats('time') p.print_stats(10) The outputs tells me that the

Re: Use of Python with GDAL. How to speed up ?

2006-03-22 Thread Kent Johnson
Julien Fiore wrote: Thanks Caleb for the advice, I profiled my code with the following lines: import profile, pstats profile.runctx('openness(infile,outfile,R)',globals(),locals(),'profile.log') p = pstats.Stats('profile.log') p.sort_stats('time') p.print_stats(10)

Re: Use of Python with GDAL. How to speed up ?

2006-03-22 Thread Serge Orlov
Julien Fiore wrote: Thanks for the psyco information, Serge. 2) Rewrite the code to be vectorized (don't use psyco) Right now your code *doesn't* get any speed benefit from numpy I do not understand this point. How to rewrite the code ? vectorized code means one operation work on multiple

Use of Python with GDAL. How to speed up ?

2006-03-17 Thread Julien Fiore
Hi, I wrote a function to compute openness (a digital elevation model attribute). The function opens the gdal-compatible input raster and reads the values in a square window around each cell. The results are stored in a 1 line buffer. At the end of the line, the buffer is written to the output

Re: Use of Python with GDAL. How to speed up ?

2006-03-17 Thread Caleb Hattingh
Hi The documentation for the python profiler in the python library reference is extremely readable (well done James Roskin!?). Profile your code, and when you find where the speed problem occurs, try pitching just that section of code in comp.lang.python. You will likely get much feedback.

Re: Use of Python with GDAL. How to speed up ?

2006-03-17 Thread Serge Orlov
Julien Fiore wrote: Hi, I wrote a function to compute openness (a digital elevation model attribute). The function opens the gdal-compatible input raster and reads the values in a square window around each cell. The results are stored in a 1 line buffer. At the end of the line, the buffer is