From 26cf20353d6649d9448e1542feb389479222e8f9 Mon Sep 17 00:00:00 2001 From: zxdawn Date: Wed, 1 Apr 2020 13:40:47 +0800 Subject: [PATCH] Deal with nan in new coordinate --- xarray/core/missing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xarray/core/missing.py b/xarray/core/missing.py index 40f010b3514..075fb24b366 100644 --- a/xarray/core/missing.py +++ b/xarray/core/missing.py @@ -549,8 +549,8 @@ def _localize(var, indexes_coords): indexes = {} for dim, [x, new_x] in indexes_coords.items(): index = x.to_index() - imin = index.get_loc(np.min(new_x.values), method="nearest") - imax = index.get_loc(np.max(new_x.values), method="nearest") + imin = index.get_loc(np.nanmin(new_x.values), method="nearest") + imax = index.get_loc(np.nanmax(new_x.values), method="nearest") indexes[dim] = slice(max(imin - 2, 0), imax + 2) indexes_coords[dim] = (x[indexes[dim]], new_x)