Skip to content

Commit

Permalink
Hack coordinate names when opening grid file to avoid conflict
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
johnomotani committed Nov 13, 2024
1 parent d8b79ee commit d315d12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion xbout/geometries.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def add_toroidal_geometry_coords(ds, *, coordinates=None, grid=None):
ds = ds.rename(y=coordinates["y"])

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

Expand Down
7 changes: 6 additions & 1 deletion xbout/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,12 @@ def attrs_remove_section(obj, section):
ds.metadata[v] = grid[v].values

# Update coordinates to match particular geometry of grid
ds = geometries.apply_geometry(ds, geometry, grid=grid)
if input_type == "grid":
# Specify coordinate names to avoid name clash
coordinates = {"x": "psi_poloidal", "y": "y", "z": "zeta"}
else:
coordinates = None
ds = geometries.apply_geometry(ds, geometry, grid=grid, coordinates=coordinates)

if remove_yboundaries:
ds = ds.bout.remove_yboundaries()
Expand Down

0 comments on commit d315d12

Please sign in to comment.