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

Testing needed for dask.array input. #11

Open
jbusecke opened this issue May 21, 2019 · 2 comments
Open

Testing needed for dask.array input. #11

jbusecke opened this issue May 21, 2019 · 2 comments

Comments

@jbusecke
Copy link
Owner

As @dcherian pointed out in #6, there might be issues with passing dask arrays to Movie. I need to extend the tests to include dask.arrays.

@keewis
Copy link

keewis commented Mar 5, 2024

There's some discussion about this on the pangeo discourse. The result of that discussion seems to be a new library aiming to implement streaming saves instead of writing images then concatenating using ffmpeg. I wonder if it would make sense to collaborate between the two libraries?

cc @ahuang11

@ahuang11
Copy link

ahuang11 commented Mar 6, 2024

Thanks for starting this conversation.

To offer some context, StreamJoy is a general purpose, parallel animation package, e.g. can animate not just xarray, but a list of images, pandas, and holoviews.

xmovie on the other hand is xarray centric. Depending on performance timing and if beneficial, xmovie could use streamjoy on the backend.

Below is my docs in progress and if interested on implementation: the primary animation logic is here while the xarray reader is here


📖 Quick start

From list of images

Here, we animate a list of images from URLs for the sake of a quick example, but a list of local file paths works too!

from streamjoy import stream

URL_FMT = "https://noaadata.apps.nsidc.org/NOAA/G02135/north/daily/images/2024/01_Jan/N_202401{day:02d}_conc_v3.0.png"

stream([URL_FMT.format(day=day) for day in range(1, 31)], output_path="2024_jan_sea_ice.gif")

From directory of images

Instead of a list, we can pass a directory URL and a pattern to match the files we want to animate.

from streamjoy import stream

URL_DIR = "https://noaadata.apps.nsidc.org/NOAA/G02135/north/daily/images/2024/01_Jan/"

stream(URL_DIR, pattern="N_*_conc_v3.0.png", max_files=31, output_path="2024_jan_sea_ice.gif")

From a pandas.DataFrame

Or, we can directly animate a pandas.DataFrame!

df.plot keyword arguments can be passed to stream to customize the plot.

from streamjoy import stream
import pandas as pd

df = pd.read_csv(
    "https://raw.githubusercontent.com/franlopezguzman/gapminder-with-bokeh/master/gapminder_tidy.csv"
).set_index("Year")
df = df.query("Country in ['United States', 'China', 'South Africa']")
stream(df, groupby="Country", title="{Year}", output_path="gapminder.mp4")

From a xarray.Dataset

Similarly, we can animate a xarray.Dataset, and ds.plot keyword arguments can be passed to stream too!

from streamjoy import stream
import xarray as xr

ds = xr.tutorial.open_dataset("air_temperature").isel(time=slice(0, 100))
stream(ds, cmap="RdBu_r", output_path="air_temperature.mp4")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants