diff --git a/xbout/geometries.py b/xbout/geometries.py index 7223751b..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[()] + 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..eab34e32 100644 --- a/xbout/load.py +++ b/xbout/load.py @@ -372,9 +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 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: