yt.visualization.image_writer.write_bitmap

yt.visualization.image_writer.write_bitmap(bitmap_array, filename, max_val=None, transpose=False)[source]

Write out a bitmapped image directly to a PNG file.

This accepts a three- or four-channel bitmap_array. If the image is not already uint8, it will be scaled and converted. If it is four channel, only the first three channels will be scaled, while the fourth channel is assumed to be in the range of [0,1]. If it is not four channel, a fourth alpha channel will be added and set to fully opaque. The resultant image will be directly written to filename as a PNG with no colormap applied. max_val is a value used if the array is passed in as anything other than uint8; it will be the value used for scaling and clipping in the first three channels when the array is converted. Additionally, the minimum is assumed to be zero; this makes it primarily suited for the results of volume rendered images, rather than misaligned projections.

Parameters:

bitmap_array : array_like

Array of shape (N,M,3) or (N,M,4), to be written. If it is not already a uint8 array, it will be scaled and converted to uint8.

filename : string

Filename to save to. If None, PNG contents will be returned as a string.

max_val : float, optional

The upper limit to clip values to in the output, if converting to uint8. If bitmap_array is already uint8, this will be ignore.

transpose : boolean, optional

If transpose is False, we assume that the incoming bitmap_array is such that the first element resides in the upper-left corner. If True, the first element will be placed in the lower-left corner.