https://github.com/jbusecke/xmovie
A simple way of creating movies from xarray objects
https://github.com/jbusecke/xmovie
creating-movies movie plot xarray
Last synced: about 1 year ago
JSON representation
A simple way of creating movies from xarray objects
- Host: GitHub
- URL: https://github.com/jbusecke/xmovie
- Owner: jbusecke
- License: mit
- Created: 2018-03-13T00:24:05.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2025-03-31T17:41:37.000Z (about 1 year ago)
- Last Synced: 2025-04-11T23:15:25.521Z (about 1 year ago)
- Topics: creating-movies, movie, plot, xarray
- Language: Python
- Homepage: https://xmovie.readthedocs.io/
- Size: 27.2 MB
- Stars: 252
- Watchers: 4
- Forks: 38
- Open Issues: 44
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-meteo - xmovie
README
# xmovie
[](https://github.com/jbusecke/xmovie/actions)
[](https://xmovie.readthedocs.io/en/latest/)
[](https://results.pre-commit.ci/latest/github/jbusecke/xmovie/master)
[](https://codecov.io/gh/jbusecke/xmovie)
[](https://opensource.org/licenses/MIT)
[](https://zenodo.org/badge/latestdoi/124968397)
[](https://anaconda.org/conda-forge/xmovie)
[](https://anaconda.org/conda-forge/xmovie)
[](https://badge.fury.io/py/xmovie)
*A simple way of creating beautiful movies from [xarray](https://xarray.pydata.org) objects.*
With ever-increasing detail, modern scientific observations and model results
lend themselves to visualization in the form of movies.
Not only is a beautiful movie a fantastic way to wake up the crowd on a Friday
afternoon of a weeklong conference, but it can also speed up the discovery
process, since our eyes are amazing image processing devices.
This module aims to facilitate movie rendering from data objects based on
[xarray objects](https://xarray.pydata.org/en/stable/user-guide/data-structures.html).
Xarray already provides [a way](https://xarray.pydata.org/en/stable/user-guide/plotting.html)
to create quick and beautiful static images from your data using [Matplotlib](https://matplotlib.org/).
[Various packages](https://matplotlib.org/mpl-third-party/#animations)
provide facilities for animating Matplotlib figures.
But it can become tedious to customize plots, particularly when map projections are used.
The main aims of this module are:
- Enable quick but high-quality movie frame creation from existing xarray
objects with preset plot functions -- create a movie with only 2 lines of code.
- Provide high quality, customizable presets to create stunning visualizations with minimal setup.
- Convert your static plot workflow to a movie with only a few lines of code,
while maintaining all the flexibility of [xarray](https://xarray.pydata.org)
and [Matplotlib](https://matplotlib.org).
- Optionally, use [Dask](https://dask.org) for parallelized frame rendering.
## Installation
The easiest way to install `xmovie` is via `conda`:
```
conda install -c conda-forge xmovie
```
You can also install via `pip`:
```
pip install xmovie
```
## Documentation
Check out the examples and API documentation at .
## Quickstart
High-quality movies and gifs can be created with only a few lines
```python
import xarray as xr
from xmovie import Movie
ds = xr.tutorial.open_dataset('air_temperature').isel(time=slice(0,150))
mov = Movie(ds.air)
mov.save('movie.mp4')
```
Saving a `.gif` is as easy as changing the filename:
```python
mov.save('movie.gif')
```
That is it! Now pat yourself on the shoulder and enjoy your masterpiece.

> The GIF is created by first rendering a movie and then converting it to a GIF.
> If you want to keep both outputs you can simply do `mov.save('movie.gif', remove_movie=False)`