yt.extensions.image_writer.write_image

yt.extensions.image_writer.write_image(image, filename, color_bounds=None, cmap_name='algae')

Write out a floating point array directly to a PNG file, scaling it and applying a colormap.

This function will scale an image and directly call libpng to write out a colormapped version of that image. It is designed for rapid-fire saving of image buffers generated using yt.raven.FixedResolutionBuffers and the like.

Parameters :

image : array_like

This is an (unscaled) array of floating point values, shape (N,N,) to save in a PNG file.

filename : string

Filename to save as.

color_bounds : tuple of floats, optional

The min and max to scale between. Outlying values will be clipped.

cmap_name : string, optional

An acceptable colormap. See either raven.color_maps or http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps .

Returns :

scaled_image : uint8 image that has been saved

Examples

>>> proj = pf.h.slice(0, "Density")
>>> frb1 = FixedResolutionBuffer(proj, (0.2, 0.3, 0.4, 0.5),
                (1024, 1024))
>>> write_image(frb1, "saved.png")

Previous topic

yt.extensions.image_writer.write_bitmap

Next topic

yt.extensions.image_writer.map_to_colors

This Page