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

small corrections

parent cf65464b
No related branches found
No related tags found
No related merge requests found
......@@ -192,6 +192,7 @@ class MeshSeries:
):
values = self.hdf5["meshes"][self.hdf5_bulk_name][data_name][:]
geom = self.hdf5["meshes"][self.hdf5_bulk_name]["geometry"][0]
values = np.swapaxes(values, 0, 1)
# remove flat dimensions for interpolation
for index, axis in enumerate(geom.T):
......@@ -202,11 +203,11 @@ class MeshSeries:
if interp_method is None:
interp_method = "linear"
interp = {
"nearest": NearestNDInterpolator(geom, values.T),
"linear": LinearNDInterpolator(geom, values.T, np.nan),
"nearest": NearestNDInterpolator(geom, values),
"linear": LinearNDInterpolator(geom, values, np.nan),
}[interp_method]
return interp(points).T
return np.swapaxes(interp(points), 0, 1)
def probe(
self,
......
......@@ -23,7 +23,7 @@ from ogstools.propertylib.unit_registry import u_reg
from . import plot_features as pf
from . import setup
from .levels import get_levels
from .utils import get_style_cycler, justified_labels
from .utils import get_style_cycler
# TODO: define default data_name for regions in setup
......@@ -571,13 +571,13 @@ def plot_probe(
else:
fig = None
ax.set_prop_cycle(get_style_cycler(len(points), colors, linestyles))
if labels is None:
j_labels = justified_labels(points)
labels = [f"{i}: {label}" for i, label in enumerate(j_labels)]
ax.plot(times, values, label=labels, **kwargs)
ax.legend(facecolor="white", framealpha=1, prop={"family": "monospace"})
if labels is not None:
ax.legend(facecolor="white", framealpha=1, prop={"family": "monospace"})
time_label = f"time / {time_unit}" if time_unit else "time"
ax.set_axisbelow(True)
ax.grid(which="major", color="lightgrey", linestyle="-")
ax.grid(which="minor", color="0.95", linestyle="--")
unit_str = (
f" / {mesh_property.get_output_unit()}"
if mesh_property.get_output_unit()
......@@ -586,7 +586,6 @@ def plot_probe(
y_label = mesh_property.output_name.replace("_", " ") + unit_str
ax.set_xlabel(time_label)
ax.set_ylabel(y_label)
ax.grid(which="major", color="lightgrey", linestyle="-")
ax.grid(which="minor", color="0.95", linestyle="--")
ax.label_outer()
ax.minorticks_on()
return fig
......@@ -13,8 +13,9 @@ def justified_labels(points: np.ndarray) -> list[str]:
col_lens = np.max(
[[len(fmt(coord)) for coord in point] for point in points], axis=0
)
dim = points.shape[1]
return [
",".join(fmt(point[i]).rjust(col_lens[i]) for i in range(3))
",".join(fmt(point[i]).rjust(col_lens[i]) for i in range(dim))
for point in points
]
......
......@@ -98,6 +98,11 @@ class MeshplotlibTest(unittest.TestCase):
plot_probe(mesh_series, points, presets.temperature)
points = mesh_series.read(0).points[[0, -1]]
plot_probe(mesh_series, points, presets.temperature)
mesh_series = examples.meshseries_XDMF
points = mesh_series.read(0).center
plot_probe(mesh_series, points, presets.temperature)
mesh_property = presets.velocity.replace(data_name="darcy_velocity")
plot_probe(mesh_series, points, mesh_property)
def test_animation(self):
"""Test creation of animation."""
......
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