Skip to content

Commit

Permalink
Fix grid2loc (#95)
Browse files Browse the repository at this point in the history
* Fix grid2loc warning and force parallelization

* Remove copy in to_rect

* Fix errors handling in to_rect
  • Loading branch information
stefraynaud authored Jun 24, 2024
1 parent 6ca5e2e commit 0d92a9f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions xoa/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ def apply_along_dim(


def _pad_(da, dim, pad_width, mode, **kwargs):

pad_width = pad_width.get(dim, 0)
if not pad_width:
return da.copy()
Expand Down Expand Up @@ -584,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 Down Expand Up @@ -613,9 +612,10 @@ def to_rect(da, tol=1e-5, errors="warn"):
"Cannot convert to curvilinear to rectangular grid since since coordinate "
f"'{name}' is not constant along one of its dimensions"
)
if errors == "errors":
if errors == "raise":
raise XoaError(msg)
xoa_warn(msg)
elif errors == "ignore":
xoa_warn(msg)
if new_coords:
return (
da.reset_coords(list(new_coords), drop=True)
Expand Down
2 changes: 1 addition & 1 deletion xoa/interp.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ def grid2rellocs(xxi, yyi, xo, yo):
return pp, qq


@numba.njit(parallel=False, cache=NOT_CI)
@numba.njit(parallel=True, cache=NOT_CI)
def grid2locs(xxi, yyi, zzi, ti, vi, xo, yo, zo, to):
"""Linear interpolation of gridded data to random positions
Expand Down
2 changes: 1 addition & 1 deletion xoa/regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def grid2loc(da, loc, compat="warn"):
glon = xcoords.get_lon(da) # before to_rect
glat = xcoords.get_lat(da) # before to_rect
dims_in = set(glon.dims).union(glat.dims)
da_tmp = xgrid.to_rect(da)
da_tmp = xgrid.to_rect(da, errors="ignore")
da_tmp = xcoords.reorder(da_tmp, order)

# To numpy with singletons
Expand Down

0 comments on commit 0d92a9f

Please sign in to comment.