예제 #1
0
# plot mag uncert with mag
###############################################################################

fig = plt.figure(2, figsize=(10, 5))
sym = ['^', 'D', 'o']
cols = get_mpl2_colourlist()
for i, reg in enumerate(reg_dict):
    plt.plot(reg['mag'],
             reg['mag_uncert'],
             sym[i],
             mec=cols[i],
             mfc='none',
             mew=1.5,
             label=reg['reg'])

# get binned stats
bins = arange(2.5, 6.1, 0.1)
med_uncert, std_uncert, medx, bins, nperbin = get_binned_stats(
    bins, allmags, alluncert)
plt.errorbar(bins,
             med_uncert,
             yerr=std_uncert,
             fmt='rs',
             label='Binned Median')
plt.legend(loc=1, numpoints=1)
plt.ylim([0, 1])
plt.xlim([2.4, 5])

plt.savefig('ml_uncertainty_vs_ml.png', fmt='png', bbox_inches='tight')
plt.savefig('ml_uncertainty_vs_ml.eps', fmt='eps', bbox_inches='tight')
plt.show()
예제 #2
0
                mrhyps.append(rec['rhyp'])
                mamps.append(rec[channel]['swave_spec'][fidx])

    mrhyps = array(mrhyps)
    mamps = array(mamps)

    if len(mrhyps) > 0:
        '''
        plt.loglog(mrhyps, mamps, '+', c='0.6', lw=0.5, ms=5)
        plt.xlim([100, 2250])
        plt.ylim([1E-8, 1E-3])
        plt.ylabel(str(round(m,1)))
        i += 1
        '''
        # get binned data
        logmedamp, stdbin, medx, binstrp, nperbin = get_binned_stats(
            bins, log10(mrhyps), log10(mamps))
        #plt.loglog(10**medx, 10**logmedamp, 'rs', ms=6.5)

        # normalise data @ 630 km
        nidx = where((binstrp > 2.79) & (binstrp < 2.81))[0]

        if len(nidx) > 0:
            print(m, nidx)
            namps = log10(mamps) - logmedamp[nidx]

            if len(log_norm_amps) == 0:
                log_norm_amps = namps
                norm_rhyps = mrhyps
            else:
                log_norm_amps = hstack((log_norm_amps, namps))
                norm_rhyps = hstack((norm_rhyps, mrhyps))
예제 #3
0
# look at stats

plt.plot(rrup, rmmi, '+', c='0.5')
plt.plot([0, xmax],[0, 0], 'k--')

plt.title('Prelim Atten Res')
#plt.xlabel('Rrup')
plt.ylabel('MMI Residual')

plt.xlim([0, xmax])
plt.ylim([-3, 3])

# get stats
bins = arange(5, xmax+1, 10)

medbin, stdbin, medx, binstrp, npb = get_binned_stats(bins, rrup, rmmi)

# plot errors
plt.errorbar(binstrp, medbin, yerr=stdbin, fmt='rs', lw=1.5)

# annotate
didx = where(array(rrup) <= xmax)[0] # comparable with other mod cmp
pltstr = 'Med = ' + str('%0.2f' % median(rmmi[didx])) + '\n' \
         'Std = ' + str('%0.2f' % std(rmmi[didx]))
plt.text(280, -2.35, pltstr, fontsize=14, va='center')

