Response Module
- class nres.Response(kind='expo_gauss', vary=False, eps=1e-06, tstep=1.56255e-09, nbins=300)[source]
Bases:
object- cut_array_symmetric(arr, threshold)[source]
Symmetrically cuts the array based on a threshold.
Parameters: arr (np.ndarray): Input array to be cut. threshold (float): The threshold value for cutting the array.
Returns: np.ndarray: Symmetrically cut array with an odd number of elements.
- expogauss_response(K=0.01, x0=0.0, τ=1e-09, **kwargs)[source]
Computes the exponential-Gaussian response function.
Parameters: K (float): Shape parameter for the exponential. x0 (float): Location parameter for the Gaussian. τ (float): Scale parameter for the exponential.
Returns: np.ndarray: Normalized response array.
- plot(params=None, **kwargs)[source]
Plots the response function.
Parameters: params (dict): Parameters for the response function. **kwargs: Additional arguments for plot customization.
- register_response(response_func, lmfit_params=None, **kwargs)[source]
Registers a new response using any scipy.stats function.
Parameters: response_func (function): A function from scipy.stats, e.g., exponnorm.pdf. lmfit_params (lmfit.Parameters): Optional lmfit.Parameters to define limits and vary. kwargs: Default parameter values for the response function.
- class nres.Background(kind='expo_norm', vary=False)[source]
Bases:
object- constant_background(E, b0=0.0, **kwargs)[source]
Generates a constant background.
Parameters: E (np.ndarray): Energy values. b0 (float): Constant background value.
- plot(E, params=None, **kwargs)[source]
Plots the background function.
Parameters: E (np.ndarray): Energy values. params (dict): Parameters for the background function.
- polynomial3_background(E, b0=0.0, b1=1.0, b2=0.0, **kwargs)[source]
Computes a third-degree polynomial background.
Parameters: E (np.ndarray): Energy values. b0 (float): Constant term. b1 (float): Linear term. b2 (float): Quadratic term.
- polynomial5_background(E, b0=0.0, b1=1.0, b2=0.0, b3=0.0, b4=0.0, **kwargs)[source]
Computes a fifth-degree polynomial background.
Parameters: E (np.ndarray): Energy values. b0 (float): Constant term. b1 (float): Linear term. b2 (float): Quadratic term. b3 (float): Cubic term. b4 (float): Quartic term.