helpers

udkm1Dsim.helpers.make_hash_md5(obj)
Parameters

obj (any) – anything that can be hashed.

Returns

hash (str) – hash from object.

udkm1Dsim.helpers.make_hashable(obj)

Recursive calls to elements of tuples, lists, dicts, set, and frozensets.

Parameters

obj (any) – anything that can be hashed..

Returns

obj (tuple) – hashable object.

udkm1Dsim.helpers.m_power_x(m, x)

Apply numpy.linalg.matrix_power to last 2 dimensions of 4-dimensional input matrix.

Parameters
  • m (ndarray[float, complex]) – 4-dimensional input matrix.

  • x (float) – exponent.

Returns

m (ndarray[float, complex]) – resulting matrix.

udkm1Dsim.helpers.m_times_n(m, n)

Matrix multiplication of last 2 dimensions for two 4-dimensional input matrices.

Parameters
  • m (ndarray[float, complex]) – 4-dimensional input matrix.

  • n (ndarray[float, complex]) – 4-dimensional input matrix.

Returns

res (ndarray[float, complex]) – 4-dimensional multiplication result.

udkm1Dsim.helpers.finderb(key, array)

Binary search algorithm for sorted array. Searches for the first index i of array where key >= array[i]. key can be a scalar or a np.ndarray of keys. array must be a sorted np.ndarray.

Author: André Bojahr. Licence: BSD.

Parameters
  • key (float, ndarray[float]) – single or multiple sorted keys.

  • array (ndarray[float]) – sorted array.

Returns

i (ndarray[float]) – position indices for each key in the array.

udkm1Dsim.helpers.multi_gauss(x, s=[1], x0=[0], A=[1])

Multiple gauss functions with width s given as FWHM and area normalized to input A and maximum of gauss at x0.

Parameters
  • x (ndarray[float]) – argument of multi_gauss.

  • s (ndarray[float], optional) – FWHM of Gaussians. Defaults to 1.

  • x0 (ndarray[float], optional) – centers of Gaussians. Defaults to 0.

  • A (ndarray[float], optional) – amplitudes of Gaussians. Defaults to 1.

Returns

y (ndarray[float]) – multiple Gaussians.