Skip to content

Commit

Permalink
clarify Visualization notebook and fix path in the doc (#1137)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxThevenet authored Jul 2, 2020
1 parent e926ffc commit c8d587e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Docs/source/visualization/yt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The list of field data and particle data stored can be seen with:

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

Field data
~~~~~~~~~~
Expand Down
49 changes: 30 additions & 19 deletions Tools/PostProcessing/Visualization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
]
},
{
Expand All @@ -34,6 +30,28 @@
"## Read data in the simulation frame"
]
},
{
"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": {},
Expand All @@ -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"
]
},
{
Expand All @@ -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')"
]
},
{
Expand All @@ -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",
Expand Down

0 comments on commit c8d587e

Please sign in to comment.