Esempio n. 1
0
def plot_husid(acceleration, time_step, start_level=0., end_level=1.0,
        figure_size=(7, 5), filename=None, filetype="png", dpi=300):
    """
    Creates a Husid plot for the record
    :param tuple figure_size:
        Size of the output figure (Width, Height)
    :param str filename:
        Name of the file to export
    :param str filetype:
        Type of file for export
    :param int dpi:
        FIgure resolution in dots per inch.
    """
    plt.figure(figsize=figure_size)
    husid, time_vector = get_husid(acceleration, time_step)
    husid_norm = husid / husid[-1]
    idx = np.where(np.logical_and(husid_norm >= start_level,
                                  husid_norm <= end_level))[0]
    plt.plot(time_vector, husid_norm, "b-", linewidth=2.0,
             label="Original Record")
    plt.plot(time_vector[idx], husid_norm[idx], "r-", linewidth=2.0,
             label="%5.3f - %5.3f Arias" % (start_level, end_level))
    plt.xlabel("Time (s)", fontsize=14)
    plt.ylabel("Fraction of Arias Intensity", fontsize=14)
    plt.title("Husid Plot")
    plt.legend(loc=4, fontsize=14)
    _save_image(filename, filetype, dpi)
    plt.show()
Esempio n. 2
0
def plot_time_series(acceleration,
                     time_step,
                     velocity=[],
                     displacement=[],
                     units="cm/s/s",
                     figure_size=(8, 6),
                     filename=None,
                     filetype="png",
                     dpi=300,
                     linewidth=1.5):
    """
    Creates a plot of acceleration, velocity and displacement for a specific
    ground motion record
    """
    acceleration = convert_accel_units(acceleration, units)
    accel_time = get_time_vector(time_step, len(acceleration))
    if not len(velocity):
        velocity, dspl = get_velocity_displacement(time_step, acceleration)
    vel_time = get_time_vector(time_step, len(velocity))
    if not len(displacement):
        displacement = dspl
    disp_time = get_time_vector(time_step, len(displacement))
    fig = plt.figure(figsize=figure_size)
    fig.set_tight_layout(True)
    ax = plt.subplot(3, 1, 1)
    # Accleration
    ax.plot(accel_time, acceleration, 'k-', linewidth=linewidth)
    ax.set_xlabel("Time (s)", fontsize=12)
    ax.set_ylabel("Acceleration (cm/s/s)", fontsize=12)
    end_time = np.max(np.array([accel_time[-1], vel_time[-1], disp_time[-1]]))
    pga = np.max(np.fabs(acceleration))
    ax.set_xlim(0, end_time)
    ax.set_ylim(-1.1 * pga, 1.1 * pga)
    ax.grid()
    # Velocity
    ax = plt.subplot(3, 1, 2)
    ax.plot(vel_time, velocity, 'b-', linewidth=linewidth)
    ax.set_xlabel("Time (s)", fontsize=12)
    ax.set_ylabel("Velocity (cm/s)", fontsize=12)
    pgv = np.max(np.fabs(velocity))
    ax.set_xlim(0, end_time)
    ax.set_ylim(-1.1 * pgv, 1.1 * pgv)
    ax.grid()
    # Displacement
    ax = plt.subplot(3, 1, 3)
    ax.plot(disp_time, displacement, 'r-', linewidth=linewidth)
    ax.set_xlabel("Time (s)", fontsize=12)
    ax.set_ylabel("Displacement (cm)", fontsize=12)
    pgd = np.max(np.fabs(displacement))
    ax.set_xlim(0, end_time)
    ax.set_ylim(-1.1 * pgd, 1.1 * pgd)
    ax.grid()
    _save_image(filename, filetype, dpi)
    plt.show()
Esempio n. 3
0
def plot_fourier_spectrum(time_series, time_step, figure_size=(7, 5),
        filename=None, filetype="png", dpi=300):
    """
    Plots the Fourier spectrum of a time series 
    """
    freq, amplitude = get_fourier_spectrum(time_series, time_step)
    plt.figure(figsize=figure_size)
    plt.loglog(freq, amplitude, 'b-')
    plt.xlabel("Frequency (Hz)", fontsize=14)
    plt.ylabel("Fourier Amplitude", fontsize=14)
    _save_image(filename, filetype, dpi)
    plt.grid()
    plt.show()
