From f49585e1e1661e9acf25bd50815b8d3ffad251c1 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 1/2] 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 7223751b..e3204d03 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 683c96d8..dacd63e5 100644 --- a/xbout/load.py +++ b/xbout/load.py @@ -372,9 +372,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: From 4cc9c538c3db92f934b558919bf6136fc060693b Mon Sep 17 00:00:00 2001 From: mrhardman Date: Wed, 15 Jan 2025 10:42:42 +0000 Subject: [PATCH 2/2] Apply black formatting --- xbout/geometries.py | 2 +- xbout/load.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/xbout/geometries.py b/xbout/geometries.py index e3204d03..2d823f94 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[0,0] + 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 dacd63e5..eab34e32 100644 --- a/xbout/load.py +++ b/xbout/load.py @@ -372,7 +372,9 @@ 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 ("BOUT_VERSION" in ds.metadata 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: