Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi-dimensional category_edges for contingency, reliability, etc`` #278

Open
aaronspring opened this issue Feb 28, 2021 · 5 comments
Open
Labels
enhancement New feature or request feature request

Comments

@aaronspring
Copy link
Collaborator

aaronspring commented Feb 28, 2021

so far with xhistogram, we can only create 1d category_edges. however, sometimes we would want to make category_edges multi-dimensional (dependent on lon and lat) when e.g. calculating wrt. climatological terciles.

inspired by #275 and used in #277

I found a way to bin datasets with multi-dim edges resulting in the same results as xhistogram.

e=[.1,.2,.4,.5,.7,.9]
edges = xr.DataArray(e, dims='edge')
(ds<edges).sum('member').diff('edge') == xs.core.utils.histogram(ds,bins=[np.array(e)],dim=['member']).rename({'var1_bin':'edge'})

sounds reasonable @dougiesquire ?

@aaronspring aaronspring added enhancement New feature or request feature request labels Feb 28, 2021
@dougiesquire
Copy link
Collaborator

Seems reasonable to me. And this adds really nice functionality - nice work!

Does this mean we should phase out our dependency on xhistogram? Alternatively, we could suggest that this type of functionality is added to xhistogram?

@aaronspring
Copy link
Collaborator Author

add to xhistogram could be nice. Although it seems they are mostly focusing on 1d edges. We could raise an issue there

@dougiesquire
Copy link
Collaborator

Also, just became aware of this:
https://boost-histogram.readthedocs.io/en/latest/notebooks/xarray.html
Haven't tried to use it yet, but apparently plays nicely with xarray, and faster than xhistogram. Not sure whether there is support for multidimensional bins

@dougiesquire
Copy link
Collaborator

Also, just became aware of this:
https://boost-histogram.readthedocs.io/en/latest/notebooks/xarray.html
Haven't tried to use it yet, but apparently plays nicely with xarray, and faster than xhistogram. Not sure whether there is support for multidimensional bins

On further inspection, I think not...

@aaronspring
Copy link
Collaborator Author

Use pydata/xarray#5400

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature request
Projects
None yet
Development

No branches or pull requests

2 participants