-
Notifications
You must be signed in to change notification settings - Fork 23
Description
currently, xhistogram only allows bins to be one-dimensional.
however, when the bin edges vary in time (seasonality) or space (locations of the globe) xhistogram cannot be used with multi-dim bins. there is a hard-coded requirement for bins elements to be 1-d.
One of such multi-dim bin applications is the ranked probability score rps we use in xskillscore.rps, where we want to know how many forecasts fell into which bins. Bins are often defined as terciles of the forecast distribution and the bins for these terciles (forecast_with_lon_lat_time_dims.quantile(q=[.33,.66],dim='time')) depend on lon and lat.
How we solved this in xskillscore.rps:
<
gives us CDFs, and diff
brings it back to histograms. maybe have to throw away the upper edge
Fc = (forecasts < forecasts_edges).mean('member').diff(bin_dim)
Oc = (observations < observations_edges).astype("int").diff(bin_dim)
I first implemented rps with xhistogram, then with the snippet above, yields same results.
However, I am not sure whether such multi-dimensional bins would be an interesting addition to xhistogram or are out-of-scope.