From e1b1e1c6e1abcac20266db83965dde49fb9af164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Schw=C3=B6rer?= Date: Mon, 25 Oct 2021 12:31:16 +0200 Subject: [PATCH] Fix "all" region for FCI --- xbout/geometries.py | 14 ++++++++++---- xbout/region.py | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/xbout/geometries.py b/xbout/geometries.py index c1acabd0..375e677f 100644 --- a/xbout/geometries.py +++ b/xbout/geometries.py @@ -184,7 +184,7 @@ def apply_geometry(ds, geometry_name, *, coordinates=None, grid=None): # In BOUT++ v5, dz is either a Field2D or Field3D. # We can use it as a 1D coordinate if it's a Field3D, _or_ if nz == 1 bout_v5 = updated_ds.metadata["BOUT_VERSION"] > 5.0 or ( - updated_ds.metadata["BOUT_VERSION"] == 5.0 and updated_ds["dz"].ndim == 2 + updated_ds.metadata["BOUT_VERSION"] == 5.0 and updated_ds["dz"].ndim >= 2 ) use_metric_3d = updated_ds.metadata.get("use_metric_3d", False) can_use_1d_z_coord = (nz == 1) or use_metric_3d @@ -197,14 +197,20 @@ def apply_geometry(ds, geometry_name, *, coordinates=None, grid=None): raise ValueError( f"Spacing is not constant. Cannot create z coordinate" ) - dz = updated_ds["dz"][0, 0] + + dz = updated_ds["dz"].min() else: dz = updated_ds["dz"] z0 = 2 * np.pi * updated_ds.metadata["ZMIN"] z1 = z0 + nz * dz - if not np.isclose( - z1, 2.0 * np.pi * updated_ds.metadata["ZMAX"], rtol=1.0e-15, atol=0.0 + if not np.all( + np.isclose( + z1, + 2.0 * np.pi * updated_ds.metadata["ZMAX"], + rtol=1.0e-15, + atol=0.0, + ) ): warn( f"Size of toroidal domain as calculated from nz*dz ({str(z1 - z0)}" diff --git a/xbout/region.py b/xbout/region.py index ce401d2a..12391b12 100644 --- a/xbout/region.py +++ b/xbout/region.py @@ -1239,8 +1239,8 @@ def _create_single_region(ds, periodic_y=True): "all": Region( name="all", ds=ds, - xouter_ind=0, - xinner_ind=nx, + xouter_ind=nx, + xinner_ind=0, ylower_ind=0, yupper_ind=ny, connection_lower_y=connection,