sdynpy.core.sdynpy_data.ShockResponseSpectrumArray

class ShockResponseSpectrumArray(shape, nelements, buffer=None, offset=0, strides=None, order=None)[source]

Bases: NDDataArray

__init__()

Methods

plot([one_axis, subplots_kwargs, plot_kwargs])

Plot the shock response spectrum

sum_decayed_sines(sample_rate, block_size[, ...])

Generate a Sum of Decayed Sines signal given an SRS.

Attributes

function_type

Returns the function type of the data array

property function_type

Returns the function type of the data array

plot(one_axis: bool = True, subplots_kwargs: dict = {}, plot_kwargs: dict = {})[source]

Plot the shock response spectrum

Parameters
  • one_axis (bool, optional) – Set to True to plot all data on one axis. Set to False to plot data on multiple subplots. one_axis can also be set to a matplotlib axis to plot data on an existing axis. The default is True.

  • subplots_kwargs (dict, optional) – Keywords passed to the matplotlib subplots function to create the figure and axes. The default is {}.

  • plot_kwargs (dict, optional) – Keywords passed to the matplotlib plot function. The default is {}.

Returns

axis – On which the data were plotted

Return type

matplotlib axis or array of axes

sum_decayed_sines(sample_rate, block_size, sine_frequencies=None, sine_tone_range=None, sine_tone_per_octave=None, sine_amplitudes=None, sine_decays=None, sine_delays=None, srs_damping=0.03, srs_type='MMAA', compensation_frequency=None, compensation_decay=0.95, number_of_iterations=3, convergence=0.8, error_tolerance=0.05, tau=None, num_time_constants=None, decay_resolution=None, scale_factor=1.02, acceleration_factor=1.0, plot_results=False, srs_frequencies=None, return_velocity=False, return_displacement=False, return_srs=False, return_sine_table=False, verbose=False)[source]

Generate a Sum of Decayed Sines signal given an SRS.

Note that there are many approaches to do this, with many optional arguments so please read the documentation carefully to understand which arguments must be passed to the function.

