;+ ; NAME: ; binedge ; PURPOSE: (one line) ; Given a list of bin centers, return the bin edges ; DESCRIPTION: ; Given a list of bin centers, return the bin edges ; CATEGORY: ; Spectra ; CALLING SEQUENCE: ; binedge, x, n, x0, x1, dx ; INPUTS: ; x: centers of bins ; OPTIONAL INPUT PARAMETERS: ; none ; KEYWORD INPUT PARAMETERS: ; none ; KEYWORD OUTPUT PARAMETERS: ; none ; OUTPUTS: ; n: length of array ; x0: lower edge ; x1: upper edge ; dx: bin width ; COMMON BLOCKS: ; None ; SIDE EFFECTS: ; RESTRICTIONS: ; x has to be monotonically increasing ; PROCEDURE: ; Interior bin edges are midway between bin centers. ; X[0] and X[n-1] are in the middle of their bins ; MODIFICATION HISTORY: ; Written Leslie Young, SwRI, Nov 8, 2000 ; Jan 3 2006. Added doc, moved to layoung/spectra, LAY ;- pro binedge, x, n, x0, x1, dx n = n_elements(x) if n eq 1 then begin x0=x-.5 x1=x+.5 dx=[1] return end x0 = fltarr(n) x1 = fltarr(n) x1(0:n-2) = 0.5*(x(0:n-2) + x(1:n-1)) x0(1:n-1) = x1(0:n-2) x0(0) = x(0) - (x1(0)-x(0)) x1(n-1) = x(n-1) + (x(n-1)-x0(n-1)) dx=x1-x0 end