Esempio n. 1
0
def calc_cyc_amp_combined_arrays_w_power_law(values0, values1, n_cyc, b):
    """
    Computes the equivalent cyclic amplitude.

    For a set number of cycles using a power law and assuming both components act equally

    Parameters
    ----------
    values0: array_like
        Time series of values
    values1: array_like
        Time series of values in orthogonal direction to values0
    n_cyc: int or float
        Number of cycles
    b: float
        Power law factor

    Returns
    -------
    array_like
    """
    peak_inds_a0 = functions.get_switched_peak_array_indices(values0)
    csr_peaks_a0 = np.abs(np.take(values0, peak_inds_a0))

    peak_inds_a1 = functions.get_switched_peak_array_indices(values1)
    csr_peaks_a1 = np.abs(np.take(values1, peak_inds_a1))

    csr_peaks_s0 = np.zeros_like(values0)
    np.put(csr_peaks_s0, peak_inds_a0, csr_peaks_a0)
    csr_peaks_s1 = np.zeros_like(values1)
    np.put(csr_peaks_s1, peak_inds_a1, csr_peaks_a1)
    csr_n15_series = np.cumsum((np.abs(csr_peaks_s0) ** (1. / b) + np.abs(csr_peaks_s1) ** (1. / b)) / 2 / n_cyc) ** b

    return csr_n15_series
Esempio n. 2
0
def calc_n_cyc_array_w_power_law(values, a_ref, b, cut_off=0.01):
    """
    Calculates the equivalent number of uniform amplitude cycles using a power law

    Parameters
    ----------
    values: array_like
        Time series of values
    a_ref: float
        Reference uniform amplitude
    b: float or array_like
        Power law factor
    cut_off: float
        Low amplitude cutoff value

    Returns
    -------
    array_like
    """

    peak_indices = functions.get_switched_peak_array_indices(values)
    csr_peaks = np.abs(np.take(values, peak_indices))
    csr_peaks = np.where(csr_peaks < cut_off * np.max(abs(values)), 1.0e-14, csr_peaks)
    n_ref = 1
    perc = 0.5 / (n_ref * (a_ref / csr_peaks)[:, np.newaxis] ** (1 / b))
    n_eq = np.cumsum(perc, axis=0)
    n_eq = np.insert(n_eq, 0, 0, axis=0)
    peak_indices = np.insert(peak_indices, 0, 0, axis=0)
    n_eq = np.insert(n_eq, len(n_eq)-1, n_eq[-1], axis=0)
    peak_indices = np.insert(peak_indices, len(n_eq)-1, len(values), axis=0)

    f = scipy.interpolate.interp1d(peak_indices, n_eq, kind='previous', axis=0)
    n_series = f(np.arange(len(values)))
    return n_series
Esempio n. 3
0
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
Esempio n. 4
0
def calc_cyc_amp_array_w_power_law(values, n_cyc, b):
    """
    Calculate the equivalent uniform loading for a given number of cycles and power coefficient (b)

    :param values: array_like
        Time series of values
    :param n_cyc:
    :param b:
    :return:
    """
    a1_peak_inds_end = functions.get_switched_peak_array_indices(values)
    a1_csr_peaks_end = np.abs(np.take(values, a1_peak_inds_end))
    csr_peaks_s1 = np.zeros_like(values)
    np.put(csr_peaks_s1, a1_peak_inds_end, a1_csr_peaks_end)
    csr_n15_series1 = np.cumsum((np.abs(csr_peaks_s1)[:, np.newaxis] ** (1. / b)) / 2 / n_cyc, axis=0) ** b
    return csr_n15_series1