def test_streamlines(): mesh = examples.download_carotid() stream, src = mesh.streamlines(return_source=True, max_time=100.0, initial_step_length=2., terminal_speed=0.1, n_points=25, source_radius=2.0, source_center=(133.1, 116.3, 5.0) ) assert stream.n_points > 0 assert src.n_points == 25
Plotting Glyphs (Vectors) ~~~~~~~~~~~~~~~~~~~~~~~~~ Use vectors in a dataset to plot and orient glyphs/geometric objects. """ # sphinx_gallery_thumbnail_number = 4 import pyvista as pv from pyvista import examples import numpy as np ############################################################################### # Glyphying can be done via the :func:`pyvista.DataSetFilters.glyph` filter mesh = examples.download_carotid().threshold(145, scalars="scalars") # Make a geometric obhect to use as the glyph geom = pv.Arrow() # This could be any dataset # Perform the glyph glyphs = mesh.glyph(orient="vectors", scale="scalars", factor=0.005, geom=geom) # plot using the plotting class p = pv.Plotter() p.add_mesh(glyphs) # Set a cool camera position p.camera_position = [ (84.58052237950857, 77.76332116787425, 27.208569926456548), (131.39486171068918, 99.871379394528, 20.082859824932008), (0.13483731007732908, 0.033663777790747404, 0.9902957385932576),
def test_download_carotid(): data = examples.download_carotid() assert data.n_cells
Estimate the gradient of a scalar or vector field in a data set. The ordering for the output gradient tuple will be {du/dx, du/dy, du/dz, dv/dx, dv/dy, dv/dz, dw/dx, dw/dy, dw/dz} for an input array {u, v, w}. Showing the :func:`pyvista.DataSetFilters.compute_gradient` filter. """ # sphinx_gallery_thumbnail_number = 1 import pyvista as pv from pyvista import examples import numpy as np # A vtkStructuredGrid - but could be any mesh type mesh = examples.download_carotid() mesh ############################################################################### # Now compute the gradients of the ``vectors`` vector field in the point data # of that mesh. This is as simple as calling # :func:`pyvista.DataSetFilters.compute_gradient`. mesh_g = mesh.compute_gradient(scalars="vectors") mesh_g["gradient"] ############################################################################### # ``mesh_g["gradient"]`` is an ``N`` by 9 NumPy array of the gradients, so we # could make a dictionary of NumPy arrays of the gradients like: def gradients_to_dict(arr): """A helper method to label the gradients into a dictionary."""
def __init__(self): self._example_data = examples.download_carotid() _ExampleLoader.__init__(self)