示例#1
0
def test_determine_peaks_only_delta_series_with_triangle_series():
    values = [0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0]
    peaks_only = eqsig.determine_peaks_only_delta_series(values)
    cum_peaks = np.sum(np.abs(peaks_only))
    cum_abs_delta_values = np.sum(np.abs(np.diff(values)))
    cum_diff = np.sum(peaks_only)
    assert np.isclose(cum_diff, 0), (cum_diff, 0)
    assert np.isclose(cum_abs_delta_values, 10), (cum_abs_delta_values, 10)
示例#2
0
def test_determine_peaks_only_series_with_non_zero_end():
    end_value = 1.
    values = np.array([0, 2, -1, 2, 0, end_value])
    cum_abs_delta_values = np.sum(np.abs(np.diff(values)))
    expected_sum = cum_abs_delta_values
    delta_peaks_only = eqsig.determine_peaks_only_delta_series(values)
    cum_peaks = np.sum(np.abs(delta_peaks_only))
    assert np.isclose(cum_peaks, expected_sum), (cum_peaks, expected_sum)
示例#3
0
def test_determine_peaks_only_delta_series_with_a_double_peak_and_offset():
    values = np.array([0, 2, 1, 2, 0, 1, 0, -1, 0, 1, 0]) + 4
    cum_abs_delta_values = np.sum(np.abs(np.diff(values)))
    expected_sum = cum_abs_delta_values
    delta_peaks_only = eqsig.determine_peaks_only_delta_series(values)
    cum_peaks = np.sum(np.abs(delta_peaks_only))
    expected_series = np.array([0, 2, -1, 1, -2, 1, 0, -2, 0, 2, -1])
    assert np.sum(np.abs(delta_peaks_only - expected_series)) == 0.0
    assert np.isclose(cum_peaks, expected_sum)
示例#4
0
def test_determine_peaks_only_delta_series_with_ground_motion():
    record_path = TEST_DATA_DIR
    record_filename = 'test_motion_dt0p01.txt'
    rec = np.loadtxt(record_path + record_filename, skiprows=2)
    cum_abs_delta_values = np.sum(np.abs(np.diff(rec)))
    expected_sum = cum_abs_delta_values
    delta_peaks_only = eqsig.determine_peaks_only_delta_series(rec)
    cum_peaks = np.sum(np.abs(delta_peaks_only))
    assert np.isclose(cum_peaks, expected_sum), (cum_peaks, expected_sum)
示例#5
0
def test_determine_peaks_only_delta_series_with_sine_wave():
    time = np.arange(99)
    values = np.sin(time)
    values[-1] = 0
    cum_abs_delta_values = np.sum(np.abs(np.diff(values)))
    expected_sum = cum_abs_delta_values
    peaks_only = eqsig.determine_peaks_only_delta_series(values)
    cum_peaks = np.sum(np.abs(peaks_only))
    assert np.isclose(cum_peaks, expected_sum), (cum_peaks, expected_sum)