How to use the pyvista.examples function in pyvista

To help you get started, we’ve selected a few pyvista examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyvista / pyvista / tests / test_examples.py View on Github external
def test_download_office():
        data = examples.download_office()
        assert data.n_cells
github pyvista / pyvista / tests / test_examples.py View on Github external
def test_download_tri_quadratic_hexahedron():
        data = examples.download_tri_quadratic_hexahedron()
        assert data.n_cells
github OpenGeoVis / PVGeo / PVPlugins / PyVista_Examples.py View on Github external
def __init__(self):
        self._example_data = examples.download_bunny()
        _ExampleLoader.__init__(self)
github pyvista / pyvista / examples / 01-filter / compute-volume.py View on Github external
bodies.plot(show_grid=True, multi_colors=True, cpos=[-2, 5, 3])


###############################################################################
# -----
#
# A Real Dataset
# ++++++++++++++
#
# Here is a realistic training dataset of fluvial channels in the subsurface.
# This will threshold the channels from the dataset then separate each
# significantly large body and compute the volumes for each!
#
# Load up the data and threshold the channels:

data = examples.load_channels()
channels = data.threshold([0.9, 1.1])

###############################################################################
# Now extract all the different bodies and compute their volumes:

bodies = channels.split_bodies()
# Now remove all bodies with a small volume
for key in bodies.keys():
    b = bodies[key]
    vol = b.volume
    if vol < 1000.0:
        del bodies[key]
        continue
    # Now lets add a volume array to all blocks
    b.cell_arrays["TOTAL VOLUME"] = np.full(b.n_cells, vol)
github OpenGeoVis / PVGeo / _downloads / d1754dab2850102fd74d6417f48c95c7 / append-cell-centers.py View on Github external
"""
Append Cell Centers
~~~~~~~~~~~~~~~~~~~

This example will demonstrate how to append a dataset's cell centers as a length 3 tuple array.

This example demonstrates :class:`PVGeo.filters.AppendCellCenters`
"""

from pyvista import examples
from PVGeo.filters import AppendCellCenters

################################################################################
# Use an example mesh from pyvista
mesh = examples.load_rectilinear()
print(mesh)

################################################################################
#  Run the PVGeo algorithm
centers = AppendCellCenters().apply(mesh)
print(centers)

################################################################################
centers.plot()
github OpenGeoVis / PVGeo / _downloads / 6836d877af5c90d76168dff8e79ce15c / normalize-array.py View on Github external
output. The user can specify how they want to rename the array, can choose a
multiplier, and can choose from two types of common normalizations:
Feature Scaling and Standard Score.

This example demos :class:`PVGeo.filters.NormalizeArray`

"""
import numpy as np
import pyvista
from pyvista import examples
import PVGeo
from PVGeo.filters import NormalizeArray

################################################################################
# Create some input data. this can be any `vtkDataObject`
mesh = examples.load_uniform()
title = 'Spatial Point Data'
mesh.plot(scalars=title)
################################################################################

# Apply the filter
f = NormalizeArray(normalization='feature_scale', new_name='foo')
output = f.apply(mesh, title)
print(output)

################################################################################
output.plot(scalars='foo')
github pyvista / pyvista / examples / 01-filter / connectivity.py View on Github external
"""
Connectivity
~~~~~~~~~~~~

Use the connectivity filter to remove noisy isosurfaces.

This example is very similar to `this VTK example `__
"""
# sphinx_gallery_thumbnail_number = 2
import pyvista as pv
from pyvista import examples

###############################################################################
# Load a dataset that has noisy isosurfaces
mesh = examples.download_pine_roots()

cpos = [(40.6018, -280.533, 47.0172),
        (40.6018, 37.2813, 50.1953),
        (0.0, 0.0, 1.0)]

# Plot the raw data
p = pv.Plotter()
p.add_mesh(mesh, color='#965434')
p.add_mesh(mesh.outline())
p.show(cpos=cpos)

###############################################################################
# The mesh plotted above is very noisy. We can extract the largest connected
# isosurface in that mesh using the :func:`pyvista.DataSetFilters.connectivity`
# filter and passing ``largest=True`` to the ``connectivity``
# filter or by using the :func:`pyvista.DataSetFilters.extract_largest` filter
github OpenGeoVis / PVGeo / examples / gslib / read-point-set.py View on Github external
"""
Read GSLib Point Set
~~~~~~~~~~~~~~~~~~~~

Read GSLib point set file
"""
# sphinx_gallery_thumbnail_number = 1
from pyvista import examples
from PVGeo.gslib import GSLibPointSetReader

###############################################################################

# points_url = 'http://www.trainingimages.org/uploads/3/4/7/0/34703305/b_100sampledatawl.sgems'
filename, _ = examples.downloads._download_file('b_100sampledatawl.sgems')

point_set = GSLibPointSetReader().apply(filename)
print(point_set)

###############################################################################
point_set.plot()
github pyvista / pyvista / joss / images / code.py View on Github external
# Obligatory set up code
import pyvista
from pyvista import examples
import numpy as np
# Set a document-friendly plotting theme
pyvista.set_plot_theme('document')

# Load an example uniform grid
dataset = examples.load_uniform()
# Apply a threshold over a data range
threshed = dataset.threshold([100, 500]) # Figure 4 A

outline = dataset.outline()
contours = dataset.contour() # Figure 4 B
slices = dataset.slice_orthogonal() # Figure 4 C
glyphs = dataset.glyph(factor=1e-3, geom=pyvista.Sphere()) # Figure 4 D

# Two by two comparison
pyvista.plot_compare_four(threshed, contours, slices, glyphs,
                        {'show_scalar_bar':False},
                        {'border':False},
                        camera_position=[-2,5,3], outline=outline,
                        screenshot='filters.png')

# Apply a filtering chain