示例#1
0
    def check(self):
        """ Checks parameters and paths
        """

        if 'TITLE' not in PAR:
            setattr(PAR, 'TITLE', unix.basename(abspath('..')))

        if 'SUBTITLE' not in PAR:
            setattr(PAR, 'SUBTITLE', unix.basename(abspath('.')))

        # check parameters
        if 'NTASK' not in PAR:
            setattr(PAR, 'NTASK', 1)

        if 'NPROC' not in PAR:
            setattr(PAR, 'NPROC', 1)

        if 'VERBOSE' not in PAR:
            setattr(PAR, 'VERBOSE', 1)

        # check paths
        if 'GLOBAL' not in PATH:
            setattr(PATH, 'GLOBAL', join(abspath('.'), 'scratch'))

        if 'LOCAL' not in PATH:
            setattr(PATH, 'LOCAL', '')

        if 'SUBMIT' not in PATH:
            setattr(PATH, 'SUBMIT', unix.pwd())

        if 'OUTPUT' not in PATH:
            setattr(PATH, 'OUTPUT', join(PATH.SUBMIT, 'output'))

        if 'SYSTEM' not in PATH:
            setattr(PATH, 'SYSTEM', join(PATH.GLOBAL, 'system'))
示例#2
0
    def check(self):
        """ Checks parameters and paths
        """

        if 'TITLE' not in PAR:
            setattr(PAR, 'TITLE', unix.basename(abspath('..')))

        if 'SUBTITLE' not in PAR:
            setattr(PAR, 'SUBTITLE', unix.basename(abspath('.')))

        # check parameters
        if 'WALLTIME' not in PAR:
            setattr(PAR, 'WALLTIME', 30.)

        if 'VERBOSE' not in PAR:
            setattr(PAR, 'VERBOSE', 1)

        if 'NPROC' not in PAR:
            raise ParameterError(PAR, 'NPROC')

        if 'NTASK' not in PAR:
            raise ParameterError(PAR, 'NTASK')

        # check paths
        if 'GLOBAL' not in PATH:
            setattr(PATH, 'GLOBAL', join(abspath('.'), 'scratch'))

        if 'LOCAL' not in PATH:
            setattr(PATH, 'LOCAL', None)

        if 'SUBMIT' not in PATH:
            setattr(PATH, 'SUBMIT', unix.pwd())

        if 'OUTPUT' not in PATH:
            setattr(PATH, 'OUTPUT', join(PATH.SUBMIT, 'output'))
示例#3
0
    def check(self):
        """ Checks parameters and paths
        """

        if 'TITLE' not in PAR:
            setattr(PAR, 'TITLE', unix.basename(abspath('..')))

        if 'SUBTITLE' not in PAR:
            setattr(PAR, 'SUBTITLE', unix.basename(abspath('.')))

        # check parameters
        if 'WALLTIME' not in PAR:
            setattr(PAR, 'WALLTIME', 30.)

        if 'VERBOSE' not in PAR:
            setattr(PAR, 'VERBOSE', 1)

        if 'NPROC' not in PAR:
            raise ParameterError(PAR, 'NPROC')

        if 'NTASK' not in PAR:
            raise ParameterError(PAR, 'NTASK')

        # check paths
        if 'GLOBAL' not in PATH:
            setattr(PATH, 'GLOBAL', join(abspath('.'), 'scratch'))

        if 'LOCAL' not in PATH:
            setattr(PATH, 'LOCAL', None)

        if 'SUBMIT' not in PATH:
            setattr(PATH, 'SUBMIT', unix.pwd())

        if 'OUTPUT' not in PATH:
            setattr(PATH, 'OUTPUT', join(PATH.SUBMIT, 'output'))
示例#4
0
def ascii_specfem3d(**kwargs):
    """ Reads seismic traces from text files
    """
    files = glob(solver='3d', **kwargs)
    t = _np.loadtxt(files[0])[:, 0]
    h = Struct()
    h['t0'] = t[0]
    h['nr'] = len(files)
    h['ns'] = 1
    h['dt'] = _np.mean(_np.diff(t))
    h['nt'] = len(t)

    # read data
    s = _np.zeros((h['nt'], h['nr']))
    i = 0
    for file in files:
        s[:, i] = _np.loadtxt(file)[:, 1]
        i += 1

    # keep track of file names
    h.files = []
    for file in files:
        file = unix.basename(file)
        h.files.append(file)

    return s, h
示例#5
0
def ascii_specfem2d(**kwargs):
    """ Reads seismic traces from text files
    """
    files = glob(solver='specfem2d', **kwargs)
    t = _np.loadtxt(files[0])[:,0]
    h = Struct()
    h['t0'] = t[0]
    h['nr'] = len(files)
    h['ns'] = 1
    h['dt'] = _np.mean(_np.diff(t))
    h['nt'] = len(t)

    # read data
    s = _np.zeros((h['nt'], h['nr']))
    i = 0
    for file in files:
        s[:, i] = _np.loadtxt(file)[:, 1]
        i += 1

    # keep track of file names
    h.files = []
    for file in files:
        file = unix.basename(file)
        h.files.append(file)

    return s, h
示例#6
0
def su_specfem3d_obspy(prefix='SEM', channel=None, suffix='', byteorder='<', verbose=False):
    """ Reads Seismic Unix file
    """
    from obspy.segy.core import readSU

    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')

    filenamess = _glob.glob(wildcard)

    sort_by = lambda x: int(unix.basename(x).split('_')[0])
    filenames = sorted(filenamess, key=sort_by)

    streamobj = readSU(filenames.pop(), byteorder=byteorder)
    for filename in filenames:
        streamobj += readSU(filename, byteorder=byteorder)

    return streamobj
示例#7
0
def _cmp(names):
    rank = []
    for name in names:
        ii = int(unix.basename(name).split('_')[0])
        rank.append(ii)
    print rank
    return [names[ii] for ii in rank]
示例#8
0
    def check(self):
        """ Checks parameters and paths
        """

        if 'TITLE' not in PAR:
            setattr(PAR, 'TITLE', unix.basename(abspath('..')))

        if 'SUBTITLE' not in PAR:
            setattr(PAR, 'SUBTITLE', unix.basename(abspath('.')))

        if 'GLOBAL' not in PATH:
            setattr(PATH, 'GLOBAL',
                    join('/scratch/gpfs', unix.whoami(), PAR.TITLE, PAR.SUBTITLE))

        if 'LOCAL' not in PATH:
            setattr(PATH, 'LOCAL', '')

        super(tiger_sm, self).check()
示例#9
0
    def getname(self):
        """name of current source"""
        if not hasattr(self, 'sources'):
            # generate list of all sources
            paths = glob(PATH.SOLVER_FILES + '/' + 'SOURCE_*')
            self.sources = []
            for path in paths:
                self.sources += [unix.basename(path).split('_')[-1]]
            self.sources.sort()

        return self.sources[system.getnode()]
示例#10
0
文件: config.py 项目: mpbl/seisflows
    def load(self, name, path='.', files=None):
        try:
            fullpath = join(abspath(path), name)
        except:
            raise IOError(path)

        if not files:
            files = []
            files += [fullpath + '/' + 'system.p']
            files += [fullpath + '/' + 'preprocess.p']
            files += [fullpath + '/' + 'solver.p']
            files += [fullpath + '/' + 'postprocess.p']
            files += [fullpath + '/' + 'optimize.p']
            files += [fullpath + '/' + 'workflow.p']

        for file in files:
            key, _ = os.path.splitext(unix.basename(file))
            self.keys.add(key)
            sys.modules[key] = loadobj(file)
示例#11
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 ValueError('CHANNEL must be one of the following: x y z p')

    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
示例#12
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(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
示例#13
0
 def event(self):
     if not hasattr(self, '_event'):
         self._event = unix.basename(
             glob(PATH.OUTPUT + '/' + 'traces/*')[0])
     return self._event
示例#14
0
 def event(self):
     if not hasattr(self, '_event'):
         self._event = unix.basename(glob(PATH.OUTPUT+'/'+'traces/*')[0])
     return self._event