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

Python unix.mv函数代码示例

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

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



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

示例1: export_kernels

    def export_kernels(self, path):
        unix.cd(self.kernel_databases)

        # work around conflicting name conventions
        files = []
        files += glob('*proc??????_alpha_kernel.bin')
        files += glob('*proc??????_alpha[hv]_kernel.bin')
        files += glob('*proc??????_reg1_alpha_kernel.bin')
        files += glob('*proc??????_reg1_alpha[hv]_kernel.bin')
        unix.rename('alpha', 'vp', files)

        files = []
        files += glob('*proc??????_beta_kernel.bin') 
        files += glob('*proc??????_beta[hv]_kernel.bin')
        files += glob('*proc??????_reg1_beta_kernel.bin')
        files += glob('*proc??????_reg1_beta[hv]_kernel.bin')
        unix.rename('beta', 'vs', files)

        # hack to deal with problems on parallel filesystem
        unix.mkdir(join(path, 'kernels'), noexit=True)

        unix.mkdir(join(path, 'kernels', basename(self.getpath)))
        src = join(glob('*_kernel.bin'))
        dst = join(path, 'kernels', basename(self.getpath))
        unix.mv(src, dst)
开发者ID:gianmatharu,项目名称:seisflows-research,代码行数:25,代码来源:base.py


示例2: export_residuals

    def export_residuals(self, path):
        # hack deals with problems on parallel filesystem
        unix.mkdir(join(path, 'residuals'), noexit=True)

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


示例3: smooth

    def smooth(self, path='', parameters='dummy', span=0. ):
        """ Smooths SPECFEM2D kernels by convolving them with a Gaussian
        """
        from seisflows.tools.array import meshsmooth, stack

        #assert parameters == self.parameters

        # implementing nproc > 1 would be straightforward, but a bit tedious
        #assert self.mesh.nproc == 1

        kernels = self.load(path, suffix='_kernel')
        if not span:
            return kernels

        # set up grid
        _,x = loadbypar(PATH.MODEL_INIT, ['x'], 0)
        _,z = loadbypar(PATH.MODEL_INIT, ['z'], 0)
        mesh = stack(x[0], z[0])

        for key in self.parameters:
            kernels[key] = [meshsmooth(kernels[key][0], mesh, span)]

        unix.rm(path + '_nosmooth')
        unix.mv(path, path + '_nosmooth')
        self.save(path, kernels, suffix='_kernel')
开发者ID:AlainPlattner,项目名称:seisflows,代码行数:25,代码来源:specfem2d.py


示例4: forward

 def forward(self):
     """ Calls SPECFEM3D_GLOBE forward solver
     """
     solvertools.setpar('SIMULATION_TYPE', '1')
     solvertools.setpar('SAVE_FORWARD', '.true.')
     self.mpirun('bin/xspecfem3D')
     unix.mv(self.data_wildcard, 'traces/syn')
开发者ID:yanhuay,项目名称:seisflows,代码行数:7,代码来源:specfem3d_globe.py


示例5: smooth

    def smooth(self, path='', parameters=[], span=0.):
        """ Smooths kernels by convolving them with a Gaussian.  Wrapper over 
            xsmooth_sem utility.
        """
        assert exists(path)
        assert len(parameters) > 0

        # apply smoothing operator
        unix.cd(self.getpath)
        for name in parameters:
            print ' smoothing', name
            self.mpirun(
                PATH.SPECFEM_BIN +'/'+ 'xsmooth_sem '
                + str(span) + ' '
                + str(span) + ' '
                + name + '_kernel' + ' '
                + path + '/ '
                + path + '/ ',
                output=self.getpath+'/'+'OUTPUT_FILES/output_smooth_sem.txt')

        print ''

        # move input files
        src = path
        dst = path + '_nosmooth'
        unix.mkdir(dst)
        for name in self.parameters:
            unix.mv(glob(src+'/*'+name+'.bin'), dst)

        # rename output files
        unix.rename('_smooth', '', glob(src+'/*'))
开发者ID:gianmatharu,项目名称:seisflows-research,代码行数:31,代码来源:base.py


示例6: clip

    def clip(self, path='', parameters=[], minval=-np.inf, maxval=np.inf):
        """ Clips kernels by convolving them with a Gaussian.  Wrapper over 
            xclip_sem utility.
        """
        assert exists(path)
        assert len(parameters) > 0

        unix.cd(self.getpath)
        for name in self.parameters:
            self.mpirun(
                PATH.SPECFEM_BIN +'/'+ 'xclip_sem '
                + str(minval) + ' '
                + str(maxval) + ' '
                + name + '_kernel' + ' '
                + path + '/ '
                + path + '/ ')

        # move input files
        src = path
        dst = path + '_noclip'
        unix.mkdir(dst)
        for name in self.parameters:
            unix.mv(glob(src+'/*'+name+'.bin'), dst)

        # rename output files
        unix.rename('_clip', '', glob(src+'/*'))
开发者ID:gianmatharu,项目名称:seisflows-research,代码行数:26,代码来源:base.py


示例7: save

    def save(self, path, v, backup=None):
        if backup:
            src = path +'/'+ 'gradient'
            dst = path +'/'+ 'gradient_'+backup
            unix.mv(src, dst)

        solver.save(path +'/'+ 'gradient',
                    solver.split(v),
                    suffix='_kernel')
开发者ID:HongjianFang,项目名称:seisflows,代码行数:9,代码来源:base.py


示例8: export_kernels

    def export_kernels(self, path):
        unix.cd(self.kernel_databases)

        # work around conflicting name conventions
        self.rename_kernels()

        src = glob('*_kernel.bin')
        dst = join(path, 'kernels', self.source_name)
        unix.mkdir(dst)
        unix.mv(src, dst)
开发者ID:PrincetonUniversity,项目名称:seisflows,代码行数:10,代码来源:base.py


示例9: clean

 def clean(self):
     isready = self.solver_status()
     if isready:
         unix.rm(PATH.GRAD)
         unix.mv(PATH.FUNC, PATH.GRAD)
         unix.mkdir(PATH.FUNC)
         unix.rm(PATH.SOLVER)
         unix.mv(PATH.SOLVER+'_best', PATH.SOLVER)
     else:
         super(thrifty_inversion, self).clean()
开发者ID:AlainPlattner,项目名称:seisflows,代码行数:10,代码来源:thrifty_inversion.py


示例10: clean

    def clean(self):
        # can forward simulations from line search be carried over?
        self.update_status()

        if self.status==1:
            unix.rm(PATH.GRAD)
            unix.mv(PATH.FUNC, PATH.GRAD)
            unix.mkdir(PATH.FUNC)
        else:
            super(thrifty_inversion, self).clean()
开发者ID:PrincetonUniversity,项目名称:seisflows,代码行数:10,代码来源:thrifty_inversion.py


示例11: forward

    def forward(self, path='traces/syn'):
        """ Calls SPECFEM3D_GLOBE forward solver
        """
        solvertools.setpar('SIMULATION_TYPE', '1')
        solvertools.setpar('SAVE_FORWARD', '.true.')
        call_solver(system.mpiexec(), 'bin/xspecfem3D')

        if PAR.FORMAT in ['ASCII', 'ascii']:
            src = glob('OUTPUT_FILES/*.sem.ascii')
            dst = path
            unix.mv(src, dst)
开发者ID:PrincetonUniversity,项目名称:seisflows,代码行数:11,代码来源:specfem3d_globe.py


示例12: update_aggregate_gradient

    def update_aggregate_gradient(self):
        """ Update stored aggregate gradient.
        """
        names = self.check_source_names()
        subset = [names[isrc] for isrc in self._source_subset]
        print subset

        for source_name in subset:
            src = glob(join(PATH.GRAD, 'kernels', source_name, '*'))
            dst = join(PATH.GRAD_AGG, source_name)
            unix.mv(src, dst)
开发者ID:gianmatharu,项目名称:seisflows,代码行数:11,代码来源:stochastic_saga.py


示例13: iterate_search

    def iterate_search(self):
        super(thrifty_inversion, self).iterate_search()

        isdone = optimize.isdone
        isready = self.solver_status()

        # to avoid redundant forward simulation, save solver files associated
        # with 'best' trial model
        if isready and isdone:
            unix.rm(PATH.SOLVER+'_best')
            unix.mv(PATH.SOLVER, PATH.SOLVER+'_best')
开发者ID:AlainPlattner,项目名称:seisflows,代码行数:11,代码来源:thrifty_inversion.py


示例14: generate_data

    def generate_data(self, **model_kwargs):
        """ Generates data
        """
        self.generate_mesh(**model_kwargs)

        unix.cd(self.getpath)
        setpar('SIMULATION_TYPE', '1')
        setpar('SAVE_FORWARD', '.true.')
        self.call('bin/xspecfem3D')

        unix.mv(self.data_wildcard, 'traces/obs')
        self.export_traces(PATH.OUTPUT, 'traces/obs')
开发者ID:HongjianFang,项目名称:seisflows,代码行数:12,代码来源:specfem3d.py


示例15: forward

    def forward(self, path='traces/syn'):
        """ Calls SPECFEM3D forward solver
        """
        setpar('SIMULATION_TYPE', '1')
        setpar('SAVE_FORWARD', '.true.')
        call_solver(system.mpiexec(), 'bin/xgenerate_databases')
        call_solver(system.mpiexec(), 'bin/xspecfem3D')

        if PAR.FORMAT in ['SU', 'su']:
            src = glob('OUTPUT_FILES/*_d?_SU')
            dst = path
            unix.mv(src, dst)
开发者ID:PrincetonUniversity,项目名称:seisflows,代码行数:12,代码来源:specfem3d.py


示例16: forward

    def forward(self, path='traces/syn'):
        """ Calls SPECFEM2D forward solver
        """
        setpar('SIMULATION_TYPE', '1')
        setpar('SAVE_FORWARD', '.true.')

        call_solver(system.mpiexec(), 'bin/xmeshfem2D')
        call_solver(system.mpiexec(), 'bin/xspecfem2D')

        if PAR.FORMAT in ['SU', 'su']:
            filenames = glob('OUTPUT_FILES/*.su')
            unix.mv(filenames, path)
开发者ID:PrincetonUniversity,项目名称:seisflows,代码行数:12,代码来源:specfem2d.py


示例17: eval_func

    def eval_func(self, path='', export_traces=False):
        """ Evaluates misfit function by carrying out forward simulation and
            comparing observations and synthetics.
        """
        unix.cd(self.getpath)
        self.import_model(path)

        self.forward()
        unix.mv(self.data_wildcard, 'traces/syn')
        preprocess.prepare_eval_grad(self.getpath)

        self.export_residuals(path)
        if export_traces:
            self.export_traces(path, prefix='traces/syn')
开发者ID:gianmatharu,项目名称:seisflows-research,代码行数:14,代码来源:base.py


示例18: clip

    def clip(self, path='', thresh=1.):
        """ Clips SPECFEM2D kernels
        """
        parts = self.load(path)
        if thresh >= 1.:
            return parts

        for key in self.parameters:
            # scale to [-1,1]
            minval = parts[key][0].min()
            maxval = parts[key][0].max()
            np.clip(parts[key][0], thresh*minval, thresh*maxval, out=parts[key][0])
        unix.mv(path, path + '_noclip')
        self.save(path, parts)
开发者ID:iceseismic,项目名称:seisflows,代码行数:14,代码来源:specfem2d_legacy.py


示例19: apply_hess

    def apply_hess(self, path=''):
        """ Computes action of Hessian on a given model vector.
        """
        # a gradient evaluation must have already been carried out
        unix.cd(self.getpath)
        unix.mkdir('traces/lcg')

        self.import_model(path)
        self.forward()
        unix.mv(self.data_wildcard, 'traces/lcg')
        preprocess.prepare_apply_hess(self.getpath)

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


示例20: finalize_search

    def finalize_search(self):
        """ Cleans working directory and writes updated model
        """
        unix.cd(PATH.OPTIMIZE)

        m = self.load("m_new")
        g = self.load("g_new")
        p = self.load("p_new")
        s = loadtxt("s_new")

        x = self.step_lens()
        f = self.func_vals()

        # clean working directory
        unix.rm("alpha")
        unix.rm("m_try")
        unix.rm("f_try")

        if self.iter > 1:
            unix.rm("m_old")
            unix.rm("f_old")
            unix.rm("g_old")
            unix.rm("p_old")
            unix.rm("s_old")

        unix.mv("m_new", "m_old")
        unix.mv("f_new", "f_old")
        unix.mv("g_new", "g_old")
        unix.mv("p_new", "p_old")
        unix.mv("s_new", "s_old")

        # write updated model
        alpha = x[f.argmin()]
        savetxt("alpha", alpha)
        self.save("m_new", m + alpha * p)
        savetxt("f_new", f.min())

        # append latest output
        self.writer("factor", -self.dot(g, g) ** -0.5 * (f[1] - f[0]) / (x[1] - x[0]))
        self.writer("gradient_norm_L1", np.linalg.norm(g, 1))
        self.writer("gradient_norm_L2", np.linalg.norm(g, 2))
        self.writer("misfit", f[0])
        self.writer("restarted", self.restarted)
        self.writer("slope", (f[1] - f[0]) / (x[1] - x[0]))
        self.writer("step_count", self.step_count)
        self.writer("step_length", x[f.argmin()])
        self.writer("theta", 180.0 * np.pi ** -1 * angle(p, -g))

        self.stepwriter.newline()
开发者ID:iceseismic,项目名称:seisflows,代码行数:49,代码来源:base.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python processor.Processor类代码示例发布时间:2022-05-27
下一篇:
Python unix.mkdir函数代码示例发布时间: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