speed of clearing and creating a new array

I am starting with a zero array, populate it according to some
condition, save the graph, and then reset the array to zero. Can
someone tell me if there is a better (faster) way to do this? Or am I

just doing that much, and that is how long it will take? I have a
couple hundred graphs that I am creating, that will ultimately be
combined for animation.

ay=4000
ax=60
#create empty array
a = zeros((ay,ax), int)

while something:
pcolormesh(X, Y, a)
figname = ‘Frame%03d’ %int(field)
print figname
savefig(figname)

reset values

a = zeros((ay,ax), int)
if something:
if something:

 a[y,x] = a[y,x]+1

I am starting with a zero array, populate it according to some
condition, save the graph, and then reset the array to zero. Can
someone tell me if there is a better (faster) way to do this?

You might ask at the numpy mailing list, but I suspect that

a *= 0

might be faster.

···

On Tuesday 08 April 2008 10:46:32 am Bryan Fodness wrote:

Or am I
just doing that much, and that is how long it will take? I have a
couple hundred graphs that I am creating, that will ultimately be
combined for animation.

ay=4000
ax=60
#create empty array
a = zeros((ay,ax), int)

while something:
  pcolormesh(X, Y, a)
  figname = 'Frame%03d' %int(field)
  print figname
  savefig(figname)
  # reset values
  a = zeros((ay,ax), int)
  if something:
     if something:
     a[y,x] = a[y,x]+1

I am going to need something along this line pretty soon.
What is the difference between matshow and pcolormesh for
this? (Besides the aspect ratio?)

Thank you,
Alan Isaac

···

On Tuesday 08 April 2008 10:46:32 am Bryan Fodness wrote:

I am starting with a zero array, populate it according to
some condition, save the graph

My 2c:

* Use inplace addition to save some space

while something:
    ....
    if something:
        if something:
        a[y,x] += 1

* To set all the values to 0:
a.flat = 0

···

On Tuesday 08 April 2008 10:46:32 Bryan Fodness wrote:

I am starting with a zero array, populate it according to some
condition, save the graph, and then reset the array to zero. Can
someone tell me if there is a better (faster) way to do this?

Alan G Isaac wrote:

I am starting with a zero array, populate it according to some condition, save the graph

I am going to need something along this line pretty soon.
What is the difference between matshow and pcolormesh for
this? (Besides the aspect ratio?)

matshow is a compatibility interface to imshow, which is restricted to regular rectangular grids, but is the fastest way to make an image-like plot. pcolormesh is not as fast, but can handle arbitrary quadrilateral grids. There is also code to handle irregular rectangular grids at a speed intermediate between imshow and pcolormesh (which is a wrapper for quadmesh).

A unified interface to all of these is provided by the pcolorfast axes method in svn. Its API may need tweaking; suggestions are welcome.

Eric

···

On Tuesday 08 April 2008 10:46:32 am Bryan Fodness wrote:

Thank you,
Alan Isaac

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Register now and save $200. Hurry, offer ends at 11:59 p.m., Monday, April 7! Use priority code J8TLD2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users