Mathematical utilities
- pymodaq_utils.math_utils.find_index(x, threshold)[source]
find_index finds the index ix such that x(ix) is the closest from threshold
- pymodaq_utils.math_utils.ft(x, dim=-1)[source]
Process the 1D fast fourier transform and swaps the axis to get coorect results using ftAxis :type x:
(ndarray) the array on which the FFT should be done:param x: :type x:(ndarray) the array on which the FFT should be done:type dim:the axis over which is done the FFT (default is the lastofthe array):param dim: :type dim:the axis over which is done the FFT (default is the lastofthe array)See also
ftAxis,ftAxis_time,ift,ft2,ift2
- pymodaq_utils.math_utils.ft2(x, dim=(-2, -1))[source]
Process the 2D fast fourier transform and swaps the axis to get correct results using ftAxis :type x:
(ndarray) the array on which the FFT should be done:param x: :type x:(ndarray) the array on which the FFT should be done:type dim:the axis over which is done the FFT (default is the lastofthe array):param dim: :type dim:the axis over which is done the FFT (default is the lastofthe array)See also
ftAxis,ftAxis_time,ift,ft2,ift2
- pymodaq_utils.math_utils.ftAxis(Npts, omega_max)[source]
Given two numbers Npts,omega_max, return two vectors spanning the temporal and spectral range. They are related by Fourier Transform
- Parameters:
Npts (
(int)) – A number of points defining the length of both gridsomega_max (
(float)) – The maximum circular frequency in the spectral domain. its unit defines the temporal units. ex: omega_max in rad/fs implies time_grid in fs
- Returns:
omega_grid (
(ndarray)) – The spectral axis of the FFTtime_grid (
(ndarray))) – The temporal axis of the FFT
See also
ftAxis,ftAxis_time,ift,ft2,ift2
- pymodaq_utils.math_utils.ftAxis_time(Npts, time_max)[source]
Given two numbers Npts,omega_max, return two vectors spanning the temporal and spectral range. They are related by Fourier Transform
- Parameters:
Npts (
number) – A number of points defining the length of both gridstime_max (
number) – The maximum tmporal window
- Returns:
omega_grid (
vector) – The spectral axis of the FFTtime_grid (
vector) – The temporal axis of the FFT
See also
ftAxis,ftAxis_time,ift,ft2,ift2
- pymodaq_utils.math_utils.gauss1D(x, x0, dx, n=1)[source]
compute the gaussian function along a vector x, centered in x0 and with a FWHM i intensity of dx. n=1 is for the standart gaussian while n>1 defines a hypergaussian
- Parameters:
x (
(ndarray) first axisofthe 2D gaussian)x0 (
(float) the central positionofthe gaussian)dx (
(float) :the FWHMofthe gaussian)n=1 (
an integertodefine hypergaussian,n=1 by default for regular gaussian)
- Returns:
out – the value taken by the gaussian along x axis
- Return type:
vector
- pymodaq_utils.math_utils.gauss2D(x, x0, dx, y, y0, dy, n=1, angle=0)[source]
compute the 2D gaussian function along a vector x, centered in x0 and with a FWHM in intensity of dx and smae along y axis. n=1 is for the standard gaussian while n>1 defines a hypergaussian. optionally rotate it by an angle in degree
- Parameters:
x (
(ndarray) first axisofthe 2D gaussian)x0 (
(float) the central positionofthe gaussian)dx (
(float) :the FWHMofthe gaussian)y (
(ndarray) second axisofthe 2D gaussian)y0 (
(float) the central positionofthe gaussian)dy (
(float) :the FWHMofthe gaussian)n=1 (
an integertodefine hypergaussian,n=1 by default for regular gaussian)angle (
(float) a floattorotate main axes,in degree)
- Returns:
out
- Return type:
ndarray 2 dimensions
- pymodaq_utils.math_utils.ift(x, dim=0)[source]
Process the inverse 1D fast fourier transform and swaps the axis to get correct results using ftAxis :type x:
(ndarray) the array on which the FFT should be done:param x: :type x:(ndarray) the array on which the FFT should be done:type dim:the axis over which is done the FFT (default is the lastofthe array):param dim: :type dim:the axis over which is done the FFT (default is the lastofthe array)See also
ftAxis,ftAxis_time,ift,ft2,ift2
- pymodaq_utils.math_utils.ift2(x, dim=(-2, -1))[source]
Process the inverse 2D fast fourier transform and swaps the axis to get correct results using ftAxis :type x:
(ndarray) the array on which the FFT should be done:param x: :type x:(ndarray) the array on which the FFT should be done:type dim:the axis (or a tupleofaxes) over which is done the FFT (default is the lastofthe array):param dim: :type dim:the axis (or a tupleofaxes) over which is done the FFT (default is the lastofthe array)See also
ftAxis,ftAxis_time,ift,ft2,ift2
- pymodaq_utils.math_utils.linspace_step(start, stop, step)[source]
Compute a regular linspace_step distribution from start to stop values.
Parameters
Type
Description
start
scalar
the starting value of distribution
stop
scalar
the stopping value of distribution
step
scalar
the length of a distribution step
- Returns:
scalar array– The computed distribution axis as an array.