Cool, I was able to export a MP4 (later manually converted to GIF to upload here) using Pangeo Forge, Kerchunk, Datashader, and hvPlot (dynamic=False); took 22 minutes though for 731 frames; forgot to set a colorbar limit here though. Also, one thing I’m not sure how to do is control the animation speed and crop whitespace.
import os
import time
import apache_beam as beam
import fsspec
import hvplot.xarray
import xarray as xr
from pangeo_forge_recipes.patterns import ConcatDim, FilePattern
from pangeo_forge_recipes.transforms import (
OpenWithKerchunk,
WriteCombinedReference,
)
# Constants
target_root = "references"
store_name = "Pangeo_Forge"
full_path = os.path.join(target_root, store_name, "reference.json")
years = list(range(1979, 1980))
time_dim = ConcatDim("time", keys=years)
# Functions
def format_function(time):
return f"http://www.northwestknowledge.net/metdata/data/bi_{time}.nc"
# Patterns
pattern = FilePattern(format_function, time_dim, file_type="netcdf4")
pattern = pattern.prune()
# Apache Beam transforms
transforms = (
beam.Create(pattern.items())
| OpenWithKerchunk(file_type=pattern.file_type)
| WriteCombinedReference(
target_root=target_root,
store_name=store_name,
concat_dims=["day"],
identical_dims=["lat", "lon", "crs"],
)
)
# Constants
target_root = "references"
store_name = "Pangeo_Forge"
full_path = os.path.join(target_root, store_name, "reference.json")
years = list(range(1979, 1980))
time_dim = ConcatDim("time", keys=years)
# Functions
def format_function(time):
return f"http://www.northwestknowledge.net/metdata/data/bi_{time}.nc"
# Patterns
pattern = FilePattern(format_function, time_dim, file_type="netcdf4")
pattern = pattern.prune()
# Apache Beam transforms
transforms = (
beam.Create(pattern.items())
| OpenWithKerchunk(file_type=pattern.file_type)
| WriteCombinedReference(
target_root=target_root,
store_name=store_name,
concat_dims=["day"],
identical_dims=["lat", "lon", "crs"],
)
)
import holoviews as hv
hv.extension("matplotlib")
mapper = fsspec.get_mapper(
"reference://",
fo=full_path,
remote_protocol="http",
)
ds_kerchunk = xr.open_dataset(
mapper, engine="zarr", decode_coords="all", backend_kwargs={"consolidated": False}
)
hv.save(
ds_kerchunk
.hvplot("lon", "lat", rasterize=True, dynamic=False)
.opts(fig_size=200),
"example.mp4",
fmt="mp4",
)