Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
xarray >= 0.12.2
dask[array] >= 1.0.0
natsort >= 5.5.0
matplotlib >= 2.2
matplotlib >= 3.0.3
animatplot >= 0.3
netcdf4 >= 1.4.0
Pillow >= 6.1.0
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
'xarray>=v0.10.0',
'dask[array]>=1.0.0',
'natsort>=5.5.0',
'matplotlib>=2.2',
'animatplot>=0.3'
'matplotlib>=3.0.3',
'animatplot>=0.3',
'Pillow>=6.1.0'
],
extras_require={
'tests': ['pytest >= 3.3.0'],
Expand Down
10 changes: 3 additions & 7 deletions xbout/plotting/animate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import animatplot as amp

from .utils import plot_separatrix

from matplotlib.animation import PillowWriter

def animate_imshow(data, animate_over='t', x='x', y='y', animate=True,
vmin=None, vmax=None, fps=10, save_as=None,
Expand Down Expand Up @@ -93,9 +93,7 @@ def animate_imshow(data, animate_over='t', x='x', y='y', animate=True,

if not save_as:
save_as = "{}_over_{}".format(variable, animate_over)
# TODO save using PillowWriter instead once matplotlib 3.1 comes out
# see https://github.com/t-makaro/animatplot/issues/24
anim.save(save_as + '.gif', writer='imagemagick')
anim.save(save_as + '.gif', writer=PillowWriter(fps=fps))

return imshow_block

Expand Down Expand Up @@ -178,8 +176,6 @@ def animate_line(data, animate_over='t', animate=True,

if not save_as:
save_as = "{}_over_{}".format(variable, animate_over)
# TODO save using PillowWriter instead once matplotlib 3.1 comes out
# see https://github.com/t-makaro/animatplot/issues/24
anim.save(save_as + '.gif', writer='imagemagick')
anim.save(save_as + '.gif', writer=PillowWriter(fps=fps))

return line_block
39 changes: 39 additions & 0 deletions xbout/tests/test_animate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import pytest

from xbout import open_boutdataset
from xbout.boutdataarray import BoutDataArrayAccessor

from animatplot.blocks import Imshow, Line

# Path to test dmp files
DATA_PATH = './xbout/tests/data/dump_files/along_x/BOUT.dmp.*.nc'


@pytest.fixture
def create_test_file(tmpdir_factory):

# Create temp dir for output of animate1D/2D
save_dir = tmpdir_factory.mktemp("test_data")
ds = open_boutdataset(DATA_PATH).squeeze(drop=True) # Open test data

return save_dir, ds


class TestAnimate:
"""
Set of tests to check whether animate1D() and animate2D() are running properly
and PillowWriter is saving each animation correctly
"""
def test_animate2D(self, create_test_file):

save_dir, ds = create_test_file
animation = ds['T'].bout.animate2D(y='z', save_as="%s/test" % save_dir)

assert isinstance(animation, Imshow)

def test_animate1D(self, create_test_file):

save_dir, ds = create_test_file
animation = ds['T'][:, :, 0].bout.animate1D(save_as="%s/test" % save_dir)

assert isinstance(animation, Line)