From 0d92a9ff94944f34ac30ca6ac41e79eab56b4853 Mon Sep 17 00:00:00 2001 From: Stephane Raynaud Date: Mon, 24 Jun 2024 16:48:44 +0200 Subject: [PATCH] Fix grid2loc (#95) * Fix grid2loc warning and force parallelization * Remove copy in to_rect * Fix errors handling in to_rect --- xoa/grid.py | 8 ++++---- xoa/interp.py | 2 +- xoa/regrid.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xoa/grid.py b/xoa/grid.py index c055121..f3a22e2 100644 --- a/xoa/grid.py +++ b/xoa/grid.py @@ -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() @@ -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) @@ -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) diff --git a/xoa/interp.py b/xoa/interp.py index 7cb3190..009e896 100644 --- a/xoa/interp.py +++ b/xoa/interp.py @@ -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 diff --git a/xoa/regrid.py b/xoa/regrid.py index cc093e8..e696f18 100644 --- a/xoa/regrid.py +++ b/xoa/regrid.py @@ -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