Exemple #1
0
def kiksyn(nt,dt,ib,ic,str,dip,rak,z,az,p,g,t12,
           velmod_filename=None,pad=False,verbose=False):
    """
        Wrapper for Kikuchi body wave synthetic routine
    Input:
    nt,dt            length and sampling of output time series
    ib,ic            ib=1 for P; ic=1,2,3 for Z,NS,EW, resp.
                     ib=2 for SV; ic=1,2 for Z,radial, resp.
                     ib=3 for SH; (ic ignored)
    p, g             slowness and geometrical spreading (from raypgeom)
    z, az            event depth and source-to-recever azimuth
    str,dip,rak      fault geometry
    t12              half-duration of symmetrical trangle stf
    velmod_filename  velocity model file name
    Output
    syn              real array of length nt
    """
# From Hong Kie's ffi program:
#      read(5,*) ms,t1,t2
#        read(1,*) az(js),az2(js),del(js),p(js),g(js),ix0(js)
#        read(1,*) im(js),ib(js),ic(js)
#     -- read velocity model --------------------------------------------
#      read(2,'(a40)') dsn
#      read(2,*) tqp,tqs,nl,(vp(l),vs(l),den(l),dep(l),l=1,nl)
#      read(2,*) nl1,(vp1(l),vs1(l),den1(l),dep1(l),l=1,nl1)
#      read(2,*) nl2,(vp2(l),vs2(l),den2(l),dep2(l),l=1,nl2)
    if velmod_filename != None:
           lines = open(velmod_filename,'r').readlines()
           buf = []
           for line in lines[1:]: buf.extend(line.split())
           tqp,tqs = [float(x) for x in buf[0:2]]
           # Pack velocity model
           nl = int(buf[2])
           nl1 = int(buf[nl*4+3])
           nl2 = int(buf[(nl+nl1+1)*4])
           vmod=np.zeros((4,(nl+nl1+nl2)))
           vmod[0:4,       0:nl      ] = np.array([float(x) for x in buf[3:nl*4+3]]).reshape((nl,4)).transpose()
           vmod[0:4,    nl:nl+nl1    ] = np.array([float(x) for x in buf[4*(nl+1):4*(nl+nl1+1)]]).reshape((nl1,4)).transpose()
           vmod[0:4,nl+nl1:nl+nl1+nl2] = np.array([float(x) for x in buf[4*(nl+nl1+1)+1:4*(nl+nl1+nl2+1)+1]]).reshape((nl2,4)).transpose()
    else:
           tqp = 0.
           tqs = 0.
           vmod = []
           nl = 0
           nl1 = 0
           nl2 = 0
    # Pad nt to power of 2 if needed
    if mt.log(nt,2) % 1 != 0.:
        nt1 = int(mt.pow(2,int(mt.log(nt,2))+1))
        if verbose: print 'nt=%d raised to next power of two (%d)' % (nt,nt1)
    else:
        nt1 = nt
    if pad:
        nt1 *=2
    # Now call synthetic generating routine
    syn = kiklib.kiksyn(nt1,dt,ib,ic,az,p,g,str,dip,rak,z,t12,
                        tqp,tqs,vmod,[nl,nl1,nl2],velmod_filename!=None)
    return syn[0:nt]
Exemple #2
0
def kiksyn(nt,dt,ib,ic,str,dip,rak,z,az,p,g,t12,velmod,\
           set_velmod=True,pad=False,verbose=False):
    """
        Wrapper for Kikuchi body wave synthetic routine
    Input:
    nt,dt            length and sampling of output time series
    ib,ic            ib=1 for P; ic=1,2,3 for Z,NS,EW, resp.
                     ib=2 for SV; ic=1,2 for Z,radial, resp.
                     ib=3 for SH; (ic ignored)
    p, g             slowness and geometrical spreading (from raypgeom)
    z, az            event depth and source-to-recever azimuth
    str,dip,rak      fault geometry
    t12              half-duration of symmetrical trangle stf
    velmod           velocity model dictionary returned by read_velmod
    Output
    syn              real array of length nt
    """
# From Hong Kie's ffi program:
#      read(5,*) ms,t1,t2
#        read(1,*) az(js),az2(js),del(js),p(js),g(js),ix0(js)
#        read(1,*) im(js),ib(js),ic(js)
#     -- read velocity model --------------------------------------------
#      read(2,'(a40)') dsn
#      read(2,*) tqp,tqs,nl,(vp(l),vs(l),den(l),dep(l),l=1,nl)
#      read(2,*) nl1,(vp1(l),vs1(l),den1(l),dep1(l),l=1,nl1)
#      read(2,*) nl2,(vp2(l),vs2(l),den2(l),dep2(l),l=1,nl2)
    # Pad nt to power of 2 if needed
    if mt.log(nt,2) % 1 != 0.:
        nt1 = int(mt.pow(2,int(mt.log(nt,2))+1))
        if verbose: print 'nt=%d raised to next power of two (%d)' % (nt,nt1)
    else:
        nt1 = nt
    if pad:
        nt1 *=2
    # Now call synthetic generating routine
    tqp  = velmod['tqp']
    tqs  = velmod['tqs']
    ns   = velmod['ns']
    vmod = velmod['vmod']
    syn  = kiklib.kiksyn(nt1,dt,ib,ic,az,p,g,str,dip,rak,z,t12,
                        tqp,tqs,vmod,ns,set_velmod)
    return syn[0:nt]
Exemple #3
0
def kiksyn(nt,dt,ib,ic,str,dip,rak,z,az,p,g,t12,velmod,\
           set_velmod=True,pad=False,verbose=False):
    """
        Wrapper for Kikuchi body wave synthetic routine
    Input:
    nt,dt            length and sampling of output time series
    ib,ic            ib=1 for P; ic=1,2,3 for Z,NS,EW, resp.
                     ib=2 for SV; ic=1,2 for Z,radial, resp.
                     ib=3 for SH; (ic ignored)
    p, g             slowness and geometrical spreading (from raypgeom)
    z, az            event depth and source-to-recever azimuth
    str,dip,rak      fault geometry
    t12              half-duration of symmetrical trangle stf
    velmod           velocity model dictionary returned by read_velmod
    Output
    syn              real array of length nt
    """
    # From Hong Kie's ffi program:
    #      read(5,*) ms,t1,t2
    #        read(1,*) az(js),az2(js),del(js),p(js),g(js),ix0(js)
    #        read(1,*) im(js),ib(js),ic(js)
    #     -- read velocity model --------------------------------------------
    #      read(2,'(a40)') dsn
    #      read(2,*) tqp,tqs,nl,(vp(l),vs(l),den(l),dep(l),l=1,nl)
    #      read(2,*) nl1,(vp1(l),vs1(l),den1(l),dep1(l),l=1,nl1)
    #      read(2,*) nl2,(vp2(l),vs2(l),den2(l),dep2(l),l=1,nl2)
    # Pad nt to power of 2 if needed
    if mt.log(nt, 2) % 1 != 0.:
        nt1 = int(mt.pow(2, int(mt.log(nt, 2)) + 1))
        if verbose: print 'nt=%d raised to next power of two (%d)' % (nt, nt1)
    else:
        nt1 = nt
    if pad:
        nt1 *= 2
    # Now call synthetic generating routine
    tqp = velmod['tqp']
    tqs = velmod['tqs']
    ns = velmod['ns']
    vmod = velmod['vmod']
    syn = kiklib.kiksyn(nt1, dt, ib, ic, az, p, g, str, dip, rak, z, t12, tqp,
                        tqs, vmod, ns, set_velmod)
    return syn[0:nt]
Exemple #4
0
def kiksyn(nt,
           dt,
           ib,
           ic,
           str,
           dip,
           rak,
           z,
           az,
           p,
           g,
           t12,
           velmod_filename=None,
           pad=False,
           verbose=False):
    """
        Wrapper for Kikuchi body wave synthetic routine
    Input:
    nt,dt            length and sampling of output time series
    ib,ic            ib=1 for P; ic=1,2,3 for Z,NS,EW, resp.
                     ib=2 for SV; ic=1,2 for Z,radial, resp.
                     ib=3 for SH; (ic ignored)
    p, g             slowness and geometrical spreading (from raypgeom)
    z, az            event depth and source-to-recever azimuth
    str,dip,rak      fault geometry
    t12              half-duration of symmetrical trangle stf
    velmod_filename  velocity model file name
    Output
    syn              real array of length nt
    """
    # From Hong Kie's ffi program:
    #      read(5,*) ms,t1,t2
    #        read(1,*) az(js),az2(js),del(js),p(js),g(js),ix0(js)
    #        read(1,*) im(js),ib(js),ic(js)
    #     -- read velocity model --------------------------------------------
    #      read(2,'(a40)') dsn
    #      read(2,*) tqp,tqs,nl,(vp(l),vs(l),den(l),dep(l),l=1,nl)
    #      read(2,*) nl1,(vp1(l),vs1(l),den1(l),dep1(l),l=1,nl1)
    #      read(2,*) nl2,(vp2(l),vs2(l),den2(l),dep2(l),l=1,nl2)
    if velmod_filename != None:
        lines = open(velmod_filename, 'r').readlines()
        buf = []
        for line in lines[1:]:
            buf.extend(line.split())
        tqp, tqs = [float(x) for x in buf[0:2]]
        # Pack velocity model
        nl = int(buf[2])
        nl1 = int(buf[nl * 4 + 3])
        nl2 = int(buf[(nl + nl1 + 1) * 4])
        vmod = np.zeros((4, (nl + nl1 + nl2)))
        vmod[0:4,
             0:nl] = np.array([float(x) for x in buf[3:nl * 4 + 3]]).reshape(
                 (nl, 4)).transpose()
        vmod[0:4, nl:nl + nl1] = np.array(
            [float(x) for x in buf[4 * (nl + 1):4 * (nl + nl1 + 1)]]).reshape(
                (nl1, 4)).transpose()
        vmod[0:4, nl + nl1:nl + nl1 + nl2] = np.array([
            float(x)
            for x in buf[4 * (nl + nl1 + 1) + 1:4 * (nl + nl1 + nl2 + 1) + 1]
        ]).reshape((nl2, 4)).transpose()
    else:
        tqp = 0.
        tqs = 0.
        vmod = []
        nl = 0
        nl1 = 0
        nl2 = 0
    # Pad nt to power of 2 if needed
    if mt.log(nt, 2) % 1 != 0.:
        nt1 = int(mt.pow(2, int(mt.log(nt, 2)) + 1))
        if verbose: print 'nt=%d raised to next power of two (%d)' % (nt, nt1)
    else:
        nt1 = nt
    if pad:
        nt1 *= 2
    # Now call synthetic generating routine
    syn = kiklib.kiksyn(nt1, dt, ib, ic, az, p, g, str, dip, rak, z, t12, tqp,
                        tqs, vmod, [nl, nl1, nl2], velmod_filename != None)
    return syn[0:nt]
Exemple #5
0
def kiksyn(nt,
           dt,
           ib,
           ic,
           strike,
           dip,
           rak,
           z,
           az,
           p,
           g,
           trise,
           tdur,
           istype=3,
           velmod=None,
           set_velmod=True,
           pad=False,
           verbose=False,
           frq4=None):
    """
        Wrapper for Kikuchi body wave synthetic routine
    Input:
    nt,dt            length and sampling of output time series
    ib,ic            ib=1 for P; ic=1,2,3 for Z,NS,EW, resp.
                     ib=2 for SV; ic=1,2 for Z,radial, resp.
                     ib=3 for SH; (ic ignored)
    p, g             slowness and geometrical spreading (from raypgeom)
    z, az            event depth and source-to-recever azimuth
    str,dip,rak      fault geometry
    trise,tdur       rise time and total duration, resp.
    istype sets the source time funciton, according to:
       istype=0 : Impulsive time function
             =1 : Ramp function       if tdur < trise
                  Symmetric trapezoid if tdur >= trise
             =2 : Ramp function with cosine taper if tdur < trise
                  Symmetric trapezoid             if tdur >= trise
             =3 : Triangle

    velmod           velocity model dictionary returned by read_velmod
    Output
    syn              real array of length nt
    """
    # From Hong Kie's ffi program:
    #      read(5,*) ms,t1,t2
    #        read(1,*) az(js),az2(js),del(js),p(js),g(js),ix0(js)
    #        read(1,*) im(js),ib(js),ic(js)
    #     -- read velocity model --------------------------------------------
    #      read(2,'(a40)') dsn
    #      read(2,*) tqp,tqs,nl,(vp(l),vs(l),den(l),dep(l),l=1,nl)
    #      read(2,*) nl1,(vp1(l),vs1(l),den1(l),dep1(l),l=1,nl1)
    #      read(2,*) nl2,(vp2(l),vs2(l),den2(l),dep2(l),l=1,nl2)
    # Pad nt to power of 2 if needed
    if mt.log(nt, 2) % 1 != 0.:
        nt1 = int(mt.pow(2, int(mt.log(nt, 2)) + 1))
        if verbose: print 'nt=%d raised to next power of two (%d)' % (nt, nt1)
    else:
        nt1 = nt
    if pad:
        nt1 *= 4
    # Now call synthetic generating routine
    tqp = velmod['tqp']
    tqs = velmod['tqs']
    ns = velmod['ns']
    vmod = velmod['vmod']
    if frq4 is None:
        frq4 = -1. * np.ones(4)
    syn = kiklib.kiksyn(nt1, dt, ib, ic, az, p, g, strike, dip, rak, z, trise,
                        tdur, istype, tqp, tqs, vmod, ns, set_velmod, frq4)
    return syn[0:nt]