• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python unix.cp函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中seisflows.tools.unix.cp函数的典型用法代码示例。如果您正苦于以下问题:Python cp函数的具体用法?Python cp怎么用?Python cp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了cp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setup

    def setup(self):
        """ Prepares solver for inversion or migration
        """
        # clean up for new inversion
        unix.rm(self.getpath)

        # As input for an inversion or migration, users can choose between
        # providing data, or providing a target model from which data are
        # generated on the fly. In the former case, a value for PATH.DATA must
        # be supplied; in the latter case, a value for PATH.MODEL_TRUE must be
        # provided

        if PATH.DATA:
            # copy user supplied data
            self.initialize_solver_directories()

            src = glob(PATH.DATA +'/'+ basename(self.getpath) +'/'+ '*')
            dst = 'traces/obs/'
            unix.cp(src, dst)

        else:
            # generate data on the fly
            self.generate_data(
                model_path=PATH.MODEL_TRUE,
                model_name='model_true',
                model_type='gll')

        # prepare initial model
        self.generate_mesh(
            model_path=PATH.MODEL_INIT,
            model_name='model_init',
            model_type='gll')

        self.initialize_adjoint_traces()
开发者ID:gianmatharu,项目名称:seisflows-research,代码行数:34,代码来源:base.py


示例2: export_traces

    def export_traces(self, path, prefix='traces/obs'):
        # hack deals with problems on parallel filesystem
        unix.mkdir(join(path, 'traces'), noexit=True)

        src = join(self.getpath, prefix)
        dst = join(path, 'traces', basename(self.getpath))
        unix.cp(src, dst)
开发者ID:gianmatharu,项目名称:seisflows-research,代码行数:7,代码来源:base.py


示例3: evaluate_gradient

    def evaluate_gradient(self, model_dir=''):
        """ Compute event gradient by running adjoint simulation
        """

        # get task number
        itask = system.getnode()

        # setup directories
        syn_dir = join(self.getpath, 'traces', 'syn')
        adj_dir = join(self.getpath, 'traces', 'adj')

        # set par.cfg file for solver
        self.set_par_cfg(external_model_dir=model_dir, output_dir=syn_dir, save_forward_wavefield=False,
                         adjoint_sim=True, adjoint_dir=adj_dir)

        # set src.cfg for solver
        xsrc = self.sources[itask][0]
        zsrc = self.sources[itask][1]
        self.set_src_cfg(xs=float(xsrc), zs=float(zsrc))

        # copy cfg files
        unix.cp(join(self.getpath, 'INPUT', 'par.cfg'), adj_dir)
        unix.cp(join(self.getpath, 'INPUT', 'src.cfg'), adj_dir)

        # run adjoint sim
        self.adjoint()

        # clean saved boundaries
        unix.rm(glob(join(syn_dir, 'proc*')))
开发者ID:gianmatharu,项目名称:seisflows-research,代码行数:29,代码来源:ewf2d.py


示例4: generate_mesh

    def generate_mesh(self, model_path=None, model_name=None, model_type='gll'):
        """ Performs meshing and database generation
        """
        assert(model_name)
        assert(model_type)

        self.initialize_solver_directories()
        unix.cd(self.getpath)

        if model_type in ['gll']:
            par = getpar('MODEL').strip()
            if par != 'gll':
                if self.getnode == 0:
                    print 'WARNING: Unexpected Par_file setting:'
                    print 'MODEL =', par
            
            assert(exists(model_path))
            self.check_mesh_properties(model_path)

            src = glob(model_path +'/'+ '*')
            dst = self.model_databases
            unix.cp(src, dst)

            self.call('bin/xmeshfem3D')
            self.call('bin/xgenerate_databases')
            self.export_model(PATH.OUTPUT +'/'+ model_name)

        else:
            raise NotImplementedError
开发者ID:HongjianFang,项目名称:seisflows,代码行数:29,代码来源:specfem3d.py


示例5: write_model

 def write_model(self, path='', suffix=''):
     """ Writes model in format used by solver
     """
     unix.mkdir(path)
     src = PATH.OPTIMIZE +'/'+ 'm_' + suffix
     dst = path +'/'+ 'model'
     unix.mkdir(dst)
     unix.cp(glob(join(PATH.MODEL, '*.bin')), dst)
     solver.split(src, dst, '.bin')
开发者ID:gianmatharu,项目名称:seisflows-research,代码行数:9,代码来源:alt_inversion.py


示例6: setup

    def setup(self):
        """ Lays groundwork for inversion
        """
        if PAR.BEGIN == 1:
            # copy initial gradient to working directory
            unix.cp(PATH.GRAD_INIT, PATH.GRAD_AGG)

            preprocess.setup()
            postprocess.setup()
            optimize.setup()

        for isrc in range(PAR.NSRC):
            solver.setup(subset=[isrc])
开发者ID:gianmatharu,项目名称:seisflows,代码行数:13,代码来源:stochastic_saga.py


