The Axis class functions allows quick access to information about the histograms binnings etc.
Bases: object
The Axis is the container for all the functions specific to one particular dimension of the histogram.
E.g. the type of the edge values, number of bins etc.
Initialization of a new axis
Parameters: |
|
---|
Example
Initialization with bin edges
>>> ax = Axis(hist, [1, 4, 9])
>>> ax = Axis(hist, ['My', 'name', 'is', 'Bond']])
Initialization with number of bins (10), lowest (0) and highest bound (1)
>>> ax = Axis(hist, 10, 0, 1)
Returns the center of the given bin, if appropriate converted to the axis’s type.
This function is not available if the axis is of type ‘regex’.
Parameters: | i (int) – Axis bin number |
---|---|
Return type: | float or datetime |
Returns the centers of the bins along this axis.
This function is not available if the axis is of type ‘regex’.
Return type: | array_like |
---|
Returns the edges of the bins along this axis.
This function is not available if the axis is of type ‘regex’.
Parameters: | convert (bool) – If true, the returned value will be converted to the appropriate type of the axis (e.g. datetime) |
---|---|
Returns: | The length of this array is nbins + 1 |
Return type: | array_like |
Returns only the lower bin edges of the bins along this axis.
This function is not available if the axis is of type ‘regex’.
Parameters: | convert (bool) – If true, the returned value will be converted to the appropriate type of the axis (e.g. datetime) |
---|---|
Return type: | array_like |
Return the regex for the respective bin on this axis.
This function is not available if the axis is of type datetime, numerical
Parameters: | i (int) – Axis bin number |
---|---|
Return type: | array_like |
Returns the regexes (not the patterns) of the bins along this axis.
This function is only available for axes of the type ‘regex’.
Return type: | array_like |
---|
Returns only the upper bin edge of for a given axis-bin number.
This function is not available if the axis is of type ‘regex’.
Parameters: | convert (bool) – If true, the returned value will be converted to the appropriate type of the axis (e.g. datetime) |
---|---|
Return type: | array_like |
Returns the width of the given bin in the appropriate type.
This function is not available if the axis is of type ‘regex’.
Parameters: | i (int) – Axis bin number |
---|---|
Return type: | float or datetime |
Returns the number of bins along this axis.
Return type: | int |
---|
Bases: object
This class provides access to the histogram’s bins without creating the need for the user to know anything about the internal storage mechanisms. Bins are organized in one long array with a unique mapping from the axis bin numbers i, j, k to the global bin number b. It is important to remember that each of these indices starts at 1 not 0.
Having I bins along the x-axis, J bins along the y-axis and K bins along the z-axis, the mapping from the xyz bin numbers (i, j, k) to the global bin number b is given by::
b = (k-1)*(J-1)*I + (j-1)*I + i
Thus, in case of a 2D histogram (k=K=1; j>1) this reduces to::
b = (j-1)*I + i
and for a 1D histogram (k=K=1=j=J=1)::
b = i
The bin container class does not deal with the finding of bins in user defined units. It exclusively deals with bin numbers and leaves the user defined bin sizes and units to the axis class.
Initialization of the Bin_container.
Parameters: | nybins, nzbins (nxbins,) – Number of bins along each axis. Must be greater than 1 |
---|
Increment the value of the given bin by the given weight
Parameters: | gidx (int) – Global bin number |
---|---|
Return type: | None |
Returns the content of a given bin.
Parameters: | gidx (int) – Global bin number |
---|---|
Return type: | float |
Returns the error of a given bin.
Parameters: | gidx (int) – Global bin number |
---|---|
Return type: | float |
Returns the global bin number given the axis bin numbers.
The axis bin numbers are denoted as i, j, k for the x, y and z axis respectively. They are element of [1, N] where N is I, J, or K respectively.
Parameters: |
|
---|---|
Return type: | int |
Returns the local bin numbers for each axis given the global bin number.
Parameters: | gidx (int) – Global bin number |
---|---|
Returns: | The three axis bin numbers (i, j, k) |
Return type: | tuple |
Returns the total number of bins of in this histogram
Return type: | int |
---|
Replaces the content of a bin with the given value.
Parameters: |
|
---|
Replaces the error of a bin with the given value.
Parameters: |
|
---|
Bases: object
The bin proxy is a convenient interface for getting additional information about each bin when iterating through several bins of the histogram.
The bin proxy is created for each bin yielded by h.bins(), e.g.::
>>> for bin in h.bins():
... print bin.center
Initialization of a new Bin_proxy.
Parameters: |
|
---|
Returns the axial indices (i, j, k) for this bin.
This function always returns three indices regardless of the histograms dimensionality.
Returns: | Tuple of the three axial indices (i, j, k) |
---|---|
Return type: | tuple |
Number of effective entries in this bin. The number of unweighted entries this bin would need to contain in order to have the same statistical power as this bin with possibly weighted entries, estimated by:
(sum of weights) ** 2 / (sum of squares of weights)
Return the error of this bin.
Return type: | float |
---|
Return the value of this bin.
Return type: | float |
---|
Provides an entry point for retrieving x-axis specific information from this bin.
Return type: | pyhistogram.bin_proxy.bi |
---|
Provides an entry point for retrieving y-axis specific information from this bin.
Return type: | pyhistogram.bin_proxy.bi |
---|
Provides an entry point for retrieving z-axis specific information from this bin.
Return type: | pyhistogram.bin_proxy.bi |
---|
Defining exceptions to be raised if a look for a bin yielded an over/under flow
Bases: exceptions.Exception
Bases: exceptions.Exception
The Hist classes are the entry point for the user for creating and using the histogram
Bases: object
Initialization of a one dimensional histogram
Parameters: |
|
---|
A iterator for all the bins in the histogram.
Returns: | A class giving easy access to all the information of this bin. |
---|---|
Return type: | Bin_proxy |
Function for adding content to the histogram.
The bin containing the given x coordinate will be incremented with the value given as weight.
Parameters: |
|
---|
Example
>>> h = Hist(10, 0, 1)
>>> h.fill(2.5, weight=0.5)
Return overflow of the entire histogram.
No differentiation between individual axes nor under and overflow is implemented, yet.
Returns: | The number of times the histogram was filled with coordinates not matching any bins |
---|---|
Return type: | int |
Plot the current histogram.
This requires matplotlib to be installed. All the given keywords are passed to the bar() function of matplotlib.
Parameters: | kwargs (dict) – are passed on to the bar() function of matplotlib. |
---|---|
Returns: | This is the return value of the bar() function |
Return type: | matplotlib.patches.Rectangle |
Convert v to a python datetime if dtype is ‘datetime’