[SciPy-User] Speed-up simple function

Charles R Harris charlesr.harris at gmail.com
Mon Jan 10 10:21:00 EST 2011


On Mon, Jan 10, 2011 at 7:45 AM, <g.plantageneto at runbox.com> wrote:

>
> Thanks for the quick answers. To be more specific, the slow part is
> something like this (see comments in the code):
>
> for tstep in xrange(0,end):     # I need this cycle otherwise I run out of
> memory
>        VAR1     = file.variables['VAR1'][tstep,:,:,:] #Read from a NetCDF
> file
>        VAR2     = file.variables['VAR2'][tstep,:,:,:] #Read another
> variable from the same NetCDF file
>        # Use the data read above in two functions. I do also some reshaping
> to have the correct
>        # input for the function. The polynomials computed in the functions
> are of order 10 at most.
>        COMP1  =
> FUNC1(VAR1,VAR2,np.tile(5000,VAR1.shape),np.reshape(np.repeat(SOMETHING,nrep),VAR1.shape))
>        COMP2  = FUNC2(VAR1,COMP1,np.tile(5000,VAR1.shape))
>        #Compute an average on the output of previous computations
>        RESULT[tstep] = np.average(COMP2,weights=W)
>
>
This looks terribly over complicated. What are you trying to do and where is
the polynomial?

<snip>

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110110/b904210c/attachment.html>


More information about the SciPy-User mailing list