Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
akaszynski committed Mar 8, 2023
0 parents commit e1d576c
Show file tree
Hide file tree
Showing 160 changed files with 20,605 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/docker.yml
@@ -0,0 +1,45 @@
name: Docker Package
on:
workflow_dispatch:
push:
pull_request:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-publish:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || ( github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository )
steps:
- uses: actions/checkout@v2
- name: Log into the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: token
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for the Docker image
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Set Docker tag based on branch
run: |
if {{ github.ref == 'refs/heads/master' }}
then
echo "BASE_IMAGE_TAG=latest" >> $GITHUB_ENV
else
echo "BASE_IMAGE_TAG=main" >> $GITHUB_ENV
fi
- name: Build and push the Docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BASE_IMAGE_TAG=${{ env.BASE_IMAGE_TAG }}
37 changes: 37 additions & 0 deletions .gitignore
@@ -0,0 +1,37 @@
MANIFEST
build
dist
_build
notebook/i18n/*/LC_MESSAGES/*.mo
notebook/i18n/*/LC_MESSAGES/nbjs.json
notebook/static/components
notebook/static/style/*.min.css*
notebook/static/*/js/built/
notebook/static/*/built/
notebook/static/built/
notebook/static/*/js/main.min.js*
notebook/static/lab/*bundle.js
node_modules
*.py[co]
__pycache__
*.egg-info
*~
*.bak
.ipynb_checkpoints
.tox
.DS_Store
\#*#
.#*
.coverage
src

*.swp
*.map
.idea/
Read the Docs
config.rst

/.project
/.pydevproject

package-lock.json
Empty file added .nojekyll
Empty file.
6 changes: 6 additions & 0 deletions Dockerfile
@@ -0,0 +1,6 @@
ARG BASE_IMAGE_TAG=latest
FROM ghcr.io/pyvista/pyvista:$BASE_IMAGE_TAG

COPY . ${HOME}
WORKDIR ${HOME}
RUN pip install -r requirements.txt
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
The MIT License

Copyright (c) 2023, PyVista Developers
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
19 changes: 19 additions & 0 deletions README.rst
@@ -0,0 +1,19 @@
pyvista-examples
================

.. image:: https://mybinder.org/badge_logo.svg
:target: https://mybinder.org/v2/gh/pyvista/pyvista-examples/master
:alt: Launch on Binder


Quick examples demonstrating what PyVista can do! Simply launch this Binder project and test drive PyVista



Credits
-------

This project was created with `Cookiecutter`_ and the `pyvista/cookiecutter-pyvista-binder`_ project template.

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`pyvista/cookiecutter-pyvista-binder`: https://github.com/pyvista/cookiecutter-pyvista-binder
54 changes: 54 additions & 0 deletions examples/00-load/create-explicit-structured-grid.ipynb
@@ -0,0 +1,54 @@
{
"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": [
"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"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"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)"
]
}
],
"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.9.16"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
90 changes: 90 additions & 0 deletions examples/00-load/create-geometric-objects.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": [
"Geometric Objects {#ref_geometric_example}\n=================\n\nThe \\\"Hello, world!\\\" of VTK\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import pyvista as pv"
]
},
{
"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"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"cyl = pv.Cylinder()\narrow = pv.Arrow()\nsphere = pv.Sphere()\nplane = pv.Plane()\nline = pv.Line()\nbox = pv.Box()\ncone = pv.Cone()\npoly = pv.Polygon()\ndisc = pv.Disc()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now let\\'s plot them all in one window\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"p = pv.Plotter(shape=(3, 3))\n# Top row\np.subplot(0, 0)\np.add_mesh(cyl, color=\"tan\", show_edges=True)\np.subplot(0, 1)\np.add_mesh(arrow, color=\"tan\", show_edges=True)\np.subplot(0, 2)\np.add_mesh(sphere, color=\"tan\", show_edges=True)\n# Middle row\np.subplot(1, 0)\np.add_mesh(plane, color=\"tan\", show_edges=True)\np.subplot(1, 1)\np.add_mesh(line, color=\"tan\", line_width=3)\np.subplot(1, 2)\np.add_mesh(box, color=\"tan\", show_edges=True)\n# Bottom row\np.subplot(2, 0)\np.add_mesh(cone, color=\"tan\", show_edges=True)\np.subplot(2, 1)\np.add_mesh(poly, color=\"tan\", show_edges=True)\np.subplot(2, 2)\np.add_mesh(disc, color=\"tan\", show_edges=True)\n# Render all of them\np.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.9.16"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
90 changes: 90 additions & 0 deletions examples/00-load/create-kochanek-spline.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": [
"Create a Kochanek Spline {#create_kochanek_spline_example}\n========================\n\nCreate a Kochanek spline/polyline from a numpy array of XYZ vertices.\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": [
"Create a dataset to plot\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def make_points():\n \"\"\"Helper to make XYZ points\"\"\"\n theta = np.linspace(-4 * np.pi, 4 * np.pi, 6)\n z = np.linspace(-2, 2, 6)\n r = z**2 + 1\n x = r * np.sin(theta)\n y = r * np.cos(theta)\n return np.column_stack((x, y, z))\n\n\npoints = make_points()\npoints[0:5, :]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Interpolate those points onto a parametric Kochanek spline\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Create Kochanek spline with 6 interpolation points\np = pv.Plotter(shape=(3, 5))\n\nc = [-1.0, -0.5, 0.0, 0.5, 1.0]\nfor i in range(5):\n kochanek_spline = pv.KochanekSpline(points, continuity=[c[i], c[i], c[i]], n_points=1000)\n p.subplot(0, i)\n p.add_text(\"c = \" + str(c[i]))\n p.add_mesh(kochanek_spline, color=\"k\", point_size=10)\n p.add_mesh(\n pv.PolyData(points),\n color=\"k\",\n point_size=10,\n render_points_as_spheres=True,\n )\n\nt = [-1.0, -0.5, 0.0, 0.5, 1.0]\nfor i in range(5):\n kochanek_spline = pv.KochanekSpline(points, tension=[t[i], t[i], t[i]], n_points=1000)\n p.subplot(1, i)\n p.add_text(\"t = \" + str(t[i]))\n p.add_mesh(kochanek_spline, color=\"k\")\n p.add_mesh(\n pv.PolyData(points),\n color=\"k\",\n point_size=10,\n render_points_as_spheres=True,\n )\n\nb = [-1.0, -0.5, 0.0, 0.5, 1.0]\nfor i in range(5):\n kochanek_spline = pv.KochanekSpline(points, bias=[b[i], b[i], b[i]], n_points=1000)\n p.subplot(2, i)\n p.add_text(\"b = \" + str(b[i]))\n p.add_mesh(kochanek_spline, color=\"k\")\n p.add_mesh(\n pv.PolyData(points),\n color=\"k\",\n point_size=10,\n render_points_as_spheres=True,\n )\n\np.show(cpos=\"xy\")"
]
}
],
"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.9.16"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

0 comments on commit e1d576c

Please sign in to comment.