Exemplo n.º 1
0
def plot_trunc_gr_model(aval, bval, min_mag, max_mag, dmag, catalogue=None,
        completeness=None, figure_size=None, filename=None, filetype='png', 
        dpi=300):
    """
    Plots a Gutenberg-Richter model
    """
    input_model = TruncatedGRMFD(min_mag, max_mag, dmag, aval, bval)
    if not catalogue:
        # Plot only the modelled recurrence
        annual_rates, cumulative_rates = _get_recurrence_model(input_model)
        plt.semilogy(annual_rates[:, 0], annual_rates[:, 1], 'b-')
        plt.semilogy(annual_rates[:, 0], cumulative_rates, 'r-')
        plt.xlabel('Magnitude', fontsize='large')
        plt.ylabel('Annual Rate', fontsize='large')
        plt.legend(['Incremental Rate', 'Cumulative Rate'])
        _save_image(filename, filetype, dpi)
    else:
        completeness = _check_completeness_table(completeness, catalogue)
        plot_recurrence_model(input_model,
                              catalogue,
                              completeness,
                              input_model.bin_width,
                              figure_size,
                              filename,
                              filetype,
              		      dpi)
                    
Exemplo n.º 2
0
def plot_trunc_gr_model(aval, bval, min_mag, max_mag, dmag, catalogue=None,
        completeness=None, figure_size=None, filename=None, filetype='png', 
        dpi=300):
    """
    Plots a Gutenberg-Richter model
    """
    input_model = TruncatedGRMFD(min_mag, max_mag, dmag, aval, bval)
    if not catalogue:
        # Plot only the modelled recurrence
        annual_rates, cumulative_rates = _get_recurrence_model(input_model)
        plt.semilogy(annual_rates[:, 0], annual_rates[:, 1], 'b-')
        plt.semilogy(annual_rates[:, 0], cumulative_rates, 'r-')
        plt.xlabel('Magnitude', fontsize='large')
        plt.ylabel('Annual Rate', fontsize='large')
        plt.legend(['Incremental Rate', 'Cumulative Rate'])
        _save_image(filename, filetype, dpi)
    else:
        completeness = _check_completeness_table(completeness, catalogue)
        plot_recurrence_model(input_model,
                              catalogue,
                              completeness,
                              input_model.bin_width,
                              figure_size,
                              filename,
                              filetype,
              		      dpi)
Exemplo n.º 3
0
def plot_recurrence_model(input_model, catalogue, completeness, dmag,
        figure_size=(10, 8), filename=None, filetype='png', dpi=300):
    """
    Plot a calculated recurrence model over an observed catalogue, adjusted for
    time-varying completeness
    """
    if figure_size is None:
        figure_size=(10, 8)
    if dmag is None:
        dmag = 0.1
    annual_rates, cumulative_rates = _get_recurrence_model(input_model)
    # Get observed annual recurrence
    if not catalogue.end_year:
        catalogue.update_end_year()
    cent_mag, t_per, n_obs = get_completeness_counts(catalogue,
                                                     completeness,
                                                     dmag)
    obs_rates = n_obs / t_per
    cum_obs_rates = np.array([np.sum(obs_rates[i:])
                              for i in range(len(obs_rates))])
    # Create plot
    plt.figure(figsize=figure_size)
    plt.semilogy(cent_mag, obs_rates, 'bo')
    plt.semilogy(annual_rates[:, 0], annual_rates[:, 1], 'b-')
    plt.semilogy(cent_mag, cum_obs_rates, 'rs')
    plt.semilogy(annual_rates[:, 0], cumulative_rates, 'r-')
    plt.grid(which='both')
    plt.xlabel('Magnitude', fontsize='16')
    plt.ylabel('Annual Rate', fontsize='16')
    plt.legend(['Observed Incremental Rate',
                'Model Incremental Rate',
                'Observed Cumulative Rate',
                'Model Cumulative Rate'], fontsize=14)
    plt.tick_params(labelsize=12)
    _save_image(filename, filetype, dpi)
Exemplo n.º 4
0
def plot_recurrence_models(configs, area, slip, msr, rake,
        shear_modulus=30.0, disp_length_ratio=1.25E-5, msr_sigma=0.,
        filename=None, filetype='png', dpi=300):
    """
    Plots a set of recurrence models
    :param list configs:
        List of configuration dictionaries
    """
    plt.figure(figsize=DEFAULT_SIZE)
    for config in configs:
        model = RecurrenceBranch(area, slip, msr, rake, shear_modulus,
                                 disp_length_ratio, msr_sigma, weight=1.0)
        model.get_recurrence(config)
        occurrence = model.recurrence.occur_rates
        cumulative = np.array([np.sum(occurrence[iloc:])
                               for iloc in range(0, len(occurrence))])
        if 'AndersonLuco' in config['Model_Name']:
            flt_label = config['Model_Name'] + ' - ' + config['Model_Type'] +\
                    ' Type'
        else:
            flt_label = config['Model_Name']
        flt_color=np.random.uniform(0.1, 1.0, 3)
        plt.semilogy(model.magnitudes, cumulative, '-', label=flt_label,
            color=flt_color, linewidth=2.)
        plt.semilogy(model.magnitudes, model.recurrence.occur_rates, '--',
            color=flt_color, linewidth=2.)
    plt.xlabel('Magnitude', fontsize=14)
    plt.ylabel('Annual Rate', fontsize=14)
    plt.legend(bbox_to_anchor=(1.1, 1.0))
    _save_image(filename, filetype, dpi)
Exemplo n.º 5
0
def plot_recurrence_model(input_model, catalogue, completeness, dmag,
        filename=None, filetype='png', dpi=300):
    """
    Plot a calculated recurrence model over an observed catalogue, adjusted for
    time-varying completeness
    """
    annual_rates, cumulative_rates = _get_recurrence_model(input_model)
    # Get observed annual recurrence
    if not catalogue.end_year:
        catalogue.update_end_year()
    obs_rates = get_completeness_adjusted_table(catalogue,
                                                completeness,
                                                input_model.bin_width,
                                                catalogue.end_year)
    # Create plot
    plt.semilogy(obs_rates[:, 0] + dmag / 2., obs_rates[:, 1], 'bo')
    plt.semilogy(annual_rates[:, 0], annual_rates[:, 1], 'b-')
    plt.semilogy(obs_rates[:, 0] + dmag / 2., obs_rates[:, 2], 'rs')
    plt.semilogy(annual_rates[:, 0], cumulative_rates, 'r-')
    plt.xlabel('Magnitude', fontsize='large')
    plt.ylabel('Annual Rate', fontsize='large')
    plt.legend(['Observed Incremental Rate',
                'Model Incremental Rate',
                'Observed Cumulative Rate',
                'Model Cumulative Rate'])
    _save_image(filename, filetype, dpi)
Exemplo n.º 6
0
def plot_recurrence_models(configs,
                           area,
                           slip,
                           msr,
                           rake,
                           shear_modulus=30.0,
                           disp_length_ratio=1.25E-5,
                           msr_sigma=0.,
                           filename=None,
                           filetype='png',
                           dpi=300):
    """
    Plots a set of recurrence models
    :param list configs:
        List of configuration dictionaries
    """
    plt.figure(figsize=DEFAULT_SIZE)
    for config in configs:
        model = RecurrenceBranch(area,
                                 slip,
                                 msr,
                                 rake,
                                 shear_modulus,
                                 disp_length_ratio,
                                 msr_sigma,
                                 weight=1.0)
        model.get_recurrence(config)
        occurrence = model.recurrence.occur_rates
        cumulative = np.array(
            [np.sum(occurrence[iloc:]) for iloc in range(0, len(occurrence))])
        if 'AndersonLuco' in config['Model_Name']:
            flt_label = config['Model_Name'] + ' - ' + config['Model_Type'] +\
                    ' Type'
        else:
            flt_label = config['Model_Name']
        flt_color = np.random.uniform(0.1, 1.0, 3)
        plt.semilogy(model.magnitudes,
                     cumulative,
                     '-',
                     label=flt_label,
                     color=flt_color,
                     linewidth=2.)
        plt.semilogy(model.magnitudes,
                     model.recurrence.occur_rates,
                     '--',
                     color=flt_color,
                     linewidth=2.)
    plt.xlabel('Magnitude', fontsize=14)
    plt.ylabel('Annual Rate', fontsize=14)
    plt.legend(bbox_to_anchor=(1.1, 1.0))
    _save_image(filename, filetype, dpi)