home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 411734784

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
411734784 MDU6SXNzdWU0MTE3MzQ3ODQ= 2775 Improved inference of names when concatenating arrays 12229877 closed 0     1 2019-02-19T04:01:03Z 2019-03-04T05:39:21Z 2019-03-04T05:39:21Z CONTRIBUTOR      

Problem description

Using the name of the first element to concatenate as the name of the concatenated array is only correct if all names are identical. When names vary, using a clear placeholder name or the name of the new dimension would avoid misleading data users.

This came up for me recently when stacking several bands of a satellite image to produce a faceted plot - the resulting colorbar was labelled "blue", even though that was clearly incorrect.

A similar process is probably also desirable for aggregation of units across concatenated arrays - use first if identical, otherwise discard or error depending on the compat argument.

Code Sample, a copy-pastable example if possible

```python ds = xr.Dataset({ k: xr.DataArray(np.random.random((2, 2)), dims="x y".split(), name=k) for k in "blue green red".split() })

arr.name == "blue", could be "band" or "concat_dim"

arr = xr.concat([ds.blue, ds.green, ds.red], dim="band")

label of colorbar is "blue", which is meaningless

arr.plot.imshow(col="band") ```

One implementation that would certainly be nice for this use-case (though perhaps not generally) is that concatenating DataArrays along an entirely new dimension with unique array names and dim passed a string could create a new Index as well, as pd.Index([a.name for a in objs], name=dim).

INSTALLED VERSIONS ------------------ commit: None python: 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 158 Stepping 9, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None libhdf5: 1.10.3 libnetcdf: 4.4.1.1 xarray: 0.11.2 pandas: 0.23.1 numpy: 1.14.5 scipy: 1.2.1 netCDF4: 1.4.2 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.3.4 PseudonetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None cyordereddict: None dask: None distributed: None matplotlib: 3.0.2 cartopy: None seaborn: 0.9.0 setuptools: 40.6.2 pip: 10.0.1 conda: None pytest: 4.2.0 IPython: 6.4.0 sphinx: 1.8.0

I'd be happy to write a PR for this if it would be accepted.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/2775/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.606ms · About: xarray-datasette