spacepy.toolbox.bin_edges_to_center

spacepy.toolbox.bin_edges_to_center(edges)[source]

Convert a list of bin edges to their centers

Given a list of edge values for a set of bins, finds the center of each bin. (start of bin n+1 is assumed to be end of bin n).

Center of bin n is arithmetic mean of the edges of the adjacent bins.

Parameters:
edgeslist

list of edge values for bins

Returns:
outnumpy.ndarray

array of centers for bins

note: returned array will be one element shorter than edges

Examples

>>> import spacepy.toolbox as tb
>>> tb.bin_center_to_edges([1,2,3])
[0.5, 1.5, 2.5, 3.5]