aboutsummaryrefslogtreecommitdiff
path: root/Tools/PostProcessing/Visualization.ipynb
diff options
context:
space:
mode:
authorGravatar MaxThevenet <mthevenet@lbl.gov> 2020-07-02 02:33:15 +0200
committerGravatar GitHub <noreply@github.com> 2020-07-01 17:33:15 -0700
commitc8d587eeaaeaf8cb07f7c67f4639412bb3202ebd (patch)
tree5ee3ca221bd8af1c74da833252b93c410cafae28 /Tools/PostProcessing/Visualization.ipynb
parente926ffce49e9a94b512044379940476ac7b2626c (diff)
downloadWarpX-c8d587eeaaeaf8cb07f7c67f4639412bb3202ebd.tar.gz
WarpX-c8d587eeaaeaf8cb07f7c67f4639412bb3202ebd.tar.zst
WarpX-c8d587eeaaeaf8cb07f7c67f4639412bb3202ebd.zip
clarify Visualization notebook and fix path in the doc (#1137)
Diffstat (limited to '')
-rw-r--r--Tools/PostProcessing/Visualization.ipynb49
1 files changed, 30 insertions, 19 deletions
diff --git a/Tools/PostProcessing/Visualization.ipynb b/Tools/PostProcessing/Visualization.ipynb
index 71f482afb..8dd2f3441 100644
--- a/Tools/PostProcessing/Visualization.ipynb
+++ b/Tools/PostProcessing/Visualization.ipynb
@@ -6,11 +6,7 @@
"source": [
"# Overview\n",
"\n",
- "This a notebook that inspects the results of a WarpX simulation.\n",
- "\n",
- "# Instruction\n",
- "\n",
- "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`"
+ "This a notebook that inspects the results of a WarpX simulation."
]
},
{
@@ -38,6 +34,28 @@
"cell_type": "markdown",
"metadata": {},
"source": [
+ "# Instruction\n",
+ "\n",
+ "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`"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "plotfile = './diags/plotfiles/plt00001'\n",
+ "field = 'Ex'\n",
+ "species = 'electron'\n",
+ "ds = yt.load( plotfile ) # Load the plotfile\n",
+ "# ds.field_list # Print all available quantities"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
"### Plot data with yt"
]
},
@@ -47,12 +65,10 @@
"metadata": {},
"outputs": [],
"source": [
- "ds = yt.load( '../Examples/Modules/RigidInjection/diags/plotfiles/plt00318/' ) # Create a dataset object\n",
- "sl = yt.SlicePlot(ds, 2, 'Ex', aspect=.2) # Create a sliceplot object\n",
- "sl.annotate_particles(width=(10.e-6, 'm'), p_size=2, ptype='beam', col='black')\n",
+ "sl = yt.SlicePlot(ds, 2, field, aspect=.2) # Create a sliceplot object\n",
+ "sl.annotate_particles(width=(10.e-6, 'm'), p_size=2, ptype=species, col='black')\n",
"sl.annotate_grids() # Show grids\n",
- "sl.show() # Show the plot\n",
- "# sl.save('./toto.png')"
+ "sl.show() # Show the plot"
]
},
{
@@ -70,23 +86,20 @@
"source": [
"# Get field quantities\n",
"all_data_level_0 = ds.covering_grid(level=0,left_edge=ds.domain_left_edge, dims=ds.domain_dimensions)\n",
- "Bx = all_data_level_0['boxlib', 'Ex'].v.squeeze()\n",
+ "Bx = all_data_level_0['boxlib', field].v.squeeze()\n",
"Dx = ds.domain_width/ds.domain_dimensions\n",
"extent = [ds.domain_left_edge[ds.dimensionality-1], ds.domain_right_edge[ds.dimensionality-1],\n",
" ds.domain_left_edge[0], ds.domain_right_edge[0] ]\n",
"\n",
"# Get particle quantities\n",
"ad = ds.all_data()\n",
- "x = ad['beam', 'particle_position_x'].v\n",
- "z = ad['beam', 'particle_position_y'].v\n",
+ "x = ad[species, 'particle_position_x'].v\n",
+ "z = ad[species, 'particle_position_y'].v\n",
"\n",
"# Plot image\n",
"plt.figure()\n",
"plt.imshow(Bx, extent=extent)\n",
- "plt.scatter(z,x,s=.1,c='k')\n",
- "\n",
- "# Print all available quantities\n",
- "ds.field_list"
+ "plt.scatter(z,x,s=.1,c='k')"
]
},
{
@@ -113,9 +126,7 @@
"metadata": {},
"outputs": [],
"source": [
- "species = 'beam'\n",
"iteration = 1\n",
- "field = 'Ex'\n",
"\n",
"snapshot = './lab_frame_data/' + 'snapshot' + str(iteration).zfill(5)\n",
"header = './lab_frame_data/Header'\n",