home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 455200681

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
455200681 MDU6SXNzdWU0NTUyMDA2ODE= 3017 Why am I running into a IndexVariable error message while assigning dims? 2014301 closed 0     1 2019-06-12T13:01:44Z 2020-04-06T22:43:53Z 2020-04-06T22:43:53Z NONE      

Code Sample, a copy-pastable example if possible

I am trying to remove the (north_south, east_west) from lat and lon and and make them coordinate dimensions. The following piece of code was working fine earlier. But now I am running into an error message. I think I updated xarray. Would like to know what I am doing wrong. Or if there is another way to do this?

```python ncdat = xr.open_mfdataset(files_lis) ncdat['lat']=ncdat['lat'].isel(time=0).drop('time') ncdat['lon']=ncdat['lon'].isel(time=0).drop('time') ncdat=ncdat.rename({'north_south':'lat', 'east_west':'lon'})

lat_coords = ncdat['lat'].values[:,-1] #Extract latitudes lon_coords = ncdat['lon'].values[-1,:] #Extract longitudes

reformatted_ncdat=ncdat.assign_coords(lat=lat_coords, lon=lon_coords, time=ncdat.coords['time'])

```

Problem description

This is ncdat after xr.open_mfdataset(files_lis) <xarray.Dataset> Dimensions: (SoilMoist_profiles: 3, east_west: 172, north_south: 92, time: 10) Coordinates: * time (time) datetime64[ns] 2016-08-01 2016-08-02 ... 2016-08-10 Dimensions without coordinates: SoilMoist_profiles, east_west, north_south Data variables: lat (time, north_south, east_west) float32 dask.array<shape=(10, 92, 172), chunksize=(1, 92, 172)> lon (time, north_south, east_west) float32 dask.array<shape=(10, 92, 172), chunksize=(1, 92, 172)> Snowf_tavg (time, north_south, east_west) float32 dask.array<shape=(10, 92, 172), chunksize=(1, 92, 172)> Rainf_tavg (time, north_south, east_west) float32 dask.array<shape=(10, 92, 172), chunksize=(1, 92, 172)> Evap_tavg (time, north_south, east_west) float32 dask.array<shape=(10, 92, 172), chunksize=(1, 92, 172)> Qs_tavg (time, north_south, east_west) float32 dask.array<shape=(10, 92, 172), chunksize=(1, 92, 172)> Qsb_tavg (time, north_south, east_west) float32 dask.array<shape=(10, 92, 172), chunksize=(1, 92, 172)> Qsm_tavg (time, north_south, east_west) float32 dask.array<shape=(10, 92, 172), chunksize=(1, 92, 172)> SWE_tavg (time, north_south, east_west) float32 dask.array<shape=(10, 92, 172), chunksize=(1, 92, 172)> SnowDepth_tavg (time, north_south, east_west) float32 dask.array<shape=(10, 92, 172), chunksize=(1, 92, 172)> SoilMoist_tavg (time, SoilMoist_profiles, north_south, east_west) float32 dask.array<shape=(10, 3, 92, 172), chunksize=(1, 3, 92, 172)> CanopInt_tavg (time, north_south, east_west) float32 dask.array<shape=(10, 92, 172), chunksize=(1, 92, 172)> WaterTableD_tavg (time, north_south, east_west) float32 dask.array<shape=(10, 92, 172), chunksize=(1, 92, 172)> TWS_tavg (time, north_south, east_west) float32 dask.array<shape=(10, 92, 172), chunksize=(1, 92, 172)> GWS_tavg (time, north_south, east_west) float32 dask.array<shape=(10, 92, 172), chunksize=(1, 92, 172)> SnowCover_tavg (time, north_south, east_west) float32 dask.array<shape=(10, 92, 172), chunksize=(1, 92, 172)> TotalPrecip_tavg (time, north_south, east_west) float32 dask.array<shape=(10, 92, 172), chunksize=(1, 92, 172)>

Error

ValueError: IndexVariable objects must be 1-dimensional

Expected Output

Please ignore values. Just an illustration. <xarray.Dataset> Dimensions: (SoilMoist_profiles: 3, lat: 92, lon: 172, time: 10) Coordinates: * lat (lat) float32 4.1249995 4.375 4.625 ... 26.624996 26.875 * lon (lon) float32 nan nan nan ... 24.375 24.625004 24.874996 * time (time) datetime64[ns] 2016-08-01 2016-08-02 ... 2017-12-31 Dimensions without coordinates: SoilMoist_profiles Data variables: Snowf_tavg (time, lat, lon) float32 ... Rainf_tavg (time, lat, lon) float32 ... Evap_tavg (time, lat, lon) float32 ... Qs_tavg (time, lat, lon) float32 ... Qsb_tavg (time, lat, lon) float32 ... Qsm_tavg (time, lat, lon) float32 ... SWE_tavg (time, lat, lon) float32 ... SnowDepth_tavg (time, lat, lon) float32 ... SoilMoist_tavg (time, SoilMoist_profiles, lat, lon) float32 ... CanopInt_tavg (time, lat, lon) float32 ... WaterTableD_tavg (time, lat, lon) float32 ... TWS_tavg (time, lat, lon) float32 ... GWS_tavg (time, lat, lon) float32 ... SnowCover_tavg (time, lat, lon) float32 ... TotalPrecip_tavg (time, lat, lon) float32 ...

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.7.3 (default, Mar 27 2019, 16:54:48) [Clang 4.0.1 (tags/RELEASE_401/final)] python-bits: 64 OS: Darwin OS-release: 18.6.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.4 libnetcdf: 4.6.2 xarray: 0.12.1 pandas: 0.24.2 numpy: 1.16.4 scipy: 1.2.1 netCDF4: 1.4.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.21 cfgrib: None iris: None bottleneck: None dask: 1.2.2 distributed: 1.28.1 matplotlib: 3.1.0 cartopy: None seaborn: 0.9.0 setuptools: 41.0.1 pip: 19.1.1 conda: None pytest: None IPython: 7.5.0 sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3017/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

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