Skip to content
Snippets Groups Projects
Commit 0fe57e87 authored by Florian Zill's avatar Florian Zill
Browse files

[docs/examples] language improvements

parent 3602753c
No related branches found
No related tags found
1 merge request!134MeshSeries aggregation function
......@@ -17,37 +17,59 @@ from ogstools.propertylib import Scalar
setup.reset()
mesh_series = examples.meshseries_CT_2D
# alternatively:
# from ogstools.meshlib import MeshSeries
# mesh_series = MeshSeries("filepath/filename_pvd_or_xdmf")
# %%
mesh_property = Scalar(
data_name="Si", data_unit="", output_unit="%", output_name="Saturation"
)
# %% [markdown]
# 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`
# %% [markdown]
# Let's use fixed scale limits to prevent rescaling during the animation.
# %%
setup.p_min = 0
setup.p_max = 100
setup.dpi = 50
# %%
# %% [markdown]
# You can choose which timesteps to render by passing either an int array
# corresponding to the indices, or a float array corresponding to the timevalues
# to render. If a requested timevalue is not part of the timeseries it will be
# interpolated. In this case every second frame will be interpolated.
# %%
timevalues = np.linspace(
mesh_series.timevalues[0], mesh_series.timevalues[-1], num=25
)
# %%
# %% [markdown]
# Now, let's animate the saturation solution. A timescale at the top
# indicates existing timesteps and the position of the current timevalue.
# Note that rendering many frames in conjunction with large meshes might take
# a really long time.
# %%
titles = [f"{tv/(365.25*86400):.1f} yrs" for tv in timevalues]
si = Scalar(
data_name="Si", data_unit="", output_unit="%", output_name="Saturation"
)
anim = animate(mesh_series, si, timevalues, titles)
# the animation can be saved (as mp4) like so:
# from ogstools.meshplotlib.animation import save_animation
# save_animation(anim, "Saturation", fps=5)
anim = animate(mesh_series, mesh_property, timevalues, titles)
# %% [markdown]
# The animation can be saved (as mp4) like so:
#
# .. code-block:: python
#
# from ogstools.meshplotlib.animation import save_animation
# save_animation(anim, "Saturation", fps=5)
#
# sphinx_gallery_start_ignore
# note for developers:
......
......@@ -4,10 +4,10 @@ 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.
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.
"""
# %%
......@@ -19,34 +19,52 @@ 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)
# %% [markdown]
# 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")
#
# %%
fig = mpl.plot(mesh, presets.material_id)
# %% [markdown]
# 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.
# %%
fig = mpl.plot(mesh, presets.temperature)
# %%
# %% [markdown]
# We can also plot components of vector properties:
# %%
fig = mpl.plot(mesh, presets.displacement[0])
# %%
fig = mpl.plot(mesh, presets.displacement[1])
# %%
# %% [markdown]
# This example has hydraulically deactivated subdomains:
# %%
fig = mpl.plot(mesh, presets.pressure.get_mask())
# %%
# %% [markdown]
# Let's plot the fluid velocity field.
fig = mpl.plot(mesh, presets.velocity)
# %%
fig = mpl.plot(mesh, presets.velocity)
# %% [markdown]
# Let's plot it again, this time log-scaled.
# %%
mpl.setup.log_scaled = True
mpl.setup.p_min = -8
fig = mpl.plot(mesh, presets.velocity)
......@@ -33,9 +33,18 @@ meshplotlib.setup.reset()
si = Scalar(
data_name="Si", data_unit="", output_unit="%", output_name="Saturation"
)
# alternatively:
# from ogstools.meshlib import MeshSeries
# mesh_series = MeshSeries("filepath/filename_pvd_or_xdmf")
# %% [markdown]
# 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`
# %% [markdown]
# Let's define 4 observation points and plot them on the mesh.
......
......@@ -41,7 +41,7 @@ fig = plot_limit(mesh_series, si, "min")
# %% [markdown]
# Difference between the last and he first timestep:
# Difference between the last and the first timestep:
# %%
diff_mesh = difference(si, mesh_series.read(-1), mesh_series.read(0))
......
......@@ -91,8 +91,8 @@ class Property:
"""
Return the transformed data values.
Converts the data from data_unit to output_unit and apply a function
the transformation function of this property. The result is returned by
Converts the data from data_unit to output_unit and applies the
transformation function of this property. The result is returned by
default without units. if `strip_unit` is False, a quantity is returned.
Note:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment