From d2a91801757e349b887a4911021c41c46be80289 Mon Sep 17 00:00:00 2001 From: Michael Hardman <29800382+mrhardman@users.noreply.github.com> Date: Wed, 15 Jan 2025 10:32:52 +0000 Subject: [PATCH] Changes required to load output from a grid-free BOUT.0.nc file, necessary for MMS tests of the differential operators. --- xbout/geometries.py | 2 +- xbout/load.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/xbout/geometries.py b/xbout/geometries.py index dd1b6692..04696b67 100644 --- a/xbout/geometries.py +++ b/xbout/geometries.py @@ -214,7 +214,7 @@ def apply_geometry(ds, geometry_name, *, coordinates=None, grid=None): dz = updated_ds["dz"] z0 = 2 * np.pi * updated_ds.metadata["ZMIN"] - z1 = z0 + nz * dz.data[()] + z1 = z0 + nz * dz.data[0,0] if not np.all( np.isclose( z1, diff --git a/xbout/load.py b/xbout/load.py index 5c3d8a61..f30b0b81 100644 --- a/xbout/load.py +++ b/xbout/load.py @@ -378,9 +378,7 @@ def attrs_remove_section(obj, section): # by xBOUT, not by BOUT++ ds.bout.fine_interpolation_factor = 8 - if ("dump" in input_type or "restart" in input_type) and ds.metadata[ - "BOUT_VERSION" - ] < 4.0: + if ("dump" in input_type or "restart" in input_type) and ("BOUT_VERSION" in ds.metadata and ds.metadata["BOUT_VERSION"] < 4.0): # Add workarounds for missing information or different # conventions in data saved by BOUT++ v3.x. for v in ds: