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

Python unix.mkdir函数代码示例

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

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



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

示例1: smooth

    def smooth(self, input_path='', output_path='', parameters=[], span=0.):
        """ Smooths kernels by convolving them with a Gaussian.  Wrapper over 
            xsmooth_sem utility.
        """
        if not exists(input_path):
            raise Exception

        if not exists(output_path):
            unix.mkdir(output_path)

        # apply smoothing operator
        unix.cd(self.cwd)
        for name in parameters or self.parameters:
            print ' smoothing', name
            call_solver(
                system.mpiexec(),
                PATH.SPECFEM_BIN +'/'+ 'xsmooth_sem '
                + str(span) + ' '
                + str(span) + ' '
                + name + '_kernel' + ' '
                + input_path + '/ '
                + output_path + '/ ',
                output='/dev/null')

        print ''

        # rename output files
        files = glob(output_path+'/*')
        unix.rename('_smooth', '', files)
开发者ID:PrincetonUniversity,项目名称:seisflows,代码行数:29,代码来源:base.py


示例2: _launch

    def _launch(self, classname, funcname, hosts='all'):
        unix.mkdir(PATH.SYSTEM)

        with open(PATH.SYSTEM+'/'+'job_id', 'w') as f:
            subprocess.call('sbatch '
                + '%s ' % PAR.SLURMARGS
                + '--job-name=%s ' % PAR.TITLE
                + '--nodes=%d ' % math.ceil(PAR.NPROC/float(PAR.NODESIZE))
                + '--ntasks-per-node=%d ' % PAR.NODESIZE
                + '--ntasks=%d ' % PAR.NPROC
                + '--time=%d ' % PAR.STEPTIME
                + self._launch_args(hosts)
                + findpath('seisflows.system') +'/'+ 'wrappers/run '
                + PATH.OUTPUT + ' '
                + classname + ' '
                + funcname + ' ',
                shell=1,
                stdout=f)

        # retrieve job ids
        with open(PATH.SYSTEM+'/'+'job_id', 'r') as f:
            line = f.readline()
            job = line.split()[-1].strip()
        if hosts == 'all' and PAR.NTASK > 1:
            return [job+'_'+str(ii) for ii in range(PAR.NTASK)]
        else:
            return [job]
开发者ID:yanhuay,项目名称:seisflows,代码行数:27,代码来源:slurm_lg.py


示例3: apply_hessian

    def apply_hessian(self, m, dm, h):
        """ Computes the action of the Hessian on a given vector through
          solver calls
        """
        system = sys.modules['seisflows_system']
        solver = sys.modules['seisflows_solver']
        postprocess = sys.modules['seisflows_postprocess']

        self.save('m_lcg', m + h*dm)

        solver.save(solver.split(m + h*dm), 
                PATH.HESS+'/'+'model')

        system.run('optimize', 'apply_hess',
                path=PATH.HESS)

        postprocess.write_gradient(
                path=PATH.HESS)

        self.save('g_lcg', solver.merge(solver.load(
                PATH.HESS+'/'+'gradient', suffix='_kernel')))

        # uncomment for debugging
        #if True:
        #    unix.rm(PATH.HESS+'_debug')
        #    unix.mv(PATH.HESS, PATH.HESS+'_debug')
        #    unix.mkdir(PATH.HESS)

        unix.rm(PATH.HESS)
        unix.mkdir(PATH.HESS)

        return self.hessian_product(h)
开发者ID:gianmatharu,项目名称:seisflows,代码行数:32,代码来源:newton.py


示例4: save

    def save(self, dict, path, parameters=['vp','vs','rho'],
             prefix='', suffix=''):
        """ 
          Saves SPECFEM2D/3D models or kernels

          :input dict :: model stored as a dictionary or Container
          :input path :: directory to which model is written
          :input parameters :: list of material parameters to be written
          :input prefix :: optional filename prefix
          :input suffix :: optional filename suffix, eg '_kernel'
        """
        unix.mkdir(path)

        # fill in any missing parameters
        missing_keys = diff(parameters, dict.keys())
        for iproc in range(self.mesh_properties.nproc):
            for key in missing_keys:
                dict[key] += self.io.read_slice(
                    PATH.MODEL_INIT, prefix+key+suffix, iproc)

        # write slices to disk
        for iproc in range(self.mesh_properties.nproc):
            for key in parameters:
                self.io.write_slice(
                    dict[key][iproc], path, prefix+key+suffix, iproc)
开发者ID:PrincetonUniversity,项目名称:seisflows,代码行数:25,代码来源:base.py


示例5: combine

    def combine(self, input_path='', output_path='', parameters=[]):
        """ Sums individual source contributions. Wrapper over xcombine_sem
            utility.
        """
        if not exists(input_path):
            raise Exception

        if not exists(output_path):
            unix.mkdir(output_path)

        unix.cd(self.cwd)

        names = self.check_source_names()
        subset = [names[isrc] for isrc in self._source_subset]

        with open('kernel_paths', 'w') as f:
            f.writelines([join(input_path, dir)+'\n' for dir in subset])

        # SAGA component - include contributions from reference gradient
        remainder = list(set(self._source_names) - set(subset))

        with open('kernel_paths', 'a') as f:
            f.writelines([join(PATH.GRAD_AGG, dir)+'\n' for dir in remainder])

        for name in parameters or self.parameters:
            call_solver(
                system.mpiexec(),
                PATH.SPECFEM_BIN +'/'+ 'xcombine_sem '
                + name + '_kernel' + ' '
                + 'kernel_paths' + ' '
                + output_path)
