-
Notifications
You must be signed in to change notification settings - Fork 41
Description
I found the examples listed in the isoslice cannot run successfully.
for example:
"
Calculate slice of salt at 28 deg latitude
>>> xroms.isoslice(ds.salt, 28, iso_array=ds.lat_rho, axis='Y')
"
It only works with xroms.isoslice(ds.salt, np.array([28]), xgrid, iso_array=ds.lat_rho, axis='Y')
And when I tried to calculate salinity onto fixed depths:
xroms.isoslice(ds.salt, np.array([-33]), xgrid,iso_array=ds.z_rho, axis='Z')
An error raised:
How can I fixed it?
ValueError Traceback (most recent call last)
Cell In[18], line 1
----> 1 xroms.isoslice(ds.salt, np.array([-100]), xgrid,iso_array=ds.z_rho, axis='Z')
File ~/.conda/envs/py311/lib/python3.11/site-packages/xroms/interp.py:332, in isoslice(var, iso_values, xgrid, iso_array, axis)
329 transformed = transformed.squeeze().cf.guess_coord_axis()
331 # reorder back to normal ordering in case changed
--> 332 transformed = xroms.order(transformed)
334 return transformed
File ~/.conda/envs/py311/lib/python3.11/site-packages/xroms/utilities.py:1572, in order(var)
1546 """Reorder var to typical dimensional ordering.
1547
1548 Parameters
(...)
1566 >>> xroms.order(var)
1567 """
1569 # this looks at the dims on var directly which tends to be more accurate
1570 # since the DataArray can have extra coordinates included (but dropping
1571 # can drop too many variables).
-> 1572 return var.cf.transpose(
1573 *[
1574 dim
1575 for dim in ["T", "Z", "Y", "X"]
1576 if dim in var.cf.axes and var.cf.axes[dim][0] in var.dims
1577 ]
1578 )
File ~/.conda/envs/py311/lib/python3.11/site-packages/cf_xarray/accessor.py:753, in _getattr..wrapper(*args, **kwargs)
749 posargs, arguments = accessor._process_signature(
750 func, args, kwargs, key_mappers
751 )
752 final_func = extra_decorator(func) if extra_decorator else func
--> 753 result = final_func(*posargs, **arguments)
754 if wrap_classes and isinstance(result, _WRAPPED_CLASSES):
755 result = _CFWrappedClass(result, accessor)
File ~/.conda/envs/py311/lib/python3.11/site-packages/xarray/util/deprecation_helpers.py:143, in deprecate_dims..wrapper(*args, **kwargs)
135 emit_user_level_warning(
136 f"The {old_name} argument has been renamed to dim, and will be removed "
137 "in the future. This renaming is taking place throughout xarray over the "
(...)
140 PendingDeprecationWarning,
141 )
142 kwargs["dim"] = kwargs.pop(old_name)
--> 143 return func(*args, **kwargs)
File ~/.conda/envs/py311/lib/python3.11/site-packages/xarray/core/dataarray.py:3133, in DataArray.transpose(self, transpose_coords, missing_dims, *dim)
3100 """Return a new DataArray object with transposed dimensions.
3101
3102 Parameters
(...)
3130 Dataset.transpose
3131 """
3132 if dim:
-> 3133 dim = tuple(infix_dims(dim, self.dims, missing_dims))
3134 variable = self.variable.transpose(*dim)
3135 if transpose_coords:
File ~/.conda/envs/py311/lib/python3.11/site-packages/xarray/namedarray/utils.py:171, in infix_dims(dims_supplied, dims_all, missing_dims)
169 yield d
170 else:
--> 171 existing_dims = drop_missing_dims(dims_supplied, dims_all, missing_dims)
172 if set(existing_dims) ^ set(dims_all):
173 raise ValueError(
174 f"{dims_supplied} must be a permuted list of {dims_all}, unless ... is included"
175 )
File ~/.conda/envs/py311/lib/python3.11/site-packages/xarray/namedarray/utils.py:124, in drop_missing_dims(supplied_dims, dims, missing_dims)
122 supplied_dims_set = {val for val in supplied_dims if val is not ...}
123 if invalid := supplied_dims_set - set(dims):
--> 124 raise ValueError(
125 f"Dimensions {invalid} do not exist. Expected one or more of {dims}"
126 )
128 return supplied_dims
130 elif missing_dims == "warn":
ValueError: Dimensions {'r', 'o', 'e', 'h', 't', 'a', '_'} do not exist. Expected one or more of ('eta_rho', 'xi_rho')