Test pyvista with trame

Test pyvista with trame#

import pyvista as pv
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 1
----> 1 import pyvista as pv

ModuleNotFoundError: No module named 'pyvista'
from pyvista import examples
#pv.set_jupyter_backend('trame')  # for interactive plots when running notebook
pv.set_jupyter_backend('static')  # for static plots in jupyter book
if 1:
    vol = examples.download_knee_full()
    pl = pv.Plotter()
    pl.add_volume(vol, cmap='bone', opacity='sigmoid', show_scalar_bar=False)
    pl.enable_depth_peeling()
    pl.show()
if 1:
    sphere = pv.Sphere()
    sphere.plot()
from pylab import *
from clawpack.geoclaw import topotools

topo = topotools.Topography('../topo/topofiles/Copalis_13s.asc')
topo = topo.crop([-124.19486111, -124.15597222, 47.10791667, 47.14597222])

    
z = array([0.])
x = (topo.x - topo.x[0]) * 111e3 * cos(topo.y.mean()*pi/180)
y = -(topo.y - topo.y[0]) * 111e3
print('xmax = %.1fm, ymax = %.1fm' % (x.max(),y.max()))
X,Y,Z = meshgrid(x, y, z, indexing='ij')
topoxyz = pv.StructuredGrid(X,Y,Z)

#B = topo.Z
B = flipud(topo.Z)
#B = fliplr(B)
Bmax = 50.
#B = where(B<Bmax,B,nan)
B = minimum(B, Bmax)

topoxyz.point_data['B'] = B.flatten(order='C')
warpfactor = 15  # amplification of elevations
topowarp = topoxyz.warp_by_scalar('B', factor=warpfactor)
# plot topo alone:
p = pv.Plotter()
p.add_mesh(topowarp,cmap='gist_earth',clim=(-5,20))
p.add_title(f'\n\nCopalis Beach area with \nvertical amplification factor {warpfactor}',
            font_size=8)
p.show(window_size=(800,500))