sdynpy.core.sdynpy_data.TimeHistoryArray

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

Bases: NDDataArray

Data array used to store time history data

__init__()

Methods

burst_random_signal(dt, signal_length, ...)

Generates a burst random signal with the specified parameters

chirp_signal(dt, signal_length, coordinates)

Creates a chirp (sine sweep) signal with the specified parameters

cpsd(samples_per_frame, overlap, window[, ...])

Computes a CPSD matrix from the time histories

fft([samples_per_frame, norm, rtol, atol])

Computes the frequency spectra of the time signal

find_signal_shift(other_signal[, ...])

Computes the shift between two sets of time signals

from_exodus(exo[, x_disp, y_disp, z_disp, ...])

Reads time data from displacements in an Exodus file

haversine_signal(dt, signal_length, coordinates)

Creates a haversine pulse with the specified parameters

mimo_forward(transfer_function)

Performs the forward mimo calculation via convolution.

mimo_inverse(transfer_function[, ...])

Performs the inverse source estimation for time domain (transient) problems using Fourier deconvolution.

overlap_and_add(functions_to_overlap, ...)

Creates a time history by overlapping and adding other time histories.

pseudorandom_signal(dt, signal_length, ...)

Generates a pseudorandom signal at the specified coordinates

pulse_signal(dt, signal_length, coordinates)

Creates a pulse using a cosine function raised to a specified exponent

random_signal(dt, signal_length, coordinates)

Generates a random signal with the specified parameters

remove_rigid_body_motion(geometry)

Removes rigid body displacements from time data.

rms()

shift_signal(time_shift)

Shift a signal in time by a specified amount.

sine_signal(dt, signal_length, coordinates, ...)

Creates a sinusoidal signal with the specified parameters

split_into_frames([samples_per_frame, ...])

Splits a time history into measurement frames with a given overlap and window function applied.

srs([min_frequency, max_frequency, ...])

Compute a shock response spectrum (SRS) from the time history

stft([samples_per_frame, frame_length, ...])

Computes a Short-Time Fourier Transform (STFT)

to_rattlesnake_specification(filename[, ...])

Attributes

function_type

Returns the function type of the data array

classmethod burst_random_signal(dt, signal_length, coordinates, min_frequency=None, max_frequency=None, signal_rms=1, frames=1, frequency_shape=None, on_fraction=0.5, delay_fraction=0.0, ramp_fraction=0.05, comment1='', comment2='', comment3='', comment4='', comment5='')[source]

Generates a burst random signal with the specified parameters

Parameters
  • dt (float) – Abscissa spacing in the final signal.

  • signal_length (int) – Number of samples in the signal

  • coordinates (CoordinateArray) – Coordinate array used to generate the signal. If the last dimension of coordinates is not shape 1, then a new axis will be added to make it shape 1. The shape of the resulting TimeHistoryArray will be determined by the shape of the input coordinates.

  • min_frequency (float, optional) – Minimum frequency content in the signal. The default is the lowest nonzero frequency line.

  • max_frequency (float, optional) – Maximum frequency content in the signal. The default is the highest frequency content in the signal, e.g. the Nyquist frequency.

  • signal_rms (float or np.ndarray, optional) – RMS value for the generated signals. The default is 1. The shape of this value should be broadcastable with the size of the generated TimeHistoryArray if different RMS values are desired for each signal. Note that the RMS will be computed for the “burst” part of the signal and not include the zero portion of the signal.

  • frames (int, optional) – Number of frames to generate. These will essentially be repeats of the first frame for the number of frames specified. The default is 1.

  • frequency_shape (function, optional) – An optional function that should accept a frequency value and return an amplitude at that frequency. The default is constant scaling across all frequency lines.

  • on_fraction (float, optional) – The fraction of the frame that the signal is active, default is 0.5. This portion includes the ramp_fraction, so an on_fraction of 0.5 with a ramp_fraction of 0.05 will be at full level for 0.5-2*0.05 = 0.4 fraction of the full measurement frame.

  • delay_fraction (float, optional) – The fraction of the frame that is empty before the signal starts, default is 0.0

  • ramp_fraction (float, optional) – The fraction of the frame that is used to ramp between the off and active signal

  • comment1 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment2 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment3 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment4 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment5 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

Returns

A time history containing the specified burst random signal

Return type

TimeHistoryArray

classmethod chirp_signal(dt, signal_length, coordinates, start_frequency=None, end_frequency=None, frames=1, amplitude_function=None, force_integer_cycles=True, comment1='', comment2='', comment3='', comment4='', comment5='')[source]

Creates a chirp (sine sweep) signal with the specified parameters

Parameters
  • dt (float) – Abscissa spacing in the final signal.

  • signal_length (int) – Number of samples in the signal

  • coordinates (CoordinateArray) – Coordinate array used to generate the signal. If the last dimension of coordinates is not shape 1, then a new axis will be added to make it shape 1. The shape of the resulting TimeHistoryArray will be determined by the shape of the input coordinates.

  • start_frequency (TYPE, optional) – Starting frequency content in the signal. The default is the lowest nonzero frequency line.

  • end_frequency (TYPE, optional) – Stopping frequency content in the signal. The default is the highest non-nyquist frequency line.

  • frames (int, optional) – Number of frames to generate. These will essentially be repeats of the first frame for the number of frames specified. The default is 1.

  • amplitude_function (function, optional) – An optional function that should accept a frequency value and return an amplitude at that frequency. The default is constant scaling across all frequencies. Multiple amplitudes can be returned as long as they broadcast with the shape of the final TimeHistoryArray.

  • force_integer_cycles (bool, optional) – If True, it will force an integer number of cycles, which will adjust the maximum frequency of the signal. This will ensure the signal is continuous if repeated. If False, the

  • comment1 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment2 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment3 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment4 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment5 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

Returns

A time history containing the specified chirp signal

Return type

TimeHistoryArray

cpsd(samples_per_frame: int, overlap: float, window: str, averages_to_keep: Optional[int] = None, only_asds=False, rtol=1, atol=1e-08)[source]

Computes a CPSD matrix from the time histories

Parameters
  • samples_per_frame (int) – Number of samples per frame

  • overlap (float) – Overlap fraction (not percent, e.g. 0.5 not 50)

  • window (str) – Name of a window function in scipy.signal.windows

  • averages_to_keep (int, optional) – Optional number of averages to use, otherwise as many as possible will be used.

  • only_asds (bool, optional) – If True, only compute autospectral densities (diagonal of the CPSD matrix)

  • rtol (float, optional) – Tolerance used to check abscissa spacing. The default is 1.

  • atol (float, optional) – Tolerance used to check abscissa spacing. The default is 1e-8.

Raises

ValueError – If time history abscissa are not equally spaced.

Returns

cpsd_array – Cross Power Spectral Density Array.

Return type

PowerSpectralDensityArray

fft(samples_per_frame=None, norm='backward', rtol=1, atol=1e-08, **scipy_rfft_kwargs)[source]

Computes the frequency spectra of the time signal

Parameters
  • samples_per_frame (int, optional) – Number of samples per measurement frame. If this is specified, then the signal will be split up into frames and averaged together. Be aware that if the time signal is not periodic, averaging it may have the effect of zeroing out the spectrum (because the average time signal is zero). The default is no averaging, the frame size is the length of the signal.

  • norm (str, optional) – The type of normalization applied to the fft computation. The default is “backward”.

  • rtol (float, optional) – Relative tolerance used in the abcsissa spacing check. The default is 1e-5.

  • atol (float, optional) – Relative tolerance used in the abscissa spacing check. The default is 1e-8.

  • scipy_rfft_kwargs – Additional keywords that will be passed to SciPy’s rfft function.

Raises

ValueError – Raised if the time signal passed to this function does not have equally spaced abscissa.

Returns

The frequency spectra of the TimeHistoryArray.

Return type

SpectrumArray

find_signal_shift(other_signal, compute_subsample_shift=True, good_line_threshold=0.01)[source]

Computes the shift between two sets of time signals

This is the amount that other_signal leads self. If the time shift is positive, it means that features in other_signal occur earlier in time compared to self. If the time shift is negative, it means that features in other_signal occur later in time compared to self.

To align two signals, you can take the time shift from this function and pass it into the shift_signal method of other_signal.

