Functions
Separate functions mostly used in conjunction with various classes.
- xarpes.functions.resolve_param_name(params, label, pname)[source]
Try to find the lmfit param key corresponding to this component label and bare parameter name pname (e.g., ‘amplitude’, ‘peak’, ‘broadening’). Works with common token separators.
- xarpes.functions.residual(parameters, xdata, ydata, angle_resolution, new_distributions, kinetic_energy, hnuminPhi, matrix_element=None, element_names=None)[source]
- xarpes.functions.error_function(p, xdata, ydata, function, resolution, yerr, *extra_args)[source]
The error function used inside the fit_least_squares function.
- Parameters:
- pndarray
Array of parameters during the optimization.
- xdatandarray
Abscissa values the function is evaluated on.
- ydatandarray
Measured values to compare to.
- functioncallable
Function or class with __call__ method to evaluate.
- resolutionfloat or None
Convolution resolution (sigma), if applicable.
- yerrndarray
Standard deviations of ydata.
- extra_argstuple
Additional arguments passed to function.
- Returns:
- residualndarray
Normalized residuals between model and ydata.
- xarpes.functions.fit_least_squares(p0, xdata, ydata, function, resolution=None, yerr=None, bounds=None, extra_args=None)[source]
Least-squares fit using scipy.optimize.least_squares.
Default behavior is Levenberg–Marquardt (method=”lm”) when unbounded. If bounds is provided, switches to trust-region reflective (“trf”).
Returns (pfit, pcov, success) in the same style as the old leastsq wrapper, with an additional boolean success from SciPy.
- xarpes.functions.download_examples()[source]
Downloads the examples folder from the main xARPES repository only if it does not already exist in the current directory. Prints executed steps and a final cleanup/failure message.
- Returns:
- 0 or 1int
Returns 0 if the execution succeeds, 1 if it fails.
- xarpes.functions.set_script_dir()[source]
This function sets the directory such that the xARPES code can be executed either inside IPython environments or as .py scripts from arbitrary locations.
- xarpes.functions.MEM_core(dvec, model_in, uvec, mu, aval, wvec, V_Sigma, U, t_criterion, iter_max)[source]
Implementation of Bryan’s algorithm (not to be confused with Bryan’s ‘method’ for determining the Lagrange multiplier aval. For details, see Eur. Biophys. J. 18, 165 (1990).
- xarpes.functions.bose_einstein(omega, k_BT)[source]
Bose-Einstein distribution n_B(omega) for k_BT > 0 and omega >= 0.
- xarpes.functions.fermi(omega, k_BT)[source]
Fermi-Dirac distribution f(omega) for k_BT > 0 and omega >= 0. Could potentially be made a core block of the FermiDirac distribution.
- xarpes.functions.create_kernel_function(enel, omega, k_BT)[source]
Kernel function. Eq. 17 from https://arxiv.org/abs/2508.13845.
- Returns:
- Kndarray, complex
Shape (enel.size, omega.size) if enel and omega are 1D.
- xarpes.functions.singular_value_decomposition(kernel, sigma_svd)[source]
Some papers use kernel = U Sigma V^T; we follow Bryan’s algorithm.
- xarpes.functions.create_model_function(omega, omega_I, omega_M, omega_S, h_n)[source]
Piecewise model m_n(omega) defined on the omega grid.
Implements the piecewise definition in the figure, interpreting omega_min/max as omega.min()/omega.max().
- Parameters:
- omegandarray
Frequency grid (assumed sorted, but only min/max are used).
- omega_Ifloat
ω_n^I
- omega_Mfloat
ω_n^M
- omega_Sfloat
ω_n^S
- h_nfloat
h_n in the prefactor m_n(omega) = 2 h_n * ( … ).
- Returns:
- modelndarray
m_n(omega) evaluated on the omega grid.
- xarpes.functions.chi2kink_logistic(x, a, b, c, d)[source]
Four-parameter logistic (scaled sigmoid), evaluated stably.
- Parameters:
- xarray_like
Input values.
- afloat
Lower asymptote.
- bfloat
Amplitude (upper - lower).
- cfloat
Midpoint (inflection point).
- dfloat
Slope parameter (steepness).
- Returns:
- phindarray
Logistic curve evaluated at x.