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 #67

Open
miniufo opened this issue Jun 26, 2021 · 4 comments
Open

time-varying bins #67

miniufo opened this issue Jun 26, 2021 · 4 comments

Comments

@miniufo
Copy link

miniufo commented Jun 26, 2021

Thanks to you guys for this handy package.

I had to use time-varying bins when I tried to calculate the area enclosed by tracer contours, as the tracer changes with time. However, the bins kwarg neither support xarray nor support a mulidimendional numpy array for hist along contour space.

I also need to convert PDF of xhist to CDF for area. It seems that xhist does not directly support this. A way to do this is to use numpy.cumsum. Is it possible to integrate this functionality into xhist?

@jbusecke
Copy link
Contributor

This would only be necessary if you want to change the tracer bins with time, I think. To just count the area within e.g. tracer<=phi_0 you just want to pass fixed tracer bins and compute the histogram over x/y (not time).

@miniufo
Copy link
Author

miniufo commented Jun 29, 2021

I see there is a PR #59 by @TomNicholas. Is this able to solve this?

@TomNicholas
Copy link
Member

Hi there @miniufo , glad you are finding this package useful.

I had to use time-varying bins

@jbusecke is right that changes of the data with time don't necessarily mean you need time-varying bins, but for actual time-varying bins then yes #59 was intended to solve that. However, as per this comment I will probably wait until after integration into xarray to implement it, so it might be a little while.

I also need to convert PDF of xhist to CDF for area. It seems that xhist does not directly support this. A way to do this is to use numpy.cumsum. Is it possible to integrate this functionality into xhist?

xarray has a .cumsum() method for DataArrays, can you not just directly call that on the output of xhistogram? For non-uniform bins there is also .integrate().

@miniufo
Copy link
Author

miniufo commented Jun 30, 2021

Thanks for your gus @jbusecke @TomNicholas.

My tracer extrema vary with time. I would like to ensure the max (min) value corresponds to total (zero) area of the domain. If the bin is fixed, I may get non-monotonic tracer-area relation (which I need to reverse later). Normalization between max and min is a workaround. But I chose to loop over time for time-varying bins and then concat then along time. Not complicate for my special case, but not easy to generalize to account for many cases.

Oooops, didn't realize the xarray's cumsum(). I'll fix this, paying attension to the non-uniform bins.

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

3 participants