Source: GitHub
Signature¶
def sdynpy.signal_processing.sdynpy_srs.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, required_srs=None, srs_breakpoints=None, srs_damping=0.05, srs_type=9, 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, ignore_compensation_pulse=False, verbose=False)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, then the
sine_tone_rangeargument must be specified.sine_tone_range : np.ndarray, optional A length-2 array containing the minimum and maximum sine tone to generate. If this is argument is not specified, then the
sine_frequenciesargument must be specified instead.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 thesrs_dampingis >= 0.05. Otherwise, the formula ofsine_tone_per_octave = 9 - srs_damping*100will 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)wherefreqis the frequency of the sine tone andzetais the fraction of critical damping. If not specified, then either thetauornum_time_constantsarguments 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.
required_srs : np.ndarray, optional The SRS to match defined at each of the
sine_frequencies. If this argument is not passed, then thesrs_breakpointsargument must be passed instead. The default is None.srs_breakpoints : np.ndarray, optional A numpy array with shape
(n,2)where the first column is the frequencies at which each breakpoint occurs, and the second column is the value of the SRS at that breakpoint. SRS values at thesine_frequencieswill be interpolated in a log-log sense from this breakpoint array. If this argument is not specified, then therequired_srsmust be passed instead.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). The default is 0.03.
srs_type : int The type of spectrum desired: If
srs_type> 0 (pos) then the SRS will be a base acceleration-absolute acceleration model Ifsrs_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_decayvalues. 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 oftauwithin that frequency range. If this latter approach is used, allsine_frequenciesmust be contained within a frequency range. If this argument is not specified, then eithersine_decaysornum_time_constantsmust be specified instead.num_time_constants : int, optional If an integer is passed, then this will be used to set the
sine_decayvalues by ensuring the specified number of time constants occur in theblock_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 ofnum_time_constantsover that frequency range. If this latter approach is used, allsine_frequenciesmust be contained within a frequency range. If this argument is not specified, then eithersine_decaysortaumust 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_resultsvalue isTrue.ignore_compensation_pulse : bool, optional If True, the compensation pulse will be ignored.
verbose : True, optional If True, additional diagnostics will be printed to the console.
Returns¶
acceleration_signal : ndarray The acceleration signal that satisfies the SRS.
velocity_signal : ndarray The velocity of the acceleration signal.
displacement_signal : ndarray The displacement of the acceleration signal.
sine_frequencies : ndarray An array of frequencies for each sine tone, including the compensation pulse
sine_amplitudes : ndarray An array of amplitudes for each sine tone, including the compensation pulse
sine_decays : ndarray An array of decay values for each sine tone, including the compensation pulse
sine_delays : ndarray An array of delay values for each sine tone, including the compensation pulse
fig : matplotlib.Figure A reference to the plotted figure. Only returned if
plot_resultsisTrue.ax : matplotlib.Axes A reference to the plotted axes. Only returned if
plot_resultsisTrue.