Algorithms (cdl.algorithms)#

This package contains the algorithms used by the DataLab project. Those algorithms operate directly on NumPy arrays and are designed to be used in the DataLab pipeline, but can be used independently as well.

See also

The cdl.algorithms package is the main entry point for the DataLab algorithms when manipulating NumPy arrays. See the cdl.computation package for algorithms that operate directly on DataLab objects (i.e. cdl.obj.SignalObj and cdl.obj.ImageObj).

The algorithms are organized in subpackages according to their purpose. The following subpackages are available:

Signal Processing Algorithms#

cdl.algorithms.signal.moving_average(y: ndarray, n: int) ndarray#

Compute moving average.

Parameters:
  • y – Input array

  • n – Window size

Returns:

Moving average

cdl.algorithms.signal.derivative(x: ndarray, y: ndarray) ndarray#

Compute numerical derivative.

Parameters:
  • x – X data

  • y – Y data

Returns:

Numerical derivative

cdl.algorithms.signal.normalize(yin: ndarray, parameter: Literal['maximum', 'amplitude', 'area', 'energy', 'rms'] = 'maximum') ndarray#

Normalize input array to a given parameter.

Parameters:
  • yin – Input array

  • parameter – Normalization parameter. Defaults to β€œmaximum”

Returns:

Normalized array

cdl.algorithms.signal.fft1d(x: ndarray, y: ndarray, shift: bool = True) tuple[ndarray, ndarray]#

Compute FFT on X,Y data.

Parameters:
  • x – X data

  • y – Y data

  • shift – Shift the zero frequency to the center of the spectrum. Defaults to True.

Returns:

X data, Y data (tuple)

cdl.algorithms.signal.ifft1d(x: ndarray, y: ndarray, shift: bool = True) tuple[ndarray, ndarray]#

Compute iFFT on X,Y data.

Parameters:
  • x – X data

  • y – Y data

  • shift – Shift the zero frequency to the center of the spectrum. Defaults to True.

Returns:

X data, Y data (tuple)

cdl.algorithms.signal.magnitude_spectrum(x: ndarray, y: ndarray, log_scale: bool = False) tuple[ndarray, ndarray]#

Compute magnitude spectrum.

Parameters:
  • x – X data

  • y – Y data

  • log_scale – Use log scale. Defaults to False.

Returns:

Magnitude spectrum (X data, Y data)

cdl.algorithms.signal.phase_spectrum(x: ndarray, y: ndarray) tuple[ndarray, ndarray]#

Compute phase spectrum.

Parameters:
  • x – X data

  • y – Y data

Returns:

Phase spectrum in degrees (X data, Y data)

cdl.algorithms.signal.psd(x: ndarray, y: ndarray, log_scale: bool = False) tuple[ndarray, ndarray]#

Compute Power Spectral Density (PSD), using the Welch method.

Parameters:
  • x – X data

  • y – Y data

  • log_scale – Use log scale. Defaults to False.

Returns:

X data, Y data (tuple)

Return type:

Power Spectral Density (PSD)

cdl.algorithms.signal.sort_frequencies(x: ndarray, y: ndarray) ndarray#

Sort from X,Y data by computing FFT(y).

Parameters:
  • x – X data

  • y – Y data

Returns:

Sorted frequencies in ascending order

cdl.algorithms.signal.peak_indexes(y, thres: float = 0.3, min_dist: int = 1, thres_abs: bool = False) ndarray#

Peak detection routine.

Finds the numeric index of the peaks in y by taking its first order difference. By using thres and min_dist parameters, it is possible to reduce the number of detected peaks. y must be signed.

Parameters:
  • y (ndarray (signed)) – 1D amplitude data to search for peaks.

  • thres (float between [0., 1.]) – Normalized threshold. Only the peaks with amplitude higher than the threshold will be detected.

  • min_dist (int) – Minimum distance between each detected peak. The peak with the highest amplitude is preferred to satisfy this constraint.

  • thres_abs (boolean) – If True, the thres value will be interpreted as an absolute value, instead of a normalized threshold.

Returns:

Array containing the numeric indexes of the peaks that were detected

Return type:

ndarray

cdl.algorithms.signal.xpeak(x: ndarray, y: ndarray) float#

Return default peak X-position (assuming a single peak).

Parameters:
  • x – X data

  • y – Y data

Returns:

Peak X-position

cdl.algorithms.signal.interpolate(x: ndarray, y: ndarray, xnew: ndarray, method: Literal['linear', 'spline', 'quadratic', 'cubic', 'barycentric', 'pchip'], fill_value: float | None = None) ndarray#

Interpolate data.

Parameters:
  • x – X data

  • y – Y data

  • xnew – New X data

  • method – Interpolation method

  • fill_value – Fill value. Defaults to None. This value is used to fill in for requested points outside of the X data range. It is only used if the method argument is β€˜linear’, β€˜cubic’ or β€˜pchip’.

Returns:

Interpolated Y data

cdl.algorithms.signal.windowing(y: ndarray, method: Literal['barthann', 'bartlett', 'blackman', 'blackman-harris', 'bohman', 'boxcar', 'cosine', 'exponential', 'flat-top', 'hamming', 'hanning', 'lanczos', 'nuttall', 'parzen', 'rectangular', 'taylor', 'tukey', 'kaiser', 'gaussian'] = 'hamming', alpha: float = 0.5, beta: float = 14.0, sigma: float = 7.0) ndarray#

Apply windowing to the input data.

Parameters:
  • x – X data

  • y – Y data

  • method – Windowing function. Defaults to β€œhamming”.

  • alpha – Tukey window parameter. Defaults to 0.5.

  • beta – Kaiser window parameter. Defaults to 14.0.

  • sigma – Gaussian window parameter. Defaults to 7.0.

Returns:

Windowed Y data

cdl.algorithms.signal.find_nearest_zero_point_idx(y: ndarray) ndarray#

Find the x indexes where the corresponding y is the closest to zero

Parameters:

y – Y data

Returns:

Indexes of the points right before or at zero crossing

cdl.algorithms.signal.find_x_at_value(x: ndarray, y: ndarray, value: float) ndarray#

Find the x value where the y value is the closest to the given value using linear interpolation to deduce the precise x value.

Parameters:
  • x – X data

  • y – Y data

  • value – Value to find

Returns:

X value where the Y value is the closest to the given value

cdl.algorithms.signal.bandwidth(data: ndarray, level: float = 3.0) float#

Compute the bandwidth of the signal at a given level.

Parameters:
  • data – X,Y data

  • level – Level in dB at which the bandwidth is computed. Defaults to 3.0.

Returns:

segment coordinates

Return type:

Bandwidth of the signal at the given level

cdl.algorithms.signal.sinusoidal_model(x: ndarray, a: float, f: float, phi: float, offset: float) ndarray#

Sinusoidal model function.

cdl.algorithms.signal.sinusoidal_fit(x: ndarray, y: ndarray) tuple[tuple[float, float, float, float], float]#

Fit a sinusoidal model to the input data.

Parameters:
  • x – X data

  • y – Y data

Returns:

A tuple containing the fit parameters (amplitude, frequency, phase, offset) and the residuals

cdl.algorithms.signal.sinus_frequency(x: ndarray, y: ndarray) float#

Compute the frequency of a sinusoidal signal.

Parameters:
  • x – x signal data

  • y – y signal data

Returns:

Frequency of the sinusoidal signal

cdl.algorithms.signal.enob(x: ndarray, y: ndarray, full_scale: float = 1.0) float#

Compute Effective Number of Bits (ENOB).

Parameters:
  • x – x signal data

  • y – y signal data

  • full_scale – Full scale(V). Defaults to 1.0.

Returns:

Effective Number of Bits (ENOB)

cdl.algorithms.signal.sinad(x: ndarray, y: ndarray, full_scale: float = 1.0, unit: Literal['dBc', 'dBFS'] = 'dBc') float#

Compute Signal-to-Noise and Distortion Ratio (SINAD).

Parameters:
  • x – x signal data

  • y – y signal data

  • full_scale – Full scale(V). Defaults to 1.0.

  • unit – Unit of the input data. Valid values are β€˜dBc’ and β€˜dBFS’. Defaults to β€˜dBc’.

Returns:

Signal-to-Noise and Distortion Ratio (SINAD)

cdl.algorithms.signal.thd(x: ndarray, y: ndarray, full_scale: float = 1.0, unit: Literal['dBc', 'dBFS'] = 'dBc', nb_harm: int = 5) float#

Compute Total Harmonic Distortion (THD).

Parameters:
  • x – x signal data

  • y – y signal data

  • full_scale – Full scale(V). Defaults to 1.0.

  • unit – Unit of the input data. Valid values are β€˜dBc’ and β€˜dBFS’. Defaults to β€˜dBc’.

  • nb_harm – Number of harmonics to consider. Defaults to 5.

Returns:

Total Harmonic Distortion (THD)

cdl.algorithms.signal.sfdr(x: ndarray, y: ndarray, full_scale: float = 1.0, unit: Literal['dBc', 'dBFS'] = 'dBc') float#

Compute Spurious-Free Dynamic Range (SFDR).

Parameters:
  • x – x signal data

  • y – y signal data

  • full_scale – Full scale(V). Defaults to 1.0.

  • unit – Unit of the input data. Valid values are β€˜dBc’ and β€˜dBFS’. Defaults to β€˜dBc’.

Returns:

Spurious-Free Dynamic Range (SFDR)

cdl.algorithms.signal.snr(x: ndarray, y: ndarray, full_scale: float = 1.0, unit: Literal['dBc', 'dBFS'] = 'dBc') float#

Compute Signal-to-Noise Ratio (SNR).

Parameters:
  • x – x signal data

  • y – y signal data

  • full_scale – Full scale(V). Defaults to 1.0.

  • unit – Unit of the input data. Valid values are β€˜dBc’ and β€˜dBFS’. Defaults to β€˜dBc’.

Returns:

Signal-to-Noise Ratio (SNR)

cdl.algorithms.signal.fwhm(data: ndarray, method: Literal['zero-crossing', 'gauss', 'lorentz', 'voigt'] = 'zero-crossing', xmin: float | None = None, xmax: float | None = None) tuple[float, float, float, float]#

Compute Full Width at Half Maximum (FWHM) of the input data

Parameters:
  • data – X,Y data

  • method – Calculation method. Two types of methods are supported: a zero-crossing method and fitting methods (based on various models: Gauss, Lorentz, Voigt). Defaults to β€œzero-crossing”.

  • xmin – Lower X bound for the fitting. Defaults to None (no lower bound, i.e. the fitting starts from the first point).

  • xmax – Upper X bound for the fitting. Defaults to None (no upper bound, i.e. the fitting ends at the last point)

Returns:

FWHM segment coordinates

cdl.algorithms.signal.fw1e2(data: ndarray) tuple[float, float, float, float]#

Compute Full Width at 1/eοΏ½ of the input data (using a Gaussian model fitting).

Parameters:

data – X,Y data

Returns:

FW at 1/eΒ² segment coordinates

cdl.algorithms.signal.contrast(y: ndarray) float#

Compute contrast

Parameters:

y – Input array

Returns:

Contrast

cdl.algorithms.signal.sampling_period(x: ndarray) float#

Compute sampling period

Parameters:

x – X data

Returns:

Sampling period

cdl.algorithms.signal.sampling_rate(x: ndarray) float#

Compute mean sampling rate

Parameters:

x – X data

Returns:

Sampling rate

Image Processing Algorithms#

cdl.algorithms.image.scale_data_to_min_max(data: ndarray, zmin: float | int, zmax: float | int) ndarray#

Scale array data to fit [zmin, zmax] dynamic range

Parameters:
  • data – Input data

  • zmin – Minimum value of output data

  • zmax – Maximum value of output data

Returns:

