TRXASprefitpack.mathfun.mathfun module#

TRXASprefitpack.mathfun.mathfun.compute_model(t, eigval, V, c)[source]#

Compute solution of the system of rate equations solved by solve_model Note: eigval, V, c should be obtained from solve_model

Parameters
  • t (numpy_1d_array) – time

  • eigval (numpy_1d_array) – eigenvalue for equation

  • V (numpy_nd_array) – eigenvectors for equation

  • c (numpy_1d_array) – coefficient

Returns

solution of rate equation

Return type

numpy_nd_array

TRXASprefitpack.mathfun.mathfun.compute_signal_cauchy(t, fwhm, eigval, V, c)[source]#

Compute solution of the system of rate equations solved by solve_model convolved with normalized cauchy distribution Note: eigval, V, c should be obtained from solve_model

Parameters
  • t (numpy_1d_array) – time

  • fwhm (float) – full width at half maximum of x-ray temporal pulse

  • eigval (numpy_1d_array) – eigenvalue for equation

  • V (numpy_nd_array) – eigenvectors for equation

  • c (numpy_1d_array) – coefficient

Returns

solution of rate equation convolved with normalized cachy distribution

Return type

numpy_nd_array

TRXASprefitpack.mathfun.mathfun.compute_signal_gau(t, fwhm, eigval, V, c)[source]#

Compute solution of the system of rate equations solved by solve_model convolved with normalized gaussian distribution Note: eigval, V, c should be obtained from solve_model

Parameters
  • t (numpy_1d_array) – time

  • fwhm (float) – full width at half maximum of x-ray temporal pulse

  • eigval (numpy_1d_array) – eigenvalue for equation

  • V (numpy_nd_array) – eigenvectors for equation

  • c (numpy_1d_array) – coefficient

Returns

solution of rate equation convolved with normalized gaussian distribution

Return type

numpy_nd_array

TRXASprefitpack.mathfun.mathfun.compute_signal_pvoigt(t, fwhm_G, fwhm_L, eta, eigval, V, c)[source]#

Compute solution of the system of rate equations solved by solve_model convolved with normalized pseudo voigt profile (\(pvoigt = (1-\eta) G(t) + \eta L(t)\), G(t): stands for normalized gaussian L(t): stands for normalized cauchy(lorenzian) distribution)

Note: eigval, V, c should be obtained from solve_model

Parameters
  • t (numpy_1d_array) – time

  • fwhm_G (float) – full width at half maximum of x-ray temporal pulse (gaussian part)

  • fwhm_L (float) – full width at half maximum of x-ray temporal pulse (lorenzian part)

  • eta (float) – mixing parameter

\((0 < \eta < 1)\)

Parameters
  • eigval (numpy_1d_array) – eigenvalue for equation

  • V (numpy_nd_array) – eigenvectors for equation

  • c (numpy_1d_array) – coefficient

Returns

solution of rate equation convolved with normalized pseudo voigt profile

Return type

numpy_nd_array

TRXASprefitpack.mathfun.mathfun.exp_conv_cauchy(t, fwhm, k)[source]#

Compute exponential function convolved with normalized cauchy distribution

Note. We assume temporal pulse of x-ray is normalized cauchy distribution

\[\gamma = \frac{fwhm}{2}\]
\[IRF(t) = \frac{\gamma}{\pi}\frac{1}{(x-t)^2+\gamma^2}\]
Parameters
  • t (numpy_1d_array) – time

  • fwhm (float) – full width at half maximum of x-ray temporal pulse

  • k (float) – rate constant (inverse of life time)

Returns

convolution of normalized cauchy distribution and exp(-kt)

\[\frac{\exp(-kt)}{\pi}\Im\left(\exp(-ik\gamma)\cdot\left(i\pi - {Ei}\left(kt+ik\gamma\right)\right)\right)\]
Return type

numpy_1d_array

TRXASprefitpack.mathfun.mathfun.exp_conv_gau(t, fwhm, k)[source]#

Compute exponential function convolved with normalized gaussian distribution

Note. We assume temporal pulse of x-ray is normalized gaussian distribution

\[\sigma = \frac{fwhm}{2\sqrt{2\log{2}}}\]
\[IRF(t) = \frac{1}{\sigma \sqrt{2\pi}}\exp\left(-\frac{t^2}{2\sigma^2}\right)\]
Parameters
  • t (numpy_1d_array) – time

  • fwhm (float) – full width at half maximum of x-ray temporal pulse

  • k (float) – rate constant (inverse of life time)

Returns

convolution of normalized gaussian distribution and exp(-kt)

\[\frac{1}{2}\exp\left(\frac{k^2}{2\sigma^2}-kt\right)\left(1+{erf}\left(\frac{1}{\sqrt{2}}\left(\frac{t}{\sigma}-k\sigma\right)\right)\right)\]
Return type

numpy_1d_array

TRXASprefitpack.mathfun.mathfun.fact_anal_exp_conv(t, fwhm, tau, irf='g', eta=None, data=None, eps=None, base=True)[source]#

Estimate the best coefficiets when fwhm and tau are given

Before fitting with Escan data, you want fit your model to tscan data to know how many component needed for well description of tscan data To do this you have good initial guess for not only life time of each component but also coefficients. For this, It will solve linear least square problem

Parameters
  • t (numpy_1d_array) – time

  • fwhm (numpy_1d_array) –

    fwhm of X-ray temporal pulse if irf == ‘g’ or ‘c’ then

    fwhm = [fwhm]

    if irf == ‘pv’ then

    fwhm = [fwhm_G, fwhm_L]

  • tau (numpy_1d_array) – life time for each component

  • irf (string, optional) – shape of instrumental response function [default: g] ‘g’: normalized gaussian distribution ‘c’: normalized cauchy distribution ‘pv’: pseudo voigt profile \((1-\eta)g + \eta c\)

  • eta (float, optional) – mixing parameter for pseudo voigt profile (only needed for pseudo voigt profile, Default value is guessed according to Journal of Applied Crystallography. 33 (6): 1311–1316.)

  • data (numpy_1d_array) – tscan data

  • eps (numpy_1d_array) – error for tscan data

  • base (bool, optional) – whether or not include baseline [default: True]

Returns

best coefficient for given fwhm, tau (num_comp+1,) , if base=True (num_comp,) , otherwise

Return type

numpy_1d_array

TRXASprefitpack.mathfun.mathfun.make_A_matrix(t, k)[source]#
TRXASprefitpack.mathfun.mathfun.make_A_matrix_cauchy(t, fwhm, k)[source]#
TRXASprefitpack.mathfun.mathfun.make_A_matrix_gau(t, fwhm, k)[source]#
TRXASprefitpack.mathfun.mathfun.make_A_matrix_pvoigt(t, fwhm_G, fwhm_L, eta, k)[source]#
TRXASprefitpack.mathfun.mathfun.model_n_comp_conv(t, fwhm, tau, c, base=True, irf='g', eta=None)[source]#

model for n component fitting n exponential function convolved with irf irf ‘g’: normalized gaussian distribution

‘c’: normalized cauchy distribution

‘pv’: pseudo voigt profile \((1-\eta)g + \eta c\)

Parameters
  • t (numpy_1d_array) – time

  • fwhm (numpy_1d_array) –

    fwhm of X-ray temporal pulse if irf == ‘g’ or ‘c’ then

    fwhm = [fwhm]

    if irf == ‘pv’ then

    fwhm = [fwhm_G, fwhm_L]

  • tau (numpy_1d_array) – life time for each component

  • c (numpy_1d_array) – coefficient (num_comp+1,) if base=True (num_comp,) if base=False

  • base (bool, optional) – whether or not include baseline [default: True]

  • irf (string, optional) – shape of instrumental response function [default: g] ‘g’: normalized gaussian distribution ‘c’: normalized cauchy distribution ‘pv’: pseudo voigt profile \((1-\eta)g + \eta c\)

  • eta (float, optional) – mixing parameter for pseudo voigt profile (only needed for pseudo voigt profile, Default value is guessed according to Journal of Applied Crystallography. 33 (6): 1311–1316.)

Returns

fit

Return type

numpy_1d_array

TRXASprefitpack.mathfun.mathfun.solve_model(equation, y0)[source]#

Solve system of first order rate equation

Parameters
  • equation (numpy_nd_array) – matrix corresponding to model

  • y0 (numpy_1d_array) – initial condition

Returns

eigenvalue of equation

Return type

numpy_1d_array

Returns

eigenvectors for equation

Return type

numpy_nd_array

Returns

coefficient where y_0 = Vc

Return type

numpy_1d_array