.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/howto_meshplotlib/plot_meshplotlib_2d.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_auto_examples_howto_meshplotlib_plot_meshplotlib_2d.py: Visualizing 2D model data ========================= .. sectionauthor:: Florian Zill (Helmholtz Centre for Environmental Research GmbH - UFZ) For this example we load a 2D meshseries dataset from within the ``meshplotlib`` examples. In the ``meshplotlib.setup`` we can provide a dictionary to map names to material ids. First, let's plot the material ids (cell_data). Per default in the setup, this will automatically show the element edges. .. GENERATED FROM PYTHON SOURCE LINES 14-24 .. code-block:: default import ogstools.meshplotlib as mpl from ogstools.meshplotlib.examples import meshseries_THM_2D from ogstools.propertylib import presets mpl.setup.reset() mpl.setup.length.output_unit = "km" mpl.setup.material_names = {i + 1: f"Layer {i+1}" for i in range(26)} mesh = meshseries_THM_2D.read(1) fig = mpl.plot(mesh, presets.material_id) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_meshplotlib_2d_001.png :alt: plot meshplotlib 2d :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_meshplotlib_2d_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 25-28 Now, let's plot the temperature field (point_data) at the first timestep. The default temperature property from the `propertylib` reads the temperature data as Kelvin and converts them to degrees Celsius. .. GENERATED FROM PYTHON SOURCE LINES 28-31 .. code-block:: default fig = mpl.plot(mesh, presets.temperature) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_meshplotlib_2d_002.png :alt: plot meshplotlib 2d :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_meshplotlib_2d_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 32-33 This example has hydraulically deactivated subdomains: .. GENERATED FROM PYTHON SOURCE LINES 33-36 .. code-block:: default fig = mpl.plot(mesh, presets.pressure.get_mask()) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_meshplotlib_2d_003.png :alt: plot meshplotlib 2d :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_meshplotlib_2d_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 37-38 Let's plot the fluid velocity field. .. GENERATED FROM PYTHON SOURCE LINES 38-40 .. code-block:: default fig = mpl.plot(mesh, presets.velocity) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_meshplotlib_2d_004.png :alt: plot meshplotlib 2d :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_meshplotlib_2d_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 41-42 It is also possible to plot a shape on top, e.g. to display an overburden. .. GENERATED FROM PYTHON SOURCE LINES 42-46 .. code-block:: default mpl.plot_on_top(fig.axes[0], mesh, lambda x: min(max(0, 0.1 * (x - 3)), 100)) fig # noqa: B018 .. rst-class:: sphx-glr-script-out .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 47-48 We can also plot components of vector property: .. GENERATED FROM PYTHON SOURCE LINES 48-51 .. code-block:: default fig = mpl.plot(mesh, presets.displacement[0]) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_meshplotlib_2d_005.png :alt: plot meshplotlib 2d :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_meshplotlib_2d_005.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 52-53 .. code-block:: default fig = mpl.plot(mesh, presets.displacement[1]) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_meshplotlib_2d_006.png :alt: plot meshplotlib 2d :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_meshplotlib_2d_006.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 4.199 seconds) .. _sphx_glr_download_auto_examples_howto_meshplotlib_plot_meshplotlib_2d.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_meshplotlib_2d.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_meshplotlib_2d.ipynb `