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

Python mlabraw.eval函数代码示例

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

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



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

示例1: runAceCorrect

def runAceCorrect(imgdict,params):
        imgname = imgdict['filename']
        imgpath = os.path.join(imgdict['session']['image path'], imgname+'.mrc')

        voltage = (imgdict['scope']['high tension'])
        apix    = apDatabase.getPixelSize(imgdict)

        ctfvalues, conf = ctfdb.getBestCtfValueForImage(imgdict)

        ctdimname = imgname
        ctdimpath = os.path.join(params['rundir'],ctdimname)
        print "Corrected Image written to " + ctdimpath

        #pdb.set_trace()
        acecorrectcommand=("ctfcorrect1('%s', '%s', '%.32f', '%.32f', '%f', '%f', '%f');" % \
                (imgpath, ctdimpath, ctfvalues['defocus1'], ctfvalues['defocus2'], -ctfvalues['angle_astigmatism'], voltage, apix))
        print acecorrectcommand
        try:
                matlab = pymat.open("matlab -nosplash")
        except:
                apDisplay.environmentError()
                raise
        pymat.eval(matlab, acecorrectcommand)
        pymat.close(matlab)

        return
开发者ID:kraftp,项目名称:Leginon-Feature-Detection-Modification,代码行数:26,代码来源:apMatlab.py


示例2: _get_part

 def _get_part(self, to_get):
     if self._mlabwrap._var_type(to_get) in self._mlabwrap._mlabraw_can_convert:
         #!!! need assignment to TMP_VAL__ because `mlabraw.get` only works
         # with 'atomic' values like ``foo`` and not e.g. ``foo.bar``.
         mlabraw.eval(self._mlabwrap._session, "TMP_VAL__=%s" % to_get)
         return self._mlabwrap._get('TMP_VAL__', remove=True)
     return type(self)(self._mlabwrap, to_get, self)
开发者ID:hiroshiban,项目名称:Mcalibrator2,代码行数:7,代码来源:mlabwrap.py


示例3: __init__

 def __init__(self, display = False):
     import mlabraw
     if display:
         self.handle = mlabraw.open("matlab -logfile /tmp/matlablog")       
     else:
         self.handle = mlabraw.open("matlab -nodesktop -nodisplay -nojvm -logfile /tmp/matlablog")       
     mlabraw.eval(self.handle, "addpath('%s');"%os.path.join(os.path.dirname(lfd.__file__), "matlab"))
开发者ID:benkehoe,项目名称:python,代码行数:7,代码来源:registration_matlab.py


示例4: _get_values

 def _get_values(self, varnames):
     if not varnames: raise ValueError("No varnames") #to prevent clear('')
     res = []
     for varname in varnames:
         res.append(self._get(varname))
     mlabraw.eval(self._session, "clear('%s');" % "','".join(varnames)) #FIXME wrap try/finally?
     return res
开发者ID:hiroshiban,项目名称:Mcalibrator2,代码行数:7,代码来源:mlabwrap.py


示例5: _var_type

 def _var_type(self, varname):
     mlabraw.eval(self._session,
                  "TMP_CLS__ = class(%(x)s); if issparse(%(x)s),"
                  "TMP_CLS__ = [TMP_CLS__,'-sparse']; end;" % dict(x=varname))
     res_type = mlabraw.get(self._session, "TMP_CLS__")
     mlabraw.eval(self._session, "clear TMP_CLS__;") # unlikely to need try/finally to ensure clear
     return res_type
开发者ID:hiroshiban,项目名称:Mcalibrator2,代码行数:7,代码来源:mlabwrap.py


示例6: _get

    def _get(self, name, remove=False):
        r"""Directly access a variable in matlab space. 

        This should normally not be used by user code."""
        # FIXME should this really be needed in normal operation?
        if name in self._proxies: return self._proxies[name]
        varname = name
        vartype = self._var_type(varname)
        if vartype in self._mlabraw_can_convert:
            var = mlabraw.get(self._session, varname)
            if isinstance(var, ndarray):
                if var.shape:
                  if self._flatten_row_vecs and numpy.shape(var)[0] == 1:
                      var.shape = var.shape[1:2]
                  elif len(var.shape) > 1 and self._flatten_col_vecs and numpy.shape(var)[1] == 1:
                      var.shape = var.shape[0:1]
                if self._array_cast:
                    var = self._array_cast(var)
        else:
            var = None
            if self._dont_proxy.get(vartype):
                # manual conversions may fail (e.g. for multidimensional
                # cell arrays), in that case just fall back on proxying.
                try:
                    var = self._manually_convert(varname, vartype)
                except MlabConversionError: pass
            if var is None:
                # we can't convert this to a python object, so we just
                # create a proxy, and don't delete the real matlab
                # reference until the proxy is garbage collected
                var = self._make_proxy(varname)
        if remove:
            mlabraw.eval(self._session, "clear('%s');" % varname)
        return var
