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

time-varying bins #1

Open
miniufo opened this issue Jul 5, 2022 · 2 comments
Open

time-varying bins #1

miniufo opened this issue Jul 5, 2022 · 2 comments

Comments

@miniufo
Copy link

miniufo commented Jul 5, 2022

Hi, it is a nice package. Just want to know if the bins parameter can be time-varying. Or more flexible, can the bins parameter be also a xarray.DataArray? I find that xhistogram at here cannot accept xarray.DataArray as its bin argument.

@Descanonge
Copy link
Owner

Hi, thanks!
I hadn't thought of time-varying bins, but I can see it implemented without too much trouble.
As for accepting xarray.DataArray for the bins argument, it is also feasible (I guess it would be a good idea to make it mandatory for time-varying bins).

This needs some refactoring so that the code stays clean but right now I don't see anything impossible. That would be nice since it seems from this comment that it won't be implemented in xhistogram before a while. I will work on that as soon as I have a solid base package (in a few days hopefully).

@miniufo
Copy link
Author

miniufo commented Jul 6, 2022

That's a good news. I have to calculate PDF of a tracer field between min and max values and these values change with time (or even with depth). So I am expecting this behavior or similar:

# tracer[T, Z, Y, X] is a 4D variable
hist = xh.histogram(tracer, bins=[tracer.min(['X', 'Y']), tracer.max(['X', 'Y'])], dims=['X', 'Y'])
# output hist[T, Z, PDF] should be 3D variable

xhistogram cannot accept xarray as its bins argument because it relies on numpy. In addition, it does not support dask well. Looking forward to your solutions. I guess the bins argument accepting xarray.DataArray would be a very good point for your release.

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

No branches or pull requests

2 participants