id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 1768118776,I_kwDOAMm_X85pY1n4,7935,Interpolation loses edge points,31730876,open,0,,,0,2023-06-21T17:51:13Z,2023-06-21T17:51:13Z,,NONE,,,,"### What happened? I'm not sure if this is a bug, normal behaviour or a feature request but if it's expected behaviour, it should be better documented. I want to interpolate a 2D dataset to a finer spatial grid. I've put together a reproducible example based on the tutorial here: https://docs.xarray.dev/en/stable/user-guide/interpolation.html The result is this: When I do this, the edge points are lost (as you can see on the west/north boundaries here). ### What did you expect to happen? I'd expect the interpolation to protect the boundary points and not lose them. ### Minimal Complete Verifiable Example ```Python ds = xr.tutorial.load_dataset(""air_temperature"") subplot_kw = dict(projection=ccrs.PlateCarree()) new_lon = np.linspace(ds.lon[0], ds.lon[-1], ds.dims[""lon""] * 4) new_lat = np.linspace(ds.lat[0], ds.lat[-1], ds.dims[""lat""] * 4) dsi = ds.interp(lat=new_lat, lon=new_lon, method='nearest', kwargs={'fill_value':None}) fig, axes = plt.subplots(1, 2, figsize=(18, 12), subplot_kw=subplot_kw) axes = np.ravel(axes) ax = axes[1] ds.air.isel(time=0).plot(x='lon', y='lat', ax=ax, add_colorbar=False) ax.set_extent([ds.lon.min()-5., ds.lon.min()+20., ds.lat.max()-20, ds.lat.max()+5]) ax.coastlines() ax = axes[0] dsi.air.isel(time=0).plot(x='lon', y='lat', ax=ax, add_colorbar=False) ax.set_extent([ds.lon.min()-5., ds.lon.min()+20., ds.lat.max()-20, ds.lat.max()+5]) ax.coastlines() plt.show() ``` ### MVCE confirmation - [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray. - [X] Complete example — the example is self-contained, including all data and the text of any traceback. - [X] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result. - [X] New issue — a search of GitHub Issues suggests this is not a duplicate. ### Relevant log output _No response_ ### Anything else we need to know? _No response_ ### Environment
INSTALLED VERSIONS ------------------ commit: None python: 3.7.8 | packaged by conda-forge | (default, Jul 31 2020, 02:25:08) [GCC 7.5.0] python-bits: 64 OS: Linux OS-release: 3.10.0-1160.90.1.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8 libhdf5: 1.10.6 libnetcdf: 4.7.4 xarray: 0.16.1 pandas: 1.1.3 numpy: 1.19.2 scipy: 1.5.2 netCDF4: 1.5.4 pydap: None h5netcdf: None h5py: 2.10.0 Nio: None zarr: None cftime: 1.2.1 nc_time_axis: 1.2.0 PseudoNetCDF: None rasterio: 1.1.8 cfgrib: None iris: 2.4.0 bottleneck: None dask: 2.30.0 distributed: 2.30.0 matplotlib: 3.3.2 cartopy: 0.18.0 seaborn: 0.11.0 numbagg: None pint: None setuptools: 49.6.0.post20201009 pip: 20.2.3 conda: None pytest: None IPython: 5.8.0 sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7935/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 618141254,MDU6SXNzdWU2MTgxNDEyNTQ=,4061,Colormap Normalisation Giving Unexpected/Incorrect Output,31730876,open,0,,,11,2020-05-14T11:10:53Z,2023-03-10T16:10:44Z,,NONE,,,,"The behaviour when specifying ""norm"" for a colormap normalisation does not work as anticipated. Below I use the example code from matplotlib and apply the same normalisation to the DataArray version of the data but get very different results. #### MCVE Code Sample ```python import numpy as np import matplotlib.pyplot as plt import matplotlib.colors as colors import xarray #example from https://matplotlib.org/3.1.1/tutorials/colors/colormapnorms.html #for colormap normalisation N = 100 X, Y = np.mgrid[-3:3:complex(0, N), -2:2:complex(0, N)] Z1 = np.exp(-X**2 - Y**2) Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2) Z = (Z1 - Z2) * 2 fig, ax = plt.subplots(2, 1, figsize=(8, 8)) ax = ax.flatten() bounds = np.linspace(-1, 1, 10) norm = colors.BoundaryNorm(boundaries=bounds, ncolors=256) ax[0].pcolormesh(X, Y, Z, norm=norm, cmap='RdBu_r') #now add data into dataset and plot it using same normalisation data = xarray.DataArray(Z, dims=('x', 'y'), coords={'x': X[:,0], 'y': Y[0,:]}) data.plot(ax=ax[1], x='x', y='y', norm=norm, add_colorbar=False) plt.show() ``` #### Expected Output Top is expected, bottom is actual #### Problem Description Colormap normalisation appears to be broken in xarray #### Versions
Output of xr.show_versions() xarray.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 3.10.0-957.21.3.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8 libhdf5: 1.10.4 libnetcdf: 4.6.2 xarray: 0.15.1 pandas: 0.25.1 numpy: 1.17.2 scipy: 1.3.1 netCDF4: 1.5.1.2 pydap: None h5netcdf: None h5py: 2.9.0 Nio: None zarr: None cftime: 1.0.3.4 nc_time_axis: None PseudoNetCDF: None rasterio: 1.0.28 cfgrib: None iris: 2.2.0 bottleneck: None dask: 2.5.2 distributed: 2.5.2 matplotlib: 3.1.1 cartopy: 0.17.0 seaborn: 0.9.0 numbagg: None setuptools: 41.4.0 pip: 19.2.3 conda: None pytest: None IPython: 7.8.0 sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4061/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue