.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/co2_leakage_along_a_fault/4_import_and_visualize_simulation_outputs_in_pyvista.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_co2_leakage_along_a_fault_4_import_and_visualize_simulation_outputs_in_pyvista.py: Import and visualize simulation outputs in PyVista ================================================== Once the TOUGH simulation has ended, there is not much things left to do with :mod:`toughio`. We can either: - Run the command :code:`toughio-export OUTPUT_ELEME.csv -m mesh.pickle` and drag-and-drop the generated VTK file in a compatible visualization software (e.g., ParaView), .. image:: ../../figures/co2_leakage_along_a_fault_paraview.png - Import the output file *OUTPUT_ELEME.csv* in Python using :mod:`toughio` (two-liners) and do whatever post-processing we want and need. This example briefly shows how to import TOUGH output file using :mod:`toughio` and how to visualize it with :mod:`pyvista` (adapted from :mod:`pyvista`'s `documentation `__). .. GENERATED FROM PYTHON SOURCE LINES 18-19 First, we unpickle the mesh file and import the last time step of the output file (`OUTPUT_ELEME.csv` in TOUGH3, `OUTPUT` in TOUGH2). .. GENERATED FROM PYTHON SOURCE LINES 19-25 .. code-block:: Python import toughio mesh = toughio.read_mesh("mesh.pickle") mesh.read_output("OUTPUT_ELEME.csv", time_step=-1) .. GENERATED FROM PYTHON SOURCE LINES 28-29 Once output data have been imported, we can simply call the method :meth:`toughio.Mesh.to_pyvista` to convert the mesh to a :class:`pyvista.UnstructuredGrid` object that can be processed by :mod:`pyvista`. .. GENERATED FROM PYTHON SOURCE LINES 29-65 .. code-block:: Python import pyvista pyvista.set_plot_theme("document") p = pyvista.Plotter(window_size=(1000, 1000)) p.add_mesh( mesh.to_pyvista(), scalars="SAT_G", cmap="viridis_r", clim=(0.0, 1.0), n_colors=20, show_edges=False, edge_color=(0.5, 0.5, 0.5), scalar_bar_args={ "title": "Gas saturation", "position_y": 0.01, "vertical": False, "n_labels": 6, "fmt": "%.1f", "title_font_size": 20, "font_family": "arial", "shadow": True, }, ) p.show_grid( show_xaxis=True, show_yaxis=False, show_zaxis=True, xlabel="Distance (m)", zlabel="Elevation (m)", ticks="outside", font_family="arial", ) p.view_xz() p.show() .. image-sg:: /examples/co2_leakage_along_a_fault/images/sphx_glr_4_import_and_visualize_simulation_outputs_in_pyvista_001.png :alt: 4 import and visualize simulation outputs in pyvista :srcset: /examples/co2_leakage_along_a_fault/images/sphx_glr_4_import_and_visualize_simulation_outputs_in_pyvista_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/pyvista/plotting/renderer.py:1456: PyVistaDeprecationWarning: `xlabel` is deprecated. Use `xtitle` instead. warnings.warn( /opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/pyvista/plotting/renderer.py:1468: PyVistaDeprecationWarning: `zlabel` is deprecated. Use `ztitle` instead. warnings.warn( .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.951 seconds) .. _sphx_glr_download_examples_co2_leakage_along_a_fault_4_import_and_visualize_simulation_outputs_in_pyvista.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 4_import_and_visualize_simulation_outputs_in_pyvista.ipynb <4_import_and_visualize_simulation_outputs_in_pyvista.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 4_import_and_visualize_simulation_outputs_in_pyvista.py <4_import_and_visualize_simulation_outputs_in_pyvista.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_