From 32aa6fe97505d0ba104a439e3c01ec11ab6b55bf Mon Sep 17 00:00:00 2001 From: Gaylor Wafflard Date: Wed, 4 Dec 2024 15:15:55 +0100 Subject: [PATCH] return artist when 1D plot and bug-fix fargo3d spherical --- nonos/_readers/binary.py | 13 ++++++++++--- nonos/api/analysis.py | 4 +++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/nonos/_readers/binary.py b/nonos/_readers/binary.py index dd298398..094a68ee 100644 --- a/nonos/_readers/binary.py +++ b/nonos/_readers/binary.py @@ -600,14 +600,21 @@ def read( n1 = len(V["x1"]) - 1 n2 = len(V["x2"]) - 1 n3 = len(V["x3"]) - 1 - grid_shape = n3, n1, n2 - shift = n2 // 2 + if geometry_str == "cylindrical": + grid_shape = n3, n1, n2 + tuple_transposition = (1, 2, 0) + shift = n2 // 2 + elif geometry_str == "spherical": + grid_shape = n2, n1, n3 + tuple_transposition = (1, 0, 2) + shift = n3 // 2 def _read_array(file: Path): return np.roll( np.fromfile(file, dtype="float64") .reshape(grid_shape) - .transpose(1, 2, 0), + # .transpose(1, 2, 0), + .transpose(tuple_transposition), shift, axis=1, ) diff --git a/nonos/api/analysis.py b/nonos/api/analysis.py index 20167dca..5a811f3c 100644 --- a/nonos/api/analysis.py +++ b/nonos/api/analysis.py @@ -130,12 +130,14 @@ def plot( if "norm" in kwargs: logger.info("norm has no meaning in 1D.") kwargs.pop("norm") - ax.plot(self.avalue, data, **kwargs) + im = ax.plot(self.avalue, data, **kwargs) ax.set_ylim(ymin=vmin) ax.set_ylim(ymax=vmax) ax.set_xlabel(self.akey) if title is not None: ax.set_ylabel(title) + else: + return im else: raise TypeError( "Plotable doesn't support data with dimensionality>2, "