additional_tools

Module Contents

Classes

Functions

Attributes

class fast_LUT_interpolation(independent_variables, dependent_variables)[source]

Class designed for fast interpolation in look-up table when successive searchs are called often. Otherwise use griddata

interpolate(point, fill_value=np.nan)[source]

Perform the interpolation :param point: coordinates to interpolate (tuple or list of tuples for multipoints) :param fill_value: value to put if extrapolated. :return: coordinates

interpolate_table(x0, x_values, y_values)[source]

From sorted table (x,y) find y0 corresponding to x0 (linear interpolation)

derivate(t, y)[source]
linspace(start, stop, npoints)[source]
reconstitute_signal(amplitudes, phases, numberOfPeriods=1, x_points=None, n_points=50)[source]

Reconstitute the signal from fft. Number of periods of the signal must be specified if different of 1

my_fft(y)[source]

Real FFT of signal Bx, with real amplitude of harmonics. Input signal must be within a period.

cart2pol(x, y)[source]
pol2cart(rho, phi)[source]
partition(array, begin, end)[source]
quicksort(array)[source]
dist(p, q)[source]

Return the Euclidean distance between points p and q. :param p: [x, y] :param q: [x, y] :return: distance (float)

sparse_subset(points, r)[source]

Returns a maximal list of elements of points such that no pairs of points in the result have distance less than r. :param points: list of tuples (x,y) :param r: distance :return: corresponding subset (list), indices of the subset (list)

integrate(x, y)[source]

Performs Integral(x[0] to x[-1]) of y dx

Parameters:
  • x – x axis coordinates (list)
  • y – y axis coordinates (list)
Returns:

integral value

my_fourier(x, y, n, L)[source]

Fourier analys

Parameters:
  • x – x axis coordinates
  • y – y axis coordinates
  • n – number of considered harmonic
  • L – half-period length
Returns:

a and b coefficients (y = a*cos(x) + b*sin(y))

get_ellipse_axes(a, b, dphi)[source]

Trouve les longueurs des axes majeurs et mineurs de l’ellipse, ainsi que l’orientation de l’ellipse. ellipse: x(t) = A*cos(t), y(t) = B*cos(t+dphi) Etapes: longueur demi ellipse CENTRéE = sqrt(a^2 cos^2(x) + b^2 cos^2(t+phi) Minimisation de cette formule => obtention formule tg(2x) = alpha/beta

convert_color(color)[source]

Convert a color to a tuple if color is a char, otherwise return the tuple.

Parameters:color – (r,g,b) or char.
Returns:
convert_color_with_alpha(color, alpha=255)[source]

Same as meth:convert_color but with transparency