def test_cavdp(): asig = conftest.t_asig() cav_dp = im.calc_cav_dp(asig)[-1] # 0.810412819 from eqsig 0.5.26 tested with several motions assert np.isclose(cav_dp, 0.81041282, rtol=0.001), cav_dp
def test_calc_cum_abs_surface_energy_start_from_top(): accsig = conftest.t_asig() travel_times = np.array([0.01, 0.2, 0.5]) stt = 0.0 cases_w_s = eqsig.surface.calc_cum_abs_surface_energy(accsig, travel_times, nodal=True, up_red=1, down_red=1, stt=stt, trim=True, start=True) cases = eqsig.surface.calc_cum_abs_surface_energy(accsig, travel_times, nodal=True, up_red=1, down_red=1, stt=stt, trim=True, start=False) case_interp_0 = np.interp(accsig.time + (stt - travel_times[0]), accsig.time, cases_w_s[0]) diff0 = np.sum(abs(case_interp_0 - cases[0])) / cases[0][-1] assert np.isclose(diff0, 0., atol=5.0e-3), diff0 case_interp_1 = np.interp(accsig.time + (stt - travel_times[1]), accsig.time, cases_w_s[1]) diff1 = np.sum(abs(case_interp_1 - cases[1])) / cases[1][-1] assert np.isclose(diff1, 0., atol=5.0e-3), diff1 case_interp_2 = np.interp(accsig.time + (stt - travel_times[2]), accsig.time, cases_w_s[2]) diff2 = np.sum(abs(case_interp_2 - cases[2])) / cases[2][-1] assert np.isclose(diff2, 0., atol=8.0e-2), diff2
def test_calc_cyclic_amp_gm_arrays_w_power_law(): asig = conftest.t_asig() csr_array0 = asig.values csr_array1 = asig.values b = 0.34 csr_n15_series = im.calc_cyc_amp_gm_arrays_w_power_law(csr_array0, csr_array1, n_cyc=15, b=b) assert np.isclose(csr_n15_series[-1], 0.96290891), (csr_n15_series[-1], 0.96290891) # v=1.1.2
def test_n_cyc_and_cyc_amplitude(): asig = conftest.t_asig() csr_array0 = asig.values n_cyc = im.calc_n_cyc_array_w_power_law(csr_array0, a_ref=asig.pga * 0.65, b=0.3, cut_off=0.01) csr = im.calc_cyc_amp_array_w_power_law(csr_array0, n_cyc=n_cyc[-1], b=0.3) assert np.isclose(csr[-1], asig.pga * 0.65), (csr[-1], asig.pga * 0.65) assert np.isclose(n_cyc[-1], 17.23, rtol=1.0e-3), n_cyc[-1] # v=1.1.2 assert np.isclose(csr[-1], 0.9165), csr[-1] # v=1.1.2
def test_calc_cyclic_amp_combined_arrays_w_power_law(): asig = conftest.t_asig() csr_array0 = asig.values csr_array1 = asig.values b = 0.34 csr_n15_series = im.calc_cyc_amp_combined_arrays_w_power_law(csr_array0, csr_array1, n_cyc=15, b=b) a1_peak_inds_end = functions.get_switched_peak_array_indices(csr_array0) a1_csr_peaks_end = np.abs(np.take(csr_array0, a1_peak_inds_end)) a2_peak_inds_end = functions.get_switched_peak_array_indices(csr_array1) a2_csr_peaks_end = np.abs(np.take(csr_array1, a2_peak_inds_end)) all_csr_peaks_end = np.array( list(a1_csr_peaks_end) + list(a2_csr_peaks_end)) csr_n15_end = np.sum((np.abs(all_csr_peaks_end)**(1. / b)) / 2 / 15)**b assert np.isclose(csr_n15_series[-1], csr_n15_end), (csr_n15_series[-1], csr_n15_end) assert np.isclose(csr_n15_series[-1], 1.2188083, rtol=1.0e-4) # v=1.1.2
def test_calc_cum_abs_surface_energy(): accsig = conftest.t_asig() tshifts = np.array([0.01, 0.2, 0.5]) cases = eqsig.surface.calc_cum_abs_surface_energy(accsig, tshifts, nodal=True, up_red=1, down_red=1, stt=0.0, trim=True, start=False) expected_cases = _time_shifted_response_series(accsig, 2 * tshifts, up_red=1, down_red=1, add=False, trim=True) assert len(cases[0]) == accsig.npts assert np.isclose(cases[0][-1], expected_cases[0][-1]) assert np.isclose(cases[1][-1], expected_cases[1][-1]) assert np.isclose(cases[2][-1], expected_cases[2][-1])
def test_calc_cum_abs_surface_energy_start_check_same_energy(): accsig = conftest.t_asig() tshifts = np.array([0.01, 0.2, 0.5]) cases = eqsig.surface.calc_cum_abs_surface_energy(accsig, tshifts, nodal=True, up_red=1, down_red=1, stt=0.0, trim=False, start=False) cases_w_s = eqsig.surface.calc_cum_abs_surface_energy(accsig, tshifts, nodal=True, up_red=1, down_red=1, stt=0.0, trim=False, start=True) diff = np.sum(abs(cases[:, -1] - cases_w_s[:, -1])) assert diff < 2.0e-5, diff
def test_pseudo_response_spectra(): asig = conftest.t_asig() periods = [0, 2, 4] xi = 0.05 sd, sv, sa = sdof.pseudo_response_spectra(asig.values, asig.dt, periods, xi) assert sa[0] == asig.pga
def test_calc_unit_kinetic_energy(): asig = conftest.t_asig() uke = im.calc_unit_kinetic_energy(asig)[-1] assert np.isclose(uke, 0.4504992), uke # version 1.1.1