Source: GitHub
Signature¶
def sdynpy.signal_processing.sdynpy_srs.generate_single_windowed_random_realization(ref_srs: numpy.ndarray, window: numpy.ndarray, sample_rate: float, gravity: float = 386.0, damping: float = 0.03, srs_type: int = 9, match_points_per_octave: float = 4.0, output_points_per_octave: float = 12.0, amp_init: Optional[numpy.ndarray] = None, phase_init: Optional[numpy.ndarray] = None, iterations: int = 10, correction: float = 0.8, error_tolerance: float = 0.05, randomize_phase: bool = False, max_frequency: Optional[float] = None, rng: Optional[numpy.random._generator.Generator] = None) -> Dict[str, Any]Generate a single windowed random realization matched to a target SRS.
Parameters¶
ref_srs : ndarray Target SRS breakpoint array with shape
(n_breakpoints, 2). The first column is frequency and the second is SRS amplitude.window : ndarray Time-domain window with shape
(n_samples,).sample_rate : float Sampling rate in samples per second.
gravity : float, default=386.0 Acceleration-of-gravity conversion factor used when integrating to velocity and displacement.
damping : float, default=0.03 Fraction of critical damping used for SRS calculations.
srs_type : int, default=9 SRS type passed to :func:
sdynpy_srs.srs.match_points_per_octave : float, default=4.0 Frequency resolution used during the iterative SRS matching process.
output_points_per_octave : float, default=12.0 Frequency resolution used for the returned SRS curve.
amp_init : ndarray, optional Initial spectrum amplitude guess as a two-column array
[frequency, amplitude].phase_init : ndarray, optional Initial one-sided phase vector in radians.
iterations : int, default=10 Maximum number of matching iterations.
correction : float, default=0.8 Fraction of the SRS error corrected at each iteration.
error_tolerance : float, default=0.05 Relative SRS error tolerance for convergence.
randomize_phase : bool, default=False If True, ignore
phase_initand generate a random phase realization.max_frequency : float, optional Maximum frequency for nonzero Fourier amplitude. If not specified, the default is
min(sample_rate/4, ref_srs[-1, 0]).rng : numpy.random.Generator, optional Random number generator used when random phase is required.
Returns¶
dict
Dictionary containing:
-
"time": ndarrayTime vector.
-
"xc": ndarrayCompensated windowed acceleration history.
-
"rr": ndarrayStationary random acceleration history before windowing.
-
"srs_freq": ndarrayFrequency vector for the returned SRS.
-
"srs_values": ndarraySRS values for the returned realization.
-
"srsc": ndarrayMatching-frequency SRS array with columns
[frequency, amplitude].-
"metrics": WindowedRandomMetricsScalar metrics for the realization.
-
"amp": ndarrayFinal matched spectral amplitudes at the matching frequencies.
-
"phase": ndarrayFinal phase vector used for waveform synthesis.
Raises¶
ValueError
If the FFT line spacing is too coarse to resolve the lowest matched SRS
frequency, or if the internally defined frequency grid is invalid.
Notes¶
This function is the numerical core corresponding to one pass through the
MATLAB wrcomp_tdh / gwinrand workflow.