From b9f3cdb9c3faec3e6167a63121bd46a06b7d5f5a Mon Sep 17 00:00:00 2001 From: Jakub Both Date: Sun, 5 Nov 2023 01:47:36 +0100 Subject: [PATCH] BUG: Correct ordering of components. --- src/darsia/utils/plotting.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/darsia/utils/plotting.py b/src/darsia/utils/plotting.py index c4a130cb..1ea79e6e 100644 --- a/src/darsia/utils/plotting.py +++ b/src/darsia/utils/plotting.py @@ -209,7 +209,13 @@ def to_vtk( while len(img) < 3: img.append(np.zeros(target_shape)) assert len(img) == 3, "pyevtk only allows 3 components" - img = tuple(img) + # Flip the directions as part of the conversion + if image.space_dim == 1: + img = tuple(img) + elif image.space_dim == 2: + img = (img[1], img[0], img[2]) + elif image.space_dim == 3: + img = (img[1], img[2], img[0]) cellData[name] = img # Write to VTK