Skip to content

Commit b3f96e7

Browse files
authored
Merge pull request #5256 from chrishavlin/fix_tfh_tutorial
fix/update tfh tutorial
2 parents 42c1bc3 + 8ab972f commit b3f96e7

File tree

1 file changed

+27
-42
lines changed

1 file changed

+27
-42
lines changed

doc/source/visualizing/TransferFunctionHelper_Tutorial.ipynb

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"collapsed": false,
2424
"jupyter": {
2525
"outputs_hidden": false
26-
}
26+
},
27+
"tags": []
2728
},
2829
"outputs": [],
2930
"source": [
@@ -33,16 +34,7 @@
3334
"import yt\n",
3435
"from yt.visualization.volume_rendering.transfer_function_helper import (\n",
3536
" TransferFunctionHelper,\n",
36-
")\n",
37-
"\n",
38-
"\n",
39-
"def showme(im):\n",
40-
" # screen out NaNs\n",
41-
" im[im != im] = 0.0\n",
42-
"\n",
43-
" # Create an RGBA bitmap to display\n",
44-
" imb = yt.write_bitmap(im, None)\n",
45-
" return Image(imb)"
37+
")"
4638
]
4739
},
4840
{
@@ -59,7 +51,8 @@
5951
"collapsed": false,
6052
"jupyter": {
6153
"outputs_hidden": false
62-
}
54+
},
55+
"tags": []
6356
},
6457
"outputs": [],
6558
"source": [
@@ -80,7 +73,8 @@
8073
"collapsed": false,
8174
"jupyter": {
8275
"outputs_hidden": false
83-
}
76+
},
77+
"tags": []
8478
},
8579
"outputs": [],
8680
"source": [
@@ -101,7 +95,8 @@
10195
"collapsed": false,
10296
"jupyter": {
10397
"outputs_hidden": false
104-
}
98+
},
99+
"tags": []
105100
},
106101
"outputs": [],
107102
"source": [
@@ -129,7 +124,8 @@
129124
"collapsed": false,
130125
"jupyter": {
131126
"outputs_hidden": false
132-
}
127+
},
128+
"tags": []
133129
},
134130
"outputs": [],
135131
"source": [
@@ -150,7 +146,8 @@
150146
"collapsed": false,
151147
"jupyter": {
152148
"outputs_hidden": false
153-
}
149+
},
150+
"tags": []
154151
},
155152
"outputs": [],
156153
"source": [
@@ -159,15 +156,6 @@
159156
"tfh.set_bounds()\n",
160157
"tfh.set_log(True)\n",
161158
"tfh.build_transfer_function()\n",
162-
"tfh.tf.add_layers(\n",
163-
" 8,\n",
164-
" w=0.01,\n",
165-
" mi=4.0,\n",
166-
" ma=8.0,\n",
167-
" col_bounds=[4.0, 8.0],\n",
168-
" alpha=np.logspace(-1, 2, 7),\n",
169-
" colormap=\"RdBu_r\",\n",
170-
")\n",
171159
"tfh.tf.map_to_colormap(6.0, 8.0, colormap=\"Reds\")\n",
172160
"tfh.tf.map_to_colormap(-1.0, 6.0, colormap=\"Blues_r\")\n",
173161
"\n",
@@ -196,11 +184,17 @@
196184
"\n",
197185
"source = sc.get_source()\n",
198186
"source.set_transfer_function(tfh.tf)\n",
199-
"im2 = sc.render()\n",
200-
"\n",
201-
"showme(im2[:, :, :3])"
187+
"sc.render()\n",
188+
"sc.show()"
202189
]
203190
},
191+
{
192+
"cell_type": "code",
193+
"execution_count": null,
194+
"metadata": {},
195+
"outputs": [],
196+
"source": []
197+
},
204198
{
205199
"cell_type": "markdown",
206200
"metadata": {},
@@ -215,7 +209,8 @@
215209
"collapsed": false,
216210
"jupyter": {
217211
"outputs_hidden": false
218-
}
212+
},
213+
"tags": []
219214
},
220215
"outputs": [],
221216
"source": [
@@ -224,15 +219,6 @@
224219
"tfh2.set_bounds()\n",
225220
"tfh2.set_log(True)\n",
226221
"tfh2.build_transfer_function()\n",
227-
"tfh2.tf.add_layers(\n",
228-
" 8,\n",
229-
" w=0.01,\n",
230-
" mi=4.0,\n",
231-
" ma=8.0,\n",
232-
" col_bounds=[4.0, 8.0],\n",
233-
" alpha=np.logspace(-1, 2, 7),\n",
234-
" colormap=\"RdBu_r\",\n",
235-
")\n",
236222
"tfh2.tf.map_to_colormap(6.0, 8.0, colormap=\"Reds\", scale=5.0)\n",
237223
"tfh2.tf.map_to_colormap(-1.0, 6.0, colormap=\"Blues_r\", scale=1.0)\n",
238224
"\n",
@@ -258,9 +244,8 @@
258244
"outputs": [],
259245
"source": [
260246
"source.set_transfer_function(tfh2.tf)\n",
261-
"im3 = sc.render()\n",
262-
"\n",
263-
"showme(im3[:, :, :3])"
247+
"sc.render()\n",
248+
"sc.show()"
264249
]
265250
},
266251
{
@@ -287,7 +272,7 @@
287272
"name": "python",
288273
"nbconvert_exporter": "python",
289274
"pygments_lexer": "ipython3",
290-
"version": "3.10.12"
275+
"version": "3.10.11"
291276
}
292277
},
293278
"nbformat": 4,

0 commit comments

Comments
 (0)