home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 574015429

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
574015429 MDU6SXNzdWU1NzQwMTU0Mjk= 3819 expand_dims changes attrs and encoding of coordinate variable 11731042 closed 0     3 2020-03-02T14:33:30Z 2020-07-02T22:00:03Z 2020-07-02T22:00:02Z NONE      

Expanding the dimensions of a variable with a dimension having the same name as a coordinate variable will also change the attributes (including encoding attributes) of this coordinate variable!

The following examples prints the attrs and encoding of coordinate variable time before/after expanding the dimensions of the variable sea_surface_temperature

```python import xarray as xr import numpy as np

grid = xr.Dataset({ 'time': (('time',), [np.datetime64('2018-01-01')]), 'lat': (('lat'), np.arange(-80, 80, 1)), 'lon': (('lon',), np.arange(-180, 180, 1)), 'sea_surface_temperature': (('lat', 'lon',), np.ones(shape=(160, 360))) })

grid['time'].encoding['units'] = 'seconds since 1981-01-01 00:00:00' grid['time'].attrs['comment'] = 'some comment'

print(grid['time'].encoding, grid['time'].attrs) grid['sea_surface_temperature'] = grid['sea_surface_temperature'].expand_dims('time', axis=0) print(grid['time'].encoding, grid['time'].attrs)

``` The current output is:

{'units': 'seconds since 1981-01-01 00:00:00'} {'comment': 'some comment'} {} {}

Expected Output

I would not expect any change to other coordinates or variables than the expanded one (here sea_surface_temperature)

{'units': 'seconds since 1981-01-01 00:00:00'} {'comment': 'some comment'} {'units': 'seconds since 1981-01-01 00:00:00'} {'comment': 'some comment'}

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.8.1 (default, Jan 8 2020, 22:29:32) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.15.0-72-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: fr_FR.UTF-8 LOCALE: fr_FR.UTF-8 libhdf5: 1.10.4 libnetcdf: 4.7.3 xarray: 0.15.0 pandas: 1.0.1 numpy: 1.18.1 scipy: 1.4.1 netCDF4: 1.5.3 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.4.2 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2.11.0 distributed: 2.11.0 matplotlib: None cartopy: None seaborn: None numbagg: None setuptools: 45.2.0.post20200210 pip: 20.0.2 conda: None pytest: None IPython: None sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3819/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 3 rows from issue in issue_comments
Powered by Datasette · Queries took 0.7ms · About: xarray-datasette