py4py.array
Array Functions
Standard functions used for manipulating arrays, e.g. to calculate full width half maxima, centroids or midpoints.
|
Calculate FWHM from arrays |
|
Returns the centroid position, with optional percentile bounds. |
|
Converts bin boundaries into midpoints |
Module Contents
- py4py.array.calculate_fwhm(midpoints: numpy.typing.NDArray[numpy.floating], vals: numpy.typing.NDArray[numpy.floating]) float
Calculate FWHM from arrays
Taken from http://stackoverflow.com/questions/10582795/finding-the-full-width-half-maximum-of-a-peak I don’t think this can cope with being passed a doublet or an array with no peak within it. Doublets will calculate FWHM from the HM of both!
- Parameters:
midpoints (numpy.typing.NDArray[numpy.floating]) – Array of bin midpoints
vals (numpy.typing.NDArray[numpy.floating]) – Array of bin values
- Returns:
FWHM of the peak (should it exist!)
- Return type:
float
- py4py.array.calculate_centroid(bins: numpy.ndarray, vals: numpy.ndarray, bounds: float = None) float | Tuple[float, float, float]
Returns the centroid position, with optional percentile bounds.
- Parameters:
bins (np.ndarray) – Array of bin bounds
vals (np.ndarray) – Array of bin values
bounds (float) – Fraction from 0-0.5. Percentile either side of the centroid to find (e.g. .2 -> 30%, 70%)
- Returns:
Flux-weighted centroid, and if ‘bounds’ passed both lower and upper percentile bounds
- Return type:
Union[float, Tuple[float, float, float]]
- py4py.array.calculate_midpoints(bins: numpy.typing.NDArray[numpy.floating]) numpy.typing.NDArray[numpy.floating]
Converts bin boundaries into midpoints
- Parameters:
bins (numpy.typing.NDArray[numpy.floating]) – Array of bin boundaries
- Returns:
Array of bin midpoints (1 shorter!)
- Return type:
numpy.typing.NDArray[numpy.floating]