Parameters
  • other_signal (TimeHistoryArray) – The signal against which this signal should be compared in time. It should have the same coordinate ordering and the same number of abscissa as this signal.

  • compute_subsample_shift (bool, optional) – If False, this function will simply align to the nearest sample. If True, this function will attempt to use FFT phases to compute a subsample shift between the signals. Default is True.

  • good_line_threshold (float, optional) – Threshold to use to compute “good” frequency lines. This function uses phase to compute subsample shifts. If there are frequency lines without content, they should be ignored. Frequency lines less than good_line_threshold times the maximum of the spectra are ignored. The default is 0.01.

Returns

time_shift – The time difference between the two signals.

Return type

float

classmethod from_exodus(exo, x_disp='DispX', y_disp='DispY', z_disp='DispZ', x_rot=None, y_rot=None, z_rot=None, timesteps=None)[source]

Reads time data from displacements in an Exodus file

Parameters
  • exo (Exodus or ExodusInMemory) – The exodus data from which geometry will be created.

  • x_disp (str, optional) – String denoting the nodal variable in the exodus file from which the X-direction displacement should be read. The default is ‘DispX’.

  • y_disp (str, optional) – String denoting the nodal variable in the exodus file from which the Y-direction displacement should be read. The default is ‘DispY’.

  • z_disp (str, optional) – String denoting the nodal variable in the exodus file from which the Z-direction displacement should be read. The default is ‘DispZ’.

  • timesteps (iterable, optional) – A list of timesteps from which data should be read. The default is None, which reads all timesteps.

Returns

DESCRIPTION.

Return type

TYPE

property function_type

Returns the function type of the data array

classmethod haversine_signal(dt, signal_length, coordinates, pulse_width=None, pulse_time=None, pulse_peak=1, frames=1, comment1='', comment2='', comment3='', comment4='', comment5='')[source]

Creates a haversine pulse with the specified parameters

Parameters
  • dt (float) – Abscissa spacing in the final signal.

  • signal_length (int) – Number of samples in the signal

  • coordinates (CoordinateArray, optional) – Coordinate array used to generate the signal. If the last dimension of coordinates is not shape 1, then a new axis will be added to make it shape 1. The shape of the resulting TimeHistoryArray will be determined by the shape of the input coordinates.

  • pulse_width (float, optional) – With of the pulse in the same units as dt. The default is 5*dt.

  • pulse_time (float, optional) – The time of the pulse’s peak occurance in the same units as dt. The default is 5*dt.

  • pulse_peak (float, optional) – The peak amplitude of the pulse. The default is 1.

  • frames (int, optional) – Number of frames to generate. These will essentially be repeats of the first frame for the number of frames specified. The default is 1.

  • comment1 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment2 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment3 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment4 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment5 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

Returns

A time history containing the specified haversine pulse signal

Return type

TimeHistoryArray

mimo_forward(transfer_function)[source]

Performs the forward mimo calculation via convolution.

Parameters

transfer_function (TransferFunctionArray or ImpulseResponseFunctionArray) – This is the FRFs that will be used in the forward problem. A matrix of IRFs is prefered, but FRFs can also be used, although the FRFs will be immediately converted to IRFs.

Raises
  • ValueError – If the sampling rates for the data and IRFs/FRFs don’t match.

  • ValueError – If the references in the IRFs/FRFs don’t match the supplied input data.

Returns

Response time histories

Return type

TimeHistoryArray

mimo_inverse(transfer_function, time_method='single_frame', cola_frame_length=None, cola_window='hann', cola_overlap=None, zero_pad_length=None, inverse_method='standard', response_weighting_matrix=None, reference_weighting_matrix=None, regularization_weighting_matrix=None, regularization_parameter=None, cond_num_threshold=None, num_retained_values=None)[source]

Performs the inverse source estimation for time domain (transient) problems using Fourier deconvolution. The response nodes used in the inverse source estimation are the ones contained in the supplied FRF matrix.

Parameters
  • transer_function (TransferFunctionArray or ImpulseResponseFunctionArray) – This is the FRFs that will be used in the inverse source estimation

  • time_method (str, optional) –

    The method to used to handle the time data for the inverse source estimation. The available options are:

    • single_frame - this method performs the Fourier deconvolution

    via an FFT on a single frame that encompases the entire time signal. - COLA - this method performs the Fourier deconvolution via a series of FFTs on relatively small frames of the time signal using a “constant overlap and add” method. This method may be faster than the single_frame method.

  • cola_frame_length (float, optional) – The frame length (in samples) if the COLA method is being used. The default frame length is Fs/df from the transfer function.

  • cola_window (str, optional) – The desired window for the COLA procedure, must exist in the scipy window library. The default is a hann window.

  • cola_overlap (int, optional) – The number of overlapping samples between measurement frames in the COLA procedure. If not specified, a default value of half the cola_frame_length is used.

  • zero_pad_length (int, optional) – The number of zeros used to pre and post pad the response data, to avoid convolution wrap-around error. The default is to use the “determine_zero_pad_length” function to determine the zero_pad_length.

  • inverse_method (str, optional) –

    The method to be used for the FRF matrix inversions. The available methods are:

    • standard - basic pseudo-inverse via numpy.linalg.pinv with the default rcond parameter, this is the default method

    • threshold - pseudo-inverse via numpy.linalg.pinv with a specified condition number threshold

    • tikhonov - pseudo-inverse using the Tikhonov regularization method

    • truncation - pseudo-inverse where a fixed number of singular values are retained for the inverse

  • response_weighting_matrix (sdpy.Matrix or np.ndarray, optional) – Not currently implemented

  • reference_weighting_matrix (sdpy.Matrix or np.ndarray, optional) – Not currently implemented

  • regularization_weighting_matrix (sdpy.Matrix, optional) – Matrix used to weight input degrees of freedom via Tikhonov regularization.

  • regularization_parameter (float or np.ndarray, optional) – Scaling parameter used on the regularization weighting matrix when the tikhonov method is chosen. A vector of regularization parameters can be provided so the regularization is different at each frequency line. The vector must match the length of the FRF abscissa in this case (either be size [num_lines,] or [num_lines, 1]).

  • cond_num_threshold (float or np.ndarray, optional) – Condition number used for SVD truncation when the threshold method is chosen. A vector of condition numbers can be provided so it varies as a function of frequency. The vector must match the length of the FRF abscissa in this case (either be size [num_lines,] or [num_lines, 1]).

  • num_retained_values (float or np.ndarray, optional) – Number of singular values to retain in the pseudo-inverse when the truncation method is chosen. A vector of can be provided so the number of retained values can change as a function of frequency. The vector must match the length of the FRF abscissa in this case (either be size [num_lines,] or [num_lines, 1]).

Raises
  • NotImplementedError – If a response weighting matrix is supplied

  • NotImplementedError – If a reference weighting matrix is supplied

  • ValueError – If the sampling rates for the data and FRFs don’t match.

  • ValueError – If the number of responses in the FRFs don’t match the supplied response data.

Returns

Time history array of the estimated sources

Return type

TimeHistoryArray

Notes

This function computes the time domain inputs required to match the target time traces using Fourier deconvolution, which is essentially a frequency domain problem. The general method is to compute the frequency spectrum of the target time traces, then solve the inverse problem in the time domain using the supplied FRFs (H^+ * X). The inverse of the FRF matrix is found using the same methods as the mimo_inverse function for the PowerSpectralDensityArray class. The input spectrum is then converted back to the time domain via a inverse fourier transform.

References

1

Wikipedia, “Moore-Penrose inverse”. https://en.wikipedia.org/wiki/Moore%E2%80%93Penrose_inverse

2

A.N. Tithe, D.J. Thompson, The quantification of structure-borne transmission pathsby inverse methods. Part 2: Use of regularization techniques, Journal of Sound and Vibration, Volume 264, Issue 2, 2003, Pages 433-451, ISSN 0022-460X, https://doi.org/10.1016/S0022-460X(02)01203-8.

3

Wikipedia, “Ridge regression”. https://en.wikipedia.org/wiki/Ridge_regression

4

Wikipedia, “Overlap-add Method”. https://en.wikipedia.org/wiki/Overlap-add_method

static overlap_and_add(functions_to_overlap, overlap_samples)[source]

Creates a time history by overlapping and adding other time histories.

