geovista icon indicating copy to clipboard operation
geovista copied to clipboard

Update scalars on existing mesh

Open jbusecke opened this issue 9 months ago • 2 comments

📰 Custom Issue

I recently produced this and am wondering if I could improve performance with these sorts of high resolution climate outputs. The movie shows two 'animated' features: a) evolving scalars (time dependent velocity and salinity fields) with time b) A camera move

I wrote the model out in a fashing like this (pseudocode):

import geovista as gv

ds = load_xarray_dataset
frames = range(n)
camera_path = define_camera_path(frames)

p = gv.GeoPlotter()
p.open_movie(f'something.mp4')

for frame in frames:
    # select timestep
    da = ds.sel(time=frame).YOUR_VARIABLE
    
   # create new mesh for each timestep (point a)
    mesh = gv.Transform.from_2d(da.lon, da.lat, data=da.data)
    mesh = mesh.threshold()
    actor = p.add_mesh(mesh)
    
   # Animate camera position (point b)
    p.camera_position = camera_path.points[frame,:]

    # write movie frame and remove actor
    p.write_frame()
    p.remove_actor(actor)

p.close()

This seems super inefficent to me. I actually do not need to redraw the mesh, but instead the whole point a) is currently a change in the scalar values. I saw that there is a possibility to update just the scalars in pyvista. I wonder if there is an internal/external function that would allow me to 'map' my n dimensional array of scalar data with geovista to be in the proper format to use pyvista.Plotter.update_scalars() instead of removing/rebuilding the mesh.

jbusecke avatar Sep 20 '23 14:09 jbusecke