Write a (list of) NumPy array(s) to an (animated) GIF.
Project description
T = 0.7 T_c
T = 0.88 T_c
T = 1.06 T_c
Array2GIF provides a single top-level function, write_gif(), to write a 3-D NumPy array to a GIF, or a list of these arrays to an animated GIF. It works for me - just small animations of thermodynamics simulations - like the magnetization in the Ising model shown here.
Usage
Here is an example for a 2 pixel by 3 pixel animated GIF with two frames, switching 5 frames per second. All animations from this library will loop indefinitely.
import numpy as np
from array2gif import write_gif
dataset = [
np.array([
[[255, 0, 0], [255, 0, 0]], # red intensities
[[0, 255, 0], [0, 255, 0]], # green intensities
[[0, 0, 255], [0, 0, 255]] # blue intensities
]),
np.array([
[[0, 0, 255], [0, 0, 255]],
[[0, 255, 0], [0, 255, 0]],
[[255, 0, 0], [255, 0, 0]]
])
]
write_gif(dataset, 'rgbbgr.gif', fps=5)
# or for just a still GIF
write_gif(dataset[0], 'rgb.gif')
Installation
Either:
pip install array2gif
or:
pip install git+https://github.com/tanyaschlusser/array2gif.git#egg=array2gif
Release History
1.0.0 (2018-05-23)
Improvements
It is now possible to use PIL ordering of data (rows x cols x rgb) in addition to the original ordering (rgb x rows x cols).
Bugfixes
Fixed issue where array2gif would raise ValueError when using a 4D NumPy array with perfectly valid data. Now it is possible to use either a list of 3D NumPy arrays, or a 4D NumPy array for animated gifs.
0.1.0 (2016-09-30)
Initial release
One single function, write_gif.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for array2gif-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 840a5bc0d35c3431c90787a59bdcee2f302f69f9df69994b75c106cd679f27cf |
|
MD5 | 245da6906accc9084241b69a98cdddb4 |
|
BLAKE2b-256 | e1cc4890ea0f837796280dff08a440abc67d6aed22178b3092895a1539c108ea |
Hashes for array2gif-1.0.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac38667185fd0f56beca75ce295a83431f5446a6987f1a40f49fbacb12a5653b |
|
MD5 | 92e220675fc87e189bda6fda3f99ca8a |
|
BLAKE2b-256 | 0183c66fd5b3923d8f4ee68cfb492eaed9fd41bff2ee8a81d349bbe5815ea056 |