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 1647883619,I_kwDOAMm_X85iOLVj,7701,Recently introduced different behaviour of da.interp() when using floats vs DataArrays with new dim,60435591,closed,0,,,6,2023-03-30T15:47:53Z,2023-10-04T18:08:51Z,2023-10-04T18:07:08Z,CONTRIBUTOR,,,,"### What happened? In recent xarray versions, `da.interp()` behaves differently when using floats as input, in comparison to using a DataArray with a new dimension as input. In the attached example, the variables `interp_with_floats` and `interp_with_da` return a different amount of float/nan values: ``` [35.824154 35.810417 35.796684 nan nan] [35.824154 35.810417 nan nan nan] ``` This is the case with xarray 2023.1.0/2023.2.0, but was not yet happening in xarray 2022.6.0/2022.12.1.dev15+gd6d24507. I cannot find .interp() related changes in https://docs.xarray.dev/en/stable/whats-new.html. A CMEMS use case is described in https://github.com/Deltares/dfm_tools/issues/287 ### What did you expect to happen? Equal interpolation results with both methods since the input values are equal. ### Minimal Complete Verifiable Example ```Python import numpy as np import xarray as xr ds = xr.Dataset() so_np = np.array([[[35.819576, 35.82568 , 35.82873 ], [35.819576, 35.824154, 35.831783], [35.822628, 35.824154, 35.82873 ]], [[35.802788, 35.80584 , 35.815 ], [35.815 , 35.810417, 35.821102], [35.824154, 35.813473, 35.81805 ]], [[35.786003, 35.789055, np.nan], [35.807365, 35.796684, np.nan], [35.824154, 35.80584 , np.nan]], [[35.776848, np.nan, np.nan], [35.792107, np.nan, np.nan], [35.822628, np.nan, np.nan]], [[35.781425, np.nan, np.nan], [35.792107, np.nan, np.nan], [35.789055, np.nan, np.nan]]]) ds['so'] = xr.DataArray(so_np,dims=('depth','latitude','longitude')) ds['longitude'] = xr.DataArray([-9.6, -9.5, -9.4], dims=('longitude')) ds['latitude'] = xr.DataArray([42.9, 43.0, 43.1], dims=('latitude')) x_xr = xr.DataArray([-9.5],dims=('plipoints')) y_xr = xr.DataArray([43],dims=('plipoints')) interp_with_floats = ds.interp(longitude=x_xr[0], latitude=y_xr[0], method='linear').so #selecting one value from the da drops the new plipoints dimension interp_with_da_existing = ds.interp(longitude=x_xr.values, latitude=y_xr.values, method='linear').so.isel(longitude=0,latitude=0) #using the DataArray values keeps lat/lon dimenions, gives the same interp result interp_with_da_newdim = ds.interp(longitude=x_xr, latitude=y_xr, method='linear').so.isel(plipoints=0) #using the DataArray introduces a plipoints dimension, which gives different interp result print(interp_with_floats.to_numpy()) print(interp_with_da_existing.to_numpy()) print(interp_with_da_newdim.to_numpy()) print(xr.__version__) assert (interp_with_floats.isnull()==interp_with_da_existing.isnull()).all() #success assert (interp_with_floats.isnull()==interp_with_da_newdim.isnull()).all() #fails with scipy>=1.10.0 ``` ### 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.8.13 | packaged by conda-forge | (default, Mar 25 2022, 05:59:45) [MSC v.1929 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 85 Stepping 0, GenuineIntel byteorder: little LC_ALL: None LANG: en LOCALE: ('Dutch_Netherlands', '1252') libhdf5: 1.12.2 libnetcdf: 4.8.1 xarray: 2023.1.0 pandas: 1.5.3 numpy: 1.23.5 scipy: 1.10.1 netCDF4: 1.6.2 pydap: installed h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.6.2 nc_time_axis: None PseudoNetCDF: None rasterio: 1.3.3 cfgrib: None iris: None bottleneck: 1.3.6 dask: 2022.9.2 distributed: 2022.9.2 matplotlib: 3.6.1 cartopy: 0.21.0 seaborn: 0.10.1 numbagg: None fsspec: 2022.10.0 cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 65.5.0 pip: 23.0.1 conda: None pytest: 7.1.3 mypy: None IPython: 7.33.0 sphinx: 5.3.0
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7701/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 1395962467,I_kwDOAMm_X85TNLJj,7121,Add rename_variables argument to xr.open_dataset() to workaround vars with same names as dims,60435591,closed,0,,,2,2022-10-04T09:43:56Z,2022-10-05T10:00:12Z,2022-10-05T10:00:12Z,CONTRIBUTOR,,,,"### Is your feature request related to a problem? Yes, xarray not being able to open netcdf files with non-unique variable/dimension names is an issue for many people. Me personally have come across several files where this is an issue. As a not so nice workaround I use ``drop_variables`` for variables x/y before reading the file with xarray, and then adding them again under a different name with help of the netCDF4 library. It would be very convenient to have a ``rename_variables`` argument for ``xr.open_dataset()`` (and ``xr.open_mfdataset()``). This suggestion was also made by others in other issues but I cannot find a feature request for it: _by @jthielen in https://github.com/pydata/xarray/issues/2233#issuecomment-782188310_ _by @markelg in https://github.com/pydata/xarray/issues/2368#issuecomment-415402600_ ### Describe the solution you'd like ``rename_variables`` argument for ``xr.open_dataset()`` (and ``xr.open_mfdataset()``). ### Describe alternatives you've considered _No response_ ### Additional context _No response_","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7121/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue