sweep_design.defaults.methods

This is where default methods are defined.

Module Contents

Functions

math_operation(→ sweep_design.help_types.Y)

Math operations.

one_integrate(→ float)

Integration.

integrate(→ Tuple[XAxis, sweep_design.help_types.Y])

Integration.

differentiate(→ Tuple[XAxis, sweep_design.help_types.Y])

Differentiation.

interpolate_extrapolate(→ Callable[[XAxis], ...)

Interpolation and extrapolation

get_common_x(→ XAxis)

Specifies the overall x-axis.

correlate(→ Tuple[XAxis, numpy.ndarray])

Correlation.

convolve(→ Tuple[XAxis, numpy.ndarray])

Convolution.

_calculate_spectrum(→ Tuple[FrequencyAxis, numpy.ndarray])

signal2spectrum(→ Tuple[FrequencyAxis, numpy.ndarray])

Forward Fourier Transform.

spectrum2signal(→ Tuple[TimeAxis, numpy.ndarray])

Inverse Fourier Transform.

integrate_function(...)

Integration function y(x).

Attributes

integration

XAxis

Array axis of x.

FrequencyAxis

Array axis of frequency.

TimeAxis

Array axis of time.

sweep_design.defaults.methods.integration
sweep_design.defaults.methods.XAxis

Array axis of x.

sweep_design.defaults.methods.FrequencyAxis

Array axis of frequency.

sweep_design.defaults.methods.TimeAxis

Array axis of time.

sweep_design.defaults.methods.math_operation(y1: numpy.ndarray, y2: Union[numpy.ndarray, sweep_design.help_types.Number], name_operation: sweep_design.core.MathOperation) sweep_design.help_types.Y[source]

Math operations.

Using numpy math operations.

Parameters
  • y1 (np.ndarray) – first sequence y.

  • y2 (Union[np.ndarray, Number]) – second sequence y or other number name_operation (MathOperation): which mathematical operation (+, -, *, / and etc.)

Raises

TypeFuncError – if operation can not be executed.

Returns

result of math operation.

Return type

Y

sweep_design.defaults.methods.one_integrate(relation: sweep_design.relation.Relation) float[source]

Integration.

Taking the integral on a segment. Return of the area under the graph. using scipy trapezoid integration.

Parameters

relation (Relation) – from will be calculated integral.

Returns

result of integration.

Return type

float

sweep_design.defaults.methods.integrate(relation: sweep_design.relation.Relation) Tuple[XAxis, sweep_design.help_types.Y][source]

Integration.

Integration across the entire function. Get the expected integrated array function. Using the scipy.integrate.cumtrapz function.

Parameters

relation (Relation) – integrated function.

Returns

result of integration of function.

Return type

Tuple[XAxis, Y]

sweep_design.defaults.methods.differentiate(relation: sweep_design.relation.Relation) Tuple[XAxis, sweep_design.help_types.Y][source]

Differentiation.

The method by which differentiation is performed. Using the numpy.diff function.

Parameters

relation (Relation) – function which will be differentiated.

Returns

result of differentiation.

Return type

Tuple[XAxis, Y]

sweep_design.defaults.methods.interpolate_extrapolate(x: sweep_design.help_types.X, y: sweep_design.help_types.Y, bounds_error=False, fill_value=0.0) Callable[[XAxis], sweep_design.help_types.Y][source]

Interpolation and extrapolation

Using the scipy.interpolate.interp1d function. Returning function of interpolation.

Parameters
  • x (X) – numbers array of axis. Samples can be not equal.

  • y (Y) – Representation interpolated extrapolated functions as array.

  • bounds_error (bool, optional) – if False then do not raise error if new array behind of bound old array. Defaults to False.

  • fill_value (float, optional) – default fill value if other not expected. Defaults to 0.0.

Returns

Callable that get first new array of x and return

interpolate-extrapolate result.

Return type

Callable[[X], Y]

sweep_design.defaults.methods.get_common_x(x1: XAxis, x2: XAxis) XAxis[source]

Specifies the overall x-axis.

Finds the general sample rate and beginning and end of sequence. A method by which to find the common sequence of numbers along the x-axis, obtained from two other sequences along the x-axis.

Parameters
  • x1 (XAxis) – first axis.

  • x2 (XAxis) – second axis.

Returns

return common axis.

Return type

XAxis

sweep_design.defaults.methods.correlate(cls: Type[sweep_design.relation.Relation], r1: sweep_design.relation.Relation, r2: sweep_design.relation.Relation) Tuple[XAxis, numpy.ndarray][source]

Correlation.

The method by which the correlation is performed. Using the numpy.correlate function.

Parameters
  • cls (Type["Relation"]) – class to use equalization of two arrays.

  • r1 (Relation) – first function y.

  • r2 (Relation) – second function y.

Returns

result of correlation.

Return type

Tuple[XAxis, np.ndarray]

sweep_design.defaults.methods.convolve(cls: Type[sweep_design.relation.Relation], r1: sweep_design.relation.Relation, r2: sweep_design.relation.Relation) Tuple[XAxis, numpy.ndarray][source]

Convolution.

The method by which the convolution is performed. Using the numpy.convolve function.

Parameters
  • cls (Type["Relation"]) – class to use equalization of two arrays.

  • r1 (Relation) – first function y.

  • r2 (Relation) – second function y.

Returns

result of convolution.

Return type

Tuple[XAxis, np.ndarray]

sweep_design.defaults.methods._calculate_spectrum(time: TimeAxis, amplitude: numpy.ndarray, frequency: Optional[Union[int, sweep_design.axis.ArrayAxis]] = None) Tuple[FrequencyAxis, numpy.ndarray][source]
sweep_design.defaults.methods.signal2spectrum(relation: sweep_design.relation.Relation, frequency: Optional[Union[sweep_design.axis.ArrayAxis, int]] = None, is_start_zero=False) Tuple[FrequencyAxis, numpy.ndarray][source]

Forward Fourier Transform.

Method for converting a signal into a spectrum. Using the numpy.fft.rfft function.

Parameters
  • relation (Relation) – signal from which get spectrum.

  • frequency (ArrayAxis, int, optional) – Define frequency to calculate spectrum. Defaults to None.

  • is_start_zero (bool, optional) – Consider array started from zero time. Defaults to False.

Returns

result transformation signal to

spectrum.

Return type

Tuple[FrequencyAxis, np.ndarray]

sweep_design.defaults.methods.spectrum2signal(relation: sweep_design.relation.Relation, time: Optional[Union[sweep_design.axis.ArrayAxis, int]] = None, time_start: float = None) Tuple[TimeAxis, numpy.ndarray][source]

Inverse Fourier Transform.

Method for converting a spectrum into a signal. Using numpy.ifft function.

Parameters
  • relation (Relation) – spectrum of signal.

  • time (ArrayAxis, int, optional) – Define time to calculate signal. Defaults to None.

  • time_start (float, optional) – default fft convert to 0. time. Maybe you want another start of time. Defaults to None.

Returns

result transformation spectrogram to signal.

Return type

Tuple[TimeAxis, np.ndarray]

sweep_design.defaults.methods.integrate_function(function: Callable[[numpy.ndarray], numpy.ndarray], x: sweep_design.axis.ArrayAxis) Tuple[sweep_design.axis.ArrayAxis, numpy.ndarray][source]

Integration function y(x).

The method by which the integration function is performed. Integration across the entire function. Get the expected integrated array function. Integration of function, using scipy.integrate.quad function.

Parameters
  • function (Callable[[x], y]) – function is describing changes frequency from time.

  • x (np.ndarray) – time array.

Returns

result of integration function.

Return type

Relation