signal_design.default_functions
This is where default function are defined.
Module Contents
Functions
|
Create instance of Axis using start, end and sample params of axis. |
|
Calculate size of axis using start, end and sample. |
|
Create array of numpy from Axis, using, start, end and size of Axis. |
|
Create instance of Axis from some array of numbers. |
|
Calculate actual sample. Use for self-test. Problem with floating point |
|
Specifies the overall axis. |
|
Math operations. |
|
Integration. |
|
Integration. |
|
Differentiation. |
Interpolation and extrapolation |
|
|
Correlation. |
|
Convolution. |
|
Shifting of signal. |
|
Forward Fourier Transform. |
|
|
|
Get frequency axis from size and sample of time. |
|
Inverse Fourier Transform. |
|
Get time axis from frequency axis and desired size of time axis. |
|
Integration function y(x). |
Attributes
Axis of x. |
- signal_design.default_functions.RelationT
- signal_design.default_functions.integration
- signal_design.default_functions.Axis
Axis of x.
- signal_design.default_functions.get_using_end(start: signal_design.help_types.RealNumber, end: signal_design.help_types.RealNumber, sample: signal_design.help_types.RealNumber, is_correct_end: bool = True) Axis[source]
Create instance of Axis using start, end and sample params of axis.
- Parameters:
start (RealNumber) – start position of axis.
end (RealNumber) – end position of axis.
sample (RealNumber) – sample of axis.
is_correct_end (bool) – Default True. Checking the correctness of the end of the axis. If value is False, no end will be set for the instance.
- Returns:
new instance of Axis.
- Return type:
- signal_design.default_functions.get_size(start: signal_design.help_types.RealNumber, end: signal_design.help_types.RealNumber, sample: signal_design.help_types.RealNumber) int[source]
Calculate size of axis using start, end and sample.
- Parameters:
start (RealNumber) – start position of axis.
end (RealNumber) – end position of axis.
sample (RealNumber) – sample of axis.
- Returns:
size of axis.
- Return type:
int
- signal_design.default_functions.get_array(axis_data: signal_design.axis.Axis) numpy.ndarray[source]
Create array of numpy from Axis, using, start, end and size of Axis.
- Parameters:
axis_data (Axis) – instance of Axis
- Returns:
numpy array of axis.
- Return type:
numpy.ndarray
- signal_design.default_functions.get_axis_from_array(x: signal_design.help_types.ArrayLike, sample: Optional[signal_design.help_types.RealNumber] = None) Axis[source]
Create instance of Axis from some array of numbers.
- Parameters:
x (ArrayLike) – Input array like of numbers.
sample (Optional[RealNumber]) – Default None. Sample of array. If sample is None, it well be calculated by function.
- Returns:
new instance of Axis.
- Return type:
- signal_design.default_functions.get_actual_sample(x: numpy.ndarray) signal_design.help_types.RealNumber[source]
Calculate actual sample. Use for self-test. Problem with floating point in Python (https://docs.python.org/3/tutorial/floatingpoint.html).
- Parameters:
x (numpy.ndarray) – array of numbers.
- Returns:
an actual sample
- Return type:
RealNumber
- signal_design.default_functions.get_common_axis(axis1: Axis, axis2: Axis, is_correct_end: bool = False) Axis[source]
Specifies the overall axis.
Finds the general sample rate and beginning and end of sequence. A function by which to find the common sequence of numbers along the axis, obtained from two other sequences along the axis.
- signal_design.default_functions.math_operation(y1: numpy.ndarray, y2: Union[numpy.ndarray, signal_design.help_types.Number], name_operation: signal_design.core.MathOperation) signal_design.help_types.Y[source]
Math operations.
Using numpy math operations.
- Parameters:
y1 (numpy.ndarray) – first sequence y.
y2 (Union[numpyp.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
- signal_design.default_functions.one_integrate(relation: RelationT) 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
- signal_design.default_functions.integrate(relation_data: RelationT) RelationT[source]
Integration.
Integration across the entire function. Get the expected integrated array function. Using the
scipy.integrate.cumtrapzfunction.
- signal_design.default_functions.differentiate(relation_data: RelationT) RelationT[source]
Differentiation.
The function by which differentiation is performed. Using the numpy.diff function.
- signal_design.default_functions.interpolate_extrapolate(x: signal_design.help_types.X, y: signal_design.help_types.Y, bounds_error=False, fill_value=0.0) Callable[[signal_design.axis.Axis], signal_design.help_types.Y][source]
Interpolation and extrapolation
Using the scipy.interpolate.interp1d function. Returning function of interpolation.
- Parameters:
x (numpy.ndarray) – numbers array of axis. Samples can be not equal.
y (numpy.ndarray) – 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]
- signal_design.default_functions.correlate(cls: Type[RelationT], r1: RelationT, r2: RelationT) RelationT[source]
Correlation.
The function by which the correlation is performed. Using the numpy.correlate function.
- signal_design.default_functions.convolve(cls: Type[RelationT], r1: RelationT, r2: RelationT) RelationT[source]
Convolution.
The function by which the convolution is performed. Using the numpy.convolve function.
- signal_design.default_functions.signal_shift(signal: signal_shift.signal, x_shift: signal_design.help_types.RealNumber = 0) signal_shift.signal[source]
Shifting of signal.
Shift signal using Fourier transform.
- Parameters:
signal – input shifting signal.
x_shift – shift distance.
- Returns:
shifted signal.
- Return type:
- signal_design.default_functions.signal2spectrum(relation_data: RelationT, frequency: Optional[Union[Frequency, int]] = None, is_start_zero=False, is_real_value_transform=True) signal_design.spectrum.Spectrum[source]
Forward Fourier Transform.
Function for converting a signal into a spectrum. Using the numpy.fft.rfft function.
- Parameters:
- Returns:
result transformation Signal to Spectrum.
- Return type:
- signal_design.default_functions._calculate_spectrum(time: Time, amplitude: numpy.ndarray, frequency: Optional[Union[int, Frequency]] = None, is_real_value_transform: bool = True) signal_design.spectrum.Spectrum[source]
- signal_design.default_functions.get_frequency_axis(time_size: int, time_sample: float, is_complex_data: bool = False) Frequency[source]
Get frequency axis from size and sample of time.
Function for getting a frequency axis using size and sample of time. If the data is complex, then the frequency axis will contain negative part.
- Parameters:
time_size (int) – size of time
time_sample (float) – sample of time
is_complex_data (bool) – If the data is complex, then the frequency axis will contain a negative part. If not, then vice versa. Defaults to False.
- Returns:
frequency axis.
- Return type:
- signal_design.default_functions.spectrum2signal(relation_data: signal_design.relation.Relation, time: Optional[Union[Time, int]] = None, time_start: Union[float, None] = None) signal_design.signal.Signal[source]
Inverse Fourier Transform.
Function for converting a spectrum into a signal. Using numpy.ifft function.
- Parameters:
- Returns:
result transformation Spectrum to Signal.
- Return type:
- signal_design.default_functions.get_time_axis(frequency: Frequency, size: Optional[int] = None, time_start: Optional[float] = None) Time[source]
Get time axis from frequency axis and desired size of time axis.
Function for getting a time axis using frequency axis and desired size.
- signal_design.default_functions.integrate_function(function: Callable[[signal_design.help_types.X], signal_design.help_types.Y], x: Axis) RelationT[source]
Integration function y(x).
The function 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.