Parameters
  • sample_rate (float) – The sample rate of the generated signal.

  • block_size (int) – The number of samples in the generated signal.

  • sine_frequencies (np.ndarray, optional) – The frequencies of the sine tones. If this argument is not specified and the sine_tone_range argument is not specified, then the sine_tone_range will be set to the maximum and minimum abscissa value for this ShockResponseSpectrumArray.

  • sine_tone_range (np.ndarray, optional) – A length-2 array containing the minimum and maximum sine tone to generate. If this argument is not specified and the sine_frequencies argument is not specified, then the sine_tone_range will be set to the maximum and minimum abscissa value for this ShockResponseSpectrumArray.

  • sine_tone_per_octave (int, optional) – The number of sine tones per octave. If not specified along with sine_tone_range, then a default value of 4 will be used if the srs_damping is >= 0.05. Otherwise, the formula of sine_tone_per_octave = 9 - srs_damping*100 will be used.

  • sine_amplitudes (np.ndarray, optional) – The initial amplitude of the sine tones used in the optimization. If not specified, they will be set to the value of the SRS at each frequency divided by the quality factor of the SRS.

  • sine_decays (np.ndarray, optional) – An array of decay value time constants (often represented by variable tau). Tau is the time for the amplitude of motion to decay 63% defined by the equation 1/(2*np.pi*freq*zeta) where freq is the frequency of the sine tone and zeta is the fraction of critical damping. If not specified, then either the tau or num_time_constants arguments must be specified instead.

  • sine_delays (np.ndarray, optional) – An array of delay values for the sine components. If not specified, all tones will have zero delay.

  • srs_damping (float, optional) – Fraction of critical damping to use in the SRS calculation (e.g. you should specify 0.03 to represent 3%, not 3). If not defined, a default of 0.03 will be used.

  • srs_type (int or str) –

    The type of spectrum desired: This can be an integer or a string. If srs_type is an integer: if srs_type > 0 (pos) then the SRS will be a base acceleration-absolute acceleration model If srs_type < 0 (neg) then the SRS will be a base acceleration-relative displacement model (expressed in equivalent static acceleration units). If abs(srs_type) is:

    1–positive primary, 2–negative primary, 3–absolute maximum primary 4–positive residual, 5–negative residual, 6–absolute maximum residual 7–largest of 1&4, maximum positive, 8–largest of 2&5, maximum negative 9 – maximax, the largest absolute value of 1-8

    10 – returns a matrix s(9,length(fn)) with all the types 1-9.

  • compensation_frequency (float) – The frequency of the compensation pulse. If not specified, it will be set to 1/3 of the lowest sine tone

  • compensation_decay (float) – The decay value for the compensation pulse. If not specified, it will be set to 0.95.

  • number_of_iterations (int, optional) – The number of iterations to perform. At least two iterations should be performed. 3 iterations is preferred, and will be used if this argument is not specified.

  • convergence (float, optional) – The fraction of the error corrected each iteration. The default is 0.8.

  • error_tolerance (float, optional) – Allowable relative error in the SRS. The default is 0.05.

  • tau (float, optional) – If a floating point number is passed, then this will be used for the sine_decay values. Alternatively, a dictionary can be passed with the keys containing a length-2 tuple specifying the minimum and maximum frequency range, and the value specifying the value of tau within that frequency range. If this latter approach is used, all sine_frequencies must be contained within a frequency range. If this argument is not specified, then either sine_decays or num_time_constants must be specified instead.

  • num_time_constants (int, optional) – If an integer is passed, then this will be used to set the sine_decay values by ensuring the specified number of time constants occur in the block_size. Alternatively, a dictionary can be passed with the keys containing a length-2 tuple specifying the minimum and maximum frequency range, and the value specifying the value of num_time_constants over that frequency range. If this latter approach is used, all sine_frequencies must be contained within a frequency range. If this argument is not specified, then either sine_decays or tau must be specified instead.

  • decay_resolution (float, optional) – A scalar identifying the resolution of the fractional decay rate (often known by the variable zeta). The decay parameters will be rounded to this value. The default is to not round.

  • scale_factor (float, optional) – A scaling applied to the sine tone amplitudes so the achieved SRS better fits the specified SRS, rather than just touching it. The default is 1.02.

  • acceleration_factor (float, optional) – Optional scale factor to convert acceleration into velocity and displacement. For example, if sine amplitudes are in G and displacement is desired in inches, the acceleration factor should be set to 386.089. If sine amplitudes are in G and displacement is desired in meters, the acceleration factor should be set to 9.80665. The default is 1, which assumes consistent units (e.g. acceleration in m/s^2, velocity in m/s, displacement in m).

  • plot_results (bool, optional) – If True, a figure will be plotted showing the acceleration, velocity, and displacement signals, as well as the desired and achieved SRS.

  • srs_frequencies (np.ndarray, optional) – If specified, these frequencies will be used to compute the SRS that will be plotted when the plot_results value is True.

  • return_velocity (bool, optional) – If specified, a velocity signal will also be returned. Default is False

  • return_displacement (bool, optional) – If True, a displacement signal will also be returned. Default is False

  • return_srs (bool, optional) – If True, the SRS of the generated signal will also be returned

  • return_sine_table (bool, optional) – If True, a sine table will also be returned

  • verbose (True, optional) – If True, additional diagnostics will be printed to the console.

Returns

  • acceleration (TimeHistoryArray) – A TimeHistoryArray object containing an acceleration response that satisfies the SRS

  • velocity (TimeHistoryArray) – A TimeHistoryArray object containing the velocity corresponding to acceleration. Only returned if return_velocity is True.

  • displacement (TimeHistoryArray) – A TimeHistoryArray object containing the displacement corresponding to acceleration. Only returned if return_displacement is True.

  • srs (TimeHistoryArray) – A ShockResponseSpectrumArray containing the SRS of acceleration. This can be used to check against the original signal to identify how good the match is. Only returned if return_srs is True.

  • sine_table (DecayedSineTable) – A DecayedSineTable object containing the frequency, amplitude, delay, and decay parameters that are used to generate acceleration.