spacepy.toolbox.bin_center_to_edges

spacepy.toolbox.bin_center_to_edges(centers)[source]

Convert a list of bin centers to their edges

Given a list of center values for a set of bins, finds the start and end value for each bin. (start of bin n+1 is assumed to be end of bin n). Useful for e.g. matplotlib.pyplot.pcolor.

Edge between bins n and n+1 is arithmetic mean of the center of n and n+1; edge below bin 0 and above last bin are established to make these bins symmetric about their center value.

Parameters
centerslist

list of center values for bins

Returns
outlist

list of edges for bins

note: returned list will be one element longer than centers

Examples

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