Esempio n. 4
0
def plot_time_series(acceleration, time_step, velocity=[], displacement=[],
        units="cm/s/s", figure_size=(8, 6), filename=None, filetype="png",
        dpi=300, linewidth=1.5):
    """
    Creates a plot of acceleration, velocity and displacement for a specific
    ground motion record
    """
    acceleration = convert_accel_units(acceleration, units)
    accel_time = get_time_vector(time_step, len(acceleration))
    if len(velocity) > 0:
        velocity, dspl = get_velocity_displacement(time_step, acceleration)
    vel_time = get_time_vector(time_step, len(velocity))
    if len(displacement) > 0:
        displacement = dspl
    disp_time = get_time_vector(time_step, len(displacement))
    fig = plt.figure(figsize=figure_size)
    fig.set_tight_layout(True)
    ax = plt.subplot(3, 1, 1)
    # Accleration
    ax.plot(accel_time, acceleration, 'k-', linewidth=linewidth)
    ax.set_xlabel("Time (s)", fontsize=12)
    ax.set_ylabel("Acceleration (cm/s/s)", fontsize=12)
    end_time = np.max(np.array([accel_time[-1], vel_time[-1], disp_time[-1]]))
    pga = np.max(np.fabs(acceleration))
    ax.set_xlim(0, end_time)
    ax.set_ylim(-1.1 * pga, 1.1 * pga)
    ax.grid()
    # Velocity
    ax = plt.subplot(3, 1, 2)
    ax.plot(vel_time, velocity, 'b-', linewidth=linewidth)
    ax.set_xlabel("Time (s)", fontsize=12)
    ax.set_ylabel("Velocity (cm/s)", fontsize=12)
    pgv = np.max(np.fabs(velocity))
    ax.set_xlim(0, end_time)
    ax.set_ylim(-1.1 * pgv, 1.1 * pgv)
    ax.grid()
    # Displacement
    ax = plt.subplot(3, 1, 3)
    ax.plot(disp_time, displacement, 'r-', linewidth=linewidth)
    ax.set_xlabel("Time (s)", fontsize=12)
    ax.set_ylabel("Displacement (cm)", fontsize=12)
    pgd = np.max(np.fabs(displacement))
    ax.set_xlim(0, end_time)
    ax.set_ylim(-1.1 * pgd, 1.1 * pgd)
    ax.grid()
    _save_image(filename, filetype, dpi)
    #plt.show()
    plt.clf()
Esempio n. 5
0
def plot_response_spectra(spectra,
                          axis_type="loglog",
                          figure_size=(8, 6),
                          filename=None,
                          filetype="png",
                          dpi=300):
    """
    Creates a plot of the suite of response spectra (Acceleration,
    Velocity, Displacement, Pseudo-Acceleration, Pseudo-Velocity) derived
    from a particular ground motion record
    """
    fig = plt.figure(figsize=figure_size)
    fig.set_tight_layout(True)
    ax = plt.subplot(2, 2, 1)
    # Acceleration
    PLOT_TYPE[axis_type](ax, spectra["Period"], spectra["Acceleration"])
    PLOT_TYPE[axis_type](ax, spectra["Period"], spectra["Pseudo-Acceleration"])
    ax.set_xlabel("Periods (s)", fontsize=12)
    ax.set_ylabel("Acceleration (cm/s/s)", fontsize=12)
    ax.set_xlim(np.min(spectra["Period"]), np.max(spectra["Period"]))
    ax.grid()
    ax.legend(("Acceleration", "PSA"), loc=0)
    ax = plt.subplot(2, 2, 2)
    # Velocity
    PLOT_TYPE[axis_type](ax, spectra["Period"], spectra["Velocity"])
    PLOT_TYPE[axis_type](ax, spectra["Period"], spectra["Pseudo-Velocity"])
    ax.set_xlabel("Periods (s)", fontsize=12)
    ax.set_ylabel("Velocity (cm/s)", fontsize=12)
    ax.set_xlim(np.min(spectra["Period"]), np.max(spectra["Period"]))
    ax.grid()
    ax.legend(("Velocity", "PSV"), loc=0)
    ax = plt.subplot(2, 2, 3)
    # Displacement
    PLOT_TYPE[axis_type](ax, spectra["Period"], spectra["Displacement"])
    ax.set_xlabel("Periods (s)", fontsize=12)
    ax.set_ylabel("Displacement (cm)", fontsize=12)
    ax.set_xlim(np.min(spectra["Period"]), np.max(spectra["Period"]))
    ax.grid()
    _save_image(filename, filetype, dpi)
    plt.show()
Esempio n. 6
0
def plot_response_spectra(spectra, axis_type="loglog", figure_size=(8, 6),
        filename=None, filetype="png", dpi=300):
    """
    Creates a plot of the suite of response spectra (Acceleration,
    Velocity, Displacement, Pseudo-Acceleration, Pseudo-Velocity) derived
    from a particular ground motion record
    """
    fig = plt.figure(figsize=figure_size)
    fig.set_tight_layout(True)
    ax = plt.subplot(2, 2, 1)
    # Acceleration
    PLOT_TYPE[axis_type](ax, spectra["Period"], spectra["Acceleration"])
    PLOT_TYPE[axis_type](ax, spectra["Period"], spectra["Pseudo-Acceleration"])
    ax.set_xlabel("Periods (s)", fontsize=12)
    ax.set_ylabel("Acceleration (cm/s/s)", fontsize=12)
    ax.set_xlim(np.min(spectra["Period"]), np.max(spectra["Period"]))
    ax.grid()
    ax.legend(("Acceleration", "PSA"), loc=0) 
    ax = plt.subplot(2, 2, 2)
    # Velocity
    PLOT_TYPE[axis_type](ax, spectra["Period"], spectra["Velocity"])
    PLOT_TYPE[axis_type](ax, spectra["Period"], spectra["Pseudo-Velocity"])
    ax.set_xlabel("Periods (s)", fontsize=12)
    ax.set_ylabel("Velocity (cm/s)", fontsize=12)
    ax.set_xlim(np.min(spectra["Period"]), np.max(spectra["Period"]))
    ax.grid()
    ax.legend(("Velocity", "PSV"), loc=0) 
    ax = plt.subplot(2, 2, 3)
    # Displacement
    PLOT_TYPE[axis_type](ax, spectra["Period"], spectra["Displacement"])
    ax.set_xlabel("Periods (s)", fontsize=12)
    ax.set_ylabel("Displacement (cm)", fontsize=12)
    ax.set_xlim(np.min(spectra["Period"]), np.max(spectra["Period"]))
    ax.grid()
    _save_image(filename, filetype, dpi)
    #plt.show()
    plt.clf()