示例7: generate_mesh

    def generate_mesh(self, model_path=None, model_name=None, model_type='gll'):
        """ Performs meshing and database generation
        """
        assert(model_name)
        assert(model_type)

        self.initialize_solver_directories()
        unix.cd(self.getpath)

        assert(exists(model_path))
        self.check_mesh_properties(model_path)

        src = model_path
        dst = join(self.getpath, 'DATA/proc000000_rho_vp_vs.dat')
        unix.cp(src, dst)

        self.export_model(PATH.OUTPUT +'/'+ model_name)
开发者ID:iceseismic,项目名称:seisflows,代码行数:17,代码来源:specfem2d_legacy.py


示例8: initialize_adjoint_traces

    def initialize_adjoint_traces(self):
        super(specfem3d, self).initialize_adjoint_traces()

        # workaround for SPECFEM2D's use of different name conventions for
        # regular traces and 'adjoint' traces
        if PAR.FORMAT in ['SU', 'su']:
            files = glob(self.cwd +'/'+ 'traces/adj/*SU')
            unix.rename('_SU', '_SU.adj', files)

        # workaround for SPECFEM3D's requirement that all components exist,
        # even ones not in use
        unix.cd(self.cwd +'/'+ 'traces/adj')
        for iproc in range(PAR.NPROC):
            for channel in ['x', 'y', 'z']:
                src = '%d_d%s_SU.adj' % (iproc, PAR.CHANNELS[0])
                dst = '%d_d%s_SU.adj' % (iproc, channel)
                if not exists(dst):
                    unix.cp(src, dst)
开发者ID:PrincetonUniversity,项目名称:seisflows,代码行数:18,代码来源:specfem3d.py


示例9: initialize_adjoint_traces

    def initialize_adjoint_traces(self):
        super(specfem2d, self).initialize_adjoint_traces()

        # work around SPECFEM2D's use of different name conventions for
        # regular traces and 'adjoint' traces
        if PAR.FORMAT in ['SU', 'su']:
            files = glob('traces/adj/*.su')
            unix.rename('.su', '.su.adj', files)

        # work around SPECFEM2D's requirement that all components exist,
        # even ones not in use
        if PAR.FORMAT in ['SU', 'su']:
            unix.cd(self.cwd +'/'+ 'traces/adj')
            for channel in ['x', 'y', 'z', 'p']:
                src = 'U%s_file_single.su.adj' % PAR.CHANNELS[0]
                dst = 'U%s_file_single.su.adj' % channel
                if not exists(dst):
                    unix.cp(src, dst)
开发者ID:PrincetonUniversity,项目名称:seisflows,代码行数:18,代码来源:specfem2d.py


示例10: generate_mesh

    def generate_mesh(self, model_path=None, model_name=None, model_type='gll'):
        """ Performs meshing and database generation
        """
        assert(model_name)
        assert(model_type)

        self.initialize_solver_directories()
        unix.cd(self.cwd)

        assert(exists(model_path))
        self.check_mesh_properties(model_path)

        src = glob(join(model_path, '*'))
        dst = join(self.cwd, 'DATA')
        unix.cp(src, dst)

        if self.taskid == 0:
            self.export_model(PATH.OUTPUT +'/'+ model_name)
开发者ID:PrincetonUniversity,项目名称:seisflows,代码行数:18,代码来源:specfem2d.py


示例11: setup

    def setup(self):
        """ Perform setup. Generates synthetic observed data.
        """

        # clean up solver directories
        unix.rm(self.getpath)
        self.initialize_solver_directories()

        if PATH.DATA:
            # copy data to scratch dirs
            src = glob(PATH.DATA +'/'+ basename(self.getpath) +'/'+ '*')
            dst = 'traces/obs/'
            unix.cp(src, dst)

        else:
            # generate data on the fly
            output_dir = join(self.getpath, 'traces', 'obs')
            self.generate_data(model_dir=PATH.MODEL_TRUE, output_dir=output_dir)
开发者ID:gianmatharu,项目名称:seisflows-research,代码行数:18,代码来源:ewf2d.py


示例12: generate_mesh

    def generate_mesh(self, model_path=None, model_name=None, model_type='gll'):
        """ Performs meshing and database generation
        """
        assert(model_name)
        assert(model_type)

        self.initialize_solver_directories()
        unix.cd(self.getpath)

        if model_type == 'gll':
            assert (exists(model_path))
            self.check_mesh_properties(model_path)

            unix.cp(glob(model_path +'/'+ '*'), self.model_databases)

            self.mpirun('bin/xmeshfem3D')
            self.export_model(PATH.OUTPUT +'/'+ model_name)

        else:
            raise NotImplementedError
开发者ID:yanhuay,项目名称:seisflows,代码行数:20,代码来源:specfem3d_globe.py


示例13: generate_data

    def generate_data(self, model_dir=PATH.MODEL_TRUE, output_dir='', save_wavefield=False):
        """ Generate dataset. Defaults to generating synthetic data for true model.
        """

        # get task number
        itask = system.getnode()

        # set par.cfg file for solver
        self.set_par_cfg(external_model_dir=model_dir, output_dir=output_dir, save_forward_wavefield=save_wavefield)

        # set src.cfg for solver
        xsrc = self.sources[itask][0]
        zsrc = self.sources[itask][1]
        self.set_src_cfg(xs=float(xsrc), zs=float(zsrc))

        # copy cfg files
        unix.cp(join(self.getpath, 'INPUT', 'par.cfg'), output_dir)
        unix.cp(join(self.getpath, 'INPUT', 'src.cfg'), output_dir)

        # run forward sim
        self.forward()
开发者ID:gianmatharu,项目名称:seisflows-research,代码行数:21,代码来源:ewf2d.py


示例14: initialize_solver_directories

    def initialize_solver_directories(self):
        """ Initialize solver directories.
        """
        unix.mkdir(self.getpath)
        unix.cd(self.getpath)

        # create directory structure
        unix.mkdir('INPUT')
        unix.mkdir('bin')

        unix.mkdir('traces/obs')
        unix.mkdir('traces/syn')
        unix.mkdir('traces/adj')

        # copy exectuables
        src = glob(join(PATH.SOLVER_BIN, '*'))
        dst = 'bin/'
        unix.cp(src, dst)

        # copy input files
        src = glob(join(PATH.SOLVER_INPUT, '*'))
        dst = 'INPUT/'
        unix.cp(src, dst)
开发者ID:gianmatharu,项目名称:seisflows-research,代码行数:23,代码来源:ewf2d.py


示例15: generate_precond

    def generate_precond(self, process_traces=None, model_path=None, model_name=None, model_type='gll'):
        assert(model_name)
        assert(model_type)
        assert (exists(model_path))

        self.initialize_solver_directories()
        unix.cd(self.getpath)

        assert(exists(model_path))
        self.check_mesh_properties(model_path)

        src = model_path
        dst = join(self.getpath, 'DATA/proc000000_rho_vp_vs.dat')
        unix.cp(src, dst)

        self.export_model(PATH.OUTPUT +'/'+ model_name)

        self.forward()
        unix.mv(self.data_wildcard, 'traces/syn')
        self.initialize_adjoint_traces('traces/syn')
        process_traces(self.getpath)

        self.adjoint()
        self.export_kernels(PATH.GLOBAL)
开发者ID:iceseismic,项目名称:seisflows,代码行数:24,代码来源:specfem2d_legacy.py


示例16: initialize_solver_directories

    def initialize_solver_directories(self):
        """ Creates directory structure expected by SPECFEM3D, copies 
          executables, and prepares input files. Executables must be supplied 
          by user as there is currently no mechanism for automatically
          compiling from source.
        """
        unix.mkdir(self.getpath)
        unix.cd(self.getpath)

        # create directory structure
        unix.mkdir('bin')
        unix.mkdir('DATA')
        unix.mkdir('OUTPUT_FILES')

        unix.mkdir('traces/obs')
        unix.mkdir('traces/syn')
        unix.mkdir('traces/adj')

        unix.mkdir(self.model_databases)
        unix.mkdir(self.kernel_databases)

        # copy exectuables
        src = glob(PATH.SPECFEM_BIN +'/'+ '*')
        dst = 'bin/'
        unix.cp(src, dst)

        # copy input files
        src = glob(PATH.SPECFEM_DATA +'/'+ '*')
        dst = 'DATA/'
        unix.cp(src, dst)

        src = 'DATA/' + self.source_prefix +'_'+ basename(self.getpath)
        dst = 'DATA/' + self.source_prefix
        unix.cp(src, dst)

        self.check_solver_parameter_files()
开发者ID:gianmatharu,项目名称:seisflows-research,代码行数:36,代码来源:base.py


示例17: save_traces

 def save_traces(self):
     src = PATH.GLOBAL +'/'+ 'traces'
     dst = PATH.OUTPUT
     unix.cp(src, dst)
开发者ID:iceseismic,项目名称:seisflows,代码行数:4,代码来源:migration.py


示例18: save_kernels

 def save_kernels(self):
     src = PATH.GLOBAL +'/'+ 'kernels'
     dst = PATH.OUTPUT
     unix.mkdir(dst)
     unix.cp(src, dst)
开发者ID:iceseismic,项目名称:seisflows,代码行数:5,代码来源:migration.py


示例19: save_kernels_sum

 def save_kernels_sum(self):
     src = PATH.GLOBAL +'/'+ 'kernels/sum'
     dst = PATH.OUTPUT +'/'+ 'kernels'
     unix.mkdir(dst)
     unix.cp(src, dst)
开发者ID:iceseismic,项目名称:seisflows,代码行数:5,代码来源:migration.py


示例20: prepare_model

 def prepare_model(self):
     model = PATH.OUTPUT +'/'+ 'model_init'
     assert exists(model)
     unix.cp(model, PATH.GLOBAL +'/'+ 'model')
开发者ID:iceseismic,项目名称:seisflows,代码行数:4,代码来源:migration.py



注:本文中的seisflows.tools.unix.cp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python unix.mkdir函数代码示例发布时间:2022-05-27
下一篇:
Python unix.cd函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap