ocelot.common.math_op
¶
statistical analysis functions, fitting, optimization and the like
Module Contents¶
Functions¶
|
return ‘complete’ gamma function |
|
function to make “nearly conjugate symmetric” vector in order to |
|
Invert cumulative distribution function of the probability distribution |
|
Fat method for rolling mean |
|
Function return x-array slices with length of the window, which can be used for rolling analysis. |
|
FFT based convolution |
|
FFT based deconvolution |
|
|
|
golden section search |
|
|
|
|
|
|
|
calculates the full width at half maximum (fwhm) of the array. |
|
return mean, std, median and extreme (farthest from mean) of a time series |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mutual Coherence function |
|
-
ocelot.common.math_op.
numba_avail
= True¶
-
ocelot.common.math_op.
complete_gamma
(a, z)¶ return ‘complete’ gamma function
-
ocelot.common.math_op.
conj_sym
(x)¶ function to make “nearly conjugate symmetric” vector in order to compute matplab IFFT function with ‘symmetric’ option: MATLAB >> ifft(x, ‘symmetric’) PYTHON >> numpy.fft.ifft(conj_sym(x))
-
ocelot.common.math_op.
invert_cdf
(y, x)¶ Invert cumulative distribution function of the probability distribution
# analytical formula for the beam distribution f = lambda x: A * np.exp(-(x - mu) ** 2 / (2. * sigma ** 2))
# we are interesting in range from -30 to 30 e.g. [um] x = np.linspace(-30, 30, num=100)
# Inverted cumulative distribution function i_cdf = invert_cdf(y=f(x), x=x)
# get beam distribution (200 000 coordinates) tau = i_cdf(np.random.rand(200000))
- Parameters
y – array, [y0, y1, y2, … yn] yi = y(xi)
x – array, [x0, x1, x2, … xn] xi
- Returns
function
-
ocelot.common.math_op.
rolling_mean
(x, window)¶ Fat method for rolling mean
X = np.random.rand(10000)
X_mean = rolling_mean(X, 500)
- Parameters
x – np.array, len(a) must be larger than window
window – int, length of the window
- Returns
np.array, len = len(x) + 1 - window
-
ocelot.common.math_op.
rolling_window
(x, window)¶ Function return x-array slices with length of the window, which can be used for rolling analysis.
X = np.random.rand(10000)
X_std = np.std(rolling_window(X, 500), 1) X_mean = np.mean(rolling_window(X, 500), 1)
- Parameters
x – np.array, len(a) must be larger than window
window – int, length of the window
- Returns
np.array, shape: (len(a) + 1 - window, window)
-
ocelot.common.math_op.
convolve
(f, g)¶ FFT based convolution
- Parameters
f – array
g – array
- Returns
array, (f * g)[n]
-
ocelot.common.math_op.
deconvolve
(f, g)¶ FFT based deconvolution
- Parameters
f – array
g – array
- Returns
array,
-
ocelot.common.math_op.
peaks
(x, y, n=0)¶
-
ocelot.common.math_op.
gs_search
(f, bracket, tol=1e-06, nmax=50)¶ golden section search
-
ocelot.common.math_op.
fit_gauss_2d
(x, y, F)¶
-
ocelot.common.math_op.
fit_gauss_1d
(x, F)¶
-
ocelot.common.math_op.
fwhm
(x, F)¶
-
ocelot.common.math_op.
fwhm3
(valuelist, height=0.5, peakpos=- 1, total=1)¶ calculates the full width at half maximum (fwhm) of the array. the function will return the fwhm with sub-pixel interpolation. It will start at the maximum position and ‘walk’ left and right until it approaches the half values. if total==1, it will start at the edges and ‘walk’ towards peak until it approaches the half values. INPUT: - valuelist: e.g. the list containing the temporal shape of a pulse OPTIONAL INPUT: -peakpos: position of the peak to examine (list index) the global maximum will be used if omitted. if total = 1 - OUTPUT: - peakpos(index), interpolated_width(npoints), [index_l, index_r]
-
ocelot.common.math_op.
stats
(outputs)¶ return mean, std, median and extreme (farthest from mean) of a time series
-
ocelot.common.math_op.
find_saturation
(power, z, n_smooth=5)¶
-
ocelot.common.math_op.
find_nearest_idx
(array, value)¶
-
ocelot.common.math_op.
find_nearest
(array, value)¶
-
ocelot.common.math_op.
n_moment
(x, counts, c, n)¶
-
ocelot.common.math_op.
std_moment
(x, counts)¶
-
ocelot.common.math_op.
bin_array
(array, bin_size)¶
-
ocelot.common.math_op.
bin_scale
(scale, bin_size)¶
-
ocelot.common.math_op.
index_of
(array, value)¶
-
ocelot.common.math_op.
corr_f_py
(corr, val, n_skip=1, norm=1)¶
-
ocelot.common.math_op.
corr_f_np
(corr, val, n_skip=1, norm=1, count=0)¶
-
ocelot.common.math_op.
corr_f_nb
¶
-
ocelot.common.math_op.
correlation2d
(val, norm=0, n_skip=1, use_numba=numba_avail)¶
-
ocelot.common.math_op.
corr_c_py
(corr, n_corr, val, norm)¶
-
ocelot.common.math_op.
corr_c_np
(corr, n_corr, val, norm)¶
-
ocelot.common.math_op.
corr_c_nb
¶
-
ocelot.common.math_op.
correlation2d_center
(n_corr, val, norm=0, use_numba=1)¶
-
ocelot.common.math_op.
mut_coh_func_py
(J, fld, norm=1)¶ Mutual Coherence function
-
ocelot.common.math_op.
mut_coh_func
¶
-
ocelot.common.math_op.
gauss_fit
(X, Y)¶