示例#1
0
def plot_dg_hist_inset(evnum,sim_file,DG_MIN=-30.0,DG_MAX=30.0,NUM_BINS=100):
    from pyvc import vcplots
    from matplotlib import pyplot as plt
    #******************************************
    #evnum = 109382
    #sim_file = 'ALLCAL2_1-7-11_no-creep_dyn-05_st-20.h5'
    #*******************************************
    out_file      = 'local/dg_field_{}_hist_inset.png'.format(evnum)
    
    # For this vvv to work you must go to vcplots and make this method return the figure
    this_fig      = vcplots.plot_event_field(sim_file,evnum,output_file=out_file,
                        save_file_prefix='animation_test_g/field_values/'+str(evnum)+'_',
                        field_type='gravity')
    
    UNIT                = pow(10,-8) #microgals
    
    # Width and height are fixed
    ph = 768.0
    pw = 1024.0
    width_frac = 200.0/pw
    height_frac = 150.0/ph
    left_frac = 130.0/pw
    bottom_frac = 100.0/ph    
    
    event_field,mag     = get_dg_field(evnum,sim_file)
    dg                  = event_field.dG.flatten()/UNIT
    dg_binned,counts    = hist_1d(dg,bmin=DG_MIN,bmax=DG_MAX,num_bins=NUM_BINS,norm=True)
    
    LABEL   = r'$M={}$'.format(str(round(mag,1)))
    
    hist_inset = this_fig.add_axes((left_frac,bottom_frac,width_frac,height_frac))
    
    hist_inset.plot(dg_binned,counts,color='k')
    hist_inset.tick_params(axis='y',bottom='off',top='off',left='off',right='off',
                labelbottom='off',labeltop='off',labelleft='off',labelright='off')
    hist_inset.tick_params(axis='x', labelsize='small')
    #hist_inset.tick_params(axis='x',top='off',bottom='off')
    
    #  Make first and last ticks be <MIN and >MAX
    #tick_labels = [item.get_text() for item in hist_inset.get_xticklabels()]
    #tick_labels[0] = '<'+tick_labels[0]
    #tick_labels[-1] = '>'+tick_labels[-1]
    #hist_inset.set_xticklabels(tick_labels)
        
    #hist_inset.legend(loc=2,frameon=False,numpoints=1,handlelength=0,handletextpad=0)
    hist_inset.patch.set_alpha(0.0)
    
    this_fig.savefig(out_file,dpi=200)
    plt.clf()
示例#2
0
#start_year  = 0.0
#end_year    = 100.0
#event_range={'type':'year','filter':(start_year,end_year)}

#vcplots.event_field_animation(sim_file, output_directory, event_range,
#    field_type=FIELD, fringes=True, padding=0.08, cutoff=None,
#    animation_target_length=LENGTH, animation_fps = FPS, fade_seconds = FADE,
#    min_mag_marker = MIN_MAG_MARK, force_plot=PLOT)
#------------------------------------------------------------------------------




#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
"""
#sim_file = '../VCModels/ALLCAL2_1-7-11_no-creep/ALLCAL2_1-7-11_no-creep_dyn-0-5_st-5.h5'
sim_file     = '/home/kasey/Okubo-test/ALLCAL2_1-7-11_no-creep_dyn-05_st-20.h5'
evnum      = 109382  # Mag = 8.0
#evnum      = 1455      # Mag = 7.83
#evnum      = 48467  # Mag = 7.99
#evnum      = 49261  # Mag = 7.63
#evnum       = 54526  # Mag = 7.73
#evnum      = 54358 # Mag = 7.79
out_file     =  '/home/kasey/Okubo-test/dg_plots/dg_'+str(evnum)+'_match.png'
FRINGES = True
FIELD       = 'gravity'
LAT_RANGE = (30.65,42.85)
LON_RANGE = (-125.52,-113.24)

#if FIELD == 'gravity':