Skip to content

Commit c8d587e

Browse files
authored
clarify Visualization notebook and fix path in the doc (#1137)
1 parent e926ffc commit c8d587e

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

Docs/source/visualization/yt.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The list of field data and particle data stored can be seen with:
4343

4444
For a quick start-up, the most useful commands for post-processing can be found
4545
in our Jupyter notebook
46-
:download:`Visualization.ipynb<../../../Tools/Visualization.ipynb>`
46+
:download:`Visualization.ipynb<../../../Tools/PostProcessing/Visualization.ipynb>`
4747

4848
Field data
4949
~~~~~~~~~~

Tools/PostProcessing/Visualization.ipynb

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
"source": [
77
"# Overview\n",
88
"\n",
9-
"This a notebook that inspects the results of a WarpX simulation.\n",
10-
"\n",
11-
"# Instruction\n",
12-
"\n",
13-
"Enter the path of the data you wish to visualize below. Then execute the cells one by one, by selecting them with your mouse and typing `Shift + Enter`"
9+
"This a notebook that inspects the results of a WarpX simulation."
1410
]
1511
},
1612
{
@@ -34,6 +30,28 @@
3430
"## Read data in the simulation frame"
3531
]
3632
},
33+
{
34+
"cell_type": "markdown",
35+
"metadata": {},
36+
"source": [
37+
"# Instruction\n",
38+
"\n",
39+
"Enter the path of the data you wish to visualize below. Then execute the cells one by one, by selecting them with your mouse and typing `Shift + Enter`"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": null,
45+
"metadata": {},
46+
"outputs": [],
47+
"source": [
48+
"plotfile = './diags/plotfiles/plt00001'\n",
49+
"field = 'Ex'\n",
50+
"species = 'electron'\n",
51+
"ds = yt.load( plotfile ) # Load the plotfile\n",
52+
"# ds.field_list # Print all available quantities"
53+
]
54+
},
3755
{
3856
"cell_type": "markdown",
3957
"metadata": {},
@@ -47,12 +65,10 @@
4765
"metadata": {},
4866
"outputs": [],
4967
"source": [
50-
"ds = yt.load( '../Examples/Modules/RigidInjection/diags/plotfiles/plt00318/' ) # Create a dataset object\n",
51-
"sl = yt.SlicePlot(ds, 2, 'Ex', aspect=.2) # Create a sliceplot object\n",
52-
"sl.annotate_particles(width=(10.e-6, 'm'), p_size=2, ptype='beam', col='black')\n",
68+
"sl = yt.SlicePlot(ds, 2, field, aspect=.2) # Create a sliceplot object\n",
69+
"sl.annotate_particles(width=(10.e-6, 'm'), p_size=2, ptype=species, col='black')\n",
5370
"sl.annotate_grids() # Show grids\n",
54-
"sl.show() # Show the plot\n",
55-
"# sl.save('./toto.png')"
71+
"sl.show() # Show the plot"
5672
]
5773
},
5874
{
@@ -70,23 +86,20 @@
7086
"source": [
7187
"# Get field quantities\n",
7288
"all_data_level_0 = ds.covering_grid(level=0,left_edge=ds.domain_left_edge, dims=ds.domain_dimensions)\n",
73-
"Bx = all_data_level_0['boxlib', 'Ex'].v.squeeze()\n",
89+
"Bx = all_data_level_0['boxlib', field].v.squeeze()\n",
7490
"Dx = ds.domain_width/ds.domain_dimensions\n",
7591
"extent = [ds.domain_left_edge[ds.dimensionality-1], ds.domain_right_edge[ds.dimensionality-1],\n",
7692
" ds.domain_left_edge[0], ds.domain_right_edge[0] ]\n",
7793
"\n",
7894
"# Get particle quantities\n",
7995
"ad = ds.all_data()\n",
80-
"x = ad['beam', 'particle_position_x'].v\n",
81-
"z = ad['beam', 'particle_position_y'].v\n",
96+
"x = ad[species, 'particle_position_x'].v\n",
97+
"z = ad[species, 'particle_position_y'].v\n",
8298
"\n",
8399
"# Plot image\n",
84100
"plt.figure()\n",
85101
"plt.imshow(Bx, extent=extent)\n",
86-
"plt.scatter(z,x,s=.1,c='k')\n",
87-
"\n",
88-
"# Print all available quantities\n",
89-
"ds.field_list"
102+
"plt.scatter(z,x,s=.1,c='k')"
90103
]
91104
},
92105
{
@@ -113,9 +126,7 @@
113126
"metadata": {},
114127
"outputs": [],
115128
"source": [
116-
"species = 'beam'\n",
117129
"iteration = 1\n",
118-
"field = 'Ex'\n",
119130
"\n",
120131
"snapshot = './lab_frame_data/' + 'snapshot' + str(iteration).zfill(5)\n",
121132
"header = './lab_frame_data/Header'\n",

0 commit comments

Comments
 (0)