core.spectroscopy
Module¶
This module is for spectroscopy specific tools (spectrum fitting etc).
-
skbeam.core.spectroscopy.
align_and_scale
(energy_list, counts_list, pk_find_fun=None)¶ - Parameters
- energy_listiterable of ndarrays
list of ndarrays with the energy of each element
- counts_listiterable of ndarrays
list of ndarrays of counts/element
- pk_find_funfunction 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_elist of ndarray
The aligned/scaled energy arrays
- out_clist of ndarray
The count arrays (should be the same as the input)
-
skbeam.core.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
- xndarray
The independent variable
- yndarary
Dependent variable sampled at positions X
- windowint, optional
The size of the window around the maximum to use for the fitting
- Returns
- x0float
The location of the peak
- y0float
The magnitude of the peak
- sigmafloat
Width of the peak
-
skbeam.core.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
- xarray
Independent variable, any unit
- yarray
Dependent variable, any units
- x_minfloat or array
The lower edge of the integration region(s) in units of x.
- x_maxfloat 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
-
skbeam.core.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_edgesarray
Independent variable, any unit.
Must be one longer in length than counts
- countsarray
Dependent variable, any units
- x_minfloat or array
The lower edge of the integration region(s).
- x_maxfloat or array
The upper edge of the integration region(s).
- Returns
- float
The totals integrated value in same units as counts