开发者ID:hiroshiban,项目名称:Mcalibrator2,代码行数:34,代码来源:mlabwrap.py


示例7: _get

 def _get(self, name, remove=False):
     varname = name
     vartype = self._var_type(varname)
     if vartype in self._mlabraw_can_convert:
         var = mlabraw.get(self._session, varname)
         if type(var) is Numeric.ArrayType:
             if self._flatten_row_vecs and Numeric.shape(var)[0] == 1:
                 var.shape = var.shape[1:2]
             elif self._flatten_col_vecs and Numeric.shape(var)[1] == 1:
                 var.shape = var.shape[0:1]
             if self._array_cast:
                 var = self._array_cast(var)
     else:
         var = None
         if self._optionally_convert.get(vartype):
             # manual conversions may fail (e.g. for multidimensional
             # cell arrays), in that case just fall back on proxying.
             try:
                 var = self._manually_convert(varname, vartype)
             except MlabConversionError: pass
         if var is None:
             # we can't convert this to a python object, so we just
             # create a proxy, and don't delete the real matlab
             # reference until the proxy is garbage collected
             var = self._make_proxy(varname)
     if remove:
         mlabraw.eval(self._session, "clear('%s');" % varname)
     return var
开发者ID:bh0085,项目名称:programming,代码行数:28,代码来源:mlabwraptester.py


示例8: eval_code

 def eval_code(self, builder):
     self.builder = builder
 
     #should get a list of func names
     func_names = []
     for program in builder.project:
         print program.summary()
         #flatten tree and find Func.names
         nodes = program.flatten(False, False, False)
         for node in nodes:
             if node.cls == "Func":
                 func_names.append(node.name)
     
     #print func_names
     self.func_names = func_names
     self.called_func_names = []
     
     #check if main
     func = builder[0][1][0]
     
     if func.name == 'main':
         code_block = func[3]
     
         #evaluate, recursive function
         self._evaluate(code_block)
         mlabraw.eval(self.session, 'whos_f')
     else:
         print 'matlab have to run script file'
开发者ID:KeeganRen,项目名称:matlab2cpp,代码行数:28,代码来源:mwrapmat.py


示例9: get3d

def get3d(handle, name):
    mlabraw.eval(handle, """
    flat_array = %s(:);
    shape = size(%s);
    """%(name, name))
    flat_array = mlabraw.get(handle, "flat_array")
    shape = map(int, mlabraw.get(handle, "shape").flat)
    return np.ndarray(buffer = flat_array, shape = shape, order="F")
开发者ID:benkehoe,项目名称:python,代码行数:8,代码来源:registration_matlab.py


示例10: transform_points

 def transform_points(self, points):
     
     mlabraw.put(self.handle, "points", points)
     mlabraw.eval(self.handle,"""
     points_result = tps_eval(points, params);        
     """)
     points_result = mlabraw.get(self.handle, "points_result")
     return points_result
开发者ID:benkehoe,项目名称:python,代码行数:8,代码来源:registration_matlab.py


示例11: _set

    def _set(self, name, value):
        r"""Directly set a variable `name` in matlab space to `value`.
        
        This should normally not be used in user code."""
        if isinstance(value, MlabObjectProxy):
            mlabraw.eval(self._session, "%s = %s;" % (name, value._name))
        else:
##             mlabraw.put(self._session, name, self._as_mlabable_type(value))
            mlabraw.put(self._session, name, value)
开发者ID:hiroshiban,项目名称:Mcalibrator2,代码行数:9,代码来源:mlabwrap.py


示例12: branch_points

def branch_points(bw):
    initialize()
    mlabraw.put(MATLAB, "bw",bw)
    mlabraw.eval(MATLAB, """
    bp = bwmorph(bw,'branchpoints')
    bp_d = double(bp);
    """)
    bp_d = mlabraw.get(MATLAB, "bp_d")
    bp =  bp_d.astype('uint8')
    return bp
开发者ID:ankush-me,项目名称:python,代码行数:10,代码来源:mlabraw_image_processing.py


示例13: fit_transformation

 def fit_transformation(self, points0, points1):
     assert len(points0) == len(points1)
     mlabraw.put(self.handle, "points0", points0)
     mlabraw.put(self.handle, "points1", points1)
     
     mlabraw.eval(self.handle, """
     opts = opts_fit;
     opts.reg = .01;
     params = tps_fit(points0, points1, opts);
     save('/tmp/after_fitting.mat');
     """)                
开发者ID:benkehoe,项目名称:python,代码行数:11,代码来源:registration_matlab.py


示例14: _make_proxy

    def _make_proxy(self, varname, parent=None, constructor=MlabObjectProxy):
        """Creates a proxy for a variable.

        XXX create and cache nested proxies also here.
        """
        proxy_val_name = "PROXY_VAL%d__" % self._proxy_count
        self._proxy_count += 1
        mlabraw.eval(self._session, "%s = %s;" % (proxy_val_name, varname))
        res = constructor(self, proxy_val_name, parent)
        self._proxies[proxy_val_name] = res
        return res
开发者ID:kevin-keraudren,项目名称:mlabwrap,代码行数:11,代码来源:__init__.py


示例15: _set

    def _set(self, name, value):
        r"""Directly set a variable `name` in matlab space to `value`.
        
        This should normally not be used in user code."""
        if isinstance(value, MlabObjectProxy):
            mlabraw.eval(self._session, "%s = %s;" % (name, value._name))
        else:
##             mlabraw.put(self._session, name, self._as_mlabable_type(value))

            if isinstance(value, numpy.ndarray):
                value = value.copy() # XXX: mlabraw seems to badly handle strides.
            mlabraw.put(self._session, name, value)
开发者ID:jtaylor,项目名称:mlabwrap,代码行数:12,代码来源:mlabwrap.py


示例16: _var_type

    def _var_type(self, varname):
        """Ask matlab what the type of varname is.

        :param varname: string variable
        :return: string type, e.g. ``double`` or ``char``.
        """

        mlabraw.eval(self._session,
                     "TMP_CLS__ = class(%(x)s); if issparse(%(x)s),"
                     "TMP_CLS__ = [TMP_CLS__,'-sparse']; end;" % dict(x=varname))
        res_type = mlabraw.get(self._session, "TMP_CLS__")
        mlabraw.eval(self._session, "clear TMP_CLS__;") # unlikely to need try/finally to ensure clear
        return res_type
开发者ID:patricksnape,项目名称:mlabwrap-purepy,代码行数:13,代码来源:mlabwrap.py


示例17: setScopeParams

def setScopeParams(matlab,params):
        tempdir = params['tempdir']+"/"
        if os.path.isdir(tempdir):
                plist = (params['kv'],params['cs'],params['apix'],tempdir)
                acecmd1 = makeMatlabCmd("setscopeparams(",");",plist)
                pymat.eval(matlab,acecmd1)

                plist = (params['kv'],params['cs'],params['apix'])
                acecmd2 = makeMatlabCmd("scopeparams = [","];",plist)
                pymat.eval(matlab,acecmd2)

        else:
                apDisplay.printError("Temp directory, '"+params['tempdir']+"' not present.")
        return
开发者ID:kraftp,项目名称:Leginon-Feature-Detection-Modification,代码行数:14,代码来源:apMatlab.py


示例18: onRunParamGUI

    def onRunParamGUI(self, evt):
        # added for GUI parametrization:

        self.handle = pymat.open()

        d, f = os.path.split(self.widgets["parametergui path"].GetValue())  # self.settings['parametergui path'])

        if d:
            pymat.eval(self.handle, "path(path, '%s')" % d)

        if not f[:-2]:
            raise RuntimeError

        pymat.eval(self.handle, "%s" % f[:-2])
开发者ID:spartango,项目名称:LeginonSpots,代码行数:14,代码来源:MatlabTargetFinder.py


示例19: transform_poses

    def transform_poses(self, points, rots):
        mlabraw.put(self.handle, "points", points)                
        put3d(self.handle, "rots", rots)
        
        mlabraw.eval(self.handle,"""
        [points_result, rots_result] = tps_eval_frames(points, rots, params);
        """)
        points_result = mlabraw.get(self.handle,"points_result")
        rots_result = get3d(self.handle, "rots_result")
        
        return points_result, rots_result


        
开发者ID:benkehoe,项目名称:python,代码行数:11,代码来源:registration_matlab.py


示例20: testRawMlabraw

    def testRawMlabraw(self):
        """A few explicit tests for mlabraw"""
        import mlabraw
        #print "test mlabraw"
        self.assertRaises(TypeError, mlabraw.put, 33, 'a', 1)
        self.assertRaises(TypeError, mlabraw.get, object(), 'a')
        self.assertRaises(TypeError, mlabraw.eval, object(), '1')

        # -100 is picked kinda arbitrarily to account for internal "overhead";
        # I don't want to hardcode the exact value; users can assume 1000
        # chars is safe
        mlabraw.eval(mlab._session, '1' * (BUFSIZE - 100))
        assert numpy.inf == mlabraw.get(mlab._session, 'ans');
        # test for buffer overflow detection
        self.assertRaises(Exception, mlabraw.eval, mlab._session, '1' * BUFSIZE)
开发者ID:jtaylor,项目名称:mlabwrap,代码行数:15,代码来源:test_mlabwrap.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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