Skip to content

Commit f416a66

Browse files
authored
Merge pull request #307 from boutproject/fix-gridfile-loading
Fix loading of grid files
2 parents 64408ea + 1b8986f commit f416a66

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

examples/plot_grid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
grid["psi_poloidal"].bout.pcolormesh()
1414
grid["psi_poloidal"].bout.pcolormesh(shading="gouraud")
1515

16-
grid["psi_poloidal"].bout.regions()
16+
grid["psi_poloidal"].bout.plot_regions()
1717

1818
plt.show()

xbout/geometries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ def add_toroidal_geometry_coords(ds, *, coordinates=None, grid=None):
401401
ds = _maybe_rename_dimension(ds, "y", coordinates["y"])
402402

403403
# TODO automatically make this coordinate 1D in simplified cases?
404-
ds = ds.rename(psixy=coordinates["x"])
404+
ds[coordinates["x"]] = ds["psixy"]
405405
ds = ds.set_coords(coordinates["x"])
406406
ds[coordinates["x"]].attrs["units"] = "Wb"
407407

xbout/load.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def open_boutdataset(
6464
run_name=None,
6565
info=True,
6666
is_restart=None,
67+
is_mms_dump=False,
6768
**kwargs,
6869
):
6970
"""Load a dataset from a set of BOUT output files, including the
@@ -179,12 +180,12 @@ def open_boutdataset(
179180
chunks = {}
180181

181182
input_type = _check_dataset_type(datapath)
182-
183183
if is_restart is None:
184184
is_restart = input_type == "restart"
185185
elif is_restart is True:
186186
input_type = "restart"
187-
187+
if is_mms_dump:
188+
input_type = "dump"
188189
if "reload" in input_type:
189190
if input_type == "reload":
190191
if isinstance(datapath, Path):
@@ -358,7 +359,12 @@ def attrs_remove_section(obj, section):
358359
ds.metadata[v] = grid[v].values
359360

360361
# Update coordinates to match particular geometry of grid
361-
ds = geometries.apply_geometry(ds, geometry, grid=grid)
362+
if input_type == "grid":
363+
# Specify coordinate names to avoid name clash
364+
coordinates = {"x": "psi_poloidal", "y": "y", "z": "zeta"}
365+
else:
366+
coordinates = None
367+
ds = geometries.apply_geometry(ds, geometry, grid=grid, coordinates=coordinates)
362368

363369
if remove_yboundaries:
364370
ds = ds.bout.remove_yboundaries()
@@ -616,7 +622,6 @@ def _auto_open_mfboutdataset(
616622
nxpe, nype, mxg, myg, mxsub, mysub, is_squashed_doublenull = _read_splitting(
617623
filepaths[0], info, keep_yboundaries
618624
)
619-
620625
if is_squashed_doublenull:
621626
# Need to remove y-boundaries after loading: (i) in case
622627
# we are loading a squashed data-set, in which case we

xbout/tests/test_boutdataset.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,7 @@ def test_interpolate_parallel_all_variables_arg(self, bout_xyt_example_files):
11361136
"G3",
11371137
"J",
11381138
"Bxy",
1139+
"psixy",
11391140
)
11401141
)
11411142

0 commit comments

Comments
 (0)