res_grad_thy

TRXASprefitpack.res.res_grad_thy(x0: ndarray, policy: str, thy_peak: Sequence[ndarray], edge: str | None = None, num_edge: int | None = 0, base_order: int | None = None, fix_param_idx: ndarray | None = None, e: ndarray = None, intensity: ndarray = None, eps: ndarray = None) ndarray[source]

scipy.optimize.minimize compatible scalar residual function and its gradient for fitting static spectrum with the sum of voigt broadend theoretical spectrum, edge function base function

Parameters:
  • x0

    initial parameter

    • 1st and 2nd: fwhm_G and fwhm_L

    if policy == ‘scale’:

    • 3rd to \(2+{num}_{thy}\) : peak_scale

    if policy == ‘shift’:

    • 3rd to \(2+{num}_{thy}\) : peak_shift

    if policy == ‘both’:

    • 3rd to \(2+{num}_{thy}\) : peak_shift

    • \(2+{num}_{thy}\) to \(2+2 {num}_{thy}\): peak_scale

    if edge is not None:

    • \(2+{num}_{thy}+{num}_{edge}+i\) or \(2+2{num_thy}+{num}_{edge}+i\): i th edge position

    • \(2+{num}_{thy}+2{num}_{edge}+i\) or \(2+2{num_thy}+2{num}_{edge}+i\): fwhm of i th edge

  • policy ({'shift', 'scale', 'both'}) –

    Policy to match discrepency between experimental data and theoretical spectrum.

    • ’shift’ : Default option, shift peak position by peak_factor

    • ’scale’ : scale peak position by peak_factor

    • ’both’ : both shift and scale peak postition, peak_factor should be a tuple of shift_factor and scale_factor.

  • thy_peak – theoretically calculated peak position and intensity

  • edge ({'g', 'l'}) – type of edge shape function if edge is not set, it does not include edge function.

  • num_edge – the number of edge feature

  • base_order (int) – polynomial order of baseline function if base_order is not set, it does not include baseline function.

  • fix_param_idx – idx for fixed parameter (masked array for x0)

  • e – 1d array of energy points of data (n,)

  • intensity – intensity of static data (n,)

  • eps – estimated error of data (n,)

Returns:

Tuple of scalar residual function \((\frac{1}{2}\sum_i {res}^2_i)\) and its gradient

Note

  • If fwhm_G of ith voigt component is zero then it is treated as lorenzian function with fwhm_L

  • If fwhm_L of ith voigt component is zero then it is treated as gaussian function with fwhm_G