home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 322849322

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
322849322 MDU6SXNzdWUzMjI4NDkzMjI= 2129 Using `DataArray.where()` with a DataArray as the condition drops the name 4849151 closed 0     4 2018-05-14T14:46:18Z 2020-04-14T08:54:33Z 2020-04-14T08:54:33Z NONE      

Code Sample, a copy-pastable example if possible

Create a boolean DataArray to use as a mask for another DataArray, with the same coordinates:

python da_1 = xr.DataArray(np.array([0.861185, 0.301491, 0.642744, 0.773298, 0.786516, 0.011693, 0.659326, 0.07877 , 0.108488, 0.747863]), coords=[('coord1', np.arange(10))], name='da1') da_2 = xr.DataArray(np.array([0.116959, 0.955742, 0.121562, 0.635573, 0.304895, 0.064529, 0.042461, 0.41751 , 0.607457, 0.110104]), coords=[('coord1', np.arange(10))], name='da2') da_3 = np.rint(da_2).astype('bool') print(da_1) <xarray.DataArray 'da1' (coord1: 10)> array([0.861185, 0.301491, 0.642744, 0.773298, 0.786516, 0.011693, 0.659326, 0.07877 , 0.108488, 0.747863]) Coordinates: * coord1 (coord1) int64 0 1 2 3 4 5 6 7 8 9 print(da_1.where(da_3)) <xarray.DataArray (coord1: 10)> array([ nan, 0.301491, nan, 0.773298, nan, nan, nan, nan, 0.108488, nan]) Coordinates: * coord1 (coord1) int64 0 1 2 3 4 5 6 7 8 9

Problem description

When using a DataArray (da_3 in the example) as the condition in the where() method of another DataArray (da_1), the name of the DataArray being masked (da_1) is dropped.

Expected Output

The name should be retained. python print(da_1.where(da_3)) <xarray.DataArray 'da_1` (coord1: 10)> array([ nan, 0.301491, nan, 0.773298, nan, nan, nan, nan, 0.108488, nan]) Coordinates: * coord1 (coord1) int64 0 1 2 3 4 5 6 7 8 9

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.6.5.final.0 python-bits: 64 OS: Linux OS-release: 4.13.0-38-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8 xarray: 0.10.3 pandas: 0.22.0 numpy: 1.14.3 scipy: 1.1.0 netCDF4: 1.3.2 h5netcdf: None h5py: 2.7.1 Nio: None zarr: None bottleneck: 1.2.1 cyordereddict: None dask: 0.17.4 distributed: 1.21.8 matplotlib: 2.2.2 cartopy: None seaborn: 0.8.1 setuptools: 39.1.0 pip: 10.0.1 conda: 4.5.2 pytest: 3.5.1 IPython: 6.4.0 sphinx: 1.7.4
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/2129/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

  • 2 rows from issues_id in issues_labels
  • 4 rows from issue in issue_comments
Powered by Datasette · Queries took 0.925ms · About: xarray-datasette