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
These are animated GIFs showing a Monte Carlo simulation to obtain a distribution of equilibrium magnetization, using the Ising model, at various dimensionless temperatures relative to the Curie temperature. It explores the interplay between the magnetic coupling force between atoms, and the randomness from the temperature.
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 is currently in alpha stage, with no attempt at optimization for speed, but it works great 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
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 Distribution
Hashes for array2gif-0.1.0b1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb6bf1b07f180d5cf43d1f148c6e67eaa431becbf43e916d3fb9515614126647 |
|
MD5 | 6f4aa748e79bccb82a5733dd2968167a |
|
BLAKE2b-256 | f0a238c2e1211efbeb7483c320afba74f1b447422fff13f2a088c9a5efda28f5 |