当前位置: 首页>>代码示例>>Python>>正文


Python DataIO.read方法代码示例

本文整理汇总了Python中cc.tools.io.DataIO.read方法的典型用法代码示例。如果您正苦于以下问题:Python DataIO.read方法的具体用法?Python DataIO.read怎么用?Python DataIO.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cc.tools.io.DataIO的用法示例。


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

示例1: __init__

# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import read [as 别名]
    def __init__(self,x,y,func,*args,**kwargs):
    
        '''
        Create an instance of the Profiler2D() class. Requires 2 coordinate 
        arrays and a function object for profile.
       
        The function can also be given as an interpolation object.
        
        The optional args and kwargs give the additional arguments for the 
        function, which are ignored in case func is an interpolation object.
        
        The default coordinate grids are both evaluated for the function. 
        They are saved in self.z, as an array of dimensions (x.size,y.size). 
        Alternatively, new evaluations can be attained through eval and diff.
        
        @param x: The default coordinates of the primary independent variable. 
                  Minimum three points.
        @type x: array
        @param y: The default coordinates of the secondary independent variable. 
                  Minimum three points.
        @type y: array
        @param func: The function that describes the profile with respect to x 
                     and y. Can be given as a 2D interpolation object.
        @type func: function/interpolation object
        
        @keyword args: Additional parameters passed to the functions when eval
                       or diff are called. 
                       
                       (default: [])
        @type args: tuple
        @keyword kwargs: Additional keywords passed to the functions when eval
                         or diff are called. 
                       
                         (default: {})
        @type kwargs: dict
        
        '''

        #-- If the function is given as a string, retrieve it from the local 
        #   child module, or from the Profiler module (as parent). If the latter
        #   check if the function comes from one of Profiler's attributes, such
        #   as the loaded DataIO module.
        if isinstance(func,str):
            try:
                #-- Note that self.module refers to the child, not Profiler
                func = getattr(sys.modules[self.__module__],func)
            except AttributeError:
                #-- Recursively find the function of loaded modules in Profiler
                #   or a function of the Profiler module itself if no '.' 
                func = DataIO.read(sys.modules[__name__],return_func=1)
                
        #-- set functional args, remember spline order. args/kwargs for 
        #   func are saved separately. They are removed if either are
        #   interpolation objects. They are always accessible, the _** variables
        #   are passed to the evaluation.
        self.args = args
        self.kwargs = kwargs
        self._args = args
        self._kwargs = kwargs
        self.func = func

        if isinstance(self.func,interp2d) \
                or isinstance(self.func,BivariateSpline):
            self.interp_func = 1
            self._args = []
            self._kwargs = {}
        else:
            self.interp_func = 0
        
        #-- Evaluate the default grid with function. Set x as None first so it
        #   can actually evaluate.
        self.x = None
        self.y = None
        self.z = self.func(x,y,*self._args,**self._kwargs)
        
        #-- Now set x and y.
        self.x = x
        self.y = y 
开发者ID:MarieVdS,项目名称:ComboCode,代码行数:80,代码来源:Profiler.py


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