Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify Visualization notebook and fix path in the doc #1137

Merged
merged 1 commit into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am asking out of curiosity only.
Why not?

Suggested change
"species = 'electron'\n",
"species = 'beam'\n",

As the script was doing before.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just illustrative, I changed it because I tested it on an example with an electron. Maybe we could keep it this way, just to avoid re-running all the tests, what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, of course!!

"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