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

update the "Reading and plotting manually" portion of docs #304

Merged
merged 1 commit into from
Dec 13, 2024
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
Binary file modified docs/source/manual_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 28 additions & 7 deletions docs/source/output.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,41 @@ Reading and plotting manually
pyro output data can be read using the :func:`util.io_pyro.read <pyro.util.io_pyro.read>` method. The following
sequence (done in a python session) reads in stored data (from the
compressible Sedov problem) and plots data falling on a line in the x
direction through the y-center of the domain (note: this will include
the ghost cells).
direction through the y-center of the domain. The return value of
``read`` is a ``Simulation`` object.


.. code-block:: python

import matplotlib.pyplot as plt
import pyro.util.io_pyro as io
sim = io.read("sedov_unsplit_0000.h5")

sim = io.read("sedov_unsplit_0290.h5")
dens = sim.cc_data.get_var("density")
plt.plot(dens.g.x, dens[:,dens.g.ny//2])
plt.show()

fig, ax = plt.subplots()
ax.plot(dens.g.x, dens[:,dens.g.qy//2])
ax.grid()

.. image:: manual_plot.png
:align: center

Note: this includes the ghost cells, by default, seen as the small
regions of zeros on the left and right.
.. note::

This includes the ghost cells, by default, seen as the small
regions of zeros on the left and right. The total number of cells,
including ghost cells in the y-direction is ``qy``, which is why
we use that in our slice.

If we wanted to exclude the ghost cells, then we could use the ``.v()`` method
on the density array to exclude the ghost cells, and then manually index ``g.x``
to just include the valid part of the domain:

.. code:: python

ax.plot(dens.g.x[g.ilo:g.ihi+1], dens.v()[:, dens.g.ny//2])

.. note::

In this case, we are using ``ny`` since that is the width of the domain
excluding ghost cells.
Loading