issues: 792639470
This data as json
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
792639470 | MDU6SXNzdWU3OTI2Mzk0NzA= | 4839 | Coordinate attributes are dropped when interpolating datasets | 14371165 | closed | 0 | 3 | 2021-01-23T20:05:33Z | 2021-04-27T07:00:08Z | 2021-04-27T07:00:08Z | MEMBER | What happened: When I was interpolating datasets I noticed that the coordinate variables disappeared. What you expected to happen: Coordinate attributes should be retained just like variables are. Minimal Complete Verifiable Example: ```python import numpy as np import xarray as xr names = np.core.defchararray.add("long_variable_name", np.arange(0, 2).astype(str)) coords = dict(time=np.array([0, 1])) data_vars = dict() for v in names: data_vars[v] = xr.Variable( "time", np.array([0, 1], dtype=int), attrs=dict(unit="kg") ) ds1 = xr.Dataset(data_vars=data_vars, coords=coords) ds1.attrs = { k: 2 for k in np.core.defchararray.add("attr_", np.arange(0, 3).astype(str)) } ds1.time.attrs.update(unit="s") Print time:ds1.time Out[115]: <xarray.DataArray 'time' (time: 2)> array([0, 1]) Coordinates: * time (time) int32 0 1 Attributes: unit: s Interpolate:ds1 = ds1.interp( time=np.array([0, 0.5, 1, 2]), assume_sorted=True, method="linear", kwargs=dict(fill_value="extrapolate"), ) Print interpolated time, units are lost:ds1.time Out[117]: <xarray.DataArray 'time' (time: 4)> array([0. , 0.5, 1. , 2. ]) Coordinates: * time (time) float64 0.0 0.5 1.0 2. ``` Anything else we need to know?: Environment: Output of <tt>xr.show_versions()</tt>xr.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel byteorder: little libhdf5: 1.10.4 libnetcdf: None xarray: 0.16.2 pandas: 1.2.0 numpy: 1.17.5 scipy: 1.4.1 netCDF4: None pydap: None h5netcdf: None h5py: 2.10.0 Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.3.2 dask: 2020.12.0 distributed: 2020.12.0 matplotlib: 3.3.2 cartopy: None seaborn: 0.11.1 numbagg: None pint: None setuptools: 51.1.2.post20210112 pip: 20.3.3 conda: 4.9.2 pytest: 6.2.1 IPython: 7.19.0 sphinx: 3.4.3 |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/4839/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |