Skip to content

Commit 15e8515

Browse files
authored
Merge pull request #132 from marimeireles/nbs
Adds ipycytoscape ipygany nbs
2 parents 6c0dbb0 + 968f281 commit 15e8515

File tree

4 files changed

+985
-0
lines changed

4 files changed

+985
-0
lines changed

apt.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
xvfb

notebooks/07.05-ipycytoscape.ipynb

Lines changed: 755 additions & 0 deletions
Large diffs are not rendered by default.

notebooks/07.06-ipygany.ipynb

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "9b5fe04e",
6+
"metadata": {},
7+
"source": [
8+
"# ipygany: Interactive library for 3-D mesh analysis\n",
9+
"\n",
10+
"## A Jupyter - ParaView bridge\n",
11+
"\n",
12+
"## https://github.com/QuantStack/ipygany\n",
13+
"\n",
14+
"\n",
15+
"A widget enabling VTK loader, Structured and Unstructured grids, Animations, Point cloud visualization and a lot more for 3-D visualization\n",
16+
"\n",
17+
"- BSD-3-Clause License\n",
18+
"\n",
19+
"**Installation:**\n",
20+
"\n",
21+
"```bash\n",
22+
"conda install -c conda-forge ipygany\n",
23+
"```"
24+
]
25+
},
26+
{
27+
"cell_type": "markdown",
28+
"id": "8dbb294a",
29+
"metadata": {},
30+
"source": [
31+
"### Features\n",
32+
"\n",
33+
"* Warp\n",
34+
"* IsoColor\n",
35+
"* Threshold"
36+
]
37+
},
38+
{
39+
"cell_type": "code",
40+
"execution_count": null,
41+
"id": "940761d1",
42+
"metadata": {},
43+
"outputs": [],
44+
"source": [
45+
"# Preparing example's data\n",
46+
"from pyvista import examples\n",
47+
"import numpy as np\n",
48+
"\n",
49+
"from ipywidgets import VBox, FloatSlider\n",
50+
"from ipygany import PolyMesh, Scene, IsoColor, WarpByScalar\n",
51+
"\n",
52+
"pvmesh = examples.download_topo_global()\n",
53+
"ugrid = pvmesh.cast_to_unstructured_grid()"
54+
]
55+
},
56+
{
57+
"cell_type": "code",
58+
"execution_count": null,
59+
"id": "d76c80c3",
60+
"metadata": {},
61+
"outputs": [],
62+
"source": [
63+
"from ipygany import PolyMesh, Scene, IsoColor, WarpByScalar"
64+
]
65+
},
66+
{
67+
"cell_type": "code",
68+
"execution_count": null,
69+
"id": "4d71e5ed",
70+
"metadata": {},
71+
"outputs": [],
72+
"source": [
73+
"# Turn the PyVista mesh into a PolyMesh\n",
74+
"mesh = PolyMesh.from_vtk(ugrid)"
75+
]
76+
},
77+
{
78+
"cell_type": "code",
79+
"execution_count": null,
80+
"id": "12c38a02",
81+
"metadata": {},
82+
"outputs": [],
83+
"source": [
84+
"# Configure color mesh\n",
85+
"colored_mesh = IsoColor(mesh, min=-10421.0, max=6527.0)\n",
86+
"warped_mesh = WarpByScalar(colored_mesh, input='altitude', factor=0.5e-5)"
87+
]
88+
},
89+
{
90+
"cell_type": "code",
91+
"execution_count": null,
92+
"id": "c66cdfbc",
93+
"metadata": {},
94+
"outputs": [],
95+
"source": [
96+
"# Link a slider to the warp value\n",
97+
"warp_slider = FloatSlider(min=0., max=5., value=0.5)\n",
98+
"\n",
99+
"def on_slider_change(change):\n",
100+
" warped_mesh.factor = change['new'] * 1e-5"
101+
]
102+
},
103+
{
104+
"cell_type": "code",
105+
"execution_count": null,
106+
"id": "3ecc9a3e",
107+
"metadata": {},
108+
"outputs": [],
109+
"source": [
110+
"warp_slider.observe(on_slider_change, 'value')\n",
111+
"\n",
112+
"VBox((warp_slider, Scene([warped_mesh])))"
113+
]
114+
},
115+
{
116+
"cell_type": "code",
117+
"execution_count": null,
118+
"id": "131435f0",
119+
"metadata": {},
120+
"outputs": [],
121+
"source": [
122+
"from ipygany import ColorBar, colormaps"
123+
]
124+
},
125+
{
126+
"cell_type": "code",
127+
"execution_count": null,
128+
"id": "6a98b368",
129+
"metadata": {},
130+
"outputs": [],
131+
"source": [
132+
"bar = ColorBar(colored_mesh)\n",
133+
"bar"
134+
]
135+
},
136+
{
137+
"cell_type": "markdown",
138+
"id": "9aeddeb8",
139+
"metadata": {},
140+
"source": [
141+
"* Blues\n",
142+
"* Cividis\n",
143+
"* Greys\n",
144+
"* CubehelixDefault\n",
145+
"* Inferno"
146+
]
147+
},
148+
{
149+
"cell_type": "code",
150+
"execution_count": null,
151+
"id": "acbd0ac5",
152+
"metadata": {},
153+
"outputs": [],
154+
"source": [
155+
"colored_mesh.colormap = colormaps.Blues"
156+
]
157+
},
158+
{
159+
"cell_type": "code",
160+
"execution_count": null,
161+
"id": "6d946612",
162+
"metadata": {},
163+
"outputs": [],
164+
"source": [
165+
"from ipygany import TetraMesh,Threshold"
166+
]
167+
},
168+
{
169+
"cell_type": "code",
170+
"execution_count": null,
171+
"id": "109f0156",
172+
"metadata": {},
173+
"outputs": [],
174+
"source": [
175+
"mesh2 = TetraMesh.from_vtk('images/piston.vtu')\n",
176+
"\n",
177+
"iso2 = IsoColor(mesh2, input=('RESU____DEPL', 'DX'), min=-1.3931281e-06, max=1.3929895e-06)\n",
178+
"\n",
179+
"scene2 = Scene([iso2])\n",
180+
"scene2"
181+
]
182+
},
183+
{
184+
"cell_type": "code",
185+
"execution_count": null,
186+
"id": "7dffdcb6",
187+
"metadata": {},
188+
"outputs": [],
189+
"source": [
190+
"th = Threshold(iso2, input=('RESU____DEPL', 'DX'), min=-1.3931281e-06, max=1.0e-06)\n",
191+
"\n",
192+
"scene3 = Scene([th])\n",
193+
"\n",
194+
"scene3"
195+
]
196+
},
197+
{
198+
"cell_type": "code",
199+
"execution_count": null,
200+
"id": "efff1297",
201+
"metadata": {},
202+
"outputs": [],
203+
"source": [
204+
"th.max = 1.0e-09"
205+
]
206+
}
207+
],
208+
"metadata": {
209+
"kernelspec": {
210+
"display_name": "widgets-tutorial",
211+
"language": "python",
212+
"name": "widgets-tutorial"
213+
},
214+
"language_info": {
215+
"codemirror_mode": {
216+
"name": "ipython",
217+
"version": 3
218+
},
219+
"file_extension": ".py",
220+
"mimetype": "text/x-python",
221+
"name": "python",
222+
"nbconvert_exporter": "python",
223+
"pygments_lexer": "ipython3",
224+
"version": "3.8.0"
225+
}
226+
},
227+
"nbformat": 4,
228+
"nbformat_minor": 5
229+
}

notebooks/images/piston.vtu

4.46 MB
Binary file not shown.

0 commit comments

Comments
 (0)