Ryan's example notebook #13
rabernat
started this conversation in
Show and tell
Replies: 1 comment
-
Following up using import numpy as np
import pyvista as pv
from pvxarray import register_xy_names
import xarray as xr
import zarr
dataset_path = "/Users/bane/Software/Pan3D/ryan/test"
ds = xr.open_zarr(dataset_path, consolidated=False)
filename = "temperature_and_eddy_forcing.mp4"
# CRUCIAL: Register coordinate names with pvxarray
# These names come from this particular DataSet
register_xy_names("XC_agg", "YC_agg")
# CRUCIAL: Access/fetch DataArrays for PyVista accessor persistance
T = ds.T
E = ds.eddyV
# Grab initial mesh
mesh_t = T.pyvista[dict(time=0)].pyvista.mesh
mesh_e = E.pyvista[dict(time=0)].pyvista.mesh
# Set consistent display parameters
T_sargs = dict(height=0.25, vertical=True, position_x=0.05, position_y=0.05)
eddy_sargs = dict(height=0.25, vertical=True, position_x=0.05, position_y=0.05)
plotter = pv.Plotter(
shape=(1, 2), window_size=[int(1024 * 1.5), 768],
off_screen=True, notebook=False
)
plotter.open_movie(filename, framerate=5) # pip install imageio-ffmpeg
# Configure left plot
plotter.subplot(0, 0)
plotter.add_mesh(
mesh_t, show_edges=True, clim=[0, 8], cmap="magma", scalar_bar_args=T_sargs, lighting=False
)
plotter.set_scale(zscale=0.3e3)
# Configure right plot
plotter.subplot(0, 1)
plotter.add_mesh(
mesh_e,
show_edges=True,
clim=[-2e5, 2e5],
cmap="RdBu_r",
scalar_bar_args=eddy_sargs,
lighting=False,
)
plotter.set_scale(zscale=0.3e3)
plotter.link_views()
plotter.view_isometric()
plotter.show(auto_close=False)
# Run through each frame
plotter.write_frame() # write initial data
for step in range(len(ds.time) - 1):
T.pyvista[dict(time=step + 1)]
E.pyvista[dict(time=step + 1)]
plotter.write_frame() # Write this frame
# Be sure to close the plotter when finished
plotter.close() temperature_and_eddy_forcing.mp4 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Just some code to get started
https://gist.github.com/rabernat/4dedd891ff847c55e5becca449a5c601#file-make_movie-ipynb
Beta Was this translation helpful? Give feedback.
All reactions