From fa1c14142f3d9c621d32a7fed3cdc539c08b9a59 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Wed, 1 Jul 2020 18:07:24 +0200 Subject: [PATCH] clarify Visualization notebook and fix path in the doc --- Docs/source/visualization/yt.rst | 2 +- Tools/PostProcessing/Visualization.ipynb | 49 +++++++++++++++--------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/Docs/source/visualization/yt.rst b/Docs/source/visualization/yt.rst index cffd35773a3..b939b3b85ce 100644 --- a/Docs/source/visualization/yt.rst +++ b/Docs/source/visualization/yt.rst @@ -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 ~~~~~~~~~~ diff --git a/Tools/PostProcessing/Visualization.ipynb b/Tools/PostProcessing/Visualization.ipynb index 71f482afb43..8dd2f344161 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." ] }, { @@ -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": {}, @@ -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",