Scaled data

cdl.algorithms.image.normalize(data: ndarray, parameter: Literal['maximum', 'amplitude', 'area', 'energy', 'rms'] = 'maximum') ndarray#

Normalize input array to a given parameter.

Parameters:
  • data – Input data

  • parameter – Normalization parameter (default: β€œmaximum”)

Returns:

Normalized array

cdl.algorithms.image.fft2d(z: ndarray, shift: bool = True) ndarray#

Compute FFT of complex array z

Parameters:
  • z – Input data

  • shift – Shift zero frequency to center (default: True)

Returns:

FFT of input data

cdl.algorithms.image.ifft2d(z: ndarray, shift: bool = True) ndarray#

Compute inverse FFT of complex array z

Parameters:
  • z – Input data

  • shift – Shift zero frequency to center (default: True)

Returns:

Inverse FFT of input data

cdl.algorithms.image.magnitude_spectrum(z: ndarray, log_scale: bool = False) ndarray#

Compute magnitude spectrum of complex array z

Parameters:
  • z – Input data

  • log_scale – Use log scale (default: False)

Returns:

Magnitude spectrum of input data

cdl.algorithms.image.phase_spectrum(z: ndarray) ndarray#

Compute phase spectrum of complex array z

Parameters:

z – Input data

Returns:

Phase spectrum of input data (in degrees)

cdl.algorithms.image.psd(z: ndarray, log_scale: bool = False) ndarray#

Compute power spectral density of complex array z

Parameters:
  • z – Input data

  • log_scale – Use log scale (default: False)

Returns:

Power spectral density of input data

cdl.algorithms.image.binning(data: ndarray, binning_x: int, binning_y: int, operation: Literal['sum', 'average', 'median', 'min', 'max'], dtype=None) ndarray#

Perform image pixel binning

Parameters:
  • data – Input data

  • binning_x – Binning factor along x-axis

  • binning_y – Binning factor along y-axis

  • operation – Binning operation

  • dtype – Output data type (default: None, i.e. same as input)

Returns:

Binned data

cdl.algorithms.image.flatfield(rawdata: ndarray, flatdata: ndarray, threshold: float | None = None) ndarray#

Compute flat-field correction

Parameters:
  • rawdata – Raw data

  • flatdata – Flat-field data

  • threshold – Threshold for flat-field correction (default: None)

Returns:

Flat-field corrected data

cdl.algorithms.image.get_centroid_fourier(data: ndarray) tuple[float, float]#

Return image centroid using Fourier algorithm

Parameters:

data – Input data

Returns:

Centroid coordinates (row, col)

cdl.algorithms.image.get_absolute_level(data: ndarray, level: float) float#

Return absolute level

Parameters:
  • data – Input data

  • level – Relative level (0.0 to 1.0)

Returns:

Absolute level

cdl.algorithms.image.get_enclosing_circle(data: ndarray, level: float = 0.5) tuple[int, int, float]#

Return (x, y, radius) for the circle contour enclosing image values above threshold relative level (.5 means FWHM)

Parameters:
  • data – Input data

  • level – Relative level (default: 0.5)

Returns:

A tuple (x, y, radius)

Raises:

ValueError – No contour was found

cdl.algorithms.image.get_radial_profile(data: ndarray, center: tuple[int, int]) tuple[ndarray, ndarray]#

Return radial profile of image data

Parameters:
  • data – Input data (2D array)

  • center – Coordinates of the center of the profile (x, y)

Returns:

Radial profile (X, Y) where X is the distance from the center (1D array) and Y is the average value of pixels at this distance (1D array)

cdl.algorithms.image.distance_matrix(coords: list) ndarray#

Return distance matrix from coords

Parameters:

coords – List of coordinates

Returns:

Distance matrix

cdl.algorithms.image.get_2d_peaks_coords(data: ndarray, size: int | None = None, level: float = 0.5) ndarray#

Detect peaks in image data, return coordinates.

If neighborhoods size is None, default value is the highest value between 50 pixels and the 1/40th of the smallest image dimension.