开发者ID:gianmatharu,项目名称:seisflows,代码行数:31,代码来源:stochastic_saga.py


示例6: submit

    def submit(self, workflow):
        """Submits job
        """
        unix.mkdir(PATH.OUTPUT)
        unix.cd(PATH.OUTPUT)

        # save current state
        self.checkpoint()

        # construct resource list
        nodes = int(PAR.NTASK / PAR.NODESIZE)
        cores = PAR.NTASK % PAR.NODESIZE
        hours = int(PAR.WALLTIME / 60)
        minutes = PAR.WALLTIME % 60
        resources = 'walltime=%02d:%02d:00'%(hours, minutes)
        if nodes == 0:
            resources += ',mem=%dgb,nodes=1:ppn=%d'%(PAR.MEMORY, cores)
        elif cores == 0:
            resources += ',mem=%dgb,nodes=%d:ppn=%d'%(PAR.MEMORY, nodes, PAR.NODESIZE)
        else:
            resources += ',mem=%dgb,nodes=%d:ppn=%d+1:ppn=%d'%(PAR.MEMORY, nodes, PAR.NODESIZE, cores)

        # construct arguments list
        unix.run('qsub '
                + '-N %s '%PAR.TITLE
                + '-o %s '%(PATH.SUBMIT +'/'+ 'output.log')
                + '-l %s '%resources
                + '-j %s '%'oe'
                + findpath('system') +'/'+ 'wrappers/submit '
                + '-F %s '%PATH.OUTPUT)
开发者ID:gianmatharu,项目名称:seisflows-research,代码行数:30,代码来源:pbs_wg.py


示例7: save

 def save(self, path):
     """ Save objects to disk for later reference
     """
     fullpath = self.fullpath(path)
     unix.mkdir(fullpath)
     for key in self.objects:
         saveobj(fullpath +'/'+ key+'.p', sys.modules[key])
开发者ID:iceseismic,项目名称:seisflows,代码行数:7,代码来源:config.py


示例8: submit

    def submit(self, workflow):
        """ Submits workflow
        """
        unix.mkdir(PATH.OUTPUT)
        unix.cd(PATH.OUTPUT)
        unix.mkdir(PATH.SUBMIT+'/'+'output.pbs')

        self.checkpoint()

        hours = PAR.WALLTIME/60
        minutes = PAR.WALLTIME%60
        walltime = 'walltime=%02d:%02d:00 ' % (hours, minutes)

        ncpus = PAR.NODESIZE
        mpiprocs = PAR.NODESIZE

        # prepare qsub arguments
        unix.run( 'qsub '
                + '%s ' % PAR.PBSARGS
                + '-l select=1:ncpus=%d:mpiprocs=%d ' % (ncpus, mpiprocs)
                + '-l %s ' % walltime
                + '-N %s ' % PAR.TITLE
                + '-j %s '%'oe'
                + '-o %s ' % (PATH.SUBMIT+'/'+'output.log')
                + '-V '
                + ' -- ' + findpath('seisflows.system') +'/'+ 'wrappers/submit '
                + PATH.OUTPUT)
开发者ID:yanhuay,项目名称:seisflows,代码行数:27,代码来源:pbs_lg.py


示例9: save

 def save(self, path):
     """ Save objects to disk for later reference
     """
     unix.mkdir(_full(path))
     for name in self.names:
         fullfile = join(_full(path), name+'.p')
         saveobj(fullfile, sys.modules[name])
开发者ID:HongjianFang,项目名称:seisflows,代码行数:7,代码来源:config.py


示例10: launch

    def launch(self, classname, funcname, hosts='all'):
        unix.mkdir(PATH.SYSTEM)

        # submit job
        with open(PATH.SYSTEM+'/'+'job_id', 'w') as f:
            subprocess.call('bsub '
                + '%s ' % PAR.LSFARGS
                + '-n %d ' % PAR.NPROC 
                + '-R "span[ptile=%d]" ' % PAR.NODESIZE
                + '-W %d:00 ' % PAR.STEPTIME
                + '-J "%s' %PAR.TITLE
                + self.launch_args(hosts)
                + findpath('seisflows.system') +'/'+ 'wrapper/run '
                + PATH.OUTPUT + ' '
                + classname + ' '
                + funcname + ' ',
                shell=True,
                stdout=f)

        # retrieve job ids
        with open(PATH.SYSTEM+'/'+'job_id', 'r') as f:
            # reads one entire line from the file
            line = f.readline()
            job_buf = line.split()[1].strip()
            job = job_buf[1:-1]
        if hosts == 'all' and PAR.NSRC > 1:
            nn = range(1,PAR.NSRC+1)
            #return [job+'_'+str(ii) for ii in nn]
            return [job+'['+str(ii)+']' for ii in nn]
        else:
            return [job]
开发者ID:yanhuay,项目名称:seisflows,代码行数:31,代码来源:lsf_lg.py


示例11: 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


示例12: 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


示例13: 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


示例14: 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


示例15: 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


示例16: _launch

    def _launch(self, classname, funcname, hosts='all'):
        unix.mkdir(PATH.SYSTEM)

        # submit job
        with open(PATH.SYSTEM+'/'+'job_id', 'w') as f:
            hours = PAR.WALLTIME/60
            minutes = PAR.WALLTIME%60
            resources = 'walltime=%02d:%02d:00 '%(hours, minutes)
            args = ('/opt/pbs/12.1.1.131502/bin/qsub '
                + '-l select=1:ncpus=32:mpiprocs=32 '
                + '-l %s '%resources
                + '-q standard '
                + '-A ERDCH38424KSC '
                + '-J 0-%s ' % PAR.NTASK
                + '-N %s ' % PAR.TITLE
                + ' -- ' + findpath('system') +'/'+ 'wrappers/runpbsdsh '
                + PATH.OUTPUT + ' '
                + classname + ' '
                + funcname + ' ')

            subprocess.call(args, shell=1, stdout=f)

        # retrieve job ids
        with open(PATH.SYSTEM+'/'+'job_id', 'r') as f:
            line = f.readline()
            job = line.split()[-1].strip()
        if hosts == 'all' and PAR.NTASK > 1:
            nn = range(PAR.NTASK)
            return [job+'_'+str(ii) for ii in nn]
        else:
            return [job]
开发者ID:AlainPlattner,项目名称:seisflows,代码行数:31,代码来源:pbs_lg.py


示例17: setup

    def setup(self):
        """ Sets up nonlinear optimization machinery
        """
        unix.mkdir(PATH.OPTIMIZE)

        # prepare output writers
        self.writer = Writer(path=PATH.OUTPUT)

        self.stepwriter = StepWriter(path=PATH.SUBMIT)

        # prepare algorithm machinery
        if PAR.SCHEME in ["NLCG"]:
            self.NLCG = NLCG(path=PATH.OPTIMIZE, maxiter=PAR.NLCGMAX, thresh=PAR.NLCGTHRESH, precond=self.precond)

        elif PAR.SCHEME in ["LBFGS"]:
            self.LBFGS = LBFGS(
                path=PATH.OPTIMIZE,
                memory=PAR.LBFGSMEM,
                maxiter=PAR.LBFGSMAX,
                thresh=PAR.LBFGSTHRESH,
                precond=self.precond,
            )

        # write initial model
        if exists(PATH.MODEL_INIT):
            src = PATH.MODEL_INIT
            dst = join(PATH.OPTIMIZE, "m_new")
            savenpy(dst, solver.merge(solver.load(src)))
开发者ID:iceseismic,项目名称:seisflows,代码行数:28,代码来源:base.py


示例18: submit

    def submit(self, workflow):
        """Submits job
        """
        unix.mkdir(PATH.OUTPUT)
        unix.cd(PATH.OUTPUT)

        # save current state
        self.checkpoint()

        # construct resource list
        nodes = PAR.NTASK/PAR.NODESIZE
        cores = PAR.NTASK%PAR.NODESIZE
        hours = PAR.WALLTIME/60
        minutes = PAR.WALLTIME%60
        resources = 'walltime=%02d:%02d:00 '%(hours, minutes)
        if nodes == 0:
            resources += ',nodes=1:ppn=%d'%cores
        elif cores == 0:
            resources += ',nodes=%d:ppn=16'%nodes
        else:
            resources += ',nodes=%d:ppn=16+1:ppn=%d'%(nodes, cores)

        # construct arguments list
        unix.run('qsub '
                + '-N %s '%PAR.TITLE
                + '-o %s '%(PATH.SUBMIT +'/'+ 'output.log')
                + '-l %s '%resources
                + '-j %s '%'oe'
                + findpath('system') +'/'+ 'pbs/wrapper_qsub '
                + PATH.OUTPUT,
                shell=True)
开发者ID:iceseismic,项目名称:seisflows,代码行数:31,代码来源:pbs_sm.py


示例19: checkpoint

 def checkpoint(self, path, classname, method, args, kwargs):
     """ Writes information to disk so tasks can be executed remotely
     """
     argspath = join(path, 'kwargs')
     argsfile = join(argspath, classname+'_'+method+'.p')
     unix.mkdir(argspath)
     saveobj(argsfile, kwargs)
     save()
开发者ID:PrincetonUniversity,项目名称:seisflows,代码行数:8,代码来源:base.py


示例20: write_gradient

    def write_gradient(self, path):
        """ Reads kernels and writes gradient of objective function
        """
        if not exists(path):
            unix.mkdir(path)

        self.combine_kernels(path, solver.parameters)
        self.process_kernels(path, solver.parameters)
开发者ID:gianmatharu,项目名称:seisflows-research,代码行数:8,代码来源:ewf2d.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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