pysrw.lib.uti_math

pysrw.lib.uti_math#

Functions

find_ar_max(_ar[, _ib, _ie, _min])

Finds array (or list) maximum (or minimum), index and value :param _ar: array (or list) to find max.

fwhm(x, y[, shift, return_as_dict])

The function searches x-values (roots) where y=0 (after normalization to values between 0 and 1 and shifting the values down by 0.5 (default value)) based on linear interpolation, and calculates full width at half maximum (FWHM).

get_dist_norm(_min, _max[, _scale, _size])

Select point using a normal (Gaussian) distribution

get_dist_schultz(_min, _max[, poly_index])

elect point using a Flory–Schulz distribution

get_dist_uni(_min, _max)

Select point using a uniform distribution

integ_ar_2d(_ar, _ar_align, _x_grid, _y_grid)

Integrates 2d array (or list) within given limits :param _ar: input array to integrate :param _ar_align: input array alignment (1- _ar is 1d array with C-type data alignment, 2- _ar is 2d array) :param _x_grid: list/array specifying grid vs one dimensions (_x_grid[0] is start, _x_grid[1] is end, _x_grid[2] is number of points) :param _y_grid: list/array specifying grid vs another dimensions (_y_grid[0] is start, _y_grid[1] is end, _y_grid[2] is number of points) :param _x_lim: list/array specifying inegration limits vs one dimensions (_x_lim[0] is start, _x_lim[1] is end) :param _y_lim: list/array specifying inegration limits vs another dimensions (_y_lim[0] is start, _y_lim[1] is end)

integ_array(_ar, _h[, _dupl])

Integrates array (or list), eventually making a copy of it before the integration :param _ar: array to integrate :param _h: step size :param _dupl: duplicate the magnetic field object or not

interp_1d(_x, _x_min, _x_step, _nx, _ar_f[, ...])

Interpolate 1D function value tabulated on equidistant mesh, using polynomial interpolation :param _x: argument at which function value should be calculated :param _x_min: minimal argument value of the tabulated function :param _x_step: step of mesh at which function is tabulated :param _nx: number of points in mesh at which function is tabulated :param _ar_f: tabulated function list or array :param _ord: order of polynomial interpolation (1- linear, 2- quadratic, 3- cubic) :param _ix_per: argument index period of function data alignment (e.g. to interpolate one component of complex data, or in one dimension of multi-dimensional data) :param _ix_ofst: argument index offset of function data alignment :return: function value found by polynomial interpolation.

interp_1d_var(_x, _ar_x, _ar_f[, _ord])

Interpolate linearly 1D function value tabulated on non-equidistant (irregular) mesh :param _x: argument at which function value should be calculated :param _ar_x: array or list of increasing argument values, at which the function is tabulated :param _ar_f: array or list of tabulated values corresponding to arguments in _ar_x :param _ord: order of polynomial interpolation (1- linear, 2- quadratic, 3- cubic) :return: function value found by polynomial interpolation

interp_2d(_x, _y, _x_min, _x_step, _nx, ...)

Interpolate 2D function value tabulated on equidistant rectangular mesh and represented by C-aligned flat array, using polynomial interpolation :param _x: first argument at which function value should be calculated :param _y: second argument at which function value should be calculated :param _x_min: minimal value of the first argument of the tabulated function :param _x_step: step of the first argument at which function is tabulated :param _nx: number of points vs first argument at which function is tabulated :param _y_min: minimal value of the second argument of the tabulated function :param _y_step: step of the second argument at which function is tabulated :param _ny: number of points vs second argument at which function is tabulated :param _ar_f: function tabulated on 2D mesh, aligned as "flat" C-type list or array (first argument is changing most frequently) :param _ord: "order" of polynomial interpolation (1- bi-linear (on 4 points), 2- "bi-quadratic" (on 6 points), 3- "bi-cubic" (on 12 points)) :param _ix_per: period of first argument index of the function data alignment (e.g. to interpolate one component of complex data, or in one dimension of multi-dimensional data) :param _ix_ofst: offset of the first argument index in function data alignment :return: function value found by 2D polynomial interpolation.

matr3x3_det(_M)

matr3x3_inv(_M)

matr_3x3_det(_M)

matr_3x3_inv(_M)

matr_print(_A)

Prints matrix _A

matr_prod(_A, _B)

Multiplies matrix _A by matrix or by vector _B

matr_transp(_A)

Returns transposed matrix

num_round(_x[, _ndig])

trf_rotation(_V, _ang, _P)

Sets up matrix and vector describing rotation about axis _V passing through a point _P about an angle _ang :param _V: vector (array of 3 Cartesian coordinates) defining rotation axis :param _ang: rotation angle [rad] :param _P: point (array of 3 Cartesian coordinates) rotation axis passes through :returns list containing the 3x3 matrix and 3-element vector

vect3_prod_v(_V1, _V2)

Returns vector product of 3d vectors V1 and V2

vect_mult(_V, _a)

Multiplies vector _V (in place) by number _a

vect_norm(_V)

Returns vector norm (/length)

vect_normalize(_V)

Normalizes vector (in place, i.e. without creating new vector).

vect_prod_s(_V1, _V2)

Returns scalar product of vectors V1 and V2