Skip to content

Commit

Permalink
Fix irregular grid detection in to_rect
Browse files Browse the repository at this point in the history
  • Loading branch information
stefraynaud committed Jun 25, 2024
1 parent 1478f3d commit f9a3a92
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Deprecations

Bug fixes
---------
- Fix :func:`xoa.grid.to_rect` raising of errors and handling of missing data in coordinates.
- Fix string formatting in :func:`xoa.filter.tidal_filter` warning.

Documentation
Expand Down
4 changes: 0 additions & 4 deletions xoa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ def _get_cache_():

return _XOA_CACHE

# if not hasattr(__init__, "_XOA_CACHE"):
# __init__._XOA_CACHE = {}
# return __init__._XOA_CACHE


def load_options(cfgfile=None):
"""Load specified options
Expand Down
4 changes: 2 additions & 2 deletions xoa/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ def to_rect(da, tol=1e-5, errors="warn"):
------
xarray.DataArray, xarray.Dataset
"""
#da = da.copy()
# da = da.copy()
new_coords = {}
rename_args = {}
da = cf.infer_coords(da)
Expand All @@ -599,7 +599,7 @@ def to_rect(da, tol=1e-5, errors="warn"):
continue
dims = [odim] if odim else coord.dims
for odim in dims:
if np.allclose(coord.min(odim), coord.max(odim), atol=tol):
if np.allclose(coord.min(odim), coord.max(odim), atol=tol, equal_nan=True):
new_coords[name] = xr.DataArray(
coord.isel({odim: 0}).values, dims=name, attrs=coord.attrs
)
Expand Down

0 comments on commit f9a3a92

Please sign in to comment.