API Reference¶
pygram11 Specific¶

pygram11.
fix1d
(x, bins=10, range=None, weights=None, omp=False)[source]¶ histogram
x
with fixed (uniform) binningParameters: Returns: numpy.ndarray
– bin counts (heights)numpy.ndarray
– sum of weights squared (only ifweights
is not None)
Examples
A histogram of
x
with 20 bins between 0 and 100, and weighted.>>> h = fix1d(x, bins=20, range=(0, 100))
The same data, now histogrammed weighted & accelerated with OpenMP.
>>> h, sw2 = fix1d(x, bins=20, range=(0, 100), omp=True)

pygram11.
var1d
(x, bins, weights=None, omp=False)[source]¶ histogram
x
with variable (nonuniform) binningParameters:  x (array_like) – data to histogram
 bins (array_like) – bin edges
 weights (array_like, optional) – weight for each element of
x
 omp (bool) – use OpenMP if available
Returns: numpy.ndarray
– bin counts (heights)numpy.ndarray
– sum of weights squared (only ifweights
is not None)
Examples
A histogram of
x
where the edges are defined by the list[1, 5, 10, 12]
:>>> h, w = var1d(x, [1, 5, 10, 12])
The same data, now weighted and accelerated with OpenMP:
>>> h = var1d(x, [1, 5, 10, 12], weights=w, omp=True)

pygram11.
fix2d
(x, y, bins=10, range=None, weights=None, omp=False)[source]¶ histogram the
x
,y
data with fixed (uniform) binning in two dimensionsParameters:  x (array_like) – first entries in data pairs to histogram
 y (array_like) – second entries in data pairs to histogram
 bins (int or iterable) – if int, both dimensions will have that many bins, if iterable, the number of bins for each dimension
 range (iterable, optional) – axis limits to histogram over in the form [(xmin, xmax), (ymin, ymax)]
 weights (array_like, optional) – weight for each \((x_i, y_i)\) pair.
 omp (bool) – use OpenMP if available
Returns: numpy.ndarray
– bin counts (heights)numpy.ndarray
– sum of weights squared (only if weights is not None)
Examples
A histogram of (
x
,y
) with 20 bins between 0 and 100 in thex
dimention and 10 bins between 0 and 50 in they
dimension.>>> h = fix2d(x, y, bins=(20, 10), range=((0, 100), (0, 50)))
The same data, now histogrammed weighted (via
w
) & accelerated with OpenMP.>>> h, sw2 = fix2d(x, y, bins=(20, 10), range=((0, 100), (0, 50)), ... weights=w, omp=True)

pygram11.
var2d
(x, y, xbins, ybins, weights=None, omp=False)[source]¶ histogram the
x
andy
data with variable width binning in two dimensionsParameters:  x (array_like) – first entries in the data pairs to histogram
 y (array_like) – second entries in the data pairs to histogram
 xbins (array_like) – bin edges for the
x
dimension  ybins (array_like) – bin edges for the
y
dimension  weights (array_like, optional) – weights for each \((x_i, y_i)\) pair.
 omp (bool) – use OpenMP if available
Returns: numpy.ndarray
– bin counts (heights)numpy.ndarray
– sum of weights squared (only if weights is not None)
Examples
A histogram of (
x
,y
) where the edges are defined by anumpy.logspace()
in both dimensions, accelerated with OpenMP.>>> bins = numpy.logspace(0.1, 1.0, 10, endpoint=True) >>> h = var2d(x, y, bins, bins, omp=True)
NumPylike¶

pygram11.
histogram
(x, bins=10, range=None, weights=None, omp=False)[source]¶ Compute the histogram for the data
x
.This functions provides an API very simiar to
numpy.histogram()
. Keep in mind that the returns are different.Parameters:  x (array_like) – Data to histogram.
 bins (int or sequence of scalars, optional) – If bins is an int, that many equalwidth bins will be used to construct the histogram in the given range. If bins is a sequence, it must define a monotonically increasing array of bin edges. This allows for nonuniform bin widths.
 range ((float, float), optional) – The range over which the histogram is constructed. If a range is not provided then the default is (x.min(), x.max()). Values outside of the range are ignored. If bins is a sequence, this options is ignored.
 weights (array_like, optional) – An array of weights associated to each element of
x
. Each value of thex
will contribute its associated weight to the bin count.  omp (bool) – Use OpenMP if available.
Returns: numpy.ndarray
– bin counts (heights)numpy.ndarray
– sum of weights squared (only ifweights
is not None)

pygram11.
histogram2d
(x, y, bins=10, range=None, weights=None, omp=False)[source]¶ Compute the twodimensional histogram for the data (
x
,y
).This functions provides an API very simiar to
numpy.histogram2d()
. Keep in mind that the returns are different.Parameters:  x (array_like) – Array representing the
x
coordinate of the data to histogram.  y (array_like) – Array representing the
y
coordinate of the data to histogram.  bins (int or array_like or [int, int] or [array, array], optional) –
 The bin specification:
 If int, the number of bins for the two dimensions
(
nx = ny = bins
).  If array_like, the bin edges for the two dimensions
(
x_edges = y_edges = bins
).  If [int, int], the number of bins in each dimension
(
nx, ny = bins
).  If [array_like, array_like], the bin edges in each
dimension (
x_edges, y_edges = bins
).
 If int, the number of bins for the two dimensions
(
 range (array_like, shape(2,2), optional) – The edges of this histogram along each dimension. If
bins
is not integral, then this parameter is ignored. If None, the default is[[x.min(), x.max()], [y.min(), y.max()]]
.  weights (array_like) – An array of weights associated to each element \((x_i, y_i)\) pair. Each pair of the the data will contribute its associated weight to the bin count.
 omp (bool) – Use OpenMP if available
Returns: numpy.ndarray
– bin counts (heights)numpy.ndarray
– sum of weights squared (only ifweights
is not None)
 x (array_like) – Array representing the