pyresiflex.misc.utils#
Library of useful helper functions.
Attributes#
Functions#
|
Return the Gaussian width |
|
Return the FWHM for a given Gaussian width |
|
Return the full path of the pyresiflex folder. |
|
Return the absolute path to the data folder, or file inside. |
Module Contents#
- pyresiflex.misc.utils.ROOT_FOLDER_PATH: pathlib.Path#
- pyresiflex.misc.utils.gaussian_sigma_from_fwhm(fwhm: float) float#
Return the Gaussian width
sigmafor a given FWHM.The pulse is parametrised as \(\exp(-((t - \mu) / \sigma)^2)\) (note: no factor of two in the exponent denominator), for which the full width at half maximum is \(2 \sqrt{\ln 2}\, \sigma\).
- Parameters:
fwhm (
float) – Full width at half maximum of the Gaussian pulse.- Returns:
The corresponding standard-deviation-like width
sigma.- Return type:
Examples
>>> import numpy as np >>> from pyresiflex.misc.utils import gaussian_sigma_from_fwhm >>> bool(np.isclose(gaussian_sigma_from_fwhm(5.0), 3.0028, atol=1e-4)) True
- pyresiflex.misc.utils.gaussian_fwhm_from_sigma(sigma: float) float#
Return the FWHM for a given Gaussian width
sigma.Inverse of
gaussian_sigma_from_fwhm().- Parameters:
sigma (
float) – Standard-deviation-like width of the Gaussian pulse.- Returns:
The corresponding full width at half maximum.
- Return type:
Examples
>>> import numpy as np >>> from pyresiflex.misc.utils import ( ... gaussian_fwhm_from_sigma, ... gaussian_sigma_from_fwhm, ... ) >>> sigma = gaussian_sigma_from_fwhm(5.0) >>> bool(np.isclose(gaussian_fwhm_from_sigma(sigma), 5.0)) True
- pyresiflex.misc.utils.get_root() pathlib.Path#
Return the full path of the pyresiflex folder.
Used not to worry about the project architecture.
- Returns:
the abspath to root folder (should end with ‘pyresiflex’)
- Return type:
Examples
>>> from pyresiflex.misc.utils import get_root >>> path = get_root() / "data"
- pyresiflex.misc.utils.get_path_to_data(*paths: str, force_return: bool = False) pathlib.Path#
Return the absolute path to the data folder, or file inside.
- Parameters:
- Returns:
The abspath to the data (or file).
- Return type:
Examples
>>> from pyresiflex.misc.utils import get_path_to_data >>> path = get_path_to_data() >>> path = get_path_to_data("Minesi2022")
- Raises:
FileNotFoundError – If the file or folder is not found.