Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MultiScene.save_animation to work with new dask.distributed versions #938

Merged
merged 2 commits into from
Oct 17, 2019
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
16 changes: 8 additions & 8 deletions satpy/multiscene.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
#
# You should have received a copy of the GNU General Public License along with
# satpy. If not, see <http://www.gnu.org/licenses/>.
"""MultiScene object to blend satellite data.
"""
"""MultiScene object to work with multiple timesteps of satellite data."""

import logging
import numpy as np
Expand Down Expand Up @@ -49,15 +48,15 @@


def stack(datasets):
"""First dataset at the bottom."""
"""Overlay series of datasets on top of each other."""
base = datasets[0].copy()
for dataset in datasets[1:]:
base = base.where(dataset.isnull(), dataset)
return base


def timeseries(datasets):
"""Expands dataset with and concats by time dimension"""
"""Expand dataset with and concatenate by time dimension."""
expanded_ds = []
for ds in datasets:
tmp = ds.expand_dims("time")
Expand Down Expand Up @@ -214,6 +213,7 @@ def _all_same_area(self, dataset_ids):

@property
def all_same_area(self):
"""Determine if all contained Scenes have the same 'area'."""
return self._all_same_area(self.loaded_dataset_ids)

@staticmethod
Expand Down Expand Up @@ -304,7 +304,7 @@ def load_data(q):
log.debug("Child thread died successfully")

def _simple_save_datasets(self, scenes_iter, **kwargs):
"""Helper to simple run save_datasets on each Scene."""
"""Run save_datasets on each Scene."""
for scn in scenes_iter:
scn.save_datasets(**kwargs)

Expand Down Expand Up @@ -414,11 +414,11 @@ def load_data(frame_gen, q):

input_q = Queue(batch_size if batch_size is not None else 1)
load_thread = Thread(target=load_data, args=(frames_to_write, input_q,))
remote_q = client.gather(input_q)
load_thread.start()

while True:
future_dict = remote_q.get()
input_future = input_q.get()
future_dict = client.gather(input_future)
if future_dict is None:
break

Expand Down Expand Up @@ -448,7 +448,7 @@ def _simple_frame_compute(self, writers, frame_keys, frames_to_write):

def save_animation(self, filename, datasets=None, fps=10, fill_value=None,
batch_size=1, ignore_missing=False, client=True, **kwargs):
"""Helper method for saving to movie (MP4) or GIF formats.
"""Save series of Scenes to movie (MP4) or GIF formats.

Supported formats are dependent on the `imageio` library and are
determined by filename extension by default.
Expand Down
13 changes: 6 additions & 7 deletions satpy/tests/test_multiscene.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
#
# You should have received a copy of the GNU General Public License along with
# satpy. If not, see <http://www.gnu.org/licenses/>.
"""Unit tests for multiscene.py.
"""
"""Unit tests for multiscene.py."""

import os
import sys
Expand Down Expand Up @@ -75,12 +74,12 @@ def _create_test_dataset(name, shape=DEFAULT_SHAPE, area=None):


def _create_test_scenes(num_scenes=2, shape=DEFAULT_SHAPE, area=None):
"""Helper to create some test scenes."""
"""Create some test scenes for various test cases."""
from satpy import Scene
ds1 = _create_test_dataset('ds1', shape=shape, area=area)
ds2 = _create_test_dataset('ds2', shape=shape, area=area)
scenes = []
for scn_idx in range(num_scenes):
for _ in range(num_scenes):
scn = Scene()
scn['ds1'] = ds1.copy()
scn['ds2'] = ds2.copy()
Expand Down Expand Up @@ -153,11 +152,11 @@ class TestMultiSceneSave(unittest.TestCase):
"""Test saving a MultiScene to various formats."""

def setUp(self):
"""Create temporary directory to save files to"""
"""Create temporary directory to save files to."""
self.base_dir = tempfile.mkdtemp()

def tearDown(self):
"""Remove the temporary directory created for a test"""
"""Remove the temporary directory created for a test."""
try:
shutil.rmtree(self.base_dir, ignore_errors=True)
except OSError:
Expand Down Expand Up @@ -461,7 +460,7 @@ def test_timeseries(self):


def suite():
"""The test suite for test_multiscene."""
"""Create the test suite for test_multiscene."""
loader = unittest.TestLoader()
mysuite = unittest.TestSuite()
mysuite.addTest(loader.loadTestsFromTestCase(TestMultiScene))
Expand Down