spectroscopy Module

This module is for spectroscopy specific tools (spectrum fitting etc).

skxray.spectroscopy.align_and_scale(energy_list, counts_list, pk_find_fun=None)
Parameters:

energy_list : iterable of ndarrays

list of ndarrays with the energy of each element

counts_list : iterable of ndarrays

list of ndarrays of counts/element

pk_find_fun : function or None

A function which takes two ndarrays and returns parameters about the largest peak. If None, defaults to find_largest_peak. For this demo, the output is (center, height, width), but this sould be pinned down better.

Returns:

out_e : list of ndarray

The aligned/scaled energy arrays

out_c : list of ndarray

The count arrays (should be the same as the input)

skxray.spectroscopy.find_largest_peak(x, y, window=None)

Finds and estimates the location, width, and height of the largest peak. Assumes the top of the peak can be approximated as a Gaussian. Finds the peak properties using least-squares fitting of a parabola to the log of the counts.

The region around the peak can be approximated by Y = Y0 * exp(- (X - X0)**2 / (2 * sigma **2))

Parameters:

x : ndarray

The independent variable

y : ndarary

Dependent variable sampled at positions X

window : int, optional

The size of the window around the maximum to use for the fitting

Returns:

x0 : float

The location of the peak

y0 : float

The magnitude of the peak

sigma : float

Width of the peak

skxray.spectroscopy.integrate_ROI(x, y, x_min, x_max)

Integrate region(s) of input data.

If x_min and x_max are arrays/lists they must be equal in length. The values contained in the ‘x’ must be monotonic (up or down). The returned value is the sum of all the regions and a single scalar value is returned. Each region is computed independently, if regions overlap the overlapped area will be included multiple times in the final sum.

This function assumes that y is a function of x sampled at x.

Parameters:

x : array

Independent variable, any unit

y : array

Dependent variable, any units

x_min : float or array

The lower edge of the integration region(s) in units of x.

x_max : float or array

The upper edge of the integration region(s) in units of x.

Returns:

float :

The totals integrated value in same units as y

skxray.spectroscopy.integrate_ROI_spectrum(bin_edges, counts, x_min, x_max)

Integrate region(s) of histogram.

If x_min and x_max are arrays/lists they must be equal in length. The values contained in the ‘x_value_array’ must be monotonic (up or down). The returned value is the sum of all the regions and a single scalar value is returned. Each region is computed independently, if regions overlap the overlapped area will be included multiple times in the final sum.

bin_edges is an array of the left edges and the final right edges of the bins. counts is the value in each of those bins.

The bins who’s centers fall with in the integration limits are included in the sum.

Parameters:

bin_edges : array

Independent variable, any unit.

Must be one longer in length than counts

counts : array

Dependent variable, any units

x_min : float or array

The lower edge of the integration region(s).

x_max : float or array

The upper edge of the integration region(s).

Returns:

float :

The totals integrated value in same units as counts