Skip to content

name of array disappear when apply "where" filter with Datarray but not with np.array  #2457

Closed
@svicario

Description

@svicario

I was trying to select by non dimensional coordinate, and I found that "where" works well, but it erase the name of my datarray only if filtering is done with another datarray as a non dimensional coordinate

import xarray as xr
temp = 15 + 8 * np.random.randn(2, 2, 3)

precip = 10 * np.random.rand(2, 2, 3)

lon = [[-99.83, -99.32], [-99.79, -99.23]]

lat = [[42.25, 42.21], [42.63, 42.59]]
ds = xr.Dataset({'temperature': (['x', 'y', 'time'],  temp)},
                 coords={'lon': (['x', 'y'], lon),
                         'lat': (['x', 'y'], lat),
                         'precipitation': (['x', 'y', 'time'], precip),
                         'time': pd.date_range('2014-09-06', periods=3),
                         'reference_time': pd.Timestamp('2014-09-05')})

ds["temperature"].where(ds.precipitation>5).sum(axis=2).plot()

this line would produce a label near color bar
but only using a numpy array this happens as here

ds["temperature"].where(ds.precipitation.values>5).sum(axis=2).plot()

Expected Output

I think that selecting with a datarray should not change the label of the data.
Further I was expecting that as for "sel", "where" should change the title of the graph
so that I know from the title that I performed a selection with where with a non dimensional coordinate

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions