예제 #1
0
def su_specfem2d(prefix='SEM', channel=None, suffix='.su'):
    """ Reads Seismic Unix file
    """
    if channel in ['x']:
        file = '%s/Ux_file_single%s' % (prefix, suffix)
    elif channel in ['y']:
        file = '%s/Uy_file_single%s' % (prefix, suffix)
    elif channel in ['z']:
        file = '%s/Uz_file_single%s' % (prefix, suffix)
    elif channel in ['p']:
        file = '%s/Up_file_single%s' % (prefix, suffix)
    else:
        raise ValueError('CHANNEL must be one of the following: x y z p')

    # read data from file
    d, h = segyreader.readsu(file)
    return d, h
예제 #2
0
def su_specfem2d(channel=None, prefix='SEM', suffix='.su'):
    """ Reads Seismic Unix file
    """
    if suffix == '':
        suffix = '.su'

    if channel in ['x']:
        file = '%s/Ux_file_single%s' % (prefix, suffix)
    elif channel in ['y']:
        file = '%s/Uy_file_single%s' % (prefix, suffix)
    elif channel in ['z']:
        file = '%s/Uz_file_single%s' % (prefix, suffix)
    elif channel in ['p']:
        file = '%s/Up_file_single%s' % (prefix, suffix)
    else:
        raise Exception("Undefined Exception")

    # read data from file
    d, h = segyreader.readsu(file)
    return d, h
예제 #3
0
def su_specfem3d(prefix='SEM', channel=None, suffix='', verbose=False):
    """ Reads Seismic Unix file
    """
    if channel in ['x']:
        wildcard = '%s/*_dx_SU%s' % (prefix, suffix)
    elif channel in ['y']:
        wildcard = '%s/*_dy_SU%s' % (prefix, suffix)
    elif channel in ['z']:
        wildcard = '%s/*_dz_SU%s' % (prefix, suffix)
    elif channel in ['p']:
        wildcard = '%s/*_dp_SU%s' % (prefix, suffix)
    else:
        raise ValueError('CHANNEL must be one of the following: x y z p')

    files = _glob.glob(wildcard)
    files = sorted(files, key=lambda x: int(basename(x).split('_')[0]))

    file = files.pop(0)
    d, h = segyreader.readsu(file)

    if verbose:
        print file
        print 'number of traces:', d.shape[1]
        print 'min, max:', d.min(), d.max()
        print ''

    rx = _list(h.rx)
    ry = _list(h.ry)
    rz = _list(h.rz)
    sx = _list(h.sx)
    sy = _list(h.sy)
    sz = _list(h.sz)

    nn = [h.nr]
    nr = h.nr

    # define proc number
    i_proc_buf = file.split('/')[-1]
    i_proc = int(i_proc_buf.split('_')[0])
    ip = [i_proc]

    for file in files:
        d_, h_ = segyreader.readsu(file)

        # define proc number  
        i_proc_buf = file.split('/')[-1]
        i_proc = int(i_proc_buf.split('_')[0])

        # combine arrays
        d = _np.column_stack((d, d_))

        if verbose:
            print file
            print 'number of traces:', d_.shape[1]
            print 'min, max:', d_.min(), d_.max()
            print ''

        # combine headers
        rx.extend(h_.rx)
        ry.extend(h_.ry)
        rz.extend(h_.rz)
        sx.extend(h_.sx)
        sy.extend(h_.sy)
        sz.extend(h_.sz)
        nn.append(h_.nr)
        nr = nr + h_.nr
        ip.append(i_proc)

    h.rx = _np.array(rx)
    h.ry = _np.array(ry)
    h.rz = _np.array(rz)
    h.sx = _np.array(sx)
    h.sy = _np.array(sy)
    h.sz = _np.array(sz)

    h.nn = nn
    h.nr = nr
    h.ip = ip

    return d, h
예제 #4
0
def su_specfem3d(channel=None, prefix='SEM', suffix='', verbose=False):
    """ Reads Seismic Unix file
    """
    if channel in ['x']:
        wildcard = '%s/*_dx_SU%s' % (prefix, suffix)
    elif channel in ['y']:
        wildcard = '%s/*_dy_SU%s' % (prefix, suffix)
    elif channel in ['z']:
        wildcard = '%s/*_dz_SU%s' % (prefix, suffix)
    elif channel in ['p']:
        wildcard = '%s/*_dp_SU%s' % (prefix, suffix)
    else:
        raise Exception("Undefined Exception")

    files = _glob.glob(wildcard)
    files = sorted(files, key=lambda x: int(unix.basename(x).split('_')[0]))

    file = files.pop(0)
    d, h = segyreader.readsu(file)

    if verbose:
        print file
        print 'number of traces:', d.shape[1]
        print 'min, max:', d.min(), d.max()
        print ''

    rx = _list(h.rx)
    ry = _list(h.ry)
    rz = _list(h.rz)
    sx = _list(h.sx)
    sy = _list(h.sy)
    sz = _list(h.sz)

    nn = [h.nr]
    nr = h.nr

    for file in files:
        d_, h_ = segyreader.readsu(file)

        # combine arrays
        d = _np.column_stack((d, d_))

        if verbose:
            print file
            print 'number of traces:', d_.shape[1]
            print 'min, max:', d_.min(), d_.max()
            print ''

        # combine headers
        rx.extend(h_.rx)
        ry.extend(h_.ry)
        rz.extend(h_.rz)
        sx.extend(h_.sx)
        sy.extend(h_.sy)
        sz.extend(h_.sz)
        nn.append(h_.nr)
        nr = nr + h_.nr

    h.rx = _np.array(rx)
    h.ry = _np.array(ry)
    h.rz = _np.array(rz)
    h.sx = _np.array(sx)
    h.sy = _np.array(sy)
    h.sz = _np.array(sz)

    h.nn = nn
    h.nr = nr

    return d, h