Skip to content

Commit d315d12

Browse files
committed
Hack coordinate names when opening grid file to avoid conflict
There is a 'theta' variable in grid files, which prevents naming a dimension 'theta'. Also keep the 'psixy' variable in the Dataset - create a new variable referecing it rather than renaming it to make the 'psi_poloidal' coordinate.
1 parent d8b79ee commit d315d12

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

xbout/geometries.py

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

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

xbout/load.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,12 @@ def attrs_remove_section(obj, section):
367367
ds.metadata[v] = grid[v].values
368368

369369
# Update coordinates to match particular geometry of grid
370-
ds = geometries.apply_geometry(ds, geometry, grid=grid)
370+
if input_type == "grid":
371+
# Specify coordinate names to avoid name clash
372+
coordinates = {"x": "psi_poloidal", "y": "y", "z": "zeta"}
373+
else:
374+
coordinates = None
375+
ds = geometries.apply_geometry(ds, geometry, grid=grid, coordinates=coordinates)
371376

372377
if remove_yboundaries:
373378
ds = ds.bout.remove_yboundaries()

0 commit comments

Comments
 (0)