Detection threshold level is relative to difference between data maximum and minimum values.

Parameters:
  • data – Input data

  • size – Neighborhood size (default: None)

  • level – Relative level (default: 0.5)

Returns:

Coordinates of peaks

cdl.algorithms.image.get_contour_shapes(data: ndarray | MaskedArray, shape: Literal['circle', 'ellipse', 'polygon'] = 'ellipse', level: float = 0.5) ndarray#

Find iso-valued contours in a 2D array, above relative level (.5 means FWHM), then fit contours with shape (β€˜ellipse’ or β€˜circle’)

Parameters:
  • data – Input data

  • shape – Shape to fit. Default is β€˜ellipse’

  • level – Relative level (default: 0.5)

Returns:

Coordinates of shapes

cdl.algorithms.image.get_hough_circle_peaks(data: ndarray, min_radius: float | None = None, max_radius: float | None = None, nb_radius: int | None = None, min_distance: int = 1) ndarray#

Detect peaks in image from circle Hough transform, return circle coordinates.

Parameters:
  • data – Input data

  • min_radius – Minimum radius (default: None)

  • max_radius – Maximum radius (default: None)

  • nb_radius – Number of radii (default: None)

  • min_distance – Minimum distance between circles (default: 1)

Returns:

Coordinates of circles

cdl.algorithms.image.find_blobs_dog(data: ndarray, min_sigma: float = 1, max_sigma: float = 30, overlap: float = 0.5, threshold_rel: float = 0.2, exclude_border: bool = True) ndarray#

Finds blobs in the given grayscale image using the Difference of Gaussians (DoG) method.

Parameters:
  • data – The grayscale input image.

  • min_sigma – The minimum blob radius in pixels.

  • max_sigma – The maximum blob radius in pixels.

  • overlap – The minimum overlap between two blobs in pixels. For instance, if two blobs are detected with radii of 10 and 12 respectively, and the overlap is set to 0.5, then the area of the smaller blob will be ignored and only the area of the larger blob will be returned.

  • threshold_rel – The absolute lower bound for scale space maxima. Local maxima smaller than threshold_rel are ignored. Reduce this to detect blobs with less intensities.

  • exclude_border – If True, exclude blobs from detection if they are too close to the border of the image. Border size is min_sigma.

Returns:

Coordinates of blobs

cdl.algorithms.image.find_blobs_doh(data: ndarray, min_sigma: float = 1, max_sigma: float = 30, overlap: float = 0.5, log_scale: bool = False, threshold_rel: float = 0.2) ndarray#

Finds blobs in the given grayscale image using the Determinant of Hessian (DoH) method.

Parameters:
  • data – The grayscale input image.

  • min_sigma – The minimum blob radius in pixels.

  • max_sigma – The maximum blob radius in pixels.

  • overlap – The minimum overlap between two blobs in pixels. For instance, if two blobs are detected with radii of 10 and 12 respectively, and the overlap is set to 0.5, then the area of the smaller blob will be ignored and only the area of the larger blob will be returned.

  • log_scale – If True, the radius of each blob is returned as sqrt(sigma) for each detected blob.

  • threshold_rel – The absolute lower bound for scale space maxima. Local maxima smaller than threshold_rel are ignored. Reduce this to detect blobs with less intensities.

Returns:

Coordinates of blobs

cdl.algorithms.image.find_blobs_log(data: ndarray, min_sigma: float = 1, max_sigma: float = 30, overlap: float = 0.5, log_scale: bool = False, threshold_rel: float = 0.2, exclude_border: bool = True) ndarray#

Finds blobs in the given grayscale image using the Laplacian of Gaussian (LoG) method.

