baldaquin.hist
— Histograms#
Module documentation#
Histogram facilities.
- exception baldaquin.hist.InvalidShapeError(expected, actual)[source]#
RuntimeError subclass to signal an invalid shape while operating with arrays.
- class baldaquin.hist.HistogramBase(binning, labels)[source]#
Base class for an n-dimensional histogram.
This interface to histograms is profoundly different for the minimal numpy/matplotlib approach, where histogramming methods return bare vectors of bin edges and counts.
Note that this base class is not meant to be instantiated directly, and the interfaces to concrete histograms of specific dimensionality are defined in the sub-classes.
- Parameters:
binning (n-dimensional tuple of arrays) – the bin edges on the different axes.
labels (n-dimensional tuple of strings) – the text labels for the different axes.
- PLOT_OPTIONS = {}#
- _zeros(dtype: type = <class 'float'>)[source]#
Return an array of zeros of the proper shape for the underlying histograms quantities.
- static calculate_axis_statistics(bin_centers: array, content: array) dict [source]#
Calculate the basic statistics (normalization, mean and rms) for a given set of binned data.
- _check_array_shape(data: array) None [source]#
Check the shape of a given array used to update the histogram.
- set_errors(errors: array) None [source]#
Set the proper value for the _sumw2 underlying array, given the errors on the bin content.
- fill(*values, weights=None)[source]#
Fill the histogram from unbinned data.
Note this method is returning the histogram instance, so that the function call can be chained.
- set_content(content: array, entries: array | None = None, errors: array | None = None)[source]#
Set the bin contents programmatically from binned data.
Note this method is returning the histogram instance, so that the function call can be chained.
- static bisect(binning: array, values: array, side: str = 'left') array [source]#
Return the indices corresponding to a given array of values for a given binning.
- find_bin(*coords)[source]#
Find the bin corresponding to a given set of “physical” coordinates on the histogram axes.
This returns a tuple of integer indices that can be used to address the histogram content.
- class baldaquin.hist.Histogram1d(xbinning: array, xlabel: str = '', ylabel: str = 'Entries/bin')[source]#
A one-dimensional histogram.
- PLOT_OPTIONS = {'alpha': 0.4, 'histtype': 'stepfilled', 'lw': 1.25}#
- class baldaquin.hist.Histogram2d(xbinning, ybinning, xlabel='', ylabel='', zlabel='Entries/bin')[source]#
A two-dimensional histogram.
- PLOT_OPTIONS = {'cmap': <matplotlib.colors.LinearSegmentedColormap object>}#