py4py.array =========== .. py:module:: py4py.array .. autoapi-nested-parse:: Array Functions Standard functions used for manipulating arrays, e.g. to calculate full width half maxima, centroids or midpoints. .. autoapisummary:: py4py.array.calculate_fwhm py4py.array.calculate_centroid py4py.array.calculate_midpoints Module Contents --------------- .. py:function:: 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! :param midpoints: Array of bin midpoints :param vals: Array of bin values :returns: FWHM of the peak (should it exist!) .. py:function:: calculate_centroid(bins: numpy.ndarray, vals: numpy.ndarray, bounds: float = None) -> Union[float, Tuple[float, float, float]] Returns the centroid position, with optional percentile bounds. :param bins: Array of bin bounds :type bins: np.ndarray :param vals: Array of bin values :type vals: np.ndarray :param bounds: Fraction from 0-0.5. Percentile either side of the centroid to find (e.g. .2 -> 30%, 70%) :type bounds: float :returns: Flux-weighted centroid, and if 'bounds' passed both lower and upper percentile bounds .. py:function:: calculate_midpoints(bins: numpy.typing.NDArray[numpy.floating]) -> numpy.typing.NDArray[numpy.floating] Converts bin boundaries into midpoints :param bins: Array of bin boundaries :returns: Array of bin midpoints (1 shorter!)