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 one-minus-log-uniform bins defined by num points. In the vernacular, the space is ‘split in the nines’. Note that this assumes base = 10.0.

Parameters
startnumber

The starting value of the sequence.

stopnumber

The final value of the sequence, unless endpoint is False. In that case, num + 1 values are spaced over the interval in nines-space, of which all but the last (a sequence of length num) are returned.

numinteger, optional

Number of samples to generate. See endpoint.

endpointboolean, optional

If true, stop is the last sample. Otherwise, it is not included.

Returns
samplesndarray

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_garray-like

Group boundaries, length G+1 for G groups, must be monotonic in the same direction as x.

xarray-like

Pointwise abscissa to be collapsed, must be monotonic in the same direction as x_g and have the same length as y.

yarray-like

Pointwise data to be interpolated, must have the same length as x.

logx: bool, optional, default=False

lin-log interpolation

logy: bool, optional, default=False

log-lin interpolation

logbool, optional, default=False

log-log interpolation

Returns
y_gnp.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_garray-like

Group boundaries, length G+1 for G groups, must be monotonic in the same direction as x.

xarray-like

Pointwise abscissa to be collapsed, must be monotonic in the same direction as x_g and have the same length as y.

yarray-like

Pointwise data to be interpolated, must have the same length as x.

Returns
y_gnp.ndarray

The group collapsed data, length G.

pyne.bins.stair_step()

Makes a 1d data set of boundaries (x) and cell-centered 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
xsequence

Data of length G+1.

ysequence

Data of length G.

Returns
xssndarray

Stair-step version of x data, length 2G.

yssndarray

Stair-step 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.]))