[Yt-dev] Simple image writing

Matthew Turk matthewturk at gmail.com
Thu Apr 15 10:52:39 PDT 2010


Hi guys,

I wrote a new module (in branch yt of hg) that will do simple image
writing; it only depends on libpng (no matplotlib dependencies) and
does not do anything fancy: no text, no callbacks, no colormaps.  But,
it's really quite fast and it comes with a couple colormaps -- algae,
jet, gist_stern and hot.  The API is pretty easy.  You can either
call:

import yt.extensions.image_writer as iw
iw.write_image(image, filename, color_bounds = None, cmap = "algae")

where image is a numpy array of values to be colormapped, or you can
directly call the image writer:

yt.amr_utils.write_png(some_image_data, filename)

where some_image_data is uint8 and is (N,M,4).

Unfortunately, generating FixedResolutionBuffers still requires that
matplotlib be imported; I'll work on getting around this sometime,
because if this ends up working we should be able to run on Kraken in
the compute nodes without importing matplotlib.  Although, Cray has
now announced they're going to support dynamically linked libraries on
their compute nodes, so maybe we won't need this for long.

That being said, it should also be pretty handy for things like
writing out volume renderings and anywhere else we previously used
pylab to save images rather than plots.  Let me know if you have any
ideas or problems!

-Matt



More information about the yt-dev mailing list