Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ twine==1.14.0
Click==7.1.2
pytest==6.2.4
shapely>=2.0
uxarray==2025.6.0
uxarray==2025.12.0
netcdf>=1.6
xarray>=2023.4.1
holoviews>=1.16.0
9 changes: 8 additions & 1 deletion suxarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ def __init__(self, *args, sxgrid: Grid = None, **kwargs):
if sxgrid is not None and not isinstance(sxgrid, Grid):
raise RuntimeError("sxgrid must be a Grid object")

# temporary fix to avoid passing uxgrid to parent class through kwargs.
if "uxgrid" in kwargs: # check if uxgrid is in kwargs
if isinstance(kwargs["uxgrid"], Grid): # type check
sxgrid = kwargs["uxgrid"] # assign to sxgrid
kwargs.pop(
"uxgrid"
) # remove uxgrid from kwargs to avoid passing it to parent class

super().__init__(*args, uxgrid=sxgrid, **kwargs)

subset = UncachedAccessor(DataArraySubsetAccessor)
Expand All @@ -32,7 +40,6 @@ def isel(self, ignore_grid=False, *args, **kwargs):
da_new.uxgrid = da_new.uxgrid.sgrid_isel(**kwargs)
return da_new


def depth_average(self) -> SxDataArray:
"""Calculate depth-average of a variable

Expand Down
18 changes: 16 additions & 2 deletions suxarray/io/_schismgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def _read_schism_grid(
# Use uxarray _read_ugrid to remap the dimensions
# Note that it does not update the grid_topology information though
# variable names are updated.

# Note, as of uxarray==2025.9.0 _read_ugrid does not correctly rename the
# n_edge dimension to nSCHISM_hgrid_edge, which causes issues with the isel
# method. This is a temporary patch to rename the dimensions back to n_edge,
# n_face, and n_node after reading the grid. This will need to be removed
# once the issue is fixed in uxarray.
ds_out2d, dim_dict = _read_ugrid(ds_out2d)

ds_out2d = _rename_coords(ds_out2d)
Expand Down Expand Up @@ -205,7 +211,7 @@ def _transform_coordinates(


def _rename_coords(
data: Union[xr.DataArray, xr.Dataset]
data: Union[xr.DataArray, xr.Dataset],
) -> Union[xr.DataArray, xr.Dataset]:
if SCHISM_CARTESIAN_NODE_COORDINATES[0] in data:
coord_dict = {
Expand All @@ -225,11 +231,19 @@ def _rename_coords(
SCHISM_CARTESIAN_FACE_COORDINATES[1]: CARTESIAN_FACE_COORDINATES[1],
}
data = data.rename(coord_dict)
# Patch for dimension name renaming.
if "nSCHISM_hgrid_edge" in data.dims:
data = data.rename({"nSCHISM_hgrid_edge": "n_edge"})
if "nSCHISM_hgrid_face" in data.dims:
data = data.rename({"nSCHISM_hgrid_face": "n_face"})
if "nSCHISM_hgrid_node" in data.dims:
data = data.rename({"nSCHISM_hgrid_node": "n_node"})

return data


def _rename_coords_back(
data: Union[xr.DataArray, xr.Dataset]
data: Union[xr.DataArray, xr.Dataset],
) -> Union[xr.DataArray, xr.Dataset]:
if CARTESIAN_NODE_COORDINATES[0] in data.coords:
coord_dict = {
Expand Down
Loading