Blackbody.bin(wave, interp_method='simps', ends='symmetric', preserve_power=True, sample_method='linear', fill_value=0, waveunit='nm')

Compute a binned representation of the Spectrum data at a given array of central wavelengths.

The general algorithm computes bin edges, sampling the Spectrum values at these edges, and numerically integrating within the edges of each bin. For $$n$$ bins (centered at the wavelength values in the wave array), there will be $$n+1$$ edges. The edges at each bin centered at $$\lambda_k$$ are given by

\begin{align}\begin{aligned}e_{\mbox{left}} = \lambda_k - \frac{\lambda_k - \lambda_{k-1}}{2}\\e_{\mbox{right}} = \lambda_k + \frac{\lambda_{k+1} - \lambda_k}{2}\end{aligned}\end{align}

Special treatment is required for the first and last edges ($$\lambda_k =$$ wave[0] and $$\lambda_k =$$ wave[-1]) since $$\lambda_{k-1}$$ and $$\lambda_{k+1}$$ are undefined, respectively.

Two different first/last bin edge methods are available:

ends

Left edge for wave[0]

Right edge for wave[-1]

symmetric

$$\lambda_1-\frac{\lambda_2-\lambda_1}{2}$$

$$\lambda_{\mbox{end}}+\frac{\lambda_{\mbox{end}}-\lambda_{\mbox{end}-1}}{2}$$

inside

$$\lambda_1$$

$$\lambda_{\mbox{end}}$$

Parameters
• wave (array_like) – Central wavelength set for binning. At least two wavelengths must be provided.

• interp_method ({'simps', 'trapz'}, optional) – Numerical integration method. ‘simps’ (default) is better for smooth data while ‘trapz’ is better for linear data.

• ends ({'symmetric', 'inside'}, optional) – Method for handling the first and last bin edge value. Default is ‘symmetric’. See the notes below for details on the available methods.

• preserve_power (bool, optional) –

• sample_method ({'linear', 'quadratic', 'cubic'}, optional) –

• ‘linear’ uses linear interpolation (default)

• ’quadratic’ uses second order spline interpolation

• ’cubic’ uses third order spline interpolation

• fill_value (float or array_like, optional) –

• If a float, this value will be used to fill in requested points outside of the data range.

• If a two-element array, the first element is used to fill value_new < value[0] and the second element is used for value_new > value[-1].

• If not provided, the default is 0.

Returns

value – The binned values, same shape as wave.

Return type

ndarray