[To summarize an off-list conversation -- Eric and I had been discussing ways to speed up pcolor plots. After some improvements, quadmeshes are still about a factor of 2 slower on the branch than on the trunk. His use case often involves the simpler problem of rectilinear meshes, which can be handled by NonUniformImage, which should be much faster in all cases.]
Eric Firing wrote:
you might want to look at the long-neglected but promising pcolor method in the _image.cpp, used by the NonUniformImage class in image.py.
There is an example on using NonUniformImage in pcolor_nonuniform.py that seems to work -- so this code isn't too neglected
I suspect that the axes pcolor method should actually be using this if the grid is rectilinear and using quadmesh otherwise.
Implementation wise (just to get something working), it was easier to extend imshow to take two 1D-arrays X and Y which define a non-uniform grid for the image. (My changes merely give NonUniformImage a pyplot API, so the user doesn't have to do as much work as in the example.) But if we think this functionality belongs with pcolor, it can be exposed that way instead. However, there should be some way to let pcolor know that the mesh is rectilinear. (It would otherwise be wasteful computation just to determine that and proceed accordingly).
As expected, there are significant performance benefits:
Branch:
nonuniformimage:
init: 0.27
fps: 21.37
pcolormesh:
init: 0.42
fps: 2.61
Trunk:
nonuniformimage:
init: 0.25
fps: 22.52
pcolormesh:
init: 0.28
fps: 6.64
I've committed my changes on the transforms branch so you can play with it -- I'm holding off on changing the trunk due to the pending release. But if everyone agrees on the way to expose this, it would be nice to merge this over to trunk before the release.
Cheers,
Mike
nonuniformimage.py (539 Bytes)
pcolormesh.py (535 Bytes)
···
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA