sweep_design.utility_functions

Submodules

Package Contents

Functions

tukey_a_t(→ numpy.ndarray)

Calculate array envelope for signal.

get_IMFs_ceemdan(→ List[sweep_design.signal.Signal])

Empirical mode decomposition (EMD).

get_IMFs_emd(→ List[sweep_design.signal.Signal])

"Empirical mode decomposition (EMD).

f_t_linear_array(→ numpy.ndarray)

Create array of number describe linear changes frequency-time.

f_t_linear_function(→ Callable[[numpy.ndarray], ...)

Create liner function of changes frequency-time.

proportional_freq2time(...)

Convert spectrum to frequency-time and amplitude-time arrays.

dwell(→ Callable[[sweep_design.spectrum.Spectrum], ...)

Convert spectrum to frequency-time and amplitude-time arrays.

correct_sweep(→ sweep_design.signal.Signal)

Apply correction to sweep signal.

get_correction_for_source(→ sweep_design.signal.Signal)

Sweep signal correction for realization on the vibration source.

sweep_design.utility_functions.tukey_a_t(time: numpy.ndarray, time_tapper: Optional[float], location: Location = 'both') numpy.ndarray[source]

Calculate array envelope for signal.

Parameters
  • time (np.ndarray) – time

  • time_tapper (float) – time_tapper in time, where coefficient will be equal 1.

  • location (Literal["left", "right", "both"], optional) – Where the correction will be applied. “left” is at the start. “right” is at the end. “both” is at the start and at the end. Defaults to “both”.

Returns

amplitude correction for signal. Multiple signal to result

of function.

Return type

np.ndarray

sweep_design.utility_functions.get_IMFs_ceemdan(data: sweep_design.signal.Signal, number_seedman=30, epsilon=0.005, ext_EMD: Any = None, parallel=False, processes=None, noise_scale=1, noise_kind='normal', range_thr=0.01, total_power_thr=0.05) List[sweep_design.signal.Signal][source]

Empirical mode decomposition (EMD). Using CEEMDAN from PyEMD (https://pyemd.readthedocs.io/) to calculate IMFs and return them as a list of Signals.

About empirical mode decomposition on https://en.wikipedia.org/wiki/Hilbert%E2%80%93Huang_transform#Techniques

Parameters
  • data (Signal) – _description_

  • number_seedman (int, optional) – _description_. Defaults to 30.

  • epsilon (float, optional) – Scale for added noise (epsilon) which multiply std sigma: eta = epsilon cdot sigma. Defaults to 0.005.

  • ext_EMD (Any, optional) – One can pass EMD object defined outside, which will be used to compute IMF decompositions in each trial. If none is passed then EMD with default options is used. Defaults to None.

  • parallel (bool, optional) – Flag whether to use multiprocessing in EEMD execution. Since each EMD(s+noise) is independent this should improve execution speed considerably. Note that it’s disabled by default because it’s the most common problem when CEEMDAN takes too long time to finish. If you set the flag to True, make also sure to set processes to some reasonable value. Defaults to False.

  • processes (_type_, optional) – Number of processes harness when executing in parallel mode. The value should be between 1 and max that depends on your hardware. Defaults to None.

  • noise_scale (int, optional) – Scale (amplitude) of the added noise. Defaults to 1.

  • noise_kind (str, optional) – What type of noise to add. Allowed are “normal” (default) and “uniform”. Defaults to “normal”.

  • range_thr (float, optional) – Range threshold used as an IMF check. The value is in percentage compared to initial signal’s amplitude. If absolute amplitude (max - min) is below the range_thr then the decomposition is finished. Defaults to 0.01.

  • total_power_thr (float, optional) – Signal’s power threshold. Finishes decomposition if sum(abs(r)) < thr. Defaults to 0.05.

Returns

List of Signals expected IMFs.

Return type

List[Signal]

sweep_design.utility_functions.get_IMFs_emd(data: sweep_design.signal.Signal) List[sweep_design.signal.Signal][source]

“Empirical mode decomposition (EMD).

Using EMD from PyEMD (https://pyemd.readthedocs.io/) to calculate IMFs and return them as a list of Signals.

About empirical mode decomposition on https://en.wikipedia.org/wiki/Hilbert%E2%80%93Huang_transform#Techniques

Parameters

data (Signal) – signal to calculate IMFs.

Returns

List of Signals expected IMFs.

Return type

List[Signal]

sweep_design.utility_functions.f_t_linear_array(time: numpy.ndarray, f_start=1.0, f_end=100.0) numpy.ndarray[source]

Create array of number describe linear changes frequency-time.

Use parameters to calculate linear function f(t) = b*t+k, where t is time, f(t) function frequency-time.

Parameters
  • time (np.ndarray) – time changes array.

  • f_start (RealNumber, optional) – start frequency. Defaults to 1..

  • f_end (RealNumber, optional) – end frequency. Defaults to 100..

Returns

array of numbers describe linear changes frequency-time.

Return type

np.ndarray

sweep_design.utility_functions.f_t_linear_function(time_start=0.0, time_end=10.0, f_start=1.0, f_end=100.0) Callable[[numpy.ndarray], numpy.ndarray][source]

Create liner function of changes frequency-time.

Use parameters to calculate linear function f(t) = b*t+k, where t is time, f(t) function frequency-time.

Parameters
  • time_start (RealNumber, optional) – start time. Defaults to 0..

  • time_end (RealNumber, optional) – end time. Defaults to 10..

  • f_start (RealNumber, optional) – start frequency. Defaults to 1..

  • f_end (RealNumber, optional) – end frequency. Defaults to 100..

Returns

linear function frequency-time.

Return type

Callable[[np.ndarray], np.ndarray]

sweep_design.utility_functions.proportional_freq2time(spectrum: sweep_design.spectrum.Spectrum) Tuple[sweep_design.help_types.Time, sweep_design.help_types.Frequency, sweep_design.help_types.Envelope][source]

Convert spectrum to frequency-time and amplitude-time arrays.

A function to get frequency versus time and amplitude versus time changes from an a priori spectrum to create a sweep signal. In this implementation, the amplitude of change over time is a constant. The spectrum of the resulting sweep signal will be equal to the prior spectrum.

sweep_design.utility_functions.dwell(f_start: float = None, f_end: float = None, fc: float = None) Callable[[sweep_design.spectrum.Spectrum], Tuple[sweep_design.help_types.Time, sweep_design.help_types.Frequency, sweep_design.help_types.Envelope]][source]

Convert spectrum to frequency-time and amplitude-time arrays.

A function to get frequency versus time and amplitude versus time changes from an a priori spectrum to create a sweep signal. In this implementation, the amplitude of the envelope monotonously increases in proportion to the change in frequency up to the cutoff frequency fc, after which the amplitude of the envelope is constant. The spectrum of the resulting sweep signal will be equal to the prior spectrum.

sweep_design.utility_functions.correct_sweep(signal: sweep_design.signal.Signal, start_window: float = None) sweep_design.signal.Signal[source]

Apply correction to sweep signal.

Using the EMD to subtract the last IMF from the displacement and if window is not None then apply a window in the star so that the displacement starts at zero.

Parameters
  • signal (Relation) – The sweep signal on which the correction will be applied.

  • start_window (float, optional) – The time interval at the beginning to reduce the deviation from zero. If None, then window is not applied. Defaults to None.

Returns

corrected sweep signal.

Return type

Relation

sweep_design.utility_functions.get_correction_for_source(signal: sweep_design.signal.Signal, reaction_mass: float = 1.0, limits: float = None, limits_percent=0.85, limit_iteration: Optional[int] = 10, window_percent=0.01, coefficient_function: Callable[[float], float] = lambda x: ...) sweep_design.signal.Signal[source]

Sweep signal correction for realization on the vibration source.

Steps of corrections: 1. Calculate displacement from force. 2. Using EMD find first IMFs of displacement. 3. Apply suppression amplitude after limits. 4. Apply window at the start to ensure a zero first amplitude. 5. Return calculated force from displacement

Parameters
  • signal (Signal) – signal to be corrected.

  • reaction_mass (float, optional) – reaction mass of source. Defaults to 1.0.

  • limits (float, optional) – displacement limitation of source. Defaults to None.

  • limits_percent (float, optional) – from 0 to 1, determine the limits = limits*limits_percent up to which the displacement amplitude will not changed, after that, the limit amplitude will be changed using the soft_clip function. Defaults to 0.85.

  • limit_iteration (Optional[int], optional) – iterate corrections. Defaults to 10.

  • window_percent (float, optional) – apply window at the initial displacement to ensure a zero first amplitude. Defaults to 0.01.

  • coefficient_function (_type_, optional) – function to suppress.. Defaults to lambda x:x.

Returns

correct force signal.

Return type

Signal