Parameters
  • functions_to_overlap (TimeHistoryArray or list of TimeHistoryArray) – A set of TimeHistoryArrays to overlap and add together. If a single TimeHistoryArray is specified, then the first dimension will be used to split the signal into segments. All TimeHistoryArrays must have the same shape and metadata, but need not have the same number of elements.

  • overlap_samples (int) – Number of samples to overlap the segments as they are added together

Returns

A TimeHistoryArray consisting of the signals overlapped and added together.

Return type

TimeHistoryArray

Notes

All metadata is taken from the first signal. No checks are performed to make sure that the subsequent functions have common coordinates or abscissa spacing.

classmethod pseudorandom_signal(dt, signal_length, coordinates, min_frequency=None, max_frequency=None, signal_rms=1, frames=1, frequency_shape=None, different_realizations=False, comment1='', comment2='', comment3='', comment4='', comment5='')[source]

Generates a pseudorandom signal at the specified coordinates

Parameters
  • dt (float) – Abscissa spacing in the final signal.

  • signal_length (int) – Number of samples in the signal

  • coordinates (CoordinateArray) – Coordinate array used to generate the signal. If the last dimension of coordinates is not shape 1, then a new axis will be added to make it shape 1. The shape of the resulting TimeHistoryArray will be determined by the shape of the input coordinates.

  • min_frequency (float, optional) – Minimum frequency content in the signal. The default is the lowest nonzero frequency line.

  • max_frequency (float, optional) – Maximum frequency content in the signal. The default is the highest frequency content in the signal, e.g. the Nyquist frequency.

  • signal_rms (float or np.ndarray, optional) – RMS value for the generated signals. The default is 1. The shape of this value should be broadcastable with the size of the generated TimeHistoryArray if different RMS values are desired for each signal.

  • frames (int, optional) – Number of frames to generate. These will essentially be repeats of the first frame for the number of frames specified. The default is 1.

  • frequency_shape (function, optional) – An optional function that should accept a frequency value and return an amplitude at that frequency. The default is constant scaling across all frequency lines.

  • different_realizations (bool) – An optional argument that specifies whether or not different functions should have different realizations of the pseudorandom signal, or if they should all be identical.

  • comment1 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment2 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment3 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment4 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment5 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

Returns

A time history containing the specified pseudorandom signal

Return type

TimeHistoryArray

classmethod pulse_signal(dt, signal_length, coordinates, pulse_width=None, pulse_time=None, pulse_peak=1, sine_exponent=1, frames=1, comment1='', comment2='', comment3='', comment4='', comment5='')[source]

Creates a pulse using a cosine function raised to a specified exponent

Parameters
  • dt (float) – Abscissa spacing in the final signal.

  • signal_length (int) – Number of samples in the signal

  • coordinates (CoordinateArray) – Coordinate array used to generate the signal. If the last dimension of coordinates is not shape 1, then a new axis will be added to make it shape 1. The shape of the resulting TimeHistoryArray will be determined by the shape of the input coordinates.

  • pulse_width (float, optional) – With of the pulse in the same units as dt. The default is 5*dt.

  • pulse_time (float, optional) – The time of the pulse’s occurance in the same units as dt. The default is 5*dt.

  • pulse_peak (float, optional) – The peak amplitude of the pulse. The default is 1.

  • sine_exponent (float, optional) – The exponent that the cosine function is raised to. The default is 1.

  • frames (int, optional) – Number of frames to generate. These will essentially be repeats of the first frame for the number of frames specified. The default is 1.

  • comment1 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment2 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment3 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment4 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment5 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

Returns

A time history containing the specified pulse signal

Return type

TimeHistoryArray

classmethod random_signal(dt, signal_length, coordinates, min_frequency=None, max_frequency=None, signal_rms=1, frames=1, frequency_shape=None, comment1='', comment2='', comment3='', comment4='', comment5='')[source]

Generates a random signal with the specified parameters

Parameters
  • dt (float) – Abscissa spacing in the final signal.

  • signal_length (int) – Number of samples in the signal

  • coordinates (CoordinateArray) – Coordinate array used to generate the signal. If the last dimension of coordinates is not shape 1, then a new axis will be added to make it shape 1. The shape of the resulting TimeHistoryArray will be determined by the shape of the input coordinates.

  • min_frequency (float, optional) – Minimum frequency content in the signal. The default is the lowest nonzero frequency line.

  • max_frequency (float, optional) – Maximum frequency content in the signal. The default is the highest frequency content in the signal, e.g. the Nyquist frequency.

  • signal_rms (float or np.ndarray, optional) – RMS value for the generated signals. The default is 1. The shape of this value should be broadcastable with the size of the generated TimeHistoryArray if different RMS values are desired for each signal.

  • frames (int, optional) – Number of frames to generate. These will essentially be repeats of the first frame for the number of frames specified. The default is 1.

  • frequency_shape (function, optional) – An optional function that should accept a frequency value and return an amplitude at that frequency. The default is constant scaling across all frequency lines.

  • comment1 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment2 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment3 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment4 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment5 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

Returns

A time history containing the specified random signal

Return type

TimeHistoryArray

remove_rigid_body_motion(geometry)[source]

Removes rigid body displacements from time data.

This function assumes the current TimeHistoryArray is a displacement signal and adds it to the geometry to create node positions over time, then it fits a rigid coordinate transformation to each time step and subtracts off that portion of the motion from the displacement signal.

Parameters

geometry (Geometry) – Geometry with which the node positions are computed

Returns

A TimeHistoryArray with the rigid body component of motion removed

Return type

TimeHistoryArray

rms()[source]
shift_signal(time_shift)[source]

Shift a signal in time by a specified amount.

Utilizes the FFT shift theorem to move a signal in time.

Parameters

time_shift (float) – The time shift to apply to the signal. A negative value will cause features to occur earlier in time. A positive value will cause features to occur later in time.

Returns

shifted_signal – A shifted version of the original signal.

Return type

TimeHistoryArray

classmethod sine_signal(dt, signal_length, coordinates, frequency, amplitude=1, phase=0, comment1='', comment2='', comment3='', comment4='', comment5='')[source]

Creates a sinusoidal signal with the specified parameters

Parameters
  • dt (float) – Abscissa spacing in the final signal.

  • signal_length (int) – Number of samples in the signal

  • coordinates (CoordinateArray) – Coordinate array used to generate the signal. If the last dimension of coordinates is not shape 1, then a new axis will be added to make it shape 1. The shape of the resulting TimeHistoryArray will be determined by the shape of the input coordinates.

  • frequency (float or np.ndarray) – Frequency of signal that will be generated. If multiple frequencies are specified, they must broadcast with the final size of the TimeHistoryArray.

  • amplitude (TYPE, optional) – Amplitude of signal that will be generated. If multiple amplitudes are specified, they must broadcast with the final size of the TimeHistoryArray. The default is 1.

  • phase (TYPE, optional) – Phase of signal that will be generated. If multiple phases are specified, they must broadcast with the final size of the TimeHistoryArray.. The default is 0.

  • comment1 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment2 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment3 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment4 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

  • comment5 (np.ndarray, optional) – Comment used to describe the data in the data array. The default is ‘’.

Returns

A time history containing the specified sine signal

Return type

TimeHistoryArray

split_into_frames(samples_per_frame=None, frame_length=None, overlap=None, overlap_samples=None, window=None, check_cola=False, allow_fractional_frames=False)[source]

Splits a time history into measurement frames with a given overlap and window function applied.

Parameters
  • samples_per_frame (int, optional) – Number of samples in each measurement frame. Either this argument or frame_length must be specified. If both or neither are specified, a ValueError is raised.

  • frame_length (float, optional) – Length of each measurement frame in the same units as the abscissa field (samples_per_frame = frame_length/self.abscissa_spacing). Either this argument or samples_per_frame must be specified. If both or neither are specified, a ValueError is raised.

  • overlap (float, optional) – Fraction of the measurement frame to overlap (i.e. 0.25 not 25 to overlap a quarter of the frame). Either this argument or overlap_samples must be specified. If both are specified, a ValueError is raised. If neither are specified, no overlap is used.

  • overlap_samples (int, optional) – Number of samples in the measurement frame to overlap. Either this argument or overlap_samples must be specified. If both are specified, a ValueError is raised. If neither are specified, no overlap is used.

  • window (str or tuple or array_like, optional) – Desired window to use. If window is a string or tuple, it is passed to scipy.signal.get_window to generate the window values, which are DFT-even by default. See get_window for a list of windows and required parameters. If window is array_like it will be used directly as the window and its length must be samples_per_frame. If not specified, no window will be applied.

  • check_cola (bool, optional) – If True, raise a ValueError if the specified overlap and window function are not compatible with COLA. The default is False.

  • allow_fractional_frames (bool, optional) – If False (default), the signal will be split into a number of full frames, and any remaining fractional frame will be discarded. This will not allow COLA to be satisfied. If True, fractional frames will be retained and zero padded to create a full frames.

