Skip to content

Commit 8f5723c

Browse files
authored
update the "Reading and plotting manually" portion of docs (#304)
this adds how to exclude ghost cells.
1 parent 89a07d7 commit 8f5723c

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

docs/source/manual_plot.png

793 Bytes
Loading

docs/source/output.rst

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,41 @@ Reading and plotting manually
4242
pyro output data can be read using the :func:`util.io_pyro.read <pyro.util.io_pyro.read>` method. The following
4343
sequence (done in a python session) reads in stored data (from the
4444
compressible Sedov problem) and plots data falling on a line in the x
45-
direction through the y-center of the domain (note: this will include
46-
the ghost cells).
45+
direction through the y-center of the domain. The return value of
46+
``read`` is a ``Simulation`` object.
47+
4748

4849
.. code-block:: python
4950
5051
import matplotlib.pyplot as plt
5152
import pyro.util.io_pyro as io
52-
sim = io.read("sedov_unsplit_0000.h5")
53+
54+
sim = io.read("sedov_unsplit_0290.h5")
5355
dens = sim.cc_data.get_var("density")
54-
plt.plot(dens.g.x, dens[:,dens.g.ny//2])
55-
plt.show()
56+
57+
fig, ax = plt.subplots()
58+
ax.plot(dens.g.x, dens[:,dens.g.qy//2])
59+
ax.grid()
5660
5761
.. image:: manual_plot.png
5862
:align: center
5963

60-
Note: this includes the ghost cells, by default, seen as the small
61-
regions of zeros on the left and right.
64+
.. note::
65+
66+
This includes the ghost cells, by default, seen as the small
67+
regions of zeros on the left and right. The total number of cells,
68+
including ghost cells in the y-direction is ``qy``, which is why
69+
we use that in our slice.
70+
71+
If we wanted to exclude the ghost cells, then we could use the ``.v()`` method
72+
on the density array to exclude the ghost cells, and then manually index ``g.x``
73+
to just include the valid part of the domain:
74+
75+
.. code:: python
76+
77+
ax.plot(dens.g.x[g.ilo:g.ihi+1], dens.v()[:, dens.g.ny//2])
78+
79+
.. note::
80+
81+
In this case, we are using ``ny`` since that is the width of the domain
82+
excluding ghost cells.

0 commit comments

Comments
 (0)