.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/howto_meshplotlib/plot_special.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_special.py: Analyzing Meshseries Data ========================= .. sectionauthor:: Florian Zill (Helmholtz Centre for Environmental Research GmbH - UFZ) In this example we show how to aggregate data in a model over all timesteps as well as plot differences between to timesteps. For this purpose we use a component transport example from the ogs benchmark gallery (https://www.opengeosys.org/docs/benchmarks/hydro-component/elder/). To see this benchmark results over all timesteps have a look at :ref:`sphx_glr_auto_examples_howto_meshplotlib_plot_animation.py`. .. GENERATED FROM PYTHON SOURCE LINES 17-28 .. code-block:: Python from ogstools import examples from ogstools.meshlib import difference from ogstools.meshplotlib import plot, setup from ogstools.propertylib import Scalar setup.reset() mesh_series = examples.load_meshseries_CT_2D_XDMF() si = Scalar( data_name="Si", data_unit="", output_unit="%", output_name="Saturation" ) .. GENERATED FROM PYTHON SOURCE LINES 29-39 To read your own data as a mesh series you can do: .. code-block:: python from ogstools.meshlib import MeshSeries mesh_series = MeshSeries("filepath/filename_pvd_or_xdmf") You can also use a property from the available presets instead of needing to create your own: :ref:`sphx_glr_auto_examples_howto_propertylib_plot_propertylib.py` .. GENERATED FROM PYTHON SOURCE LINES 41-48 You aggregate the data in MeshSeries over all timesteps given some aggregation function, e.g. "min", "max", "var" (see: :meth:`~ogstools.meshlib.mesh_series.MeshSeries.aggregate`). The following code gets the maximum saturation for each point in the mesh over all timesteps and plots it. Note: the data in the returned mesh has a suffix equal to the aggregation functions name. The plot function will find the correct data anyway if given the original mesh_property .. GENERATED FROM PYTHON SOURCE LINES 50-53 .. code-block:: Python mesh = mesh_series.aggregate(si, "max") fig = plot(mesh, si) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_special_001.png :alt: plot special :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_special_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 54-57 It is also possible to plot the time when the minimum or maximum occurs. However, here we have to use a new mesh_property for the plot to handle the units correctly: .. GENERATED FROM PYTHON SOURCE LINES 59-62 .. code-block:: Python mesh = mesh_series.aggregate(si, "max_time") fig = plot(mesh, Scalar("Saturation_max_time", "s", "a")) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_special_002.png :alt: plot special :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_special_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 63-64 Likewise we can calculate and visualize the variance of the saturation: .. GENERATED FROM PYTHON SOURCE LINES 67-70 .. code-block:: Python mesh = mesh_series.aggregate(si, "var") fig = plot(mesh, si) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_special_003.png :alt: plot special :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_special_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 71-72 Difference between the last and the first timestep: .. GENERATED FROM PYTHON SOURCE LINES 74-76 .. code-block:: Python mesh = difference(mesh_series.read(-1), mesh_series.read(0), si) fig = plot(mesh, si) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_special_004.png :alt: plot special :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_special_004.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.804 seconds) .. _sphx_glr_download_auto_examples_howto_meshplotlib_plot_special.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_special.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_special.py `