Binning Functions – pyne.bins
¶
This module holds some basic utility functions that are used throughout PyNE. You may find them useful as well!
All functionality may be found in the bins
module:
from pyne import bins
Special Binning Functions¶
Tools to generate and handle various binning structures.

pyne.bins.
ninespace
()¶ Splits the range into oneminusloguniform bins defined by num points. In the vernacular, the space is ‘split in the nines’. Note that this assumes base = 10.0.
Parameters: start : number
The starting value of the sequence.
stop : number
The final value of the sequence, unless endpoint is False. In that case, num + 1 values are spaced over the interval in ninesspace, of which all but the last (a sequence of length num) are returned.
num : integer, optional
Number of samples to generate. See endpoint.
endpoint : boolean, optional
If true, stop is the last sample. Otherwise, it is not included.
Returns: samples : ndarray
num samples, equally spaced in the nines.
Examples
>>> ninespace(0.9, 0.9999, 4) array([0.9, 0.99, 0.999, 0.9999])

pyne.bins.
pointwise_collapse
()¶ Collapses pointwise data to G groups based on a interpolation between the points. This is useful for collapsing cross section data.
Parameters: x_g : arraylike
Group boundaries, length G+1 for G groups, must be monotonic in the same direction as x.
x : arraylike
Pointwise abscissa to be collapsed, must be monotonic in the same direction as x_g and have the same length as y.
y : arraylike
Pointwise data to be interpolated, must have the same length as x.
logx: bool, optional, default=False
linlog interpolation
logy: bool, optional, default=False
loglin interpolation
log : bool, optional, default=False
loglog interpolation
Returns: y_g : np.ndarray
The group collapsed data, length G.

pyne.bins.
pointwise_linear_collapse
()¶ Collapses pointwise data to G groups based on a linear interpolation between the points. This is useful for collapsing cross section data.
Parameters: x_g : arraylike
Group boundaries, length G+1 for G groups, must be monotonic in the same direction as x.
x : arraylike
Pointwise abscissa to be collapsed, must be monotonic in the same direction as x_g and have the same length as y.
y : arraylike
Pointwise data to be interpolated, must have the same length as x.
Returns: y_g : np.ndarray
The group collapsed data, length G.

pyne.bins.
stair_step
()¶ Makes a 1d data set of boundaries (x) and cellcentered values (y) into stair step arrays of the same length. The returned arrays are suitable for graphing. This is especially useful in energy vs. spectrum data where there are G+1 boundaries and G data points.
Parameters: x : sequence
Data of length G+1.
y : sequence
Data of length G.
Returns: xss : ndarray
Stairstep version of x data, length 2G.
yss : ndarray
Stairstep version of y data, length 2G.
Examples
>>> x = [0.1, 1.0, 10.0, 100.0] >>> y = [2.0, 3.0, 4.0] >>> bins.stair_step(x, y) (array([ 0.1, 1. , 1. , 10. , 10. , 100. ]), array([ 2., 2., 3., 3., 4., 4.]))