Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
akaszynski committed May 5, 2023
1 parent dd92506 commit 5ac4005
Show file tree
Hide file tree
Showing 158 changed files with 1,025 additions and 215 deletions.
6 changes: 3 additions & 3 deletions examples/00-load/create-explicit-structured-grid.ipynb
Expand Up @@ -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"
]
},
{
Expand All @@ -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)"
]
}
],
Expand All @@ -46,7 +46,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions examples/00-load/create-geometric-objects.ipynb
Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -82,7 +82,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/00-load/create-kochanek-spline.ipynb
Expand Up @@ -82,7 +82,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/00-load/create-parametric-geometric-objects.ipynb
Expand Up @@ -478,7 +478,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/00-load/create-pixel-art.ipynb
Expand Up @@ -100,7 +100,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions examples/00-load/create-platonic-solids.ipynb
Expand Up @@ -33,7 +33,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We can either use the generic\n`PlatonicSolid() <pyvista.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<pyvista.examples.downloads.download_teapot>`{.interpreted-text\nrole=\"func\"}.\n"
"We can either use the generic\n`PlatonicSolid() <pyvista.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<pyvista.examples.downloads.download_teapot>`{.interpreted-text\nrole=\"func\"}.\n"
]
},
{
Expand Down Expand Up @@ -89,7 +89,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions examples/00-load/create-point-cloud.ipynb
Expand Up @@ -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, :]"
]
},
{
Expand Down Expand Up @@ -201,7 +201,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/00-load/create-pointset.ipynb
Expand Up @@ -100,7 +100,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/00-load/create-poly.ipynb
Expand Up @@ -82,7 +82,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/00-load/create-polydata-strips.ipynb
Expand Up @@ -154,7 +154,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/00-load/create-polyhedron.ipynb
Expand Up @@ -172,7 +172,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/00-load/create-spline.ipynb
Expand Up @@ -201,7 +201,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions examples/00-load/create-structured-surface.ipynb
Expand Up @@ -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\")"
]
},
{
Expand Down Expand Up @@ -194,7 +194,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
10 changes: 5 additions & 5 deletions examples/00-load/create-surface-draped.ipynb
Expand Up @@ -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"
]
},
{
Expand All @@ -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()"
]
},
{
Expand All @@ -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"
]
},
{
Expand Down Expand Up @@ -122,7 +122,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/00-load/create-tri-surface.ipynb
Expand Up @@ -172,7 +172,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/00-load/create-truss.ipynb
Expand Up @@ -82,7 +82,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions examples/00-load/create-uniform-grid.ipynb
Expand Up @@ -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)"
]
},
{
Expand All @@ -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)"
]
}
],
Expand All @@ -89,7 +89,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 5ac4005

Please sign in to comment.