MBravoS / splotch

Simple PLOTs, Contours and Histograms is a small package with wrapper functions designed to simplify plotting calls from matplotlib.
BSD 3-Clause "New" or "Revised" License
4 stars 0 forks source link

hist2d() does not accept weights #61

Open AstroRobin opened 3 years ago

AstroRobin commented 3 years ago

It looks like there is no easy way to parse weights into the hist2d() function. As kwargs are given to pcolormesh(), we will need to create a parameter "weights" which can then be given to histogram_2d() or binned_statistics_2d().

There probably does not need to be many checks on this parameter as most of the exceptions will be raised by numpy/scipy.

MBravoS commented 1 year ago

Adding weights to the standard 2D histograms is easy (and has been added as of v0.5.11.0), but for the generalised version is a harder problem. I haven't found method that does the same as binned_statistic_2d, so for the moment the only option I can think of would be to re-invent the wheel and make our own version. I'm not convinced that we can easily make it as fast as scipy's implementation. Furthermore, I think I understand why the might have ignored the problem, as a several "weighted statistics" are undefined (e.g., what's a weighted maximum?).

I will leave for the time being this issue open, with the understanding that our solution for the moment is not complete.