signal_design.spectrum

Module Contents

Classes

Spectrum

A class that describes the spectrum of a signal.

Functions

input2spectrum_operation(→ Callable[[SP, SSPRN], SP])

_input2spectrum_operation(→ SPRN)

input2spectrum(→ Callable[[Type[SP], SSPR, SSPR], SP])

_input2spectrum(→ Spectrum)

Attributes

SP

Instance of Spectrum

SSPR

Instance of Spectrum or Signal or Relation

SPRN

Instance of Spectrum or Signal or Relation or Number

SSPRN

Instance of Spectrum or Signal or Relation or Number

signal_design.spectrum.SP

Instance of Spectrum

signal_design.spectrum.SSPR

Instance of Spectrum or Signal or Relation

signal_design.spectrum.SPRN

Instance of Spectrum or Signal or Relation or Number

signal_design.spectrum.SSPRN

Instance of Spectrum or Signal or Relation or Number

signal_design.spectrum.input2spectrum_operation(func: Callable[[SP, SPRN], SP]) Callable[[SP, SSPRN], SP][source]
signal_design.spectrum._input2spectrum_operation(input: SSPRN) SPRN[source]
signal_design.spectrum.input2spectrum(func: Callable[[Type[SP], Spectrum, Spectrum], SP]) Callable[[Type[SP], SSPR, SSPR], SP][source]
signal_design.spectrum._input2spectrum(input: SSPR) Spectrum[source]
class signal_design.spectrum.Spectrum(frequency: Union[signal_design.core.RelationProtocol, signal_design.axis.Axis, signal_design.help_types.ArrayLike], spectrum_amplitude: Optional[signal_design.help_types.ArrayLike] = None, signal: Optional[Spectrum.__init__.signal] = None)[source]

Bases: signal_design.relation.Relation

A class that describes the spectrum of a signal.

The Spectrum class derived from the signal_design.relation.Relation class.

Each ‘Spectrum’ can be converted into a signal_design.signal.Signal using method get_spectrum To convert the Spectrum into a signal_design.signal.Signal, the method defined in the default_functions module is used. (signal_design.default_functions.spectrum2signal). Current method can be overridden by own.

When performing arithmetic operations on instances of the signal_design.signal.Signal class, an instance of the Spectrum class will be extracted from the signal_design.signal.Signal instance, and arithmetic operations will be performed on this instance. An instance of signal_design.relation.Relation class will be converted into the instance of Spectrum class.

Initialization of instance of Spectrum.

Parameters:
  • frequency (Union[RelationProtocol, Axis, ArrayLike]) – An instance of signal_design.relation.Relation class or inherited from it, or Axis instance, or array_like object containing numbers (real).

  • spectrum_amplitude (ArrayLike, optional) – None or array_like object containing numbers (real or complex). Defaults to None.

property frequency: signal_design.axis.Axis

Frequency array axis.

Equal to property x. :returns: frequency array axis. :rtype: Axis

property amplitude: numpy.ndarray

Spectrum amplitude array.

Equal to property y. :returns: spectrum amplitude array. :rtype: numpy.ndarray

get_signal(time: Optional[Union[signal_design.axis.Axis, int]] = None, start_time: Optional[float] = None) signal_design.signal.Signal[source]

Get signal from spectrum.

Compute the signal from the spectrum.

Parameters:
  • time (Axis, int, optional) – Define time to calculate signal. Defaults to None.

  • start_time (float, optional) – If True then the signal will be shifted to zero. Defaults to False.

Returns:

instance of signal_design.signal.Signal described this Spectrum.

Return type:

signal.Signal

get_amplitude_spectrum() signal_design.relation.Relation[source]

Get amplitude spectrum.

Calculate the relationship between the frequency and the absolute value of the spectrum amplitude.

Parameters:

self (SP) – instance of Spectrum.

Returns:

new instance of Relation.

Return type:

Relation

get_phase_spectrum() signal_design.relation.Relation[source]

Get phase spectrum.

Calculate the relationship between frequency and phase of the spectrum.

Parameters:

self (SP) – instance of Spectrum.

Returns:

new instance of Relation.

Return type:

Relation

get_reverse_filter(percent: Union[float, int] = 5.0, subtract_phase=True, frequency_start: Optional[float] = None, frequency_end: Optional[float] = None) SP[source]

Calculate filter of reversed signal.

Parameters:
  • self (SP) – instance of Spectrum.

  • percent (Union[float, int], optional) – level of added white noise in percent. Defaults to 5.0.

  • subtract_phase (bool, optional) – If True performs phase subtraction. If False succeeds, add the phase. Defaults to True.

  • frequency_start (float, optional) – The start frequency. Defaults to None.

  • frequency_end (float, optional) – The end frequency. Defaults to None.

Returns:

new instance of Spectrum.

Return type:

SP

add_phase(other: SSPR) SP[source]

Add phase to spectrum.

Parameters:
  • self (SP) – instance of Spectrum

  • other (SSPR) – Extracting the Spectrum from the object and adding the phase Spectrum to the Spectrum.

Returns:

new instance of Spectrum.

Return type:

SP

sub_phase(other: SSPR) SP[source]

Subtract phase from spectrum.

Parameters:
  • self (SP) – instance of Spectrum

  • other (SSPR) – Extracting the Spectrum from the object and subtract the phase Spectrum from the Spectrum.

Returns:

new instance of Spectrum.

Return type:

SP

static get_frequency_axis_from_time(time: signal_design.axis.Axis, is_complex_data: bool = False) signal_design.axis.Axis[source]

Get frequency axis from axis of time.

Method for getting a frequency axis using time axis. If the data is complex, then the frequency axis will contain negative part.

Parameters:
  • time (Axis) – axis 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:

Axis

classmethod get_from_amplitude_phase(amplitude_spectrum: signal_design.relation.Relation, phase_spectrum: signal_design.relation.Relation) SP[source]

Calculate of the spectrum from the amplitude and phase spectrum.

The spectrum is calculated through the amplitude and phase spectrum using the formula abs*exp(1j*phase).

Parameters:
Returns:

new instance of Spectrum

Return type:

SP

classmethod convolve(sp1: Spectrum, sp2: Spectrum) SP[source]

Convolution of two instances of signal_design.relation.Relation and return new instance of Spectrum. Instances of signal_design.signal.Signal will be converted to Spectrum

Parameters:
Returns:

new instance of Spectrum.

Return type:

S

classmethod correlate(sp1: Spectrum, sp2: Spectrum) SP[source]

Correlation of two instances of signal_design.relation.Relation and return new instance of Spectrum. Instances of signal_design.signal.Signal will be converted to Spectrum

Parameters:
Returns:

new instance of Spectrum.

Return type:

S

__add__(a: SPRN) SP[source]
__sub__(a: SPRN) SP[source]
__mul__(a: SPRN) SP[source]
__truediv__(a: SPRN) SP[source]
__pow__(a: SPRN) SP[source]