dep = []
    ax = plt.subplot(2, 2, i + 1)

    for sd in stdict:
        res.append(interp(log(T), log(gmmT), sd['lnRes']))
        dep.append(sd['dep'])

    plt.semilogx(dep, res, 'o', c='dodgerblue', mec='blue', ms=6)
    plt.semilogx([5, 1000], [0, 0], 'k--', lw=1.)

    deps, dep_terms = return_dep_terms(T)
    plt.semilogx(deps, dep_terms, '-', c='darkorange', lw=2.5)

    if i >= 2:
        plt.xlabel('Depth (km)', fontsize=16)
    if i == 0 or i == 2:
        plt.ylabel('ln Residual', fontsize=16)

    plt.xlim([5, 750])
    plt.ylim([-4, 4])
    pertxt = ' '.join(('T =', str(T), 's'))
    xpos = get_log_xy_locs([5, 750], 0.04)
    ypos = (8 * 0.92) - 4
    plt.text(xpos, ypos, pertxt, ha='left', va='top', fontsize=16, bbox=props)

plt.savefig('figures/simple_nac_depth_dependence.png',
            fmt='png',
            bbox_inches='tight')
plt.savefig('figures/fig_7.eps', fmt='eps', bbox_inches='tight')
plt.show()
Пример #2
0
###############################################################################
# make plot 1
###############################################################################
ax = plt.subplot(2, 1, 1)

for pd, c in zip(pltDict, cs):
    plt.loglog(pd['poe_probs_annual'],
               pd['imls'],
               c=c,
               lw=2.0,
               label=pd['place'])

plt.semilogy([yhaz2, yhaz2], [1E-4, 10], 'k--')
plt.semilogy([yhaz10, yhaz10], [1E-4, 10], 'k--')
yoff = get_log_xy_locs([1e-5, .1], .015)
plt.text(yhaz10 + yoff,
         1.1E-4,
         '1/475 AEP',
         rotation=90.,
         va='bottom',
         ha='right',
         fontsize=14)
yoff = get_log_xy_locs([1e-5, .1], .005)
plt.text(yhaz2 + yoff / 5.,
         1.1E-4,
         '1/2475 AEP',
         rotation=90.,
         va='bottom',
         ha='right',
         fontsize=14)
Пример #3
0
               lw=2.0,
               color='gold',
               label='Somerville et al. (2009; Yilgarn Craton)')
    plt.loglog(rjb, exp(A12r), '-', lw=2.0, color=cs[5], label='Allen (2012)')
    plt.loglog(rjb,
               exp(Bea14r),
               '-',
               lw=2.0,
               color=cs[6],
               label='Boore et al. (2014)')

    plt.xlabel(r'$\mathregular{R_{JB}}$ (km)', fontsize=18)
    plt.ylabel('PGA (g)', fontsize=18)
    plt.xlim([1, 500])
    if t < 0.5:
        plt.ylim([1E-3, 2])
    elif t > 1.0:
        plt.ylim([1E-5, 0.01])
    else:
        plt.ylim([1E-4, 0.1])

    #plt.title(titles[j])
    xtxt = get_log_xy_locs(ax.get_xlim(), 0.95)
    ytxt = get_log_xy_locs(ax.get_ylim(), 0.95)
    #plt.text(xtxt, ytxt, titles[j], size=18, horizontalalignment='right', verticalalignment='top', weight='normal')
    plt.grid(which='both', color='0.5')

    plt.legend(loc=3, numpoints=1, fontsize=13.25)

plt.savefig('nsha18_atten.png', format='png', dpi=800, bbox_inches='tight')
plt.show()
                    # plt haz curves
                    if pltTrue == True:
                        hx = plt.semilogy(imls,
                                          sdx['poe_probs_annual'],
                                          '--',
                                          color=cs[p * 2 + 1],
                                          lw=2.0,
                                          label=label_place + ' (NF)')

###############################################################################
# make plot pretty
###############################################################################
plt.semilogy([0, 2.5], [yhaz2, yhaz2], 'k--')
plt.semilogy([0, 2.5], [yhaz10, yhaz10], 'k--')
yoff = get_log_xy_locs([1e-4, .1], .015)
plt.text(0.245,
         yhaz10 + yoff,
         '1/475 AEP',
         va='bottom',
         ha='right',
         fontsize=16)
yoff = get_log_xy_locs([1e-4, .1], .005)
plt.text(0.245,
         yhaz2 + yoff / 5.,
         '1/2475 AEP',
         va='bottom',
         ha='right',
         fontsize=16)
plt.legend()
def makesubplt(i, fig, plt, sta, sps, mag, dep, ztor, dip, rake, rhyp, vs30,
               datestr):
    import matplotlib
    matplotlib.rc('xtick', labelsize=12)
    matplotlib.rc('ytick', labelsize=12)
    props = dict(boxstyle='square', facecolor='w', alpha=1)

    #dates = ['1995-12-25', '1995-12-25', '2019-06-24', '2019-06-24']

    rrup = rhyp
    rjb = sqrt(rrup**2 - dep**2)  # assume point source; i.e. repi = rjb

    A19imt_BS = calc_nac_gmm_spectra(mag, rhyp, dep, vs30, 'BS')  # use rrup

    nga_e_imt = nga_east_mean(mag, dep, dip, rake, rrup, vs30)

    Yea97imt, AB03imt, AB03CISimt, Gea05imt, Zea06imt, Zea06imt, MP10imt, Aea16imt, Zea16imt, Kea20imt \
            = inslab_gsims(mag, dep, ztor, dip, rake, rrup, rjb, vs30)

    # adjust NGA-E from 3000 -> target
    nga_e_imt = adjust_gmm_with_nga_east(nga_e_imt, vs30)

    ax = plt.subplot(2, 2, i)
    if colTrue == 'True':
        plt.loglog(nga_e_imt['per'],
                   exp(nga_e_imt['sa']),
                   '--',
                   lw=1.5,
                   color=cs[0])
        plt.loglog(Kea20imt['per'],
                   exp(Kea20imt['sa']),
                   '-.',
                   lw=2.,
                   color=cs[1])
        plt.loglog(A19imt_BS['per'],
                   exp(A19imt_BS['sa']),
                   '-',
                   lw=1.5,
                   color=cs[2])

    # get recorded process_waves.py psa data
    T, geomean, pga, rhyp = get_site_geomean(sta, folder)
    plt.loglog(T, geomean, lw=1.5, color='k')

    if i >= 3:
        plt.xlabel('Period (s)', fontsize=14)
    if i == 1 or i == 3 or i == 7:
        plt.ylabel('Spectral Acceleration (g)', fontsize=14)

    plt.xlim([0.02, 10])
    plt.ylim([1e-4, .1])
    plt.grid(which='both', color='0.75')

    if i == 1:
        #plt.legend(['Yea97', 'AB06','A12imt','Aea16', 'A19 (BS)', 'A19 (NGH)', 'A19 (OB)','Data'],loc=3, fontsize=7.)
        plt.legend([
            'Goulet et al (2017)', 'Kuehn et al (2020)', 'Present Study',
            'Geometric Mean'
        ],
                   loc=4,
                   fontsize=10)

    txtbox = datestr+'\nStation: AU.'+sta+'\n'+'$\mathregular{M_W}$: '+str(mag) \
             +'\n$\mathregular{R_{hyp}}$: '+str(int(round(rhyp)))+' km'\
             +'\n$\mathregular{h_z}$: '+str(int(round(dep)))+' km'\
             +'\n'+'$\mathregular{V_{S30}}$: '+ str(int(round(vs30))) +' m/s'
    print(txtbox)

    xtxt = get_log_xy_locs(ax.get_xlim(), 0.03)
    ytxt = get_log_xy_locs(ax.get_ylim(), 0.03)

    lspace = (2, 2, 1, 1)
    plt.text(xtxt,
             ytxt,
             txtbox,
             size=11,
             ha='left',
             va='bottom',
             weight='normal')  #, linespacing=lspace) #, bbox=props)

    # add letter
    ylims = ax.get_ylim()
    plt.text(0.017,
             ylims[1] * 1.25,
             letters[i - 1],
             va='bottom',
             ha='right',
             fontsize=17)
Пример #6
0
        idx = where(Tplt == T)[0]
        if len(idx) > 0:
            ax = plt.subplot(2, 2, i + 1)

            plt.plot(mag, res, 'o', c='dodgerblue', mec='blue', ms=6)
            plt.plot([5, 1000], [0, 0], 'k--', lw=1.)

            if i >= 2:
                plt.xlabel('Moment Magnitude', fontsize=16)
            if i == 0 or i == 2:
                plt.ylabel('Between-Event Terms\n(ln Residual)', fontsize=16)

            plt.xlim([5, 7.7])
            plt.ylim([-3, 3])
            pertxt = ' '.join(('T =', str(T), 's'))
            xpos = get_log_xy_locs([5, 7.7], 0.96)
            ypos = (6 * 0.92) - 3
            plt.text(xpos,
                     ypos,
                     pertxt,
                     ha='right',
                     va='top',
                     fontsize=16,
                     bbox=props)

            i += 1

            # get data for plotting later
            if T == 0.5:
                tau05 = res
                taumag = mag
Пример #7
0
#plt.xlim([datetime(2012,6,15), datetime(2012,12,31)])

# take b-val at ML 0.9 and get a-value
mc = 1.0
m_upper = mc + 1.  # only include well behaved data
a_val = fit_a_value(cum_mag, bvals[10], mrng, mc, m_upper)
N = 10**(a_val - bvals[10] * mrng)
ax1.semilogy(mrng[10:], N[10:], 'r-', lw=2.)
ax1.set_xlim([-0.2, 4.5])
ax1.set_ylim([0.5, 1000])

# label b-value
abtxt = 'a-value = ' + str('%0.2f' % a_val) + '\nb-value = ' + str(
    '%0.2f' % bvals[10])
xtxt = 1.  #ax1.get_xlim()[1] * 0.96
ytxt = get_log_xy_locs(ax1.get_ylim(), 0.96)
props = dict(boxstyle='round', facecolor='w', alpha=1)
tb = ax1.text(xtxt,
              ytxt,
              abtxt,
              size=18,
              ha='left',
              va='top',
              weight='normal',
              bbox=props)

xdiff = diff(ax1.get_xlim())[0]
xtxt = ax1.get_xlim()[0] + xdiff * 0.02
ytxt = get_log_xy_locs(ax1.get_ylim(), 0.98)
ax1.text(xtxt,
         ytxt,
plt.xlim([0.1, 40])

# do odr for completeness
start = [0.5, -2.]
om, oc = odr_lin_reg(log10(vsrl[idx]), log10(rat_vdsrl[idx]), start)
plt_vsrl = arange(0.2, 37.1, 0.1)
plt_rat = 10**(om * log10(plt_vsrl) + oc)
plt.semilogy(plt_vsrl,
             plt_rat,
             '-',
             c='k',
             lw=1.5,
             label='Present Study (ODR)')
plt.ylim([0.1, 1])

xpos = get_log_xy_locs([0.1, 40], 0.02)
ypos = get_log_xy_locs([0.1, 1], 0.98)

# set y ticks
ticks = array([0.1, 0.2, 0.5, 1.0])
ticklabels = [str(x) for x in ticks]
ax.set_yticks(ticks)
ax.set_yticklabels(ticklabels)

txt = plt.text(xpos, ypos, '(c)', va='top', ha='left', fontsize=18)
txt.set_path_effects([PathEffects.withStroke(linewidth=5, foreground='w')])

print('\nRatio coeffs')
print('odr2', om, oc)

##############################################################################
Пример #9
0
        ticks = [0.005, 0.01, 0.02, 0.05, 0.1, 0.2]

        # reset ticks
        if i == 7 and i == 0:
            if altPlaces == True:
                plt.xlim([0.01, 0.3])
                ticks = [0.01, 0.02, 0.05, 0.1, 0.2]
            else:
                plt.xlim([0.003, 0.2])
        else:
            plt.xlim([0.003, 0.2])

        # set letters
        if altPlaces == False:
            xplt = get_log_xy_locs(ax.get_xlim(), 0.02)
            txt = plt.text(xplt,
                           0.98,
                           letters[i],
                           fontsize=18,
                           va='top',
                           ha='left')
        else:
            xplt = get_log_xy_locs(ax.get_xlim(), 0.98)
            txt = plt.text(xplt,
                           0.98,
                           letters[i],
                           fontsize=18,
                           va='top',
                           ha='right')
        txt.set_path_effects(