Parameters:
  • data – The grayscale input image.

  • min_sigma – The minimum blob radius in pixels.

  • max_sigma – The maximum blob radius in pixels.

  • overlap – The minimum overlap between two blobs in pixels. For instance, if two blobs are detected with radii of 10 and 12 respectively, and the overlap is set to 0.5, then the area of the smaller blob will be ignored and only the area of the larger blob will be returned.

  • log_scale – If True, the radius of each blob is returned as sqrt(sigma) for each detected blob.

  • threshold_rel – The absolute lower bound for scale space maxima. Local maxima smaller than threshold_rel are ignored. Reduce this to detect blobs with less intensities.

  • exclude_border – If True, exclude blobs from detection if they are too close to the border of the image. Border size is min_sigma.

Returns:

Coordinates of blobs

cdl.algorithms.image.remove_overlapping_disks(coords: ndarray) ndarray#

Remove overlapping disks among coordinates

Parameters:

coords – The coordinates of the disks

Returns:

The coordinates of the disks with overlapping disks removed

cdl.algorithms.image.find_blobs_opencv(data: ndarray, min_threshold: float | None = None, max_threshold: float | None = None, min_repeatability: int | None = None, min_dist_between_blobs: float | None = None, filter_by_color: bool | None = None, blob_color: int | None = None, filter_by_area: bool | None = None, min_area: float | None = None, max_area: float | None = None, filter_by_circularity: bool | None = None, min_circularity: float | None = None, max_circularity: float | None = None, filter_by_inertia: bool | None = None, min_inertia_ratio: float | None = None, max_inertia_ratio: float | None = None, filter_by_convexity: bool | None = None, min_convexity: float | None = None, max_convexity: float | None = None) ndarray#

Finds blobs in the given grayscale image using OpenCV’s SimpleBlobDetector.

Parameters:
  • data – The grayscale input image.

  • min_threshold – The minimum blob intensity.

  • max_threshold – The maximum blob intensity.

  • min_repeatability – The minimum number of times a blob is detected before it is reported.

  • min_dist_between_blobs – The minimum distance between blobs.

  • filter_by_color – If True, blobs are filtered by color.

  • blob_color – The color of the blobs to filter by.

  • filter_by_area – If True, blobs are filtered by area.

  • min_area – The minimum blob area.

  • max_area – The maximum blob area.

  • filter_by_circularity – If True, blobs are filtered by circularity.

  • min_circularity – The minimum blob circularity.

  • max_circularity – The maximum blob circularity.

  • filter_by_inertia – If True, blobs are filtered by inertia.

  • min_inertia_ratio – The minimum blob inertia ratio.

  • max_inertia_ratio – The maximum blob inertia ratio.

  • filter_by_convexity – If True, blobs are filtered by convexity.

  • min_convexity – The minimum blob convexity.

  • max_convexity – The maximum blob convexity.

Returns:

Coordinates of blobs

Data Type Conversion Algorithms#

cdl.algorithms.datatypes.is_integer_dtype(dtype: dtype) bool#

Return True if data type is an integer type

Parameters:

dtype – Data type to check

Returns:

True if data type is an integer type

cdl.algorithms.datatypes.is_complex_dtype(dtype: dtype) bool#

Return True if data type is a complex type

Parameters:

dtype – Data type to check

Returns:

True if data type is a complex type

Coordinate Conversion Algorithms#

cdl.algorithms.coordinates.circle_to_diameter(xc: float, yc: float, r: float) tuple[float, float, float, float]#

Convert circle center and radius to X diameter coordinates

Parameters:
  • xc – Circle center X coordinate

  • yc – Circle center Y coordinate

  • r – Circle radius

Returns:

Circle X diameter coordinates

Return type:

tuple

cdl.algorithms.coordinates.array_circle_to_diameter(data: ndarray) ndarray#

Convert circle center and radius to X diameter coordinates (array version)

Parameters:

data – Circle center and radius, in the form of a 2D array (N, 3)

Returns:

Circle X diameter coordinates, in the form of a 2D array (N, 4)

cdl.algorithms.coordinates.circle_to_center_radius(x0: float, y0: float, x1: float, y1: float) tuple[float, float, float]#

Convert circle X diameter coordinates to center and radius

Parameters:
  • x0 – Diameter start X coordinate

  • y0 – Diameter start Y coordinate

  • x1 – Diameter end X coordinate

  • y1 – Diameter end Y coordinate

