diff --git a/examples/00-load/create-explicit-structured-grid.ipynb b/examples/00-load/create-explicit-structured-grid.ipynb index 6194906..60c2aca 100644 --- a/examples/00-load/create-explicit-structured-grid.ipynb +++ b/examples/00-load/create-explicit-structured-grid.ipynb @@ -15,7 +15,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Creating an Explicit Structured Grid {#ref_create_explicit_structured_grid}\n====================================\n\nCreate an explicit structured grid from NumPy arrays.\n\nNote this feature is only available for `vtk>=9`.\n" + "Creating an Explicit Structured Grid {#ref_create_explicit_structured_grid}\n====================================\n\nCreate an explicit structured grid from NumPy arrays.\n" ] }, { @@ -26,7 +26,7 @@ }, "outputs": [], "source": [ - "import numpy as np\n\nimport pyvista as pv\n\nni, nj, nk = 4, 5, 6\nsi, sj, sk = 20, 10, 1\n\nxcorn = np.arange(0, (ni + 1) * si, si)\nxcorn = np.repeat(xcorn, 2)\nxcorn = xcorn[1:-1]\nxcorn = np.tile(xcorn, 4 * nj * nk)\n\nycorn = np.arange(0, (nj + 1) * sj, sj)\nycorn = np.repeat(ycorn, 2)\nycorn = ycorn[1:-1]\nycorn = np.tile(ycorn, (2 * ni, 2 * nk))\nycorn = np.transpose(ycorn)\nycorn = ycorn.flatten()\n\nzcorn = np.arange(0, (nk + 1) * sk, sk)\nzcorn = np.repeat(zcorn, 2)\nzcorn = zcorn[1:-1]\nzcorn = np.repeat(zcorn, (4 * ni * nj))\n\ncorners = np.stack((xcorn, ycorn, zcorn))\ncorners = corners.transpose()\n\nif pv._vtk.VTK9:\n dims = np.asarray((ni, nj, nk)) + 1\n grid = pv.ExplicitStructuredGrid(dims, corners)\n grid = grid.compute_connectivity()\n grid.plot(show_edges=True)" + "import numpy as np\n\nimport pyvista as pv\n\nni, nj, nk = 4, 5, 6\nsi, sj, sk = 20, 10, 1\n\nxcorn = np.arange(0, (ni + 1) * si, si)\nxcorn = np.repeat(xcorn, 2)\nxcorn = xcorn[1:-1]\nxcorn = np.tile(xcorn, 4 * nj * nk)\n\nycorn = np.arange(0, (nj + 1) * sj, sj)\nycorn = np.repeat(ycorn, 2)\nycorn = ycorn[1:-1]\nycorn = np.tile(ycorn, (2 * ni, 2 * nk))\nycorn = np.transpose(ycorn)\nycorn = ycorn.flatten()\n\nzcorn = np.arange(0, (nk + 1) * sk, sk)\nzcorn = np.repeat(zcorn, 2)\nzcorn = zcorn[1:-1]\nzcorn = np.repeat(zcorn, (4 * ni * nj))\n\ncorners = np.stack((xcorn, ycorn, zcorn))\ncorners = corners.transpose()\n\ndims = np.asarray((ni, nj, nk)) + 1\ngrid = pv.ExplicitStructuredGrid(dims, corners)\ngrid = grid.compute_connectivity()\ngrid.plot(show_edges=True)" ] } ], @@ -46,7 +46,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/create-geometric-objects.ipynb b/examples/00-load/create-geometric-objects.ipynb index a615173..bae8796 100644 --- a/examples/00-load/create-geometric-objects.ipynb +++ b/examples/00-load/create-geometric-objects.ipynb @@ -33,7 +33,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This runs through several of the available geometric objects available\nin VTK which PyVista provides simple convenience methods for generating.\n\nLet\\'s run through creating a few geometric objects!\n" + "This runs through several of the available geometric objects available\nin VTK which PyVista provides simple convenience methods for generating.\n\nLet\\'s run through creating a few geometric objects.\n" ] }, { @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/create-kochanek-spline.ipynb b/examples/00-load/create-kochanek-spline.ipynb index bfc2aa7..7bcc59c 100644 --- a/examples/00-load/create-kochanek-spline.ipynb +++ b/examples/00-load/create-kochanek-spline.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/create-parametric-geometric-objects.ipynb b/examples/00-load/create-parametric-geometric-objects.ipynb index 93abe9e..0ef921e 100644 --- a/examples/00-load/create-parametric-geometric-objects.ipynb +++ b/examples/00-load/create-parametric-geometric-objects.ipynb @@ -478,7 +478,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/create-pixel-art.ipynb b/examples/00-load/create-pixel-art.ipynb index 067f784..2d02faf 100644 --- a/examples/00-load/create-pixel-art.ipynb +++ b/examples/00-load/create-pixel-art.ipynb @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/create-platonic-solids.ipynb b/examples/00-load/create-platonic-solids.ipynb index dad886a..3dc33ca 100644 --- a/examples/00-load/create-platonic-solids.ipynb +++ b/examples/00-load/create-platonic-solids.ipynb @@ -33,7 +33,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We can either use the generic\n`PlatonicSolid() `{.interpreted-text role=\"func\"}\nand specify the different kinds of solids to generate, or we can use the\nthin wrappers:\n\n> - `pyvista.Tetrahedron`{.interpreted-text role=\"func\"}\n> - `pyvista.Octahedron`{.interpreted-text role=\"func\"}\n> - `pyvista.Dodecahedron`{.interpreted-text role=\"func\"}\n> - `pyvista.Icosahedron`{.interpreted-text role=\"func\"}\n> - `pyvista.Cube`{.interpreted-text role=\"func\"} (implemented via a\n> different filter)\n\nLet\\'s generate all the Platonic solids, along with the `teapotahedron\n`{.interpreted-text\nrole=\"func\"}.\n" + "We can either use the generic\n`PlatonicSolid() `{.interpreted-text role=\"func\"}\nand specify the different kinds of solids to generate, or we can use the\nthin wrappers:\n\n- `pyvista.Tetrahedron`{.interpreted-text role=\"func\"}\n- `pyvista.Octahedron`{.interpreted-text role=\"func\"}\n- `pyvista.Dodecahedron`{.interpreted-text role=\"func\"}\n- `pyvista.Icosahedron`{.interpreted-text role=\"func\"}\n- `pyvista.Cube`{.interpreted-text role=\"func\"} (implemented via a\n different filter)\n\nLet\\'s generate all the Platonic solids, along with the `teapotahedron\n`{.interpreted-text\nrole=\"func\"}.\n" ] }, { @@ -89,7 +89,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/create-point-cloud.ipynb b/examples/00-load/create-point-cloud.ipynb index 8e5906d..f3a92a5 100644 --- a/examples/00-load/create-point-cloud.ipynb +++ b/examples/00-load/create-point-cloud.ipynb @@ -44,7 +44,7 @@ }, "outputs": [], "source": [ - "# Define some helpers - ignore these and use your own data!\ndef generate_points(subset=0.02):\n \"\"\"A helper to make a 3D NumPy array of points (n_points by 3)\"\"\"\n dataset = examples.download_lidar()\n ids = np.random.randint(low=0, high=dataset.n_points - 1, size=int(dataset.n_points * subset))\n return dataset.points[ids]\n\n\npoints = generate_points()\n# Print first 5 rows to prove its a numpy array (n_points by 3)\n# Columns are (X Y Z)\npoints[0:5, :]" + "# Define some helpers - ignore these and use your own data.\ndef generate_points(subset=0.02):\n \"\"\"A helper to make a 3D NumPy array of points (n_points by 3)\"\"\"\n dataset = examples.download_lidar()\n ids = np.random.randint(low=0, high=dataset.n_points - 1, size=int(dataset.n_points * subset))\n return dataset.points[ids]\n\n\npoints = generate_points()\n# Print first 5 rows to prove its a numpy array (n_points by 3)\n# Columns are (X Y Z)\npoints[0:5, :]" ] }, { @@ -201,7 +201,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/create-pointset.ipynb b/examples/00-load/create-pointset.ipynb index 0d4eeee..b26b8d3 100644 --- a/examples/00-load/create-pointset.ipynb +++ b/examples/00-load/create-pointset.ipynb @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/create-poly.ipynb b/examples/00-load/create-poly.ipynb index aeb2808..beaed4d 100644 --- a/examples/00-load/create-poly.ipynb +++ b/examples/00-load/create-poly.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/create-polydata-strips.ipynb b/examples/00-load/create-polydata-strips.ipynb index 0d3d2b0..9845fb0 100644 --- a/examples/00-load/create-polydata-strips.ipynb +++ b/examples/00-load/create-polydata-strips.ipynb @@ -154,7 +154,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/create-polyhedron.ipynb b/examples/00-load/create-polyhedron.ipynb index b219918..a975e38 100644 --- a/examples/00-load/create-polyhedron.ipynb +++ b/examples/00-load/create-polyhedron.ipynb @@ -172,7 +172,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/create-spline.ipynb b/examples/00-load/create-spline.ipynb index 960e9c0..91406cb 100644 --- a/examples/00-load/create-spline.ipynb +++ b/examples/00-load/create-spline.ipynb @@ -201,7 +201,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/create-structured-surface.ipynb b/examples/00-load/create-structured-surface.ipynb index c4dfdc4..8e83bc9 100644 --- a/examples/00-load/create-structured-surface.ipynb +++ b/examples/00-load/create-structured-surface.ipynb @@ -145,7 +145,7 @@ }, "outputs": [], "source": [ - "# Once you've figured out your grid's dimensions, simple create the\n# :class:`pyvista.StructuredGrid` as follows:\n\nmesh = pv.StructuredGrid()\n# Set the coordinates from the numpy array\nmesh.points = points\n# set the dimensions\nmesh.dimensions = [29, 32, 1]\n\n# and then inspect it!\nmesh.plot(show_edges=True, show_grid=True, cpos=\"xy\")" + "# Once you've figured out your grid's dimensions, simple create the\n# :class:`pyvista.StructuredGrid` as follows:\n\nmesh = pv.StructuredGrid()\n# Set the coordinates from the numpy array\nmesh.points = points\n# set the dimensions\nmesh.dimensions = [29, 32, 1]\n\n# and then inspect it\nmesh.plot(show_edges=True, show_grid=True, cpos=\"xy\")" ] }, { @@ -194,7 +194,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/create-surface-draped.ipynb b/examples/00-load/create-surface-draped.ipynb index b548ec6..29929e8 100644 --- a/examples/00-load/create-surface-draped.ipynb +++ b/examples/00-load/create-surface-draped.ipynb @@ -44,7 +44,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "View the the path of the GPR profile from a top-down perspective. Since\nwe have the full coordinates (XY and Z), we can create a structured mesh\n\\\"draping\\\" down from those coordinates to hold the GPR image data.\n" + "View the path of the GPR profile from a top-down perspective. Since we\nhave the full coordinates (XY and Z), we can create a structured mesh\n\\\"draping\\\" down from those coordinates to hold the GPR image data.\n" ] }, { @@ -66,7 +66,7 @@ }, "outputs": [], "source": [ - "assert len(path) in data.shape, \"Make sure coordinates are present for every trace.\"\n# If not, you'll need to interpolate the path!\n\n# Grab the number of samples (in Z dir) and number of traces/soundings\nnsamples, ntraces = data.shape # Might be opposite for your data, pay attention here\n\n# Define the Z spacing of your 2D section\nz_spacing = 0.12\n\n# Create structured points draping down from the path\npoints = np.repeat(path, nsamples, axis=0)\n# repeat the Z locations across\ntp = np.arange(0, z_spacing * nsamples, z_spacing)\ntp = path[:, 2][:, None] - tp\npoints[:, -1] = tp.ravel()" + "assert len(path) in data.shape, \"Make sure coordinates are present for every trace.\"\n# If not, you'll need to interpolate the path\n\n# Grab the number of samples (in Z dir) and number of traces/soundings\nnsamples, ntraces = data.shape # Might be opposite for your data, pay attention here\n\n# Define the Z spacing of your 2D section\nz_spacing = 0.12\n\n# Create structured points draping down from the path\npoints = np.repeat(path, nsamples, axis=0)\n# repeat the Z locations across\ntp = np.arange(0, z_spacing * nsamples, z_spacing)\ntp = path[:, 2][:, None] - tp\npoints[:, -1] = tp.ravel()" ] }, { @@ -84,14 +84,14 @@ }, "outputs": [], "source": [ - "grid = pv.StructuredGrid()\ngrid.points = points\ngrid.dimensions = nsamples, ntraces, 1\n\n# Add the data array - note the ordering!\ngrid[\"values\"] = data.ravel(order=\"F\")" + "grid = pv.StructuredGrid()\ngrid.points = points\ngrid.dimensions = nsamples, ntraces, 1\n\n# Add the data array - note the ordering\ngrid[\"values\"] = data.ravel(order=\"F\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "And now we can plot it! or process or do anything, because it is a\nPyVista mesh and the possibilities are endless with PyVista\n" + "And now we can plot it, process it, or do anything, because it is a\nPyVista mesh and the possibilities are endless with PyVista.\n" ] }, { @@ -122,7 +122,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/create-tri-surface.ipynb b/examples/00-load/create-tri-surface.ipynb index afd0f17..0bb40b7 100644 --- a/examples/00-load/create-tri-surface.ipynb +++ b/examples/00-load/create-tri-surface.ipynb @@ -172,7 +172,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/create-truss.ipynb b/examples/00-load/create-truss.ipynb index 5dee236..31bd43d 100644 --- a/examples/00-load/create-truss.ipynb +++ b/examples/00-load/create-truss.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/create-uniform-grid.ipynb b/examples/00-load/create-uniform-grid.ipynb index 12bb281..f3a9192 100644 --- a/examples/00-load/create-uniform-grid.ipynb +++ b/examples/00-load/create-uniform-grid.ipynb @@ -51,7 +51,7 @@ }, "outputs": [], "source": [ - "values = np.linspace(0, 10, 1000).reshape((20, 5, 10))\nvalues.shape\n\n# Create the spatial reference\ngrid = pv.UniformGrid()\n\n# Set the grid dimensions: shape + 1 because we want to inject our values on\n# the CELL data\ngrid.dimensions = np.array(values.shape) + 1\n\n# Edit the spatial reference\ngrid.origin = (100, 33, 55.6) # The bottom left corner of the data set\ngrid.spacing = (1, 5, 2) # These are the cell sizes along each axis\n\n# Add the data values to the cell data\ngrid.cell_data[\"values\"] = values.flatten(order=\"F\") # Flatten the array!\n\n# Now plot the grid!\ngrid.plot(show_edges=True)" + "values = np.linspace(0, 10, 1000).reshape((20, 5, 10))\nvalues.shape\n\n# Create the spatial reference\ngrid = pv.UniformGrid()\n\n# Set the grid dimensions: shape + 1 because we want to inject our values on\n# the CELL data\ngrid.dimensions = np.array(values.shape) + 1\n\n# Edit the spatial reference\ngrid.origin = (100, 33, 55.6) # The bottom left corner of the data set\ngrid.spacing = (1, 5, 2) # These are the cell sizes along each axis\n\n# Add the data values to the cell data\ngrid.cell_data[\"values\"] = values.flatten(order=\"F\") # Flatten the array\n\n# Now plot the grid\ngrid.plot(show_edges=True)" ] }, { @@ -69,7 +69,7 @@ }, "outputs": [], "source": [ - "# Create the 3D NumPy array of spatially referenced data\n# This is spatially referenced such that the grid is 20 by 5 by 10\n# (nx by ny by nz)\nvalues = np.linspace(0, 10, 1000).reshape((20, 5, 10))\nvalues.shape\n\n# Create the spatial reference\ngrid = pv.UniformGrid()\n\n# Set the grid dimensions: shape because we want to inject our values on the\n# POINT data\ngrid.dimensions = values.shape\n\n# Edit the spatial reference\ngrid.origin = (100, 33, 55.6) # The bottom left corner of the data set\ngrid.spacing = (1, 5, 2) # These are the cell sizes along each axis\n\n# Add the data values to the cell data\ngrid.point_data[\"values\"] = values.flatten(order=\"F\") # Flatten the array!\n\n# Now plot the grid!\ngrid.plot(show_edges=True)" + "# Create the 3D NumPy array of spatially referenced data\n# This is spatially referenced such that the grid is 20 by 5 by 10\n# (nx by ny by nz)\nvalues = np.linspace(0, 10, 1000).reshape((20, 5, 10))\nvalues.shape\n\n# Create the spatial reference\ngrid = pv.UniformGrid()\n\n# Set the grid dimensions: shape because we want to inject our values on the\n# POINT data\ngrid.dimensions = values.shape\n\n# Edit the spatial reference\ngrid.origin = (100, 33, 55.6) # The bottom left corner of the data set\ngrid.spacing = (1, 5, 2) # These are the cell sizes along each axis\n\n# Add the data values to the cell data\ngrid.point_data[\"values\"] = values.flatten(order=\"F\") # Flatten the array\n\n# Now plot the grid\ngrid.plot(show_edges=True)" ] } ], @@ -89,7 +89,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/create-unstructured-surface.ipynb b/examples/00-load/create-unstructured-surface.ipynb index cf6d40d..7e41820 100644 --- a/examples/00-load/create-unstructured-surface.ipynb +++ b/examples/00-load/create-unstructured-surface.ipynb @@ -44,7 +44,7 @@ }, "outputs": [], "source": [ - "# offset array. Identifies the start of each cell in the cells array\noffset = np.array([0, 9])\n\n# Contains information on the points composing each cell.\n# Each cell begins with the number of points in the cell and then the points\n# composing the cell\ncells = np.array([8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15])\n\n# cell type array. Contains the cell type of each cell\ncell_type = np.array([CellType.HEXAHEDRON, CellType.HEXAHEDRON])\n\n# in this example, each cell uses separate points\ncell1 = np.array(\n [\n [0, 0, 0],\n [1, 0, 0],\n [1, 1, 0],\n [0, 1, 0],\n [0, 0, 1],\n [1, 0, 1],\n [1, 1, 1],\n [0, 1, 1],\n ]\n)\n\ncell2 = np.array(\n [\n [0, 0, 2],\n [1, 0, 2],\n [1, 1, 2],\n [0, 1, 2],\n [0, 0, 3],\n [1, 0, 3],\n [1, 1, 3],\n [0, 1, 3],\n ]\n)\n\n# points of the cell array\npoints = np.vstack((cell1, cell2)).astype(float)\n\n# create the unstructured grid directly from the numpy arrays\n# The offset is optional and will be either calculated if not given (VTK version < 9),\n# or is not necessary anymore (VTK version >= 9)\nif pv.vtk_version_info < (9,):\n grid = pv.UnstructuredGrid(offset, cells, cell_type, points)\nelse:\n grid = pv.UnstructuredGrid(cells, cell_type, points)\n\n# For cells of fixed sizes (like the mentioned Hexahedra), it is also possible to use the\n# simplified dictionary interface. This automatically calculates the cell array with types\n# and offsets. Note that for mixing with additional cell types, just the appropriate key needs to be\n# added to the dictionary.\ncells_hex = np.arange(16).reshape([2, 8])\n# = np.array([[0, 1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14, 15]])\ngrid = pv.UnstructuredGrid({CellType.HEXAHEDRON: cells_hex}, points)\n\n# plot the grid (and suppress the camera position output)\n_ = grid.plot(show_edges=True)" + "# Contains information on the points composing each cell.\n# Each cell begins with the number of points in the cell and then the points\n# composing the cell\ncells = np.array([8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15])\n\n# cell type array. Contains the cell type of each cell\ncell_type = np.array([CellType.HEXAHEDRON, CellType.HEXAHEDRON])\n\n# in this example, each cell uses separate points\ncell1 = np.array(\n [\n [0, 0, 0],\n [1, 0, 0],\n [1, 1, 0],\n [0, 1, 0],\n [0, 0, 1],\n [1, 0, 1],\n [1, 1, 1],\n [0, 1, 1],\n ]\n)\n\ncell2 = np.array(\n [\n [0, 0, 2],\n [1, 0, 2],\n [1, 1, 2],\n [0, 1, 2],\n [0, 0, 3],\n [1, 0, 3],\n [1, 1, 3],\n [0, 1, 3],\n ]\n)\n\n# points of the cell array\npoints = np.vstack((cell1, cell2)).astype(float)\n\n# create the unstructured grid directly from the numpy arrays\ngrid = pv.UnstructuredGrid(cells, cell_type, points)\n\n# For cells of fixed sizes (like the mentioned Hexahedra), it is also possible to use the\n# simplified dictionary interface. This automatically calculates the cell array.\n# Note that for mixing with additional cell types, just the appropriate key needs to be\n# added to the dictionary.\ncells_hex = np.arange(16).reshape([2, 8])\n# = np.array([[0, 1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14, 15]])\ngrid = pv.UnstructuredGrid({CellType.HEXAHEDRON: cells_hex}, points)\n\n# plot the grid (and suppress the camera position output)\n_ = grid.plot(show_edges=True)" ] }, { @@ -62,7 +62,7 @@ }, "outputs": [], "source": [ - "# these points will all be shared between the cells\npoints = np.array(\n [\n [0.0, 0.0, 0.0],\n [1.0, 0.0, 0.0],\n [0.5, 0.0, 0.0],\n [1.0, 1.0, 0.0],\n [1.0, 0.5, 0.0],\n [0.0, 1.0, 0.0],\n [0.5, 1.0, 0.0],\n [0.0, 0.5, 0.0],\n [0.5, 0.5, 0.0],\n [1.0, 0.0, 0.5],\n [1.0, 0.0, 1.0],\n [0.0, 0.0, 0.5],\n [0.0, 0.0, 1.0],\n [0.5, 0.0, 0.5],\n [0.5, 0.0, 1.0],\n [1.0, 1.0, 0.5],\n [1.0, 1.0, 1.0],\n [1.0, 0.5, 0.5],\n [1.0, 0.5, 1.0],\n [0.0, 1.0, 0.5],\n [0.0, 1.0, 1.0],\n [0.5, 1.0, 0.5],\n [0.5, 1.0, 1.0],\n [0.0, 0.5, 0.5],\n [0.0, 0.5, 1.0],\n [0.5, 0.5, 0.5],\n [0.5, 0.5, 1.0],\n ]\n)\n\n\n# Each cell in the cell array needs to include the size of the cell\n# and the points belonging to the cell. In this example, there are 8\n# hexahedral cells that have common points between them.\ncells = np.array(\n [\n [8, 0, 2, 8, 7, 11, 13, 25, 23],\n [8, 2, 1, 4, 8, 13, 9, 17, 25],\n [8, 7, 8, 6, 5, 23, 25, 21, 19],\n [8, 8, 4, 3, 6, 25, 17, 15, 21],\n [8, 11, 13, 25, 23, 12, 14, 26, 24],\n [8, 13, 9, 17, 25, 14, 10, 18, 26],\n [8, 23, 25, 21, 19, 24, 26, 22, 20],\n [8, 25, 17, 15, 21, 26, 18, 16, 22],\n ]\n).ravel()\n\n# each cell is a HEXAHEDRON\ncelltypes = np.empty(8, dtype=np.uint8)\ncelltypes[:] = CellType.HEXAHEDRON\n\n# the offset array points to the start of each cell (via flat indexing)\noffset = np.array([0, 9, 18, 27, 36, 45, 54, 63])\n\n# Effectively, when visualizing a VTK unstructured grid, it will\n# sequentially access the cell array by first looking at each index of\n# cell array (based on the offset array), and then read the number of\n# points based on the first value of the cell. In this case, the\n# HEXAHEDRON is described by 8 points.\n\n# for example, the 5th cell would be accessed by vtk with:\nstart_of_cell = offset[4]\nn_points_in_cell = cells[start_of_cell]\nindices_in_cell = cells[start_of_cell + 1 : start_of_cell + n_points_in_cell + 1]\nprint(indices_in_cell)" + "# these points will all be shared between the cells\npoints = np.array(\n [\n [0.0, 0.0, 0.0],\n [1.0, 0.0, 0.0],\n [0.5, 0.0, 0.0],\n [1.0, 1.0, 0.0],\n [1.0, 0.5, 0.0],\n [0.0, 1.0, 0.0],\n [0.5, 1.0, 0.0],\n [0.0, 0.5, 0.0],\n [0.5, 0.5, 0.0],\n [1.0, 0.0, 0.5],\n [1.0, 0.0, 1.0],\n [0.0, 0.0, 0.5],\n [0.0, 0.0, 1.0],\n [0.5, 0.0, 0.5],\n [0.5, 0.0, 1.0],\n [1.0, 1.0, 0.5],\n [1.0, 1.0, 1.0],\n [1.0, 0.5, 0.5],\n [1.0, 0.5, 1.0],\n [0.0, 1.0, 0.5],\n [0.0, 1.0, 1.0],\n [0.5, 1.0, 0.5],\n [0.5, 1.0, 1.0],\n [0.0, 0.5, 0.5],\n [0.0, 0.5, 1.0],\n [0.5, 0.5, 0.5],\n [0.5, 0.5, 1.0],\n ]\n)\n\n\n# Each cell in the cell array needs to include the size of the cell\n# and the points belonging to the cell. In this example, there are 8\n# hexahedral cells that have common points between them.\ncells = np.array(\n [\n [8, 0, 2, 8, 7, 11, 13, 25, 23],\n [8, 2, 1, 4, 8, 13, 9, 17, 25],\n [8, 7, 8, 6, 5, 23, 25, 21, 19],\n [8, 8, 4, 3, 6, 25, 17, 15, 21],\n [8, 11, 13, 25, 23, 12, 14, 26, 24],\n [8, 13, 9, 17, 25, 14, 10, 18, 26],\n [8, 23, 25, 21, 19, 24, 26, 22, 20],\n [8, 25, 17, 15, 21, 26, 18, 16, 22],\n ]\n).ravel()\n\n# each cell is a HEXAHEDRON\ncelltypes = np.full(8, CellType.HEXAHEDRON, dtype=np.uint8)" ] }, { @@ -80,7 +80,7 @@ }, "outputs": [], "source": [ - "# if you are using VTK 9.0 or newer, you do not need to input the offset array:\n# grid = pv.UnstructuredGrid(cells, celltypes, points)\n\n# if you are not using VTK 9.0 or newer, you must use the offset array\nif pv.vtk_version_info < (9,):\n grid = pv.UnstructuredGrid(offset, cells, celltypes, points)\nelse:\n grid = pv.UnstructuredGrid(cells, celltypes, points)\n\n# Alternate versions:\ngrid = pv.UnstructuredGrid({CellType.HEXAHEDRON: cells.reshape([-1, 9])[:, 1:]}, points)\ngrid = pv.UnstructuredGrid(\n {CellType.HEXAHEDRON: np.delete(cells, np.arange(0, cells.size, 9))}, points\n)\n\n# plot the grid (and suppress the camera position output)\n_ = grid.plot(show_edges=True)" + "grid = pv.UnstructuredGrid(cells, celltypes, points)\n\n# Alternate versions:\ngrid = pv.UnstructuredGrid({CellType.HEXAHEDRON: cells.reshape([-1, 9])[:, 1:]}, points)\ngrid = pv.UnstructuredGrid(\n {CellType.HEXAHEDRON: np.delete(cells, np.arange(0, cells.size, 9))}, points\n)\n\n# plot the grid (and suppress the camera position output)\n_ = grid.plot(show_edges=True)" ] }, { @@ -136,7 +136,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/linear-cells.ipynb b/examples/00-load/linear-cells.ipynb index 909ffa9..676d9f6 100644 --- a/examples/00-load/linear-cells.ipynb +++ b/examples/00-load/linear-cells.ipynb @@ -170,7 +170,7 @@ }, "outputs": [], "source": [ - "def add_cell_helper(pl, text, grid, subplot, cpos=None):\n \"\"\"Add a single cell to a plotter with fancy plotting.\"\"\"\n pl.subplot(*subplot)\n pl.add_text(text, 'lower_edge', color='k', font_size=8)\n pl.add_mesh(grid, opacity=0.5, color='tan', line_width=5)\n edges = grid.extract_all_edges()\n if edges.n_cells:\n pl.add_mesh(grid.extract_all_edges(), line_width=5, color='k')\n pl.add_points(grid, render_points_as_spheres=True, point_size=20, color='r')\n pl.add_point_labels(\n grid.points,\n range(grid.n_points),\n always_visible=True,\n fill_shape=False,\n margin=0,\n shape_opacity=0.0,\n font_size=20,\n text_color='k',\n )\n if cpos is None:\n pl.camera.azimuth = 20\n pl.camera.elevation = -20\n else:\n pl.camera_position = cpos\n pl.camera.zoom(0.8)\n\n\npl = pv.Plotter(shape=(4, 4))\nadd_cell_helper(pl, f'VERTEX ({pv.CellType.VERTEX})', example_cells.Vertex(), (0, 0))\nadd_cell_helper(pl, f'POLY_VERTEX ({pv.CellType.POLY_VERTEX})', example_cells.PolyVertex(), (0, 1))\nadd_cell_helper(pl, f'LINE ({pv.CellType.LINE})', example_cells.Line(), (0, 2))\nadd_cell_helper(pl, f'POLY_LINE ({pv.CellType.POLY_LINE})', example_cells.PolyLine(), (0, 3))\n\nadd_cell_helper(\n pl, f'TRIANGLE ({pv.CellType.TRIANGLE})', example_cells.Triangle(), (1, 0), cpos='xy'\n)\nadd_cell_helper(\n pl,\n f'TRIANGLE_STRIP ({pv.CellType.TRIANGLE_STRIP})',\n example_cells.TriangleStrip().rotate_z(90, inplace=False),\n (1, 1),\n cpos='xy',\n)\nadd_cell_helper(pl, f'POLYGON ({pv.CellType.POLYGON})', example_cells.Polygon(), (1, 2), cpos='xy')\nadd_cell_helper(pl, f'PIXEL ({pv.CellType.PIXEL})', example_cells.Pixel(), (1, 3), cpos='xy')\n\n# make irregular\nquad_grid = example_cells.Quadrilateral()\nquad_grid.points += rng.random((4, 3)) * 0.5\n\nadd_cell_helper(pl, f'QUAD ({pv.CellType.QUAD})', quad_grid, (2, 0))\nadd_cell_helper(pl, f'TETRA ({pv.CellType.TETRA})', example_cells.Tetrahedron(), (2, 1))\nadd_cell_helper(pl, f'VOXEL ({pv.CellType.VOXEL})', example_cells.Voxel(), (2, 2))\n\n# make irregular\nhex_grid = example_cells.Hexahedron()\nhex_grid.points += rng.random((8, 3)) * 0.4\nadd_cell_helper(pl, f'HEXAHEDRON ({pv.CellType.HEXAHEDRON})', hex_grid, (2, 3))\n\nadd_cell_helper(pl, f'WEDGE ({pv.CellType.WEDGE})', example_cells.Wedge(), (3, 0))\nadd_cell_helper(pl, f'PYRAMID ({pv.CellType.PYRAMID})', example_cells.Pyramid(), (3, 1))\nadd_cell_helper(\n pl,\n f'PENTAGONAL_PRISM ({pv.CellType.PENTAGONAL_PRISM})',\n example_cells.PentagonalPrism(),\n (3, 2),\n)\nadd_cell_helper(\n pl, f'HEXAGONAL_PRISM ({pv.CellType.HEXAGONAL_PRISM})', example_cells.HexagonalPrism(), (3, 3)\n)\n\npl.background_color = 'w'\npl.enable_anti_aliasing()\npl.show()" + "def add_cell_helper(pl, text, grid, subplot, cpos=None):\n \"\"\"Add a single cell to a plotter with fancy plotting.\"\"\"\n pl.subplot(*subplot)\n pl.add_text(text, 'lower_edge', color='k', font_size=8)\n pl.add_mesh(grid, opacity=0.5, color='tan', line_width=5)\n edges = grid.extract_all_edges()\n if edges.n_cells:\n pl.add_mesh(grid.extract_all_edges(), line_width=5, color='k')\n pl.add_points(grid, render_points_as_spheres=True, point_size=20, color='r')\n pl.add_point_labels(\n grid.points,\n range(grid.n_points),\n always_visible=True,\n fill_shape=False,\n margin=0,\n shape_opacity=0.0,\n font_size=20,\n text_color='k',\n )\n if cpos is None:\n pl.camera.azimuth = 20\n pl.camera.elevation = -20\n else:\n pl.camera_position = cpos\n pl.camera.zoom(0.8)\n\n\npl = pv.Plotter(shape=(4, 4))\nadd_cell_helper(pl, f'VERTEX ({pv.CellType.VERTEX})', example_cells.Vertex(), (0, 0))\nadd_cell_helper(pl, f'POLY_VERTEX ({pv.CellType.POLY_VERTEX})', example_cells.PolyVertex(), (0, 1))\nadd_cell_helper(pl, f'LINE ({pv.CellType.LINE})', example_cells.Line(), (0, 2))\nadd_cell_helper(pl, f'POLY_LINE ({pv.CellType.POLY_LINE})', example_cells.PolyLine(), (0, 3))\n\nadd_cell_helper(\n pl, f'TRIANGLE ({pv.CellType.TRIANGLE})', example_cells.Triangle(), (1, 0), cpos='xy'\n)\nadd_cell_helper(\n pl,\n f'TRIANGLE_STRIP ({pv.CellType.TRIANGLE_STRIP})',\n example_cells.TriangleStrip().rotate_z(90, inplace=False),\n (1, 1),\n cpos='xy',\n)\nadd_cell_helper(pl, f'POLYGON ({pv.CellType.POLYGON})', example_cells.Polygon(), (1, 2), cpos='xy')\nadd_cell_helper(pl, f'PIXEL ({pv.CellType.PIXEL})', example_cells.Pixel(), (1, 3), cpos='xy')\n\n# make irregular\nquad_grid = example_cells.Quadrilateral()\nquad_grid.points += rng.random((4, 3)) * 0.5\n\nadd_cell_helper(pl, f'QUAD ({pv.CellType.QUAD})', quad_grid, (2, 0))\nadd_cell_helper(pl, f'TETRA ({pv.CellType.TETRA})', example_cells.Tetrahedron(), (2, 1))\nadd_cell_helper(pl, f'VOXEL ({pv.CellType.VOXEL})', example_cells.Voxel(), (2, 2))\n\n# make irregular\nhex_grid = example_cells.Hexahedron()\nhex_grid.points += rng.random((8, 3)) * 0.4\nadd_cell_helper(pl, f'HEXAHEDRON ({pv.CellType.HEXAHEDRON})', hex_grid, (2, 3))\n\nadd_cell_helper(pl, f'WEDGE ({pv.CellType.WEDGE})', example_cells.Wedge(), (3, 0))\nadd_cell_helper(pl, f'PYRAMID ({pv.CellType.PYRAMID})', example_cells.Pyramid(), (3, 1))\nadd_cell_helper(\n pl,\n f'PENTAGONAL_PRISM ({pv.CellType.PENTAGONAL_PRISM})',\n example_cells.PentagonalPrism(),\n (3, 2),\n)\nadd_cell_helper(\n pl, f'HEXAGONAL_PRISM ({pv.CellType.HEXAGONAL_PRISM})', example_cells.HexagonalPrism(), (3, 3)\n)\n\npl.background_color = 'w'\npl.show()" ] } ], @@ -190,7 +190,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/load-gltf.ipynb b/examples/00-load/load-gltf.ipynb index ccfea4e..adc794c 100644 --- a/examples/00-load/load-gltf.ipynb +++ b/examples/00-load/load-gltf.ipynb @@ -15,7 +15,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Working with glTF Files {#load_gltf}\n=======================\n\nImport a glTF file directly into a PyVista plotting scene. For more\ndetails regarding the glTF format, see: \n\nNote this feature is only available for `vtk>=9`.\n\nFirst, download the examples. Note that here we\\'re using a high dynamic\nrange texture since glTF files generally contain physically based\nrendering and VTK v9 supports high dynamic range textures.\n" + "Working with glTF Files {#load_gltf}\n=======================\n\nImport a glTF file directly into a PyVista plotting scene. For more\ndetails regarding the glTF format, see: \n\nFirst, download the examples. Note that here we\\'re using a high dynamic\nrange texture since glTF files generally contain physically based\nrendering and VTK v9 supports high dynamic range textures.\n" ] }, { @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/load-vrml.ipynb b/examples/00-load/load-vrml.ipynb index 2d56c3d..7bef88a 100644 --- a/examples/00-load/load-vrml.ipynb +++ b/examples/00-load/load-vrml.ipynb @@ -64,7 +64,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/read-dolfin.ipynb b/examples/00-load/read-dolfin.ipynb index 262ce26..687d91e 100644 --- a/examples/00-load/read-dolfin.ipynb +++ b/examples/00-load/read-dolfin.ipynb @@ -69,7 +69,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Now we can do stuff with that Dolfin mesh!\n" + "Now we can work on and plot that Dolfin mesh.\n" ] }, { @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/read-file.ipynb b/examples/00-load/read-file.ipynb index 431f1d1..6512b6a 100644 --- a/examples/00-load/read-file.ipynb +++ b/examples/00-load/read-file.ipynb @@ -130,7 +130,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Loading other files types is just as easy! Simply pass your file path to\nthe `pyvista.read`{.interpreted-text role=\"func\"} function and that\\'s\nit!\n\nHere are a few other examples - simply replace `examples.download_*` in\nthe examples below with `pyvista.read('path/to/you/file.ext')`\n" + "Loading other files types is just as easy. Simply pass your file path to\nthe `pyvista.read`{.interpreted-text role=\"func\"} function and that\\'s\nit.\n\nHere are a few other examples - simply replace `examples.download_*` in\nthe examples below with `pyvista.read('path/to/you/file.ext')`\n" ] }, { @@ -222,7 +222,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/read-image.ipynb b/examples/00-load/read-image.ipynb index dfb5101..72c362f 100644 --- a/examples/00-load/read-image.ipynb +++ b/examples/00-load/read-image.ipynb @@ -93,7 +93,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/read-parallel.ipynb b/examples/00-load/read-parallel.ipynb index 5318da0..33dd621 100644 --- a/examples/00-load/read-parallel.ipynb +++ b/examples/00-load/read-parallel.ipynb @@ -122,7 +122,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/reader.ipynb b/examples/00-load/reader.ipynb index f3328e0..1d419fd 100644 --- a/examples/00-load/reader.ipynb +++ b/examples/00-load/reader.ipynb @@ -269,7 +269,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/terrain-mesh.ipynb b/examples/00-load/terrain-mesh.ipynb index 4295084..7e91a5e 100644 --- a/examples/00-load/terrain-mesh.ipynb +++ b/examples/00-load/terrain-mesh.ipynb @@ -98,7 +98,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "And now we have a 3D structured surface of the terrain! We can now\nextend that structured surface into a 3D mesh to form a terrain\nfollowing grid. To do this, we first our cell spacings in the\nz-direction (these start from the terrain surface). Then we repeat the\nXYZ structured coordinates of the terrain mesh and decrease each Z level\nby our Z cell spacing. Once we have those structured coordinates, we can\ncreate a `pyvista.StructuredGrid`{.interpreted-text role=\"class\"}.\n" + "And now we have a 3D structured surface of the terrain. We can now\nextend that structured surface into a 3D mesh to form a terrain\nfollowing grid. To do this, we first our cell spacings in the\nz-direction (these start from the terrain surface). Then we repeat the\nXYZ structured coordinates of the terrain mesh and decrease each Z level\nby our Z cell spacing. Once we have those structured coordinates, we can\ncreate a `pyvista.StructuredGrid`{.interpreted-text role=\"class\"}.\n" ] }, { @@ -140,7 +140,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/00-load/wrap-trimesh.ipynb b/examples/00-load/wrap-trimesh.ipynb index f2ce73c..9b2a14f 100644 --- a/examples/00-load/wrap-trimesh.ipynb +++ b/examples/00-load/wrap-trimesh.ipynb @@ -89,7 +89,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/boolean-operations.ipynb b/examples/01-filter/boolean-operations.ipynb index 3d4f8f1..88c1988 100644 --- a/examples/01-filter/boolean-operations.ipynb +++ b/examples/01-filter/boolean-operations.ipynb @@ -172,7 +172,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/cell-centers.ipynb b/examples/01-filter/cell-centers.ipynb index 6c3f588..47f54f8 100644 --- a/examples/01-filter/cell-centers.ipynb +++ b/examples/01-filter/cell-centers.ipynb @@ -129,7 +129,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/clipping-with-surface.ipynb b/examples/01-filter/clipping-with-surface.ipynb index 9a389d4..33a8ac6 100644 --- a/examples/01-filter/clipping-with-surface.ipynb +++ b/examples/01-filter/clipping-with-surface.ipynb @@ -122,7 +122,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/clipping.ipynb b/examples/01-filter/clipping.ipynb index e6d2552..69ff5fa 100644 --- a/examples/01-filter/clipping.ipynb +++ b/examples/01-filter/clipping.ipynb @@ -15,7 +15,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Clipping with Planes & Boxes {#clip_with_plane_box_example}\n============================\n\nClip/cut any dataset using using planes or boxes.\n" + "Clipping with Planes & Boxes {#clip_with_plane_box_example}\n============================\n\nClip/cut any dataset using planes or boxes.\n" ] }, { @@ -208,7 +208,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/collisions.ipynb b/examples/01-filter/collisions.ipynb index 67d7abc..9d96665 100644 --- a/examples/01-filter/collisions.ipynb +++ b/examples/01-filter/collisions.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/compute-normals.ipynb b/examples/01-filter/compute-normals.ipynb index a7cc824..0307d2c 100644 --- a/examples/01-filter/compute-normals.ipynb +++ b/examples/01-filter/compute-normals.ipynb @@ -62,7 +62,7 @@ }, "outputs": [], "source": [ - "# Compute the normals in-place and use them to warp the globe\nmesh.compute_normals(inplace=True) # this activates the normals as well\n\n# Now use those normals to warp the surface\nwarp = mesh.warp_by_scalar(factor=0.5e-5)\n\n# And let's see it!\nwarp.plot(cmap=\"gist_earth\", show_scalar_bar=False)" + "# Compute the normals in-place and use them to warp the globe\nmesh.compute_normals(inplace=True) # this activates the normals as well\n\n# Now use those normals to warp the surface\nwarp = mesh.warp_by_scalar(factor=0.5e-5)\n\n# And let's see it\nwarp.plot(cmap=\"gist_earth\", show_scalar_bar=False)" ] }, { @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/compute-volume.ipynb b/examples/01-filter/compute-volume.ipynb index 06b58c8..f8f1f89 100644 --- a/examples/01-filter/compute-volume.ipynb +++ b/examples/01-filter/compute-volume.ipynb @@ -87,7 +87,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Okay awesome! But what if we have have a dataset that we threshold with\ntwo volumetric bodies left over in one dataset? Take this for example:\n" + "But what if we have a dataset that we threshold with two volumetric\nbodies left over in one dataset? Take this for example:\n" ] }, { @@ -116,7 +116,7 @@ }, "outputs": [], "source": [ - "# Create a classifying array to ID each body\nrng = dataset.get_data_range()\ncval = ((rng[1] - rng[0]) * 0.20) + rng[0]\nclassifier = threshed.cell_data[\"Spatial Cell Data\"] > cval\n\n# Compute cell volumes\nsizes = threshed.compute_cell_sizes()\nvolumes = sizes.cell_data[\"Volume\"]\n\n# Split volumes based on classifier and get volumes!\nidx = np.argwhere(classifier)\nhvol = np.sum(volumes[idx])\nidx = np.argwhere(~classifier)\nlvol = np.sum(volumes[idx])\n\nprint(f\"Low grade volume: {lvol}\")\nprint(f\"High grade volume: {hvol}\")\nprint(f\"Original volume: {dataset.volume}\")" + "# Create a classifying array to ID each body\nrng = dataset.get_data_range()\ncval = ((rng[1] - rng[0]) * 0.20) + rng[0]\nclassifier = threshed.cell_data[\"Spatial Cell Data\"] > cval\n\n# Compute cell volumes\nsizes = threshed.compute_cell_sizes()\nvolumes = sizes.cell_data[\"Volume\"]\n\n# Split volumes based on classifier and get the volumes\nidx = np.argwhere(classifier)\nhvol = np.sum(volumes[idx])\nidx = np.argwhere(~classifier)\nlvol = np.sum(volumes[idx])\n\nprint(f\"Low grade volume: {lvol}\")\nprint(f\"High grade volume: {hvol}\")\nprint(f\"Original volume: {dataset.volume}\")" ] }, { @@ -134,7 +134,7 @@ }, "outputs": [], "source": [ - "# Grab the largest connected volume present\nlargest = threshed.connectivity(largest=True)\n# or: largest = threshed.extract_largest()\n\n# Get volume as numeric value\nlarge_volume = largest.volume\n\n# Display it!\nlargest.plot(show_grid=True, cpos=[-2, 5, 3])" + "# Grab the largest connected volume present\nlargest = threshed.connectivity(largest=True)\n# or: largest = threshed.extract_largest()\n\n# Get volume as numeric value\nlarge_volume = largest.volume\n\n# Display it\nlargest.plot(show_grid=True, cpos=[-2, 5, 3])" ] }, { @@ -170,7 +170,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "------------------------------------------------------------------------\n\nA Real Dataset\n==============\n\nHere is a realistic training dataset of fluvial channels in the\nsubsurface. This will threshold the channels from the dataset then\nseparate each significantly large body and compute the volumes for each!\n\nLoad up the data and threshold the channels:\n" + "------------------------------------------------------------------------\n\nA Real Dataset\n==============\n\nHere is a realistic training dataset of fluvial channels in the\nsubsurface. This will threshold the channels from the dataset then\nseparate each significantly large body and compute the volumes for each.\n\nLoad up the data and threshold the channels:\n" ] }, { @@ -255,7 +255,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/connectivity.ipynb b/examples/01-filter/connectivity.ipynb index 41a3cd0..455cce7 100644 --- a/examples/01-filter/connectivity.ipynb +++ b/examples/01-filter/connectivity.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/contouring.ipynb b/examples/01-filter/contouring.ipynb index 2738966..a1eb3e3 100644 --- a/examples/01-filter/contouring.ipynb +++ b/examples/01-filter/contouring.ipynb @@ -147,7 +147,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/decimate.ipynb b/examples/01-filter/decimate.ipynb index 915d886..e1e792b 100644 --- a/examples/01-filter/decimate.ipynb +++ b/examples/01-filter/decimate.ipynb @@ -104,7 +104,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/distance-between-surfaces.ipynb b/examples/01-filter/distance-between-surfaces.ipynb index a2a627d..264bf98 100644 --- a/examples/01-filter/distance-between-surfaces.ipynb +++ b/examples/01-filter/distance-between-surfaces.ipynb @@ -169,7 +169,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/extract-cells-inside-surface.ipynb b/examples/01-filter/extract-cells-inside-surface.ipynb index abd0409..d687b35 100644 --- a/examples/01-filter/extract-cells-inside-surface.ipynb +++ b/examples/01-filter/extract-cells-inside-surface.ipynb @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/extract-edges.ipynb b/examples/01-filter/extract-edges.ipynb index 958c861..9b7dc0d 100644 --- a/examples/01-filter/extract-edges.ipynb +++ b/examples/01-filter/extract-edges.ipynb @@ -136,7 +136,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/extract-surface.ipynb b/examples/01-filter/extract-surface.ipynb index 1a64dbd..7a27d9b 100644 --- a/examples/01-filter/extract-surface.ipynb +++ b/examples/01-filter/extract-surface.ipynb @@ -44,7 +44,7 @@ }, "outputs": [], "source": [ - "lin_pts = np.array(\n [\n [-1, -1, -1], # point 0\n [1, -1, -1], # point 1\n [1, 1, -1], # point 2\n [-1, 1, -1], # point 3\n [-1, -1, 1], # point 4\n [1, -1, 1], # point 5\n [1, 1, 1], # point 6\n [-1, 1, 1], # point 7\n ],\n np.double,\n)\n\n# these are the \"midside\" points of a quad cell. See the definition of a\n# vtkQuadraticHexahedron at:\n# https://vtk.org/doc/nightly/html/classvtkQuadraticHexahedron.html\nquad_pts = np.array(\n [\n (lin_pts[1] + lin_pts[0]) / 2, # between point 0 and 1\n (lin_pts[1] + lin_pts[2]) / 2, # between point 1 and 2\n (lin_pts[2] + lin_pts[3]) / 2, # and so on...\n (lin_pts[3] + lin_pts[0]) / 2,\n (lin_pts[4] + lin_pts[5]) / 2,\n (lin_pts[5] + lin_pts[6]) / 2,\n (lin_pts[6] + lin_pts[7]) / 2,\n (lin_pts[7] + lin_pts[4]) / 2,\n (lin_pts[0] + lin_pts[4]) / 2,\n (lin_pts[1] + lin_pts[5]) / 2,\n (lin_pts[2] + lin_pts[6]) / 2,\n (lin_pts[3] + lin_pts[7]) / 2,\n ]\n)\n\n# introduce a minor variation to the location of the mid-side points\nquad_pts += np.random.random(quad_pts.shape) * 0.3\npts = np.vstack((lin_pts, quad_pts))\n\n# create the grid\n\n# If you are using vtk>=9, you do not need the offset array\noffset = np.array([0])\ncells = np.hstack((20, np.arange(20))).astype(np.int64, copy=False)\ncelltypes = np.array([CellType.QUADRATIC_HEXAHEDRON])\ngrid = pv.UnstructuredGrid(offset, cells, celltypes, pts)\n\n# finally, extract the surface and plot it\nsurf = grid.extract_surface()\nsurf.plot(show_scalar_bar=False)" + "lin_pts = np.array(\n [\n [-1, -1, -1], # point 0\n [1, -1, -1], # point 1\n [1, 1, -1], # point 2\n [-1, 1, -1], # point 3\n [-1, -1, 1], # point 4\n [1, -1, 1], # point 5\n [1, 1, 1], # point 6\n [-1, 1, 1], # point 7\n ],\n np.double,\n)\n\n# these are the \"midside\" points of a quad cell. See the definition of a\n# vtkQuadraticHexahedron at:\n# https://vtk.org/doc/nightly/html/classvtkQuadraticHexahedron.html\nquad_pts = np.array(\n [\n (lin_pts[1] + lin_pts[0]) / 2, # between point 0 and 1\n (lin_pts[1] + lin_pts[2]) / 2, # between point 1 and 2\n (lin_pts[2] + lin_pts[3]) / 2, # and so on...\n (lin_pts[3] + lin_pts[0]) / 2,\n (lin_pts[4] + lin_pts[5]) / 2,\n (lin_pts[5] + lin_pts[6]) / 2,\n (lin_pts[6] + lin_pts[7]) / 2,\n (lin_pts[7] + lin_pts[4]) / 2,\n (lin_pts[0] + lin_pts[4]) / 2,\n (lin_pts[1] + lin_pts[5]) / 2,\n (lin_pts[2] + lin_pts[6]) / 2,\n (lin_pts[3] + lin_pts[7]) / 2,\n ]\n)\n\n# introduce a minor variation to the location of the mid-side points\nquad_pts += np.random.random(quad_pts.shape) * 0.3\npts = np.vstack((lin_pts, quad_pts))\n\n# create the grid\ncells = np.hstack((20, np.arange(20))).astype(np.int64, copy=False)\ncelltypes = np.array([CellType.QUADRATIC_HEXAHEDRON])\ngrid = pv.UnstructuredGrid(cells, celltypes, pts)\n\n# finally, extract the surface and plot it\nsurf = grid.extract_surface()\nsurf.plot(show_scalar_bar=False)" ] }, { @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/extrude-rotate.ipynb b/examples/01-filter/extrude-rotate.ipynb index e84608f..4c3fcf8 100644 --- a/examples/01-filter/extrude-rotate.ipynb +++ b/examples/01-filter/extrude-rotate.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/extrude-trim.ipynb b/examples/01-filter/extrude-trim.ipynb index 78f3f29..c29d226 100644 --- a/examples/01-filter/extrude-trim.ipynb +++ b/examples/01-filter/extrude-trim.ipynb @@ -154,7 +154,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/flying_edges.ipynb b/examples/01-filter/flying_edges.ipynb index 0998334..6e9fa80 100644 --- a/examples/01-filter/flying_edges.ipynb +++ b/examples/01-filter/flying_edges.ipynb @@ -44,7 +44,7 @@ }, "outputs": [], "source": [ - "a = 0.9\n\n\ndef spider_cage(x, y, z):\n x2 = x * x\n y2 = y * y\n x2_y2 = x2 + y2\n return (np.sqrt((x2 - y2) ** 2 / x2_y2 + 3 * (z * np.sin(a)) ** 2) - 3) ** 2 + 6 * (\n np.sqrt((x * y) ** 2 / x2_y2 + (z * np.cos(a)) ** 2) - 1.5\n ) ** 2\n\n\n# create a uniform grid to sample the function with\nn = 100\nx_min, y_min, z_min = -5, -5, -3\ngrid = pv.UniformGrid(\n dimensions=(n, n, n),\n spacing=(abs(x_min) / n * 2, abs(y_min) / n * 2, abs(z_min) / n * 2),\n origin=(x_min, y_min, z_min),\n)\nx, y, z = grid.points.T\n\n# sample and plot\nvalues = spider_cage(x, y, z)\nmesh = grid.contour([1], values, method='marching_cubes')\ndist = np.linalg.norm(mesh.points, axis=1)\nmesh.plot(scalars=dist, smooth_shading=True, specular=5, cmap=\"plasma\", show_scalar_bar=False)" + "a = 0.9\n\n\ndef spider_cage(x, y, z):\n x2 = x * x\n y2 = y * y\n x2_y2 = x2 + y2\n return (np.sqrt((x2 - y2) ** 2 / x2_y2 + 3 * (z * np.sin(a)) ** 2) - 3) ** 2 + 6 * (\n np.sqrt((x * y) ** 2 / x2_y2 + (z * np.cos(a)) ** 2) - 1.5\n ) ** 2\n\n\n# create a uniform grid to sample the function with\nn = 100\nx_min, y_min, z_min = -5, -5, -3\ngrid = pv.UniformGrid(\n dimensions=(n, n, n),\n spacing=(abs(x_min) / n * 2, abs(y_min) / n * 2, abs(z_min) / n * 2),\n origin=(x_min, y_min, z_min),\n)\nx, y, z = grid.points.T\n\n# sample and plot\nvalues = spider_cage(x, y, z)\nmesh = grid.contour([1], values, method='marching_cubes')\ndist = np.linalg.norm(mesh.points, axis=1)\nmesh.plot(scalars=dist, smooth_shading=True, specular=1, cmap=\"plasma\", show_scalar_bar=False)" ] }, { @@ -62,7 +62,7 @@ }, "outputs": [], "source": [ - "phi = (1 + np.sqrt(5)) / 2\nphi2 = phi * phi\n\n\ndef barth_sextic(x, y, z):\n x2 = x * x\n y2 = y * y\n z2 = z * z\n arr = (\n 3 * (phi2 * x2 - y2) * (phi2 * y2 - z2) * (phi2 * z2 - x2)\n - (1 + 2 * phi) * (x2 + y2 + z2 - 1) ** 2\n )\n nan_mask = x2 + y2 + z2 > 3.1\n arr[nan_mask] = np.nan\n return arr\n\n\n# create a uniform grid to sample the function with\nn = 100\nk = 2.0\nx_min, y_min, z_min = -k, -k, -k\ngrid = pv.UniformGrid(\n dimensions=(n, n, n),\n spacing=(abs(x_min) / n * 2, abs(y_min) / n * 2, abs(z_min) / n * 2),\n origin=(x_min, y_min, z_min),\n)\nx, y, z = grid.points.T\n\n# sample and plot\nvalues = barth_sextic(x, y, z)\nmesh = grid.contour([0], values, method='flying_edges')\ndist = np.linalg.norm(mesh.points, axis=1)\nmesh.plot(scalars=dist, smooth_shading=True, specular=5, cmap=\"plasma\", show_scalar_bar=False)" + "phi = (1 + np.sqrt(5)) / 2\nphi2 = phi * phi\n\n\ndef barth_sextic(x, y, z):\n x2 = x * x\n y2 = y * y\n z2 = z * z\n arr = (\n 3 * (phi2 * x2 - y2) * (phi2 * y2 - z2) * (phi2 * z2 - x2)\n - (1 + 2 * phi) * (x2 + y2 + z2 - 1) ** 2\n )\n nan_mask = x2 + y2 + z2 > 3.1\n arr[nan_mask] = np.nan\n return arr\n\n\n# create a uniform grid to sample the function with\nn = 100\nk = 2.0\nx_min, y_min, z_min = -k, -k, -k\ngrid = pv.UniformGrid(\n dimensions=(n, n, n),\n spacing=(abs(x_min) / n * 2, abs(y_min) / n * 2, abs(z_min) / n * 2),\n origin=(x_min, y_min, z_min),\n)\nx, y, z = grid.points.T\n\n# sample and plot\nvalues = barth_sextic(x, y, z)\nmesh = grid.contour([0], values, method='flying_edges')\ndist = np.linalg.norm(mesh.points, axis=1)\nmesh.plot(scalars=dist, smooth_shading=True, specular=1, cmap=\"plasma\", show_scalar_bar=False)" ] }, { @@ -80,7 +80,7 @@ }, "outputs": [], "source": [ - "def angle_to_range(angle):\n return -2 * np.sin(angle)\n\n\npl = pv.Plotter(window_size=[800, 800], off_screen=True)\n\npl.open_gif('barth_sextic.gif')\n\nfor angle in np.linspace(0, np.pi, 20, endpoint=False):\n # clear the plotter before adding each frame's mesh\n pl.clear()\n pl.enable_lightkit()\n mesh = grid.contour([angle_to_range(angle)], values, method='flying_edges')\n dist = np.linalg.norm(mesh.points, axis=1)\n pl.add_mesh(\n mesh,\n scalars=dist,\n smooth_shading=True,\n specular=5,\n rng=[0.5, 1.5],\n cmap=\"plasma\",\n show_scalar_bar=False,\n )\n pl.write_frame()\n\npl.close()" + "def angle_to_range(angle):\n return -2 * np.sin(angle)\n\n\npl = pv.Plotter(window_size=[800, 800], off_screen=True)\n\npl.open_gif('barth_sextic.gif')\n\nfor angle in np.linspace(0, np.pi, 20, endpoint=False):\n # clear the plotter before adding each frame's mesh\n pl.clear()\n pl.enable_lightkit()\n mesh = grid.contour([angle_to_range(angle)], values, method='flying_edges')\n dist = np.linalg.norm(mesh.points, axis=1)\n pl.add_mesh(\n mesh,\n scalars=dist,\n smooth_shading=True,\n specular=1,\n rng=[0.5, 1.5],\n cmap=\"plasma\",\n show_scalar_bar=False,\n )\n pl.write_frame()\n\npl.close()" ] } ], @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/gaussian-smoothing.ipynb b/examples/01-filter/gaussian-smoothing.ipynb index 1cca0ff..ae6cb6d 100644 --- a/examples/01-filter/gaussian-smoothing.ipynb +++ b/examples/01-filter/gaussian-smoothing.ipynb @@ -33,7 +33,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Let\\'s apply the gaussian smoothing with different values of standard\ndeviation.\n" + "Let\\'s apply the Gaussian smoothing with different values of standard\ndeviation.\n" ] }, { @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/geodesic.ipynb b/examples/01-filter/geodesic.ipynb index f7999ea..f013b92 100644 --- a/examples/01-filter/geodesic.ipynb +++ b/examples/01-filter/geodesic.ipynb @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/glyphs.ipynb b/examples/01-filter/glyphs.ipynb index 53dc392..217c224 100644 --- a/examples/01-filter/glyphs.ipynb +++ b/examples/01-filter/glyphs.ipynb @@ -118,7 +118,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/glyphs_table.ipynb b/examples/01-filter/glyphs_table.ipynb index 6a578b4..7fd5663 100644 --- a/examples/01-filter/glyphs_table.ipynb +++ b/examples/01-filter/glyphs_table.ipynb @@ -64,7 +64,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/gradients.ipynb b/examples/01-filter/gradients.ipynb index 3ce5077..2405f63 100644 --- a/examples/01-filter/gradients.ipynb +++ b/examples/01-filter/gradients.ipynb @@ -105,7 +105,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "And there you have it, the gradients for a vector field! We could also\ndo this for a scalar field like for the `scalars` field in the given\ndataset.\n" + "And there you have it, the gradients for a vector field. We could also\ndo this for a scalar field like for the `scalars` field in the given\ndataset.\n" ] }, { @@ -147,7 +147,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/image-fft-perlin-noise.ipynb b/examples/01-filter/image-fft-perlin-noise.ipynb index 9715641..50d6757 100644 --- a/examples/01-filter/image-fft-perlin-noise.ipynb +++ b/examples/01-filter/image-fft-perlin-noise.ipynb @@ -80,7 +80,7 @@ }, "outputs": [], "source": [ - "# scale to make the plot viewable\nsubset['scalars'] = np.abs(subset.active_scalars)\nwarped_subset = subset.warp_by_scalar(factor=0.0001)\n\npl = pv.Plotter(lighting='three lights')\npl.add_mesh(warped_subset, cmap='blues', show_scalar_bar=False)\npl.show_bounds(\n axes_ranges=(0, max_freq, 0, max_freq, 0, warped_subset.bounds[-1]),\n xlabel='X Frequency',\n ylabel='Y Frequency',\n zlabel='Amplitude',\n show_zlabels=False,\n color='k',\n font_size=26,\n)\npl.add_text('Frequency Domain of the Perlin Noise')\npl.show()" + "# scale to make the plot viewable\nsubset['scalars'] = np.abs(subset.active_scalars)\nwarped_subset = subset.warp_by_scalar(factor=0.0001)\n\npl = pv.Plotter(lighting='three lights')\npl.add_mesh(warped_subset, cmap='blues', show_scalar_bar=False)\npl.show_bounds(\n axes_ranges=(0, max_freq, 0, max_freq, 0, warped_subset.bounds[-1]),\n xtitle='X Frequency',\n ytitle='Y Frequency',\n ztitle='Amplitude',\n show_zlabels=False,\n color='k',\n font_size=26,\n)\npl.add_text('Frequency Domain of the Perlin Noise')\npl.show()" ] }, { @@ -179,7 +179,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/image-fft.ipynb b/examples/01-filter/image-fft.ipynb index 202c7a9..f9d1934 100644 --- a/examples/01-filter/image-fft.ipynb +++ b/examples/01-filter/image-fft.ipynb @@ -136,7 +136,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/integrate-data.ipynb b/examples/01-filter/integrate-data.ipynb index db97d4c..f681fba 100644 --- a/examples/01-filter/integrate-data.ipynb +++ b/examples/01-filter/integrate-data.ipynb @@ -172,7 +172,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/interpolate.ipynb b/examples/01-filter/interpolate.ipynb index bc0d695..efad833 100644 --- a/examples/01-filter/interpolate.ipynb +++ b/examples/01-filter/interpolate.ipynb @@ -165,7 +165,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/mesh-quality.ipynb b/examples/01-filter/mesh-quality.ipynb index 7c4f146..3b1191c 100644 --- a/examples/01-filter/mesh-quality.ipynb +++ b/examples/01-filter/mesh-quality.ipynb @@ -75,7 +75,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/poly-ray-trace.ipynb b/examples/01-filter/poly-ray-trace.ipynb index 42c9072..decfafe 100644 --- a/examples/01-filter/poly-ray-trace.ipynb +++ b/examples/01-filter/poly-ray-trace.ipynb @@ -46,7 +46,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/project-plane.ipynb b/examples/01-filter/project-plane.ipynb index b8cbaf9..b832516 100644 --- a/examples/01-filter/project-plane.ipynb +++ b/examples/01-filter/project-plane.ipynb @@ -64,7 +64,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/reflect.ipynb b/examples/01-filter/reflect.ipynb index 78308fe..05af3e0 100644 --- a/examples/01-filter/reflect.ipynb +++ b/examples/01-filter/reflect.ipynb @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/resample.ipynb b/examples/01-filter/resample.ipynb index 7b794ad..c200ebc 100644 --- a/examples/01-filter/resample.ipynb +++ b/examples/01-filter/resample.ipynb @@ -136,7 +136,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/rotate.ipynb b/examples/01-filter/rotate.ipynb index 55b0675..070d9a8 100644 --- a/examples/01-filter/rotate.ipynb +++ b/examples/01-filter/rotate.ipynb @@ -154,7 +154,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/sampling_functions_2d.ipynb b/examples/01-filter/sampling_functions_2d.ipynb index e7e4cf5..4e2274c 100644 --- a/examples/01-filter/sampling_functions_2d.ipynb +++ b/examples/01-filter/sampling_functions_2d.ipynb @@ -118,7 +118,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/sampling_functions_3d.ipynb b/examples/01-filter/sampling_functions_3d.ipynb index d2e048c..c4d79e0 100644 --- a/examples/01-filter/sampling_functions_3d.ipynb +++ b/examples/01-filter/sampling_functions_3d.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/slicing.ipynb b/examples/01-filter/slicing.ipynb index c239137..f59ca23 100644 --- a/examples/01-filter/slicing.ipynb +++ b/examples/01-filter/slicing.ipynb @@ -235,7 +235,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "And now display it!\n" + "And now display it.\n" ] }, { @@ -266,7 +266,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/streamlines.ipynb b/examples/01-filter/streamlines.ipynb index d33109f..7c4c80d 100644 --- a/examples/01-filter/streamlines.ipynb +++ b/examples/01-filter/streamlines.ipynb @@ -76,7 +76,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Display the results! Please note that because this dataset\\'s velocity\nfield was measured with low resolution, many streamlines travel outside\nthe artery.\n" + "Display the results. Please note that because this dataset\\'s velocity\nfield was measured with low resolution, many streamlines travel outside\nthe artery.\n" ] }, { @@ -252,7 +252,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/streamlines_2D.ipynb b/examples/01-filter/streamlines_2D.ipynb index a81c3b0..3cebe8b 100644 --- a/examples/01-filter/streamlines_2D.ipynb +++ b/examples/01-filter/streamlines_2D.ipynb @@ -143,7 +143,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/subdivide.ipynb b/examples/01-filter/subdivide.ipynb index 63bea74..d1ca1bf 100644 --- a/examples/01-filter/subdivide.ipynb +++ b/examples/01-filter/subdivide.ipynb @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/surface-smoothing.ipynb b/examples/01-filter/surface-smoothing.ipynb index efca439..578eff5 100644 --- a/examples/01-filter/surface-smoothing.ipynb +++ b/examples/01-filter/surface-smoothing.ipynb @@ -136,7 +136,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/surface_reconstruction.ipynb b/examples/01-filter/surface_reconstruction.ipynb index 323d5ae..3ec4c0c 100644 --- a/examples/01-filter/surface_reconstruction.ipynb +++ b/examples/01-filter/surface_reconstruction.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/using-filters.ipynb b/examples/01-filter/using-filters.ipynb index aee7a7b..015c224 100644 --- a/examples/01-filter/using-filters.ipynb +++ b/examples/01-filter/using-filters.ipynb @@ -136,7 +136,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/voxelize.ipynb b/examples/01-filter/voxelize.ipynb index 12c5706..cb46b67 100644 --- a/examples/01-filter/voxelize.ipynb +++ b/examples/01-filter/voxelize.ipynb @@ -133,7 +133,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/01-filter/warp-by-vector.ipynb b/examples/01-filter/warp-by-vector.ipynb index 5943279..2303e61 100644 --- a/examples/01-filter/warp-by-vector.ipynb +++ b/examples/01-filter/warp-by-vector.ipynb @@ -71,7 +71,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/anti-aliasing.ipynb b/examples/02-plot/anti-aliasing.ipynb index 64b2df4..0443858 100644 --- a/examples/02-plot/anti-aliasing.ipynb +++ b/examples/02-plot/anti-aliasing.ipynb @@ -118,7 +118,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/backface_props.ipynb b/examples/02-plot/backface_props.ipynb index 1b2ccd9..e240511 100644 --- a/examples/02-plot/backface_props.ipynb +++ b/examples/02-plot/backface_props.ipynb @@ -143,7 +143,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/background_image.ipynb b/examples/02-plot/background_image.ipynb index cf874b5..feaa4c6 100644 --- a/examples/02-plot/background_image.ipynb +++ b/examples/02-plot/background_image.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/blurring.ipynb b/examples/02-plot/blurring.ipynb index d6a329f..c629fd5 100644 --- a/examples/02-plot/blurring.ipynb +++ b/examples/02-plot/blurring.ipynb @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/bounds.ipynb b/examples/02-plot/bounds.ipynb index f08d1db..541c2f1 100644 --- a/examples/02-plot/bounds.ipynb +++ b/examples/02-plot/bounds.ipynb @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/chart_basics.ipynb b/examples/02-plot/chart_basics.ipynb index 70f61fc..66447ce 100644 --- a/examples/02-plot/chart_basics.ipynb +++ b/examples/02-plot/chart_basics.ipynb @@ -226,7 +226,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/chart_overlays.ipynb b/examples/02-plot/chart_overlays.ipynb index eb62571..bf000b5 100644 --- a/examples/02-plot/chart_overlays.ipynb +++ b/examples/02-plot/chart_overlays.ipynb @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/clear.ipynb b/examples/02-plot/clear.ipynb index 74f7680..e0d68c4 100644 --- a/examples/02-plot/clear.ipynb +++ b/examples/02-plot/clear.ipynb @@ -73,7 +73,7 @@ }, "outputs": [], "source": [ - "plotter = pv.Plotter()\nplotter.add_mesh(pv.Sphere(), name=\"mymesh\")\nplotter.add_mesh(pv.Plane(), name=\"mymesh\")\n# Only the Plane is shown!\nplotter.show()" + "plotter = pv.Plotter()\nplotter.add_mesh(pv.Sphere(), name=\"mymesh\")\nplotter.add_mesh(pv.Plane(), name=\"mymesh\")\n# Only the Plane is shown.\nplotter.show()" ] } ], @@ -93,7 +93,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/cmap.ipynb b/examples/02-plot/cmap.ipynb index 4d8ca2d..9978050 100644 --- a/examples/02-plot/cmap.ipynb +++ b/examples/02-plot/cmap.ipynb @@ -76,7 +76,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Simply pass the colormap to the plotting routine!\n" + "Simply pass the colormap to the plotting routine.\n" ] }, { @@ -94,7 +94,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Or you could make a simple colormap\\... any Matplotlib colormap can be\npassed to PyVista!\n" + "Or you could make a simple colormap\\... any Matplotlib colormap can be\npassed to PyVista.\n" ] }, { @@ -130,7 +130,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "If you still wish to have control of the separation of values, you can\ndo this by creating a scalar array and passing that to the plotter along\nwith the the colormap\n" + "If you still wish to have control of the separation of values, you can\ndo this by creating a scalar array and passing that to the plotter along\nwith the colormap\n" ] }, { @@ -179,7 +179,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/color_cycler.ipynb b/examples/02-plot/color_cycler.ipynb index 33afa99..6a1a723 100644 --- a/examples/02-plot/color_cycler.ipynb +++ b/examples/02-plot/color_cycler.ipynb @@ -22,7 +22,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Many plotting libraries like Matplotlib cycle through a predefined list\nof colors to colorize the data being added to the graphic. PyVista\nsupports this in much the same way as Matplotlib.\n\n::: {.note}\n::: {.admonition-title}\nNote\n:::\n\nThis requires matplotlib (or at least cycler) to be installed.\n:::\n" + "Many plotting libraries like Matplotlib cycle through a predefined list\nof colors to colorize the data being added to the graphic. PyVista\nsupports this in much the same way as Matplotlib.\n" ] }, { @@ -179,7 +179,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/composite-picking.ipynb b/examples/02-plot/composite-picking.ipynb index 35c6ad3..e103725 100644 --- a/examples/02-plot/composite-picking.ipynb +++ b/examples/02-plot/composite-picking.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/depth-peeling.ipynb b/examples/02-plot/depth-peeling.ipynb index eccf1c7..2c8db36 100644 --- a/examples/02-plot/depth-peeling.ipynb +++ b/examples/02-plot/depth-peeling.ipynb @@ -104,7 +104,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/depth_of_field.ipynb b/examples/02-plot/depth_of_field.ipynb index 8bb84de..ec8f8a9 100644 --- a/examples/02-plot/depth_of_field.ipynb +++ b/examples/02-plot/depth_of_field.ipynb @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/distance-along-spline.ipynb b/examples/02-plot/distance-along-spline.ipynb index ace8bd3..e0ccade 100644 --- a/examples/02-plot/distance-along-spline.ipynb +++ b/examples/02-plot/distance-along-spline.ipynb @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/edges.ipynb b/examples/02-plot/edges.ipynb index cd35d2e..717ec4d 100644 --- a/examples/02-plot/edges.ipynb +++ b/examples/02-plot/edges.ipynb @@ -53,7 +53,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/edl.ipynb b/examples/02-plot/edl.ipynb index 18547e9..56b5ed0 100644 --- a/examples/02-plot/edl.ipynb +++ b/examples/02-plot/edl.ipynb @@ -154,7 +154,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/floors.ipynb b/examples/02-plot/floors.ipynb index f5221e2..5372ce6 100644 --- a/examples/02-plot/floors.ipynb +++ b/examples/02-plot/floors.ipynb @@ -46,7 +46,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/ghost-cells.ipynb b/examples/02-plot/ghost-cells.ipynb index c0f49f7..969456e 100644 --- a/examples/02-plot/ghost-cells.ipynb +++ b/examples/02-plot/ghost-cells.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/gif.ipynb b/examples/02-plot/gif.ipynb index 616850a..55ea80a 100644 --- a/examples/02-plot/gif.ipynb +++ b/examples/02-plot/gif.ipynb @@ -46,7 +46,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/image_depth.ipynb b/examples/02-plot/image_depth.ipynb index 8fbac8e..71c6615 100644 --- a/examples/02-plot/image_depth.ipynb +++ b/examples/02-plot/image_depth.ipynb @@ -93,7 +93,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/interpolate-before-map.ipynb b/examples/02-plot/interpolate-before-map.ipynb index a1ea0d0..6f33998 100644 --- a/examples/02-plot/interpolate-before-map.ipynb +++ b/examples/02-plot/interpolate-before-map.ipynb @@ -105,7 +105,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Left, `interpolate_before_map` OFF. Right, `interpolate_before_map` ON.\n\nNow that is much more compelling! On the right, the contours of the\nscalar field are visible, but on the left, the contours are obscured due\nto the color interpolation by OpenGL. In both cases, the colors at the\nvertices are the same, the difference is how color is assigned between\nthe vertices.\n\nIn our opinion, color interpolation is not a preferred default for\nscientific visualization and is why we have chosen to set the\n`interpolate_before_map` flag to `True`.\n" + "Left, `interpolate_before_map` OFF. Right, `interpolate_before_map` ON.\n\nNow that is much more compelling. On the right, the contours of the\nscalar field are visible, but on the left, the contours are obscured due\nto the color interpolation by OpenGL. In both cases, the colors at the\nvertices are the same, the difference is how color is assigned between\nthe vertices.\n\nIn our opinion, color interpolation is not a preferred default for\nscientific visualization and is why we have chosen to set the\n`interpolate_before_map` flag to `True`.\n" ] } ], @@ -125,7 +125,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/isovalue.ipynb b/examples/02-plot/isovalue.ipynb index abbdf44..e11cdb9 100644 --- a/examples/02-plot/isovalue.ipynb +++ b/examples/02-plot/isovalue.ipynb @@ -129,7 +129,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/labels.ipynb b/examples/02-plot/labels.ipynb index 04d1ae1..82fe5e7 100644 --- a/examples/02-plot/labels.ipynb +++ b/examples/02-plot/labels.ipynb @@ -165,7 +165,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/lighting_mesh.ipynb b/examples/02-plot/lighting_mesh.ipynb index ee3bccc..df7cb1f 100644 --- a/examples/02-plot/lighting_mesh.ipynb +++ b/examples/02-plot/lighting_mesh.ipynb @@ -161,7 +161,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/linked.ipynb b/examples/02-plot/linked.ipynb index 4c59bc3..90a033f 100644 --- a/examples/02-plot/linked.ipynb +++ b/examples/02-plot/linked.ipynb @@ -46,7 +46,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/lookup-table.ipynb b/examples/02-plot/lookup-table.ipynb index afa8809..46fab61 100644 --- a/examples/02-plot/lookup-table.ipynb +++ b/examples/02-plot/lookup-table.ipynb @@ -208,7 +208,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/mesh-picking.ipynb b/examples/02-plot/mesh-picking.ipynb index 8161df7..1dbbcae 100644 --- a/examples/02-plot/mesh-picking.ipynb +++ b/examples/02-plot/mesh-picking.ipynb @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/movie.ipynb b/examples/02-plot/movie.ipynb index d739496..50455b0 100644 --- a/examples/02-plot/movie.ipynb +++ b/examples/02-plot/movie.ipynb @@ -46,7 +46,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/movie_glyphs.ipynb b/examples/02-plot/movie_glyphs.ipynb index 27e904d..29d59d9 100644 --- a/examples/02-plot/movie_glyphs.ipynb +++ b/examples/02-plot/movie_glyphs.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/moving_cmap.ipynb b/examples/02-plot/moving_cmap.ipynb index 3222786..b641d7b 100644 --- a/examples/02-plot/moving_cmap.ipynb +++ b/examples/02-plot/moving_cmap.ipynb @@ -26,7 +26,7 @@ }, "outputs": [], "source": [ - "import numpy as np\n\nimport pyvista as pv\n\n\n# A spherical curve\ndef scurve(t):\n alpha = np.pi / 2 - (np.pi / 2 - 0.44) * np.cos(3 * t)\n beta = t + 0.44 * np.sin(6 * t)\n return np.array([np.sin(alpha) * np.cos(beta), np.sin(alpha) * np.sin(beta), np.cos(alpha)])\n\n\n# Hopf fiber\ndef hopf_fiber(p, phi):\n return np.array(\n [\n (1 + p[2]) * np.cos(phi),\n p[0] * np.sin(phi) - p[1] * np.cos(phi),\n p[0] * np.cos(phi) + p[1] * np.sin(phi),\n (1 + p[2]) * np.sin(phi),\n ]\n ) / np.sqrt(2 * (1 + p[2]))\n\n\n# Stereographic projection\ndef stereo_proj(q):\n return q[0:3] / (1 - q[3])\n\n\n# Parameterization of the Hopf torus\ndef hopf_torus(t, phi):\n return stereo_proj(hopf_fiber(scurve(t), phi))\n\n\n# Create the mesh\nangle_u = np.linspace(-np.pi, np.pi, 400)\nangle_v = np.linspace(0, np.pi, 200)\nu, v = np.meshgrid(angle_u, angle_v)\nx, y, z = hopf_torus(u, v)\ngrid = pv.StructuredGrid(x, y, z)\nmesh = grid.extract_geometry().clean(tolerance=1e-6)\n\n# Distances normalized to [0, 2*pi]\ndists = np.linalg.norm(mesh.points, axis=1)\ndists = 2 * np.pi * (dists - dists.min()) / (dists.max() - dists.min())\n\n# Make the movie\npltr = pv.Plotter(window_size=[512, 512])\npltr.set_focus([0, 0, 0])\npltr.set_position([40, 0, 0])\npltr.add_mesh(\n mesh,\n scalars=np.sin(dists),\n smooth_shading=True,\n specular=10,\n cmap=\"nipy_spectral\",\n show_scalar_bar=False,\n)\npltr.open_gif(\"Hopf_torus.gif\")\n\nfor t in np.linspace(0, 2 * np.pi, 60, endpoint=False):\n pltr.update_scalars(np.sin(dists - t), render=False)\n pltr.write_frame()\n\npltr.show()" + "import numpy as np\n\nimport pyvista as pv\n\n\n# A spherical curve\ndef scurve(t):\n alpha = np.pi / 2 - (np.pi / 2 - 0.44) * np.cos(3 * t)\n beta = t + 0.44 * np.sin(6 * t)\n return np.array([np.sin(alpha) * np.cos(beta), np.sin(alpha) * np.sin(beta), np.cos(alpha)])\n\n\n# Hopf fiber\ndef hopf_fiber(p, phi):\n return np.array(\n [\n (1 + p[2]) * np.cos(phi),\n p[0] * np.sin(phi) - p[1] * np.cos(phi),\n p[0] * np.cos(phi) + p[1] * np.sin(phi),\n (1 + p[2]) * np.sin(phi),\n ]\n ) / np.sqrt(2 * (1 + p[2]))\n\n\n# Stereographic projection\ndef stereo_proj(q):\n return q[0:3] / (1 - q[3])\n\n\n# Parameterization of the Hopf torus\ndef hopf_torus(t, phi):\n return stereo_proj(hopf_fiber(scurve(t), phi))\n\n\n# Create the mesh\nangle_u = np.linspace(-np.pi, np.pi, 400)\nangle_v = np.linspace(0, np.pi, 200)\nu, v = np.meshgrid(angle_u, angle_v)\nx, y, z = hopf_torus(u, v)\ngrid = pv.StructuredGrid(x, y, z)\nmesh = grid.extract_geometry().clean(tolerance=1e-6)\n\n# Distances normalized to [0, 2*pi]\ndists = np.linalg.norm(mesh.points, axis=1)\ndists = 2 * np.pi * (dists - dists.min()) / (dists.max() - dists.min())\n\n# Make the movie\npltr = pv.Plotter(window_size=[512, 512])\npltr.set_focus([0, 0, 0])\npltr.set_position([40, 0, 0])\npltr.add_mesh(\n mesh,\n scalars=np.sin(dists),\n smooth_shading=True,\n specular=1,\n cmap=\"nipy_spectral\",\n show_scalar_bar=False,\n)\npltr.open_gif(\"Hopf_torus.gif\")\n\nfor t in np.linspace(0, 2 * np.pi, 60, endpoint=False):\n pltr.update_scalars(np.sin(dists - t), render=False)\n pltr.write_frame()\n\npltr.show()" ] } ], @@ -46,7 +46,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/multi-window.ipynb b/examples/02-plot/multi-window.ipynb index 767171c..5a0e928 100644 --- a/examples/02-plot/multi-window.ipynb +++ b/examples/02-plot/multi-window.ipynb @@ -111,7 +111,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/opacity.ipynb b/examples/02-plot/opacity.ipynb index 0ca105e..ec84c65 100644 --- a/examples/02-plot/opacity.ipynb +++ b/examples/02-plot/opacity.ipynb @@ -226,7 +226,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/orbit.ipynb b/examples/02-plot/orbit.ipynb index 574fa4e..80ba367 100644 --- a/examples/02-plot/orbit.ipynb +++ b/examples/02-plot/orbit.ipynb @@ -97,7 +97,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/ortho-slices.ipynb b/examples/02-plot/ortho-slices.ipynb index 8a6f91a..5193c35 100644 --- a/examples/02-plot/ortho-slices.ipynb +++ b/examples/02-plot/ortho-slices.ipynb @@ -86,7 +86,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/pbr.ipynb b/examples/02-plot/pbr.ipynb index 5638b66..bf6892b 100644 --- a/examples/02-plot/pbr.ipynb +++ b/examples/02-plot/pbr.ipynb @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/plot-over-circular-arc.ipynb b/examples/02-plot/plot-over-circular-arc.ipynb index 90f5dec..bd5d710 100644 --- a/examples/02-plot/plot-over-circular-arc.ipynb +++ b/examples/02-plot/plot-over-circular-arc.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/plot-over-line.ipynb b/examples/02-plot/plot-over-line.ipynb index 9ad816e..9e1eede 100644 --- a/examples/02-plot/plot-over-line.ipynb +++ b/examples/02-plot/plot-over-line.ipynb @@ -118,7 +118,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/point-cell-scalars.ipynb b/examples/02-plot/point-cell-scalars.ipynb index 4757fef..3b6af26 100644 --- a/examples/02-plot/point-cell-scalars.ipynb +++ b/examples/02-plot/point-cell-scalars.ipynb @@ -136,7 +136,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/point-clouds.ipynb b/examples/02-plot/point-clouds.ipynb index 88526d6..3628eb3 100644 --- a/examples/02-plot/point-clouds.ipynb +++ b/examples/02-plot/point-clouds.ipynb @@ -172,7 +172,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/point-picking.ipynb b/examples/02-plot/point-picking.ipynb index 1f487b6..52c2d7a 100644 --- a/examples/02-plot/point-picking.ipynb +++ b/examples/02-plot/point-picking.ipynb @@ -118,7 +118,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/scalar-bars.ipynb b/examples/02-plot/scalar-bars.ipynb index 4a971a5..a4ada68 100644 --- a/examples/02-plot/scalar-bars.ipynb +++ b/examples/02-plot/scalar-bars.ipynb @@ -154,7 +154,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/screenshot.ipynb b/examples/02-plot/screenshot.ipynb index c2d2bf0..c64ce11 100644 --- a/examples/02-plot/screenshot.ipynb +++ b/examples/02-plot/screenshot.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/shading.ipynb b/examples/02-plot/shading.ipynb index ffbda94..e98c76b 100644 --- a/examples/02-plot/shading.ipynb +++ b/examples/02-plot/shading.ipynb @@ -136,7 +136,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/silhouette.ipynb b/examples/02-plot/silhouette.ipynb index 5e5d5ad..c822905 100644 --- a/examples/02-plot/silhouette.ipynb +++ b/examples/02-plot/silhouette.ipynb @@ -136,7 +136,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/spherical.ipynb b/examples/02-plot/spherical.ipynb index 75d8dde..b9b66ad 100644 --- a/examples/02-plot/spherical.ipynb +++ b/examples/02-plot/spherical.ipynb @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/ssao.ipynb b/examples/02-plot/ssao.ipynb index b93c819..7adc244 100644 --- a/examples/02-plot/ssao.ipynb +++ b/examples/02-plot/ssao.ipynb @@ -154,7 +154,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/surface-picking.ipynb b/examples/02-plot/surface-picking.ipynb index 3165491..97c3eb5 100644 --- a/examples/02-plot/surface-picking.ipynb +++ b/examples/02-plot/surface-picking.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/texture.ipynb b/examples/02-plot/texture.ipynb index 9722964..50317e8 100644 --- a/examples/02-plot/texture.ipynb +++ b/examples/02-plot/texture.ipynb @@ -87,7 +87,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Note that this process can be completed with any image texture!\n" + "Note that this process can be completed with any image texture.\n" ] }, { @@ -134,7 +134,7 @@ }, "outputs": [], "source": [ - "# create an image using numpy,\nxx, yy = np.meshgrid(np.linspace(-200, 200, 20), np.linspace(-200, 200, 20))\nA, b = 500, 100\nzz = A * np.exp(-0.5 * ((xx / b) ** 2.0 + (yy / b) ** 2.0))\n\n# Creating a custom RGB image\ncmap = get_cmap(\"nipy_spectral\")\nnorm = lambda x: (x - np.nanmin(x)) / (np.nanmax(x) - np.nanmin(x))\nhue = norm(zz.ravel())\ncolors = (cmap(hue)[:, 0:3] * 255.0).astype(np.uint8)\nimage = colors.reshape((xx.shape[0], xx.shape[1], 3), order=\"F\")\n\n# Convert 3D numpy array to texture\ntex = pv.numpy_to_texture(image)\n\n# Render it!\ncurvsurf.plot(texture=tex)" + "# create an image using numpy,\nxx, yy = np.meshgrid(np.linspace(-200, 200, 20), np.linspace(-200, 200, 20))\nA, b = 500, 100\nzz = A * np.exp(-0.5 * ((xx / b) ** 2.0 + (yy / b) ** 2.0))\n\n# Creating a custom RGB image\ncmap = get_cmap(\"nipy_spectral\")\nnorm = lambda x: (x - np.nanmin(x)) / (np.nanmax(x) - np.nanmin(x))\nhue = norm(zz.ravel())\ncolors = (cmap(hue)[:, 0:3] * 255.0).astype(np.uint8)\nimage = colors.reshape((xx.shape[0], xx.shape[1], 3), order=\"F\")\n\n# Convert 3D numpy array to texture\ntex = pv.numpy_to_texture(image)\n\n# Render it\ncurvsurf.plot(texture=tex)" ] }, { @@ -152,7 +152,7 @@ }, "outputs": [], "source": [ - "# Create a plotter object\nplotter = pv.Plotter(notebook=False, off_screen=True)\n\n# Open a gif\nplotter.open_gif(\"texture.gif\")\n\npts = curvsurf.points.copy()\n\n# Update Z and write a frame for each updated position\nnframe = 15\nfor phase in np.linspace(0, 2 * np.pi, nframe + 1)[:nframe]:\n\n # create an image using numpy,\n z = np.sin(r + phase)\n pts[:, -1] = z.ravel()\n\n # Creating a custom RGB image\n zz = A * np.exp(-0.5 * ((xx / b) ** 2.0 + (yy / b) ** 2.0))\n hue = norm(zz.ravel()) * 0.5 * (1.0 + np.sin(phase))\n colors = (cmap(hue)[:, 0:3] * 255.0).astype(np.uint8)\n image = colors.reshape((xx.shape[0], xx.shape[1], 3), order=\"F\")\n\n # Convert 3D numpy array to texture\n tex = pv.numpy_to_texture(image)\n\n plotter.add_mesh(curvsurf, smooth_shading=True, texture=tex)\n plotter.update_coordinates(pts, render=False)\n\n # must update normals when smooth shading is enabled\n plotter.mesh.compute_normals(cell_normals=False, inplace=True)\n plotter.write_frame()\n plotter.clear()\n\n# Closes and finalizes movie\nplotter.close()" + "# Create a plotter object\nplotter = pv.Plotter(notebook=False, off_screen=True)\n\n# Open a gif\nplotter.open_gif(\"texture.gif\")\n\npts = curvsurf.points.copy()\n\n# Update Z and write a frame for each updated position\nnframe = 15\nfor phase in np.linspace(0, 2 * np.pi, nframe + 1)[:nframe]:\n # create an image using numpy,\n z = np.sin(r + phase)\n pts[:, -1] = z.ravel()\n\n # Creating a custom RGB image\n zz = A * np.exp(-0.5 * ((xx / b) ** 2.0 + (yy / b) ** 2.0))\n hue = norm(zz.ravel()) * 0.5 * (1.0 + np.sin(phase))\n colors = (cmap(hue)[:, 0:3] * 255.0).astype(np.uint8)\n image = colors.reshape((xx.shape[0], xx.shape[1], 3), order=\"F\")\n\n # Convert 3D numpy array to texture\n tex = pv.numpy_to_texture(image)\n\n plotter.add_mesh(curvsurf, smooth_shading=True, texture=tex)\n plotter.update_coordinates(pts, render=False)\n\n # must update normals when smooth shading is enabled\n plotter.mesh.compute_normals(cell_normals=False, inplace=True)\n plotter.write_frame()\n plotter.clear()\n\n# Closes and finalizes movie\nplotter.close()" ] }, { @@ -181,7 +181,7 @@ }, "outputs": [], "source": [ - "# Render it!\ncurvsurf.plot(texture=rgba, show_grid=True)" + "# Render it\ncurvsurf.plot(texture=rgba, show_grid=True)" ] }, { @@ -224,7 +224,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Now display all the puppies!\n" + "Now display all the puppies.\n" ] }, { @@ -291,7 +291,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/themes.ipynb b/examples/02-plot/themes.ipynb index 3a687d2..91301c0 100644 --- a/examples/02-plot/themes.ipynb +++ b/examples/02-plot/themes.ipynb @@ -130,7 +130,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Note that you can also use color gradients for the background of the\nplotting window!\n" + "Note that you can also use color gradients for the background of the\nplotting window.\n" ] }, { @@ -287,7 +287,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/topo-map.ipynb b/examples/02-plot/topo-map.ipynb index 9e8a0a4..030ce22 100644 --- a/examples/02-plot/topo-map.ipynb +++ b/examples/02-plot/topo-map.ipynb @@ -26,14 +26,14 @@ }, "outputs": [], "source": [ - "import pyvista as pv\nfrom pyvista import examples\n\n# Load the elevation data as a surface\nelevation = examples.download_crater_topo().warp_by_scalar()\n# Load the topographic map from a GeoTiff\ntopo_map = examples.download_crater_imagery()\n\nelevation\n\nimport matplotlib as mpl" + "import matplotlib as mpl\nimport matplotlib.pyplot as plt\n\nimport pyvista as pv\nfrom pyvista import examples" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Let\\'s inspect the imagery that we just loaded\n" + "Start by loading the elevation data and a topographic map.\n" ] }, { @@ -44,14 +44,32 @@ }, "outputs": [], "source": [ - "import matplotlib.pyplot as plt\n\nmpl.rcParams['figure.dpi'] = 500\n\nplt.imshow(topo_map.to_array())" + "# Load the elevation data as a surface\nelevation = examples.download_crater_topo().warp_by_scalar()\n# Load the topographic map from a GeoTiff\ntopo_map = examples.download_crater_imagery()\ntopo_map = topo_map.flip_y() # flip to align to our dataset\n\nelevation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Once you have a topography mesh loaded as a surface mesh (we use a\n`pyvista.StructuredGrid`{.interpreted-text role=\"class\"} here) and an\nimage loaded as a `pyvista.Texture`{.interpreted-text role=\"class\"}\nobject using the `pyvista.read_texture`{.interpreted-text role=\"func\"}\nmethod, then you can map that imagery to the surface mesh as follows:\n" + "Let\\'s inspect the imagery that we just loaded.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "mpl.rcParams['figure.dpi'] = 500\nplt.imshow(topo_map.to_array())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Once you have a topography mesh loaded as a surface mesh (we use a\n`pyvista.StructuredGrid`{.interpreted-text role=\"class\"} here) and an\nimage loaded as a `pyvista.Texture`{.interpreted-text role=\"class\"}\nusing `pyvista.read_texture`{.interpreted-text role=\"func\"}, then you\ncan map that imagery to the surface mesh as follows:\n" ] }, { @@ -69,7 +87,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Now display it! Note that the imagery is aligned as we expect.\n" + "Now display it. Note that the imagery is aligned as we expect.\n" ] }, { @@ -87,7 +105,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "And here is a 3D perspective!\n" + "And here is a 3D perspective.\n" ] }, { @@ -136,7 +154,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/vector-component.ipynb b/examples/02-plot/vector-component.ipynb index 97cd8b9..52db9ac 100644 --- a/examples/02-plot/vector-component.ipynb +++ b/examples/02-plot/vector-component.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/vertices.ipynb b/examples/02-plot/vertices.ipynb index 5bb6c14..4123cf1 100644 --- a/examples/02-plot/vertices.ipynb +++ b/examples/02-plot/vertices.ipynb @@ -136,7 +136,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/02-plot/volume.ipynb b/examples/02-plot/volume.ipynb index ac88e86..882adaa 100644 --- a/examples/02-plot/volume.ipynb +++ b/examples/02-plot/volume.ipynb @@ -195,7 +195,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Woah, that\\'s a big volume! We probably don\\'t want to volume render the\nwhole thing. So let\\'s extract a region of interest under the volcano.\n\nThe region we will extract will be between nodes 175 and 200 on the\nx-axis, between nodes 105 and 132 on the y-axis, and between nodes 98\nand 170 on the z-axis.\n" + "Woah, that\\'s a big volume. We probably don\\'t want to volume render the\nwhole thing. So let\\'s extract a region of interest under the volcano.\n\nThe region we will extract will be between nodes 175 and 200 on the\nx-axis, between nodes 105 and 132 on the y-axis, and between nodes 98\nand 170 on the z-axis.\n" ] }, { @@ -213,7 +213,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Ah, much better. Let\\'s now volume render that region of interest!\n" + "Ah, much better. Let\\'s now volume render that region of interest.\n" ] }, { @@ -244,7 +244,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/03-widgets/box-widget.ipynb b/examples/03-widgets/box-widget.ipynb index 1a175ba..7ba94d4 100644 --- a/examples/03-widgets/box-widget.ipynb +++ b/examples/03-widgets/box-widget.ipynb @@ -75,7 +75,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/03-widgets/checkbox-widget.ipynb b/examples/03-widgets/checkbox-widget.ipynb index 4c025f1..ef0670d 100644 --- a/examples/03-widgets/checkbox-widget.ipynb +++ b/examples/03-widgets/checkbox-widget.ipynb @@ -93,7 +93,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/03-widgets/clip-volume.ipynb b/examples/03-widgets/clip-volume.ipynb index 325c43f..7517c18 100644 --- a/examples/03-widgets/clip-volume.ipynb +++ b/examples/03-widgets/clip-volume.ipynb @@ -107,7 +107,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/03-widgets/line-widget.ipynb b/examples/03-widgets/line-widget.ipynb index 3a0a83d..7c28510 100644 --- a/examples/03-widgets/line-widget.ipynb +++ b/examples/03-widgets/line-widget.ipynb @@ -64,7 +64,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/03-widgets/multi-slider-widget.ipynb b/examples/03-widgets/multi-slider-widget.ipynb index f3ec676..825f8ba 100644 --- a/examples/03-widgets/multi-slider-widget.ipynb +++ b/examples/03-widgets/multi-slider-widget.ipynb @@ -68,7 +68,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/03-widgets/plane-widget.ipynb b/examples/03-widgets/plane-widget.ipynb index 07f3151..7a3aabd 100644 --- a/examples/03-widgets/plane-widget.ipynb +++ b/examples/03-widgets/plane-widget.ipynb @@ -15,7 +15,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Plane Widget {#plane_widget_example}\n============\n\nThe plane widget can be enabled and disabled by the\n`pyvista.Plotter.add_plane_widget`{.interpreted-text role=\"func\"} and\n`pyvista.Plotter.clear_plane_widgets`{.interpreted-text role=\"func\"}\nmethods respectively. As with all widgets, you must provide a custom\ncallback method to utilize that plane. Considering that planes are most\ncommonly used for clipping and slicing meshes, we have included two\nhelper methods for doing those tasks!\n\nLet\\'s use a plane to clip a mesh:\n" + "Plane Widget {#plane_widget_example}\n============\n\nThe plane widget can be enabled and disabled by the\n`pyvista.Plotter.add_plane_widget`{.interpreted-text role=\"func\"} and\n`pyvista.Plotter.clear_plane_widgets`{.interpreted-text role=\"func\"}\nmethods respectively. As with all widgets, you must provide a custom\ncallback method to utilize that plane. Considering that planes are most\ncommonly used for clipping and slicing meshes, we have included two\nhelper methods for doing those tasks.\n\nLet\\'s use a plane to clip a mesh:\n" ] }, { @@ -200,7 +200,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/03-widgets/slider-bar-widget.ipynb b/examples/03-widgets/slider-bar-widget.ipynb index f38acdd..92f471c 100644 --- a/examples/03-widgets/slider-bar-widget.ipynb +++ b/examples/03-widgets/slider-bar-widget.ipynb @@ -114,7 +114,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/03-widgets/sphere-widget.ipynb b/examples/03-widgets/sphere-widget.ipynb index c663655..04c3982 100644 --- a/examples/03-widgets/sphere-widget.ipynb +++ b/examples/03-widgets/sphere-widget.ipynb @@ -105,7 +105,7 @@ }, "outputs": [], "source": [ - "# Begin the plotting routine\np = pv.Plotter()\n\n# Add the surface to the scene\np.add_mesh(surf, color=True)\n\n# Add the widgets which will update the surface\np.add_sphere_widget(update_surface, center=points, color=colors, radius=3)\n# Add axes grid\np.show_grid()\n\n# Show it!\np.show()" + "# Begin the plotting routine\np = pv.Plotter()\n\n# Add the surface to the scene\np.add_mesh(surf, color=True)\n\n# Add the widgets which will update the surface\np.add_sphere_widget(update_surface, center=points, color=colors, radius=3)\n# Add axes grid\np.show_grid()\n\n# Show it\np.show()" ] }, { @@ -132,7 +132,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/03-widgets/spline-widget.ipynb b/examples/03-widgets/spline-widget.ipynb index 2b9f526..e50d0cd 100644 --- a/examples/03-widgets/spline-widget.ipynb +++ b/examples/03-widgets/spline-widget.ipynb @@ -57,7 +57,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/04-lights/actors.ipynb b/examples/04-lights/actors.ipynb index ed99d64..65e6742 100644 --- a/examples/04-lights/actors.ipynb +++ b/examples/04-lights/actors.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/04-lights/attenuation.ipynb b/examples/04-lights/attenuation.ipynb index c41d8e6..241be51 100644 --- a/examples/04-lights/attenuation.ipynb +++ b/examples/04-lights/attenuation.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/04-lights/beam_shape.ipynb b/examples/04-lights/beam_shape.ipynb index 88998e2..6d163a0 100644 --- a/examples/04-lights/beam_shape.ipynb +++ b/examples/04-lights/beam_shape.ipynb @@ -125,7 +125,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/04-lights/light_types.ipynb b/examples/04-lights/light_types.ipynb index 86551be..045fb85 100644 --- a/examples/04-lights/light_types.ipynb +++ b/examples/04-lights/light_types.ipynb @@ -82,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/04-lights/mesh_lighting.ipynb b/examples/04-lights/mesh_lighting.ipynb index a3df613..bbc9616 100644 --- a/examples/04-lights/mesh_lighting.ipynb +++ b/examples/04-lights/mesh_lighting.ipynb @@ -71,7 +71,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/04-lights/plotter_builtins.ipynb b/examples/04-lights/plotter_builtins.ipynb index 461e8e5..f385776 100644 --- a/examples/04-lights/plotter_builtins.ipynb +++ b/examples/04-lights/plotter_builtins.ipynb @@ -136,7 +136,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/04-lights/shadows.ipynb b/examples/04-lights/shadows.ipynb index 86d1992..588bc90 100644 --- a/examples/04-lights/shadows.ipynb +++ b/examples/04-lights/shadows.ipynb @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/98-common/project-points-tessellate.ipynb b/examples/98-common/project-points-tessellate.ipynb new file mode 100644 index 0000000..805cd95 --- /dev/null +++ b/examples/98-common/project-points-tessellate.ipynb @@ -0,0 +1,90 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "%matplotlib inline\nfrom pyvista import set_plot_theme\nset_plot_theme('document')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Project points to a plane and Tessellate\n========================================\n\nUsing pyvista and numpy, generate a 3D point cloud, project it to a\nplane, and tessellate it.\n\nThis demonstrates how to use\n`pyvista.UnstructuredGridFilters.delaunay_2d`{.interpreted-text\nrole=\"class\"} and a simple numpy function that projects points to a\nplane.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import numpy as np\n\nimport pyvista as pv" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Project Points\n==============\n\nCreate a point cloud and project it to a plane.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "num_points = 100\npoint_cloud = np.random.random((num_points, 3))\n\n# Define a plane\norigin = [0, 0, 0]\nnormal = [0, 0, 1]\nplane = pv.Plane(center=origin, direction=normal)\n\n\ndef project_points_to_plane(points, plane_origin, plane_normal):\n \"\"\"Project points to a plane.\"\"\"\n vec = points - plane_origin\n dist = np.dot(vec, plane_normal)\n return points - np.outer(dist, plane_normal)\n\n\nprojected_points = project_points_to_plane(point_cloud, origin, normal)\n\n# Create a polydata object with projected points\npolydata = pv.PolyData(projected_points)\n\n# Mesh using delaunay_2d and pyvista\nmesh = polydata.delaunay_2d()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Visualize the Result\n====================\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Create a plane for visualization\nplane_vis = pv.Plane(\n center=origin, direction=normal, i_size=2, j_size=2, i_resolution=10, j_resolution=10\n)\n\n# plot it\npl = pv.Plotter()\npl.add_mesh(mesh, show_edges=True, color='white', opacity=0.5, label='Tessellated mesh')\npl.add_mesh(\n pv.PolyData(point_cloud),\n color='red',\n render_points_as_spheres=True,\n point_size=10,\n label='Points to project',\n)\npl.add_mesh(plane_vis, color='blue', opacity=0.1, label='Projection Plane')\npl.add_legend()\npl.show()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file diff --git a/examples/99-advanced/add-example.ipynb b/examples/99-advanced/add-example.ipynb index f8ea845..5165991 100644 --- a/examples/99-advanced/add-example.ipynb +++ b/examples/99-advanced/add-example.ipynb @@ -172,7 +172,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/99-advanced/antarctica-compare.ipynb b/examples/99-advanced/antarctica-compare.ipynb index 77b10ef..420b6a0 100644 --- a/examples/99-advanced/antarctica-compare.ipynb +++ b/examples/99-advanced/antarctica-compare.ipynb @@ -173,7 +173,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/99-advanced/atomic-orbitals.ipynb b/examples/99-advanced/atomic-orbitals.ipynb index 857671a..0858b01 100644 --- a/examples/99-advanced/atomic-orbitals.ipynb +++ b/examples/99-advanced/atomic-orbitals.ipynb @@ -197,7 +197,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/99-advanced/extending-pyvista.ipynb b/examples/99-advanced/extending-pyvista.ipynb index 8e71471..a1920a1 100644 --- a/examples/99-advanced/extending-pyvista.ipynb +++ b/examples/99-advanced/extending-pyvista.ipynb @@ -262,7 +262,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/99-advanced/fea-hertzian-contact-pressure.ipynb b/examples/99-advanced/fea-hertzian-contact-pressure.ipynb new file mode 100644 index 0000000..b4d6a7f --- /dev/null +++ b/examples/99-advanced/fea-hertzian-contact-pressure.ipynb @@ -0,0 +1,144 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "%matplotlib inline\nfrom pyvista import set_plot_theme\nset_plot_theme('document')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Visualize Hertzian Contact Stress {#hertzian_contact_example}\n=================================\n\nThe following example demonstrates how to use PyVista to visualize\nHertzian contact stress between a cylinder and a flat plate.\n\nThis example loads a dataset, constructs a line to represent the point\nof contact between the cylinder and the block, and samples the stress\nalong that line. Finally, it plots the dataset and the stress\ndistribution.\n\n**Background** Hertzian contact stress refers to the stress that occurs\nbetween two curved surfaces that are in contact with each other. It is\nnamed after Heinrich Rudolf Hertz, a German physicist who first\ndescribed the phenomenon in the late 1800s. Hertzian contact stress is\nan important concept in materials science, engineering, and other fields\nwhere the behavior of materials under stress is a critical\nconsideration.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import matplotlib.pyplot as plt\nimport numpy as np\n\nimport pyvista as pv\nfrom pyvista import examples" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Load the dataset\n================\n\nStart by loading the dataset using `pyvista.examples`{.interpreted-text\nrole=\"mod\"} module. This module provides access to a range of datasets,\nincluding FEA (finite element analysis) datasets that are useful for\nstress analysis.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "mesh = examples.download_fea_hertzian_contact_cylinder()\nmesh" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Plot the Dataset\n================\n\nPlot the dataset by part ID.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "mesh.plot(scalars='PartID', cmap=['green', 'blue'], show_scalar_bar=False)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Creating a Line to Denote the Point of Contact\n==============================================\n\nConstruct a line to represent the point of contact between the cylinder\nand the plate.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ypos = 0.024\na = [0.1, ypos, 0.2 - 1e-4]\nb = [0.095, ypos, 0.2 - 1e-4]\nline = pv.Line(a, b, resolution=100)\nline.clear_data()\nline" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Sampling the Stress along the Line\n==================================\n\nWe can sample the Z component stress along the contact edge and compare\nit with expected pressure.\n\nThe expected values array is the Hertzian contact pressure and is the\nanalytical solution to the non-adhesive contact problem. Computation of\nthese values is an exercise left up to the reader (the radius of the\ncylinder is 0.05). See [Contact\nMechanics](https://en.wikipedia.org/wiki/Contact_mechanics)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Sample the stress\nsampled = line.sample(mesh, tolerance=1e-3)\nx_coord = 0.1 - sampled.points[:, 0]\nsamp_z_stress = -sampled['Stress'][:, 2]\n\n# Expected Hertzian contact pressure\nh_pressure = np.array(\n [\n [0.0000, 1718094092],\n [0.0002, 1715185734],\n [0.0004, 1703502649],\n [0.0006, 1683850714],\n [0.0008, 1655946243],\n [0.001, 1619362676],\n [0.0012, 1573494764],\n [0.0014, 1517500856],\n [0.0016, 1450208504],\n [0.0018, 1369953775],\n [0.002, 1274289906],\n [0.0022, 1159408887],\n [0.0024, 1018830677],\n [0.0026, 839747409.8],\n [0.0028, 587969605.2],\n [0.003, 0],\n [0.005, 0],\n ]\n)\n\nplt.plot(x_coord, samp_z_stress, '.', label='Z Component Stress')\nplt.plot(h_pressure[:, 0], h_pressure[:, 1], label='Hertzian contact pressure')\nplt.legend()\nplt.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Visualizing the Z Stress Distribution\n=====================================\n\nYou can now visualize the Z stress distribution. Use\n`pyvista.Plotter`{.interpreted-text role=\"class\"} to create a plot\nwindow and add the dataset to it.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "pl = pv.Plotter()\nz_stress = np.abs(mesh['Stress'][:, 2])\npl.add_mesh(\n mesh,\n scalars=z_stress,\n clim=[0, 1.2e9],\n cmap='gouldian',\n scalar_bar_args={'title': 'Z Component Stress (Pa)', 'color': 'w'},\n lighting=True,\n show_edges=False,\n ambient=0.2,\n)\npl.camera_position = 'xz'\npl.set_focus(a)\npl.camera.zoom(2.5)\npl.show()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file diff --git a/examples/99-advanced/magnetic-fields.ipynb b/examples/99-advanced/magnetic-fields.ipynb new file mode 100644 index 0000000..3be3236 --- /dev/null +++ b/examples/99-advanced/magnetic-fields.ipynb @@ -0,0 +1,126 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "%matplotlib inline\nfrom pyvista import set_plot_theme\nset_plot_theme('document')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Plot a Magnetic Field {#magnetic_fields_example}\n=====================\n\nThe following example demonstrates how PyVista can be used to plot a\nmagnetic field.\n\nThis example relies on `streamlines_from_source()\n`{.interpreted-text\nrole=\"func\"} to generate streamlines and\n`add_volume() `{.interpreted-text\nrole=\"func\"} to plot the strength of the magnetic field.\n\nThis dataset was created from the [Coil Field\nLines](https://magpylib.readthedocs.io/en/latest/examples/examples_30_coil_field_lines.html)\nexample from the awesome\n[magpylib](https://github.com/magpylib/magpylib) library.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import numpy as np\n\nimport pyvista as pv\nfrom pyvista import examples" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Download the DataSet\n====================\n\nLet\\'s first download the example dataset and show that it\\'s a\n`pyvista.UniformGrid`{.interpreted-text role=\"class\"} with the magnetic\nfield stored as the `'B'` array in `point_data`.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "grid = examples.download_coil_magnetic_field()\ngrid.point_data" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Create Coils\n============\n\nCreate several hoops to represent the coil. This matches the geometry in\nthe original example.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "coils = []\nfor z in np.linspace(-8, 8, 16):\n coils.append(pv.Polygon((0, 0, z), radius=5, n_sides=100, fill=False))\ncoil_block = pv.MultiBlock(coils)\ncoil_block.plot(render_lines_as_tubes=True, line_width=10)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Compute and Plot Field Lines\n============================\n\nNext, let\\'s compute streamlines from the center of the coil to\nrepresent the direction of the magnetic force. For this, we can create a\nsimple `pyvista.Disc`{.interpreted-text role=\"func\"} and use that as the\nsource of the streamlines.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "seed = pv.Disc(inner=1, outer=5.4, r_res=2, c_res=12)\nstrl = grid.streamlines_from_source(\n seed,\n vectors='B',\n max_time=180,\n initial_step_length=0.1,\n integration_direction='both',\n)\n\npl = pv.Plotter()\npl.add_mesh(\n strl.tube(radius=0.1),\n cmap='bwr',\n ambient=0.2,\n)\npl.add_mesh(coil_block, render_lines_as_tubes=True, line_width=5, color='w')\npl.camera.zoom(3)\npl.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Plot the Magnet Field Strength\n==============================\n\nFinally, let\\'s bring this all together by plotting the magnetic field\nstrength while also plotting the streamlines and the coil.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Take the norm of the magnetic field\nscalars = np.linalg.norm(grid['B'], axis=1)\n\n# Customize the opacity to make it easier to visualize the strength of the\n# field nearby the coil\nopacity = 1 - np.geomspace(1.0, 0.05, 10)\n\n# Add this all to the plotter\npl = pv.Plotter()\npl.add_mesh(\n strl.tube(radius=0.1),\n color='black',\n)\npl.add_mesh(coil_block, render_lines_as_tubes=True, line_width=5, color='w')\nvol = pl.add_volume(\n grid,\n scalars=scalars,\n opacity=opacity,\n cmap='hot',\n show_scalar_bar=False,\n)\nvol.prop.interpolation_type = 'linear'\npl.camera.zoom(5)\npl.show()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file diff --git a/examples/99-advanced/openfoam-cooling.ipynb b/examples/99-advanced/openfoam-cooling.ipynb new file mode 100644 index 0000000..93bb364 --- /dev/null +++ b/examples/99-advanced/openfoam-cooling.ipynb @@ -0,0 +1,162 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "%matplotlib inline\nfrom pyvista import set_plot_theme\nset_plot_theme('document')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Electronics Cooling CFD {#openfoam_cooling_example}\n=======================\n\nPlot an electronics cooling CFD example from OpenFoam hosted on the\npublic SimScale examples at [SimScale Project\nLibrary](https://www.simscale.com/projects/) and generated from the\n[Thermal Management Tutorial: CHT Analysis of an Electronics\nBox](https://www.simscale.com/docs/tutorials/thermal-management-cht-analysis-electronics-box/).\n\nThis example dataset was read using the\n`pyvista.POpenFOAMReader`{.interpreted-text role=\"class\"} and post\nprocessed according to this\n[README.md](https://github.com/pyvista/vtk-data/blob/master/Data/fvm/cooling_electronics/README.md).\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import numpy as np\n\nimport pyvista as pv\nfrom pyvista import examples" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Load the Datasets\n=================\n\nDownload and load the datasets.\n\nThe `structure` dataset consists of a box with several components, being\ncooled down by a fan, while the `air` dataset is the air, containing\nseveral scalar arrays including the velocity and temperature of the air.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "structure, air = examples.download_electronics_cooling()\nstructure, air" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Plot the Electronics\n====================\n\nHere we plot the temperature of the electronics using the `\"reds\"`\ncolormap and improve the look of the plot using surface space ambient\nocclusion with\n`enable_ssao() `{.interpreted-text\nrole=\"func\"}.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "pl = pv.Plotter()\npl.enable_ssao(radius=0.01)\npl.add_mesh(\n structure, scalars='T', smooth_shading=True, split_sharp_edges=True, cmap='reds', ambient=0.2\n)\npl.enable_anti_aliasing('fxaa') # also try 'ssaa'\npl.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Plot Air Velocity\n=================\n\nLet\\'s plot the velocity of the air.\n\nStart by clipping the air dataset with `clip()\n`{.interpreted-text role=\"func\"} and\nplotting it alongside the electronics.\n\nAs you can see, the air enters from the front of the case (left) and is\nbeing pushed out of the \\\"back\\\" of the case via a fan.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Clip the air in the XY plane\nz_slice = air.clip('z', value=-0.005)\n\n# Plot it\npl = pv.Plotter()\npl.enable_ssao(radius=0.01)\npl.add_mesh(z_slice, scalars='U', lighting=False, scalar_bar_args={'title': 'Velocity'})\npl.add_mesh(structure, color='w', smooth_shading=True, split_sharp_edges=True)\npl.camera_position = 'xy'\npl.camera.roll = 90\npl.enable_anti_aliasing('fxaa')\npl.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Plot Air Temperature\n====================\n\nLet\\'s also plot the temperature of the air. This time, let\\'s also plot\nthe temperature of the components.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "pl = pv.Plotter()\npl.enable_ssao(radius=0.01)\npl.add_mesh(\n z_slice, scalars='T', lighting=False, scalar_bar_args={'title': 'Temperature'}, cmap='reds'\n)\npl.add_mesh(\n structure,\n scalars='T',\n smooth_shading=True,\n split_sharp_edges=True,\n cmap='reds',\n show_scalar_bar=False,\n)\npl.camera_position = 'xy'\npl.camera.roll = 90\npl.enable_anti_aliasing('fxaa')\npl.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Plot Streamlines - Flow Velocity\n================================\n\nNow, let\\'s plot the streamlines of this dataset so we can see how the\nair is flowing through the case.\n\nGenerate streamlines using `streamlines_from_source()\n`{.interpreted-text\nrole=\"func\"}.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Have our streamlines start from the regular openings of the case.\npoints = []\nfor x in np.linspace(0.045, 0.105, 7, endpoint=True):\n points.extend([x, 0.2, z] for z in np.linspace(0, 0.03, 5))\npoints = pv.PointSet(points)\nlines = air.streamlines_from_source(points, max_time=2.0)\n\n# Plot\npl = pv.Plotter()\npl.enable_ssao(radius=0.01)\npl.add_mesh(lines, line_width=2, scalars='T', cmap='reds', scalar_bar_args={'title': 'Temperature'})\npl.add_mesh(\n structure,\n scalars='T',\n smooth_shading=True,\n split_sharp_edges=True,\n cmap='reds',\n show_scalar_bar=False,\n)\npl.camera_position = 'xy'\npl.camera.roll = 90\npl.enable_anti_aliasing('fxaa') # also try 'ssaa'\npl.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Volumetric Plot - Visualize High Temperatures\n=============================================\n\nShow a 3D plot of areas of temperature.\n\nFor this example, we will first sample the results from the\n`pyvista.UnstructuredGrid`{.interpreted-text role=\"class\"} onto a\n`pyvista.UniformGrid`{.interpreted-text role=\"class\"} using\n`sample() `{.interpreted-text\nrole=\"func\"}. This is so we can visualize it using\n`add_volume() `{.interpreted-text\nrole=\"func\"}\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "bounds = np.array(air.bounds) * 1.2\norigin = (bounds[0], bounds[2], bounds[4])\nspacing = (0.002, 0.002, 0.002)\ndimensions = (\n int((bounds[1] - bounds[0]) // spacing[0] + 2),\n int((bounds[3] - bounds[2]) // spacing[1] + 2),\n int((bounds[5] - bounds[4]) // spacing[2] + 2),\n)\ngrid = pv.UniformGrid(dimensions=dimensions, spacing=spacing, origin=origin)\ngrid = grid.sample(air)\n\nopac = np.zeros(20)\nopac[1:] = np.geomspace(1e-7, 0.1, 19)\nopac[-5:] = [0.05, 0.1, 0.5, 0.5, 0.5]\n\npl = pv.Plotter()\npl.add_mesh(structure, color='w', smooth_shading=True, split_sharp_edges=True)\nvol = pl.add_volume(\n grid,\n scalars='T',\n opacity=opac,\n cmap='autumn_r',\n show_scalar_bar=True,\n scalar_bar_args={'title': 'Temperature'},\n)\nvol.prop.interpolation_type = 'linear'\npl.camera.zoom(2)\npl.show()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file diff --git a/examples/99-advanced/openfoam-example.ipynb b/examples/99-advanced/openfoam-example.ipynb index 158648f..1b6f95c 100644 --- a/examples/99-advanced/openfoam-example.ipynb +++ b/examples/99-advanced/openfoam-example.ipynb @@ -244,7 +244,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/99-advanced/openfoam-tubes.ipynb b/examples/99-advanced/openfoam-tubes.ipynb new file mode 100644 index 0000000..7566660 --- /dev/null +++ b/examples/99-advanced/openfoam-tubes.ipynb @@ -0,0 +1,144 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "%matplotlib inline\nfrom pyvista import set_plot_theme\nset_plot_theme('document')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Plot CFD Data {#openfoam_tubes_example}\n=============\n\nPlot a CFD example from OpenFoam hosted on the public SimScale examples\nat [SimScale Project Library](https://www.simscale.com/projects/).\n\nThis example dataset was read using the\n`pyvista.POpenFOAMReader`{.interpreted-text role=\"class\"}. See\n`openfoam_example`{.interpreted-text role=\"ref\"} for a full example\nusing this reader.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import numpy as np\n\nimport pyvista as pv\nfrom pyvista import examples" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Download and load the example dataset.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "block = examples.download_openfoam_tubes()\nblock" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Plot Cross Section\n==================\n\nPlot the outline of the dataset along with a cross section of the flow\nvelocity.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# first, get the first block representing the air within the tube.\nair = block[0]\n\n# generate a slice in the XZ plane\ny_slice = air.slice('y')\n\npl = pv.Plotter()\npl.add_mesh(y_slice, scalars='U', lighting=False, scalar_bar_args={'title': 'Flow Velocity'})\npl.add_mesh(air, color='w', opacity=0.25)\npl.enable_anti_aliasing()\npl.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Plot Streamlines - Flow Velocity\n================================\n\nGenerate streamlines using `streamlines_from_source()\n`{.interpreted-text\nrole=\"func\"}.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Let's use the inlet as a source. First plot it.\ninlet = block[1][2]\npl = pv.Plotter()\npl.add_mesh(inlet, color='b', label='inlet')\npl.add_mesh(air, opacity=0.2, color='w', label='air')\npl.enable_anti_aliasing()\npl.add_legend(face=None)\npl.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now, actually generate the streamlines. Since the original inlet\ncontains 1000 points, let\\'s reduce this to around 200 points by using\nevery 5th point.\n\n::: {.note}\n::: {.admonition-title}\nNote\n:::\n\nIf we wanted a uniform subsampling of the inlet, we could use\n[pyvista/pyacvd](https://github.com/pyvista/pyacvd)\n:::\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "pset = pv.PointSet(inlet.points[::5])\nlines = air.streamlines_from_source(\n pset,\n vectors='U',\n max_time=1.0,\n)\n\npl = pv.Plotter()\npl.add_mesh(\n lines,\n render_lines_as_tubes=True,\n line_width=3,\n lighting=False,\n scalar_bar_args={'title': 'Flow Velocity'},\n scalars='U',\n rng=(0, 212),\n)\npl.add_mesh(air, color='w', opacity=0.25)\npl.enable_anti_aliasing()\npl.camera_position = 'xz'\npl.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Volumetric Plot - Visualize Turbulent Kinematic Viscosity\n=========================================================\n\nThe turbulent kinematic viscosity of a fluid is a derived quantity used\nin turbulence modeling to describe the effect of turbulent motion on the\nmomentum transport within the fluid.\n\nFor this example, we will first sample the results from the\n`pyvista.UnstructuredGrid`{.interpreted-text role=\"class\"} onto a\n`pyvista.UniformGrid`{.interpreted-text role=\"class\"} using\n`sample() `{.interpreted-text\nrole=\"func\"}. This is so we can visualize it using\n`add_volume() `{.interpreted-text\nrole=\"func\"}\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "bounds = np.array(air.bounds) * 1.2\norigin = (bounds[0], bounds[2], bounds[4])\nspacing = (0.003, 0.003, 0.003)\ndimensions = (\n int((bounds[1] - bounds[0]) // spacing[0] + 2),\n int((bounds[3] - bounds[2]) // spacing[1] + 2),\n int((bounds[5] - bounds[4]) // spacing[2] + 2),\n)\ngrid = pv.UniformGrid(dimensions=dimensions, spacing=spacing, origin=origin)\ngrid = grid.sample(air)\n\npl = pv.Plotter()\nvol = pl.add_volume(\n grid,\n scalars='nut',\n opacity='linear',\n scalar_bar_args={'title': 'Turbulent Kinematic Viscosity'},\n)\nvol.prop.interpolation_type = 'linear'\npl.add_mesh(air, color='w', opacity=0.1)\npl.camera_position = 'xz'\npl.show()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file diff --git a/examples/99-advanced/osmnx-example.ipynb b/examples/99-advanced/osmnx-example.ipynb index d53326a..a67c77f 100644 --- a/examples/99-advanced/osmnx-example.ipynb +++ b/examples/99-advanced/osmnx-example.ipynb @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/99-advanced/planets.ipynb b/examples/99-advanced/planets.ipynb index 6397a2c..15e4324 100644 --- a/examples/99-advanced/planets.ipynb +++ b/examples/99-advanced/planets.ipynb @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/99-advanced/plotting-algorithms.ipynb b/examples/99-advanced/plotting-algorithms.ipynb index b4940d4..e6601f8 100644 --- a/examples/99-advanced/plotting-algorithms.ipynb +++ b/examples/99-advanced/plotting-algorithms.ipynb @@ -118,7 +118,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/99-advanced/pump-bracket.ipynb b/examples/99-advanced/pump-bracket.ipynb new file mode 100644 index 0000000..23ebd13 --- /dev/null +++ b/examples/99-advanced/pump-bracket.ipynb @@ -0,0 +1,126 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "%matplotlib inline\nfrom pyvista import set_plot_theme\nset_plot_theme('document')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Visualize Modal Analysis of a Pump Bracket {#pump_bracket_example}\n==========================================\n\nThe following example demonstrates how to use PyVista to visualize the\nmodal analysis of a pump bracket based on point arrays representing mode\nshapes for different modes of vibration.\n\n**Background** Modal analysis is the study of the dynamic properties of\nmechanical structures in the frequency domain. It is a common technique\nin structural dynamics, particularly for automotive, aerospace, and\ncivil engineering applications.\n\nA mode shape is the deformation pattern that occurs at a specific\nnatural frequency, or mode, of a structure. When a structure is excited\nby an external force, it responds at all its natural frequencies with\neach mode shape being independent of the others. In this example, we\nwill visualize the mode shapes to get an understanding of how the pump\nbracket responds to different modes of vibration.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import numpy as np\n\nimport pyvista as pv\nfrom pyvista import examples" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Load the dataset\n================\n\nStart by loading the dataset using `download_pump_bracket()\n`{.interpreted-text\nrole=\"func\"}.\n\nThis example demonstrates the visualization of the pump bracket\\'s mode\nshape, the representation of its magnitude, and an animation of its\ndisplacement. The dataset used in this example contains 10 mode shapes\n(disp\\_0 to disp\\_9).\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "dataset = examples.download_pump_bracket()\ndataset" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Plot the Dataset\n================\n\nChoose a mode shape from the available arrays in the dataset. Each\n\\\"disp\\_N\\\" array represents an eigen solution or a single mode shape\nfor a given mode of vibration.\n\nPlot the 4th mode of the dataset. This is the first torsional mode for\nthe bracket.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "cpos = [\n (0.744, -0.502, -0.830),\n (0.0520, -0.160, 0.0743),\n (-0.180, -0.958, 0.224),\n]\n\ndataset.plot(\n scalars='disp_3',\n cpos=cpos,\n show_scalar_bar=False,\n ambient=0.2,\n anti_aliasing='fxaa',\n)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Visualize Displaced Mode Shape\n==============================\n\nWe will now visualize the mode shapes of the pump bracket by displacing\nthe original dataset using\n`warp_by_vector `{.interpreted-text\nrole=\"func\"}.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Create a plotter\npl = pv.Plotter()\n\n# Add the undeformed pump bracket\npl.add_mesh(dataset, color=\"white\", opacity=0.5)\n\n# Add the deformed pump bracket with the mode shape\nwarp = dataset.warp_by_vector('disp_2', factor=0.1)\npl.add_mesh(warp, show_scalar_bar=False, ambient=0.2)\n\npl.camera_position = cpos\npl.enable_anti_aliasing('fxaa')\npl.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Animate the Mode Shape Displacement\n===================================\n\nAnimate the mode shape\\'s displacement by updating the vertex positions\nat each time step. For a more realistic animation, we use a sinusoidal\nfunction to vary the displacement.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# feel free to change this to visualize different mode shapes\nmode_shape = 'disp_6'\n\n# copy the dataset as we will modify its coordinates\nds = dataset.copy()\n\npl = pv.Plotter(off_screen=True)\npl.add_mesh(ds, lighting=True, color='w')\npl.camera_position = cpos\npl.enable_anti_aliasing('fxaa')\n\nn_frames = 16\npl.open_gif(\"pump_bracket_mode_shape.gif\")\nfor phase in np.linspace(0, 2 * np.pi, n_frames, endpoint=False):\n # use the original unmodified points\n pl.update_coordinates(dataset.points + ds[mode_shape] * np.cos(phase) * 0.05)\n pl.write_frame()\n\npl.close()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file diff --git a/examples/99-advanced/ray-trace-moeller.ipynb b/examples/99-advanced/ray-trace-moeller.ipynb index 37fee52..1ff6a8e 100644 --- a/examples/99-advanced/ray-trace-moeller.ipynb +++ b/examples/99-advanced/ray-trace-moeller.ipynb @@ -55,7 +55,7 @@ }, "outputs": [], "source": [ - "if inter:\n\n # reconstruct intersection point in barycentric coordinates. See\n # https://en.wikipedia.org/wiki/Barycentric_coordinate_system\n a, b, c = (1 - u - v), u, v\n point = tri.points[0] * a + tri.points[1] * b + tri.points[2] * c\n\n pl = pv.Plotter()\n pl.add_text(f'Intersected at ({point[0]:.3}, {point[0]:.3}, {point[0]:.3})', font_size=26)\n pl.add_mesh(tri)\n _ = pl.add_arrows(\n np.array([start]),\n np.array([direction]),\n show_scalar_bar=False,\n color='r',\n style='wireframe',\n )\n pl.add_points(np.array([point]), point_size=20, render_points_as_spheres=True, color='b')\n pl.add_point_labels(tri, [f'a = {1 - u - v:.3}', f'b = {u:.3}', f'c = {v:.3}'], font_size=40)\n pl.show_bounds()\n pl.camera_position = 'xy'\n pl.show()\n\nelse: # no intersection\n pl = pv.Plotter()\n pl.add_text('No intersection')\n _ = pl.add_arrows(\n np.array([start]),\n np.array([direction]),\n show_scalar_bar=False,\n color='r',\n style='wireframe',\n )\n pl.add_mesh(tri)\n\n pl.show_bounds()\n pl.camera_position = 'xy'\n\n pl.show()" + "if inter:\n # reconstruct intersection point in barycentric coordinates. See\n # https://en.wikipedia.org/wiki/Barycentric_coordinate_system\n a, b, c = (1 - u - v), u, v\n point = tri.points[0] * a + tri.points[1] * b + tri.points[2] * c\n\n pl = pv.Plotter()\n pl.add_text(f'Intersected at ({point[0]:.3}, {point[0]:.3}, {point[0]:.3})', font_size=26)\n pl.add_mesh(tri)\n _ = pl.add_arrows(\n np.array([start]),\n np.array([direction]),\n show_scalar_bar=False,\n color='r',\n style='wireframe',\n )\n pl.add_points(np.array([point]), point_size=20, render_points_as_spheres=True, color='b')\n pl.add_point_labels(tri, [f'a = {1 - u - v:.3}', f'b = {u:.3}', f'c = {v:.3}'], font_size=40)\n pl.show_bounds()\n pl.camera_position = 'xy'\n pl.show()\n\nelse: # no intersection\n pl = pv.Plotter()\n pl.add_text('No intersection')\n _ = pl.add_arrows(\n np.array([start]),\n np.array([direction]),\n show_scalar_bar=False,\n color='r',\n style='wireframe',\n )\n pl.add_mesh(tri)\n\n pl.show_bounds()\n pl.camera_position = 'xy'\n\n pl.show()" ] } ], @@ -75,7 +75,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/99-advanced/ray-trace.ipynb b/examples/99-advanced/ray-trace.ipynb index d0b6392..aafecb7 100644 --- a/examples/99-advanced/ray-trace.ipynb +++ b/examples/99-advanced/ray-trace.ipynb @@ -46,7 +46,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/99-advanced/sphere_eversion.ipynb b/examples/99-advanced/sphere_eversion.ipynb index 8122235..50a8967 100644 --- a/examples/99-advanced/sphere_eversion.ipynb +++ b/examples/99-advanced/sphere_eversion.ipynb @@ -15,7 +15,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Turning the sphere inside out {#sphere_eversion_example}\n=============================\n\nThere are several videos online talking about how a sphere can be turned\ninside out in a continuous fashion, for instance in [this YouTube\nvideo](https://www.youtube.com/watch?v=OI-To1eUtuU). Thanks to [an\nexcellent paper by Adam Bednorz and Witold Bednorz, Differential and its\nApplications 64, 59\n(2019)](https://doi.org/10.1016/j.difgeo.2019.02.004) (also available\n[on arXiv](https://arxiv.org/abs/1711.10466)), we can plot this\nso-called eversion of a sphere (turning it inside out without pinching\nor tearing the surface, in other words by preserving its topology).\n\nThe mathematics involved can seem a bit, well, involved. What matters is\nthe overall process visible in the animation: first the sphere is\ncorrugated and stretched out a bit to allow some legroom for the smooth\ntransformation, then the lobes are twisted around through each other,\nand the process is reversed in order to unfold the sphere. It\\'s not\nobvious that the transformation is truly smooth; this was proved in the\npaper by Bednorz and Bednorz!\n" + "Turning the sphere inside out {#sphere_eversion_example}\n=============================\n\nThere are several videos online talking about how a sphere can be turned\ninside out in a continuous fashion, for instance in [this YouTube\nvideo](https://www.youtube.com/watch?v=OI-To1eUtuU). Thanks to [an\nexcellent paper by Adam Bednorz and Witold Bednorz, Differential and its\nApplications 64, 59\n(2019)](https://doi.org/10.1016/j.difgeo.2019.02.004) (also available\n[on arXiv](https://arxiv.org/abs/1711.10466)), we can plot this\nso-called eversion of a sphere (turning it inside out without pinching\nor tearing the surface, in other words by preserving its topology).\n\nThe mathematics involved can seem a bit, well, involved. What matters is\nthe overall process visible in the animation: first the sphere is\ncorrugated and stretched out a bit to allow some legroom for the smooth\ntransformation, then the lobes are twisted around through each other,\nand the process is reversed in order to unfold the sphere. It\\'s not\nobvious that the transformation is truly smooth; this was proved in the\npaper by Bednorz and Bednorz.\n" ] }, { @@ -100,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/examples/99-advanced/warp-by-vector-eigenmodes.ipynb b/examples/99-advanced/warp-by-vector-eigenmodes.ipynb index 4f15ce0..83f87f1 100644 --- a/examples/99-advanced/warp-by-vector-eigenmodes.ipynb +++ b/examples/99-advanced/warp-by-vector-eigenmodes.ipynb @@ -15,7 +15,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Displaying eigenmodes of vibration using `warp_by_vector`\n=========================================================\n\nThis example applies the `warp_by_vector` filter to a cube whose\neigenmodes have been computed using the Ritz method, as outlined in\nVisscher, William M., Albert Migliori, Thomas M. Bell, et Robert A.\nReinert. \\\"On the normal modes of free vibration of inhomogeneous and\nanisotropic elastic objects\\\". The Journal of the Acoustical Society of\nAmerica 90, n.4 (october 1991): 2154-62.\n\n" + "Display Eigenmodes of Vibration {#eigenmodes_example}\n===============================\n\nThis example applies the `warp_by_vector\n`{.interpreted-text role=\"func\"}\nfilter to a cube whose eigenmodes have been computed using the Ritz\nmethod, as outlined in Visscher, William M., Albert Migliori, Thomas M.\nBell, et Robert A. Reinert. \\\"On the normal modes of free vibration of\ninhomogeneous and anisotropic elastic objects\\\". The Journal of the\nAcoustical Society of America 90, n.4 (October 1991): 2154-62.\n\n" ] }, { @@ -51,7 +51,7 @@ }, "outputs": [], "source": [ - "# Create the 3D NumPy array of spatially referenced data\n# (nx by ny by nz)\nnx, ny, nz = 30, 31, 32\n\nx = np.linspace(-l1 / 2.0, l1 / 2.0, nx)\ny = np.linspace(-l2 / 2.0, l2 / 2.0, ny)\nx, y = np.meshgrid(x, y)\nz = np.zeros_like(x) + l3 / 2.0\ngrid = pv.StructuredGrid(x, y, z)\n\nslices = []\nfor zz in np.linspace(-l3 / 2.0, l3 / 2.0, nz)[::-1]:\n slice = grid.points.copy()\n slice[:, -1] = zz\n slices.append(slice)\n\nvol = pv.StructuredGrid()\nvol.points = np.vstack(slices)\nvol.dimensions = [*grid.dimensions[0:2], nz]\n\nfor i, mode_index in enumerate(mode_indices):\n eigenvector = vr[:, mode_index]\n displacement_points = np.zeros_like(vol.points)\n for weight, (component, p, q, r) in zip(eigenvector, quadruplets):\n displacement_points[:, component] += (\n weight * vol.points[:, 0] ** p * vol.points[:, 1] ** q * vol.points[:, 2] ** r\n )\n if displacement_points.max() > 0.0:\n displacement_points /= displacement_points.max()\n vol[f'eigenmode_{i:02}'] = displacement_points\n\nwarpby = 'eigenmode_00'\nwarped = vol.warp_by_vector(warpby, factor=0.04)\nwarped.translate([-1.5 * l1, 0.0, 0.0], inplace=True)\np = pv.Plotter()\np.add_mesh(vol, style='wireframe', scalars=warpby)\np.add_mesh(warped, scalars=warpby)\np.show()" + "# Create the 3D NumPy array of spatially referenced data\n# (nx by ny by nz)\nnx, ny, nz = 30, 31, 32\n\nx = np.linspace(-l1 / 2.0, l1 / 2.0, nx)\ny = np.linspace(-l2 / 2.0, l2 / 2.0, ny)\nx, y = np.meshgrid(x, y)\nz = np.zeros_like(x) + l3 / 2.0\ngrid = pv.StructuredGrid(x, y, z)\n\nslices = []\nfor zz in np.linspace(-l3 / 2.0, l3 / 2.0, nz)[::-1]:\n slice = grid.points.copy()\n slice[:, -1] = zz\n slices.append(slice)\n\nvol = pv.StructuredGrid()\nvol.points = np.vstack(slices)\nvol.dimensions = [*grid.dimensions[0:2], nz]\n\nfor i, mode_index in enumerate(mode_indices):\n eigenvector = vr[:, mode_index]\n displacement_points = np.zeros_like(vol.points)\n for weight, (component, p, q, r) in zip(eigenvector, quadruplets):\n displacement_points[:, component] += (\n weight * vol.points[:, 0] ** p * vol.points[:, 1] ** q * vol.points[:, 2] ** r\n )\n if displacement_points.max() > 0.0:\n displacement_points /= displacement_points.max()\n vol[f'eigenmode_{i:02}'] = displacement_points\n\nwarpby = 'eigenmode_00'\nwarped = vol.warp_by_vector(warpby, factor=0.04)\nwarped.translate([-1.5 * l1, 0.0, 0.0], inplace=True)\npl = pv.Plotter()\npl.add_mesh(vol, style='wireframe', scalars=warpby, show_scalar_bar=False)\npl.add_mesh(warped, scalars=warpby)\npl.show()" ] }, { @@ -69,7 +69,7 @@ }, "outputs": [], "source": [ - "p = pv.Plotter(shape=(2, 4))\nfor i in range(2):\n for j in range(4):\n p.subplot(i, j)\n current_index = 4 * i + j\n vector = f\"eigenmode_{current_index:02}\"\n p.add_text(\n f\"mode {current_index}, freq. {computed_freqs_kHz[current_index]:.1f} kHz\",\n font_size=10,\n )\n p.add_mesh(vol.warp_by_vector(vector, factor=0.03), scalars=vector)\np.show()" + "pl = pv.Plotter(shape=(2, 4))\nfor i in range(2):\n for j in range(4):\n pl.subplot(i, j)\n current_index = 4 * i + j\n vector = f\"eigenmode_{current_index:02}\"\n pl.add_text(\n f\"mode {current_index}, freq. {computed_freqs_kHz[current_index]:.1f} kHz\",\n font_size=10,\n )\n pl.add_mesh(vol.warp_by_vector(vector, factor=0.03), scalars=vector, show_scalar_bar=False)\npl.show()" ] } ], @@ -89,7 +89,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.3" } }, "nbformat": 4,