y_at_xhinge = 0
xhinge = 100.
def fit_fixed_intercept(c, x):
    '''
    x = array fo x values
예제 #4
0
if getcwd().startswith('/nas'):
    magdiffcsv = '/nas/active/ops/community_safety/ehp/georisk_earthquake/modelling/sandpits/tallen/NSHA2018/catalogue/matlab/rev_mag_diff.csv'
else:
    magdiffcsv = '/Users/trev/Documents/Geoscience_Australia/NSHA2018/catalogue/matlab/rev_mag_diff.csv'

data = loadtxt(magdiffcsv, delimiter=',')

fig = plt.figure(1, figsize=(7, 7))

plt.plot([2, 7], [2, 7], '--', c='0.25', lw=2.0, label='1:1')
plt.plot(data[:, 2], data[:, 3], '+', c='r', label='Data')

# bin data and regress
mbins = arange(1, 6.2, 0.2)
medres, stdres, medx, mbins, nperbin = get_binned_stats(
    mbins, data[:, 2], data[:, 3])
#plt.errorbar(mbins, medres, stdres, marker='s', c='orange', mec='orangered', ls='none', ms=8, label='Binned Data')
reg_pars = linregress(mbins, medres)
xplt = array([2.4, 6.5])
yplt = reg_pars[0] * xplt + reg_pars[1]

#plt.plot(xplt, yplt, 'r-', lw=2., zorder=100, label='Linear Fit')

#reg_pars2 = linregress(data[:,2], data[:,3])


# now do ODR
# Define a function (quadratic in our case) to fit the data with.
def linear_func(p, x):
    m, c = p
    return m * x + c
예제 #5
0
letters = ['(a)', '(b)', '(c)', '(d)']

plt.figure(i, figsize=(18, 7))
for mi, ma in zip(mmin, mmax):
    plt.tick_params(labelsize=15)
    midx = where((seamags > mi) & (seamags <= ma))[0]

    # get gippsland data
    gidx = where((seamags > mi) & (seamags <= ma) & (lares < -37.8))[0]
    #plt.suptitle('ML '+str(mi)+'-'+str(ma), fontsize=22)

    # get MLM92
    plt.subplot(2, 2, 2 * i + 2)
    plt.plot(rhypres[midx], mlm92res[midx], '+', color='0.6', zorder=-32)
    #plt.plot(rhypres[gidx], mlm92res[gidx], '+', color='seagreen')
    medbin, stdbin, meanx, outbins, nperbin = get_binned_stats(
        bins, rhypres[midx], mlm92res[midx])
    plt.errorbar(outbins,
                 medbin,
                 yerr=stdbin,
                 color='r',
                 fmt='s',
                 mec='r',
                 zorder=1000)

    #medbin, stdbin, meanx, outbins, nperbin = get_binned_stats(bins, rhypres[gidx], mlm92res[gidx])
    #plt.errorbar(outbins, medbin, yerr=stdbin, color='b', fmt='s', mfc='none', mec='b')

    plt.plot([0, 800], [0, 0], 'k--')
    plt.xlim([0, 800])
    plt.ylim([-0.75, 0.75])
    if i == 0:
예제 #6
0
    plt.plot(rrup, mr, '+', c='0.5')
    plt.plot([0, xmax],[0, 0], 'k--')
    
    plt.title(titles[i])
    #plt.xlabel('Rrup')
    plt.ylabel('MMI Residual')
    if i == 4 or i == 5:
        plt.xlabel('Rrup (km)')
    
    plt.xlim([0, xmax])
    plt.ylim([-3, 3])
    
    # get stats
    bins = arange(10, 361, 10)

    medbin, stdbin, medx, binstrp, npb = get_binned_stats(bins, array(rrup), mr)
    
    # plot errors
    plt.errorbar(medx, medbin, yerr=stdbin, fmt='rs', lw=1.5)


plt.savefig('figs/existing_mmi_dist_residuals.png', fmt='png', bbox_inches='tight')    
plt.show()
    
# plt residuals with mag
fig = plt.figure(2, figsize=(14, 10))
# look at stats
for i, mr in enumerate(modres):
    
    plt.subplot(3, 2, i+1)
    
예제 #7
0
            else:
                tmplognormamps = log10(array([ev['specs'][regf_idx]
                                              ])) - logsrcamp

            # build normalised array
            if len(lognormamps) > 0:
                lognormamps = hstack((lognormamps, tmplognormamps))
                normrhyps = hstack((normrhyps, ev['rhyp']))
            else:
                lognormamps = tmplognormamps
                normrhyps = ev['rhyp']

###############################################################################
# plt normalised data
###############################################################################

plt.figure(1, figsize=(9, 7))

plt.plot(log10(normrhyps), lognormamps, '+', c='0.5', ms=6)

distbins = arange(0.1, 3.1, 0.1)
medres, stdres, medx, bins, nperbin = get_binned_stats(distbins,
                                                       log10(normrhyps),
                                                       lognormamps)
nidx = where(nperbin > 2)[0]
plt.plot(medx[nidx], medres[nidx], 'rs')

plt.ylabel('Normalised Amplitude')
plt.xlabel('log10 Rhyp')
plt.show()
예제 #8
0
for mi, ma in zip(mmin, mmax):
    i += 1
    plt.figure(i, figsize=(18, 10))
    plt.tick_params(labelsize=15)
    midx = where((seamags > mi) & (seamags <= ma))[0]

    # get gippsland data
    gidx = where((seamags > mi) & (seamags <= ma) & (lares < -37.8))[0]
    #plt.suptitle('ML '+str(mi)+'-'+str(ma), fontsize=22)

    # get MLM92
    plt.subplot(323)
    plt.plot(rhypres[midx], mlm92res[midx], '+', color='0.6')
    #plt.plot(rhypres[gidx], mlm92res[gidx], '+', color='seagreen')
    medbin, stdbin, meanx, outbins, nperbin = get_binned_stats(
        bins, rhypres[midx], mlm92res[midx])
    plt.errorbar(outbins, medbin, yerr=stdbin, color='r', fmt='s', mec='r')

    medbin, stdbin, meanx, outbins, nperbin = get_binned_stats(
        bins, rhypres[gidx], mlm92res[gidx])
    #plt.errorbar(outbins, medbin, yerr=stdbin, color='b', fmt='s', mfc='none', mec='b')

    plt.plot([0, 800], [0, 0], 'k--')
    plt.xlim([0, 800])
    plt.ylim([-0.75, 0.75])
    plt.title('Michael-Lieba & Malafant (1992)', fontsize=16)
    plt.ylabel('Stn ML - Mean ML', fontsize=14)
    #plt.xlabel('Hypocentral Distance (km)', fontsize=14)
    plt_stats(plt, rhypres[midx], mlm92res[midx])

    # get WGW96