Returns

Returns a new TimeHistoryArray with shape [num_frames,…] where … is the shape of the original array.

Return type

TimeHistoryArray

srs(min_frequency=None, max_frequency=None, frequencies=None, damping=0.03, num_points=None, points_per_octave=12, srs_type='MMAA')[source]

Compute a shock response spectrum (SRS) from the time history

Parameters
  • min_frequency (float, optional) – Minimum frequency to compute the SRS. Either frequencies or min_frequency and max_frequency must be specified.

  • max_frequency (float, optional) – Maximum frequency to compute the SRS. Either frequencies or min_frequency and max_frequency must be specified.

  • frequencies (np.ndarray, optional) – Frequency lines at which to compute the SRS. Either frequencies or min_frequency and max_frequency must be specified.

  • 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.

  • num_points (int, optional) – Number of frequency lines to compute from min_frequency to max_frequency, log spaced between these two values. If min_frequency and max_frequency are specified, then either num_points or points_per_octave must be specified. If frequencies is specified, this argument is ignored.

  • points_per_octave (float, optional) – Number of frequency lines per octave to compute from min_frequency to max_frequency. If min_frequency and max_frequency are specified, then either num_points or points_per_octave must be specified. If frequencies is specified, this argument is ignored. The default is 12.

  • srs_type (str, optional) – A string encoding for the type of SRS to be computed. See notes for more information.

Returns

SRSs representing the current time histories. If srs_type is ‘all’, then an extra dimension of 9 will be added to the front of the array, and the indices in that dimension will be different SRS types.

Return type

ShockResponseSpectrumArray

Notes

The srs_type argument takes a 4 character string that specifies how the SRS is computed.

stft(samples_per_frame=None, frame_length=None, overlap=None, overlap_samples=None, window=None, check_cola=False, allow_fractional_frames=False, norm='backward')[source]

Computes a Short-Time Fourier Transform (STFT)

The time history is split up into frames with specified length and computes the spectra for each frame.

Parameters
  • samples_per_frame (int, optional) – Number of samples in each measurement frame. Either this argument or frame_length must be specified. If both or neither are specified, a ValueError is raised.

  • frame_length (float, optional) – Length of each measurement frame in the same units as the abscissa field (samples_per_frame = frame_length/self.abscissa_spacing). Either this argument or samples_per_frame must be specified. If both or neither are specified, a ValueError is raised.

  • overlap (float, optional) – Fraction of the measurement frame to overlap (i.e. 0.25 not 25 to overlap a quarter of the frame). Either this argument or overlap_samples must be specified. If both are specified, a ValueError is raised. If neither are specified, no overlap is used.

  • overlap_samples (int, optional) – Number of samples in the measurement frame to overlap. Either this argument or overlap_samples must be specified. If both are specified, a ValueError is raised. If neither are specified, no overlap is used.

  • window (str or tuple or array_like, optional) – Desired window to use. If window is a string or tuple, it is passed to scipy.signal.get_window to generate the window values, which are DFT-even by default. See get_window for a list of windows and required parameters. If window is array_like it will be used directly as the window and its length must be samples_per_frame. If not specified, no window will be applied.

  • check_cola (bool, optional) – If True, raise a ValueError if the specified overlap and window function are not compatible with COLA. The default is False.

  • allow_fractional_frames (bool, optional) – If False (default), the signal will be split into a number of full frames, and any remaining fractional frame will be discarded. This will not allow COLA to be satisfied. If True, fractional frames will be retained and zero padded to create a full frames.

Returns

  • frame_abscissa (np.ndarray) – The abscissa values at the center of each of the STFT frames

  • stft (SpectrumArray) – A spectrum array with the first axis corresponding to the time values in frame_abscissa.

to_rattlesnake_specification(filename, coordinate_order=None, min_time=None, max_time=None)[source]