Returns:

Circle center and radius

Return type:

tuple

cdl.algorithms.coordinates.array_circle_to_center_radius(data: ndarray) ndarray#

Convert circle X diameter coordinates to center and radius (array version)

Parameters:

data – Circle X diameter coordinates, in the form of a 2D array (N, 4)

Returns:

Circle center and radius, in the form of a 2D array (N, 3)

cdl.algorithms.coordinates.ellipse_to_diameters(xc: float, yc: float, a: float, b: float, theta: float) tuple[float, float, float, float, float, float, float, float]#

Convert ellipse center, axes and angle to X/Y diameters coordinates

Parameters:
  • xc – Ellipse center X coordinate

  • yc – Ellipse center Y coordinate

  • a – Ellipse half larger axis

  • b – Ellipse half smaller axis

  • theta – Ellipse angle

Returns:

Ellipse X/Y diameters (major/minor axes) coordinates

cdl.algorithms.coordinates.array_ellipse_to_diameters(data: ndarray) ndarray#

Convert ellipse center, axes and angle to X/Y diameters coordinates (array version)

Parameters:

data – Ellipse center, axes and angle, in the form of a 2D array (N, 5)

Returns:

Ellipse X/Y diameters (major/minor axes) coordinates,

in the form of a 2D array (N, 8)

cdl.algorithms.coordinates.ellipse_to_center_axes_angle(x0: float, y0: float, x1: float, y1: float, x2: float, y2: float, x3: float, y3: float) tuple[float, float, float, float, float]#

Convert ellipse X/Y diameters coordinates to center, axes and angle

Parameters:
  • x0 – major axis start X coordinate

  • y0 – major axis start Y coordinate

  • x1 – major axis end X coordinate

  • y1 – major axis end Y coordinate

  • x2 – minor axis start X coordinate

  • y2 – minor axis start Y coordinate

  • x3 – minor axis end X coordinate

  • y3 – minor axis end Y coordinate

Returns:

Ellipse center, axes and angle

cdl.algorithms.coordinates.array_ellipse_to_center_axes_angle(data: ndarray) ndarray#

Convert ellipse X/Y diameters coordinates to center, axes and angle (array version)

Parameters:

data – Ellipse X/Y diameters coordinates, in the form of a 2D array (N, 8)

Returns:

Ellipse center, axes and angle, in the form of a 2D array (N, 5)

Curve Fitting Algorithms#

class cdl.algorithms.fit.FitModel#

Curve fitting model base class

abstract classmethod func(x, amp, sigma, x0, y0)#

Return fitting function

classmethod get_amp_from_amplitude(amplitude, sigma)#

Return amp from function amplitude and sigma

classmethod amplitude(amp, sigma)#

Return function amplitude

abstract classmethod fwhm(amp, sigma)#

Return function FWHM

classmethod half_max_segment(amp, sigma, x0, y0)#

Return segment coordinates for y=half-maximum intersection

class cdl.algorithms.fit.GaussianModel#

1-dimensional Gaussian fit model

classmethod func(x, amp, sigma, x0, y0)#

Return fitting function

classmethod get_amp_from_amplitude(amplitude, sigma)#

Return amp from function amplitude and sigma

classmethod amplitude(amp, sigma)#

Return function amplitude

classmethod fwhm(amp, sigma)#

Return function FWHM

class cdl.algorithms.fit.LorentzianModel#

1-dimensional Lorentzian fit model

classmethod func(x, amp, sigma, x0, y0)#

Return fitting function

classmethod get_amp_from_amplitude(amplitude, sigma)#

Return amp from function amplitude and sigma

classmethod amplitude(amp, sigma)#

Return function amplitude

classmethod fwhm(amp, sigma)#

Return function FWHM

class cdl.algorithms.fit.VoigtModel#

1-dimensional Voigt fit model

classmethod func(x, amp, sigma, x0, y0)#

Return fitting function

classmethod fwhm(amp, sigma)#

Return function FWHM