コード例 #1
0
ファイル: gmttools.py プロジェクト: vkuna/MudPy
def make_fakequakes_sliprate_slice(rupt,nstrike,ndip,epicenter,outpath,run_name,tmax,dt,stf_type='dreger'):
    '''
    '''
    from numpy import genfromtxt,unique,zeros,where,arange,interp,c_,savetxt
    from mudpy.forward import get_source_time_function,add2stf,build_source_time_function
    
    f=genfromtxt(rupt)
    num=f[:,0]
    nfault=nstrike*ndip
    unum=unique(num)
    lon=f[0:len(unum),1]
    lat=f[0:len(unum),2]
    depth=f[0:len(unum),3]
    #Get slips
    all_ss=f[:,8]
    all_ds=f[:,9]
    #Get rigidities
    mu=f[0:len(unum),13]
    #Get rise times
    rise_time=f[0:len(unum),7]
    #Get areas
    area=f[0:len(unum),10]*f[0:len(unum),11]
    t=arange(0,tmax,dt)
    #Loop over subfaults
    for kfault in range(nfault):
        if kfault%10==0:
            print( '... working on subfault '+str(kfault)+' of '+str(nfault))
        
        #Get rupture times for subfault windows
        trup=f[kfault,12]
        
        #Get slips on subfault
        ss=all_ss[kfault]
        ds=all_ds[kfault]
        
        #Add it up
        slip=(ss**2+ds**2)**0.5
        
        #Get first source time function
        if rise_time[kfault]>0:
            tstf,Mdot=build_source_time_function(rise_time[kfault],0.05,rise_time[kfault]*1.5,stf_type=stf_type,time_offset=trup)
            #What is the moment at this subfault?
            moment=slip*mu[kfault]*area[kfault]
            #Scale stf by this moment
            scale_factor=moment/dt
            Mdot=Mdot*scale_factor
        else:
            tstf=arange(2)
            Mdot=zeros(2)
        if kfault==0: #Intialize
            M=zeros((len(t),nfault))
            T=zeros((len(t),nfault))
        
        #interpolate to requested output dt
        Mout=interp(t,tstf,Mdot)
        
        #place in output vector
        M[:,kfault]=Mout
        T[:,kfault]=t
        
    #Now look through time slices
    maxsr=0
    print( 'Writing files...')
    for ktime in range(len(t)):
        sliprate=zeros(lon.shape)
        for kfault in range(nfault):
            sliprate[kfault]=M[ktime,kfault]/(mu[kfault]*area[kfault])
        maxsr=max(maxsr,sliprate.max())
        fname=outpath+run_name+'.'+str(ktime).rjust(4,'0')+'.sliprate'
        print( sliprate.max())
        savetxt(fname, c_[lon,lat,depth,sliprate],fmt='%.6f\t%.6f\t%.4f\t%.6f')
    print( 'Maximum slip rate was '+str(maxsr)+'m/s' )  
コード例 #2
0
ファイル: test_stupid_stf.py プロジェクト: shineusn/mylife
synth = '/Users/dmelgar/FakeQuakes/Hayward/GFs/misc/gil7.mod_5.5010.sub0017_1Hz/P224.subfault0017.SS.disp.e'
#synth='/Users/dmelgar/FakeQuakes/Hayward/GFs/misc/gil7.mod_5.5010.sub0017_5Hz/15.270.grn.4'
#synth='/Users/dmelgar/FakeQuakes/Hayward/GFs/misc/gil7.mod_5.5010.sub0017_1Hz/15.270.grn.4'

st = read(synth)
sti = read(synth)

dt = st[0].stats.delta
rise_time = 1.0
NFFT = st[0].stats.npts
total_time = NFFT * dt

#First build stupid STF and convolve WITHOUT interpolation
t1, Mdot1 = build_source_time_function(rise_time,
                                       dt,
                                       total_time,
                                       stf_type='dreger',
                                       scale=True)
after_conv = convolve(st[0].data, Mdot1)[0:NFFT]

#Simple interpolationto 10Hz
sti[0].interpolate(10, method='linear')
dt = sti[0].stats.delta
NFFT = sti[0].stats.npts
total_time = dt * NFFT
#Now build an STF at 10Hz
t2, Mdot2 = build_source_time_function(rise_time,
                                       dt,
                                       total_time,
                                       stf_type='dreger',
                                       scale=True)
コード例 #3
0
ファイル: gmttools.py プロジェクト: dmelgarm/MudPy
def make_fakequakes_sliprate_slice(rupt,nstrike,ndip,epicenter,outpath,run_name,tmax,dt,stf_type='dreger'):
    '''
    '''
    from numpy import genfromtxt,unique,zeros,where,arange,interp,c_,savetxt
    from mudpy.forward import get_source_time_function,add2stf,build_source_time_function
    from string import rjust
    
    f=genfromtxt(rupt)
    num=f[:,0]
    nfault=nstrike*ndip
    unum=unique(num)
    lon=f[0:len(unum),1]
    lat=f[0:len(unum),2]
    depth=f[0:len(unum),3]
    #Get slips
    all_ss=f[:,8]
    all_ds=f[:,9]
    #Get rigidities
    mu=f[0:len(unum),13]
    #Get rise times
    rise_time=f[0:len(unum),7]
    #Get areas
    area=f[0:len(unum),10]*f[0:len(unum),11]
    t=arange(0,tmax,dt)
    #Loop over subfaults
    for kfault in range(nfault):
        if kfault%10==0:
            print '... working on subfault '+str(kfault)+' of '+str(nfault)
        
        #Get rupture times for subfault windows
        trup=f[kfault,12]
        
        #Get slips on subfault
        ss=all_ss[kfault]
        ds=all_ds[kfault]
        
        #Add it up
        slip=(ss**2+ds**2)**0.5
        
        #Get first source time function
        if rise_time[kfault]>0:
            tstf,Mdot=build_source_time_function(rise_time[kfault],0.05,rise_time[kfault]*1.5,stf_type=stf_type,time_offset=trup)
            #What is the moment at this subfault?
            moment=slip*mu[kfault]*area[kfault]
            #Scale stf by this moment
            scale_factor=moment/dt
            Mdot=Mdot*scale_factor
        else:
            tstf=arange(2)
            Mdot=zeros(2)
        if kfault==0: #Intialize
            M=zeros((len(t),nfault))
            T=zeros((len(t),nfault))
        
        #interpolate to requested output dt
        Mout=interp(t,tstf,Mdot)
        
        #place in output vector
        M[:,kfault]=Mout
        T[:,kfault]=t
        
    #Now look through time slices
    maxsr=0
    print 'Writing files...'
    for ktime in range(len(t)):
        sliprate=zeros(lon.shape)
        for kfault in range(nfault):
            sliprate[kfault]=M[ktime,kfault]/(mu[kfault]*area[kfault])
        maxsr=max(maxsr,sliprate.max())
        fname=outpath+run_name+'.'+rjust(str(ktime),4,'0')+'.sliprate'
        print sliprate.max()
        savetxt(fname, c_[lon,lat,depth,sliprate],fmt='%.6f\t%.6f\t%.4f\t%.6f')
    print 'Maximum slip rate was '+str(maxsr)+'m/s'   
コード例 #4
0
plt.ylabel('Mean potency', fontsize=14)

ax = fig.add_subplot(133)
plt.errorbar(M, array(msr), xerr=0.25, c='k')
plt.scatter(M, array(msr), c='r', marker='o', s=20)
plt.xlabel('Magnitude bin', fontsize=14)
plt.ylabel('Mean potency rate', fontsize=14)
#ax.set_ylim([0,2])

stf_type = 'dreger'
zeta = 0.2
#zeta=0.2
rate = 5
t, stf1 = forward.build_source_time_function(rt1,
                                             0.02,
                                             30,
                                             stf_type=stf_type,
                                             dreger_falloff_rate=rate,
                                             zeta=zeta)
t, stf2 = forward.build_source_time_function(rt2,
                                             0.02,
                                             30,
                                             stf_type=stf_type,
                                             dreger_falloff_rate=rate,
                                             zeta=zeta)
t, stf3 = forward.build_source_time_function(rt3,
                                             0.02,
                                             30,
                                             stf_type=stf_type,
                                             dreger_falloff_rate=rate,
                                             zeta=zeta)
t, stf4 = forward.build_source_time_function(rt4,