I've got a simulation model running in Python using NumPy and SciPy and it produces a 2D NumPy array as the output each iteration. I've been displaying this output as an image using matplotlib and the imshow function. However, I've found out about Glumpy, and on its documentation page it says:
Thanks to the IPython shell, glumpy can be ran in interactive mode where you can experience live update in displayed arrays when their contents is changed.
However, I can't seem to work out how to do this with the examples they've given. Basically my model runs as a single function which has a big for loop in it to loop for the number of iterations I'm running. At the end of each iteration of the for loop I want to display the array. At the moment I'm using matplotlib to save the image out to a png file, as displaying it on the screen through matplotlib seems to freeze the python process.
I'm sure there's a way to do this with Glumpy, I'm just not sure how, and I can't find any useful tutorials.
The Glumpy documentation is fairly nonexistent! Here's an example of a simple simulation, comparing array visualisation with
glumpy
againstmatplotlib
:Using
matplotlib
withGTKAgg
as my backend and usingblit
to avoid drawing the background each time, I can hit about 95 FPS. WithGlumpy
I get about 250-300 FPS, even though I currently a fairly crappy graphics setup on my laptop. Having said that,Glumpy
is a bit more fiddly to get working, and unless you are dealing with huge matrices, or you need a very high framerate for whatever reason, I would stick with usingmatplotlib
withblit
.