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


Python interpolate.PchipInterpolator方法代码示例

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


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

示例1: __init__

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import PchipInterpolator [as 别名]
def __init__(self, cachedir=None, **specs):
        
        #start the outspec
        self._outspec = {}

        # cache directory
        self.cachedir = get_cache_dir(cachedir)
        self._outspec['cachedir'] = self.cachedir
        specs['cachedir'] = self.cachedir

        # load the vprint function (same line in all prototype module constructors)
        self.vprint = vprint(specs.get('verbose', True))
        
        #Define Phase Function Inverse
        betas = np.linspace(start=0.,stop=np.pi,num=1000,endpoint=True)*u.rad
        Phis = self.calc_Phi(betas)
        self.betaFunction = PchipInterpolator(-Phis,betas) #the -Phis ensure the function monotonically increases

        return 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:21,代码来源:PlanetPhysicalModel.py

示例2: calc_beta

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import PchipInterpolator [as 别名]
def calc_beta(self,Phi):
        """ Calculates the Phase angle based on the assumed planet phase function
        Args:
            Phi (float) - Phase angle function value ranging from 0 to 1
        Returns:
            beta (float) - Phase angle from 0 rad to pi rad
        """
        beta = self.betaFunction(-Phi)
        #Note: the - is because betaFunction uses -Phi when calculating the Phase Function
        #This is because PchipInterpolator used requires monotonically increasing function
        return beta 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:13,代码来源:PlanetPhysicalModel.py

示例3: interp_array

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import PchipInterpolator [as 别名]
def interp_array(arr,interp_val=10):
    x=np.arange(0, len(arr), 1)
    xx=np.arange(0, len(arr)-1, 1/interp_val)
    q=pchip(x,arr)
    return q(xx) 
开发者ID:ContextLab,项目名称:hypertools,代码行数:7,代码来源:helpers.py

示例4: repanel_current_airfoil

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import PchipInterpolator [as 别名]
def repanel_current_airfoil(self, n_points_per_side=100):
        # Returns a repaneled version of the airfoil with cosine-spaced coordinates on the upper and lower surfaces.
        # Inputs:
        #   # n_points_per_side is the number of points PER SIDE (upper and lower) of the airfoil. 100 is a good number.
        # Notes: The number of points defining the final airfoil will be n_points_per_side*2-1,
        # since one point (the leading edge point) is shared by both the upper and lower surfaces.

        upper_original_coors = self.upper_coordinates()  # Note: includes leading edge point, be careful about duplicates
        lower_original_coors = self.lower_coordinates()  # Note: includes leading edge point, be careful about duplicates

        # Find distances between coordinates, assuming linear interpolation
        upper_distances_between_points = np.sqrt(
            np.power(upper_original_coors[:-1, 0] - upper_original_coors[1:, 0], 2) +
            np.power(upper_original_coors[:-1, 1] - upper_original_coors[1:, 1], 2)
        )
        lower_distances_between_points = np.sqrt(
            np.power(lower_original_coors[:-1, 0] - lower_original_coors[1:, 0], 2) +
            np.power(lower_original_coors[:-1, 1] - lower_original_coors[1:, 1], 2)
        )
        upper_distances_from_TE = np.hstack((0, np.cumsum(upper_distances_between_points)))
        lower_distances_from_LE = np.hstack((0, np.cumsum(lower_distances_between_points)))
        upper_distances_from_TE_normalized = upper_distances_from_TE / upper_distances_from_TE[-1]
        lower_distances_from_LE_normalized = lower_distances_from_LE / lower_distances_from_LE[-1]

        # Generate a cosine-spaced list of points from 0 to 1
        s = cosspace(n_points=n_points_per_side)

        x_upper_func = sp_interp.PchipInterpolator(x=upper_distances_from_TE_normalized, y=upper_original_coors[:, 0])
        y_upper_func = sp_interp.PchipInterpolator(x=upper_distances_from_TE_normalized, y=upper_original_coors[:, 1])
        x_lower_func = sp_interp.PchipInterpolator(x=lower_distances_from_LE_normalized, y=lower_original_coors[:, 0])
        y_lower_func = sp_interp.PchipInterpolator(x=lower_distances_from_LE_normalized, y=lower_original_coors[:, 1])

        x_coors = np.hstack((x_upper_func(s), x_lower_func(s)[1:]))
        y_coors = np.hstack((y_upper_func(s), y_lower_func(s)[1:]))

        coordinates = np.column_stack((x_coors, y_coors))
        self.coordinates = coordinates 
开发者ID:peterdsharpe,项目名称:AeroSandbox,代码行数:39,代码来源:geometry.py

示例5: __init__

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import PchipInterpolator [as 别名]
def __init__(self, ds, fractions, order=3, monotonic=True):
        self.order = order
        self.monotonic = monotonic
        self.parameters = {}
        
        ds = list(ds)
        fractions = list(fractions)
        
        if len(ds) == len(fractions)+1:
            # size classes, the last point will be zero
            fractions.insert(0, 0.0)
            self.d_minimum = min(ds)
        elif ds[0] != 0:
            ds = [0] + ds
            if len(ds) != len(fractions):
                fractions = [0] + fractions
            self.d_minimum = 0.0
            
        self.ds = ds
        self.fractions = fractions

        self.d_excessive = max(ds)
        

        self.fraction_cdf = cumsum(fractions)
        if self.monotonic:
            from scipy.interpolate import PchipInterpolator
            globals()['PchipInterpolator'] = PchipInterpolator

            self.cdf_spline = PchipInterpolator(ds, self.fraction_cdf, extrapolate=True)
            self.pdf_spline = PchipInterpolator(ds, self.fraction_cdf, extrapolate=True).derivative(1)
        else:
            from scipy.interpolate import UnivariateSpline
            globals()['UnivariateSpline'] = UnivariateSpline
            
            self.cdf_spline = UnivariateSpline(ds, self.fraction_cdf, ext=3, s=0)
            self.pdf_spline = UnivariateSpline(ds, self.fraction_cdf, ext=3, s=0).derivative(1)

        # The pdf basis integral splines will be stored here
        self.basis_integrals = {} 
开发者ID:CalebBell,项目名称:fluids,代码行数:42,代码来源:particle_size_distribution.py

示例6: _pdf_basis_integral

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import PchipInterpolator [as 别名]
def _pdf_basis_integral(self, d, n):
        # there are slight errors with this approach - but they are OK to 
        # ignore. 
        # DO NOT evaluate the first point as it leads to inf values; just set
        # it to zero
        from fluids.numerics import numpy as np
        if n not in self.basis_integrals:
            ds = np.array(self.ds[1:])
            pdf_vals = self.pdf_spline(ds)
            basis_integral = ds**n*pdf_vals
            if self.monotonic:
                self.basis_integrals[n] = PchipInterpolator(ds, basis_integral, extrapolate=True).antiderivative(1)
            else:
                self.basis_integrals[n] = UnivariateSpline(ds, basis_integral, ext=3, s=0).antiderivative(n=1)
        return max(float(self.basis_integrals[n](d)), 0.0) 
开发者ID:CalebBell,项目名称:fluids,代码行数:17,代码来源:particle_size_distribution.py

示例7: __init__

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import PchipInterpolator [as 别名]
def __init__(self, x, y, cutOutWindSpeed):
        
        self.first_value = x[0]
        self.last_value = x[-1]
        
        self.interpolator = interpolate.PchipInterpolator(x,y,extrapolate =False)

        self.cutOutWindSpeed = cutOutWindSpeed 
开发者ID:PCWG,项目名称:PCWG,代码行数:10,代码来源:interpolators.py

示例8: get_repaneled_airfoil

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import PchipInterpolator [as 别名]
def get_repaneled_airfoil(self, n_points_per_side=100):
        # Returns a repaneled version of the airfoil with cosine-spaced coordinates on the upper and lower surfaces.
        # Inputs:
        #   # n_points_per_side is the number of points PER SIDE (upper and lower) of the airfoil. 100 is a good number.
        # Notes: The number of points defining the final airfoil will be n_points_per_side*2-1,
        # since one point (the leading edge point) is shared by both the upper and lower surfaces.

        upper_original_coors = self.upper_coordinates()  # Note: includes leading edge point, be careful about duplicates
        lower_original_coors = self.lower_coordinates()  # Note: includes leading edge point, be careful about duplicates

        # Find distances between coordinates, assuming linear interpolation
        upper_distances_between_points = np.sqrt(
            np.power(upper_original_coors[:-1, 0] - upper_original_coors[1:, 0], 2) +
            np.power(upper_original_coors[:-1, 1] - upper_original_coors[1:, 1], 2)
        )
        lower_distances_between_points = np.sqrt(
            np.power(lower_original_coors[:-1, 0] - lower_original_coors[1:, 0], 2) +
            np.power(lower_original_coors[:-1, 1] - lower_original_coors[1:, 1], 2)
        )
        upper_distances_from_TE = np.hstack((0, np.cumsum(upper_distances_between_points)))
        lower_distances_from_LE = np.hstack((0, np.cumsum(lower_distances_between_points)))
        upper_distances_from_TE_normalized = upper_distances_from_TE / upper_distances_from_TE[-1]
        lower_distances_from_LE_normalized = lower_distances_from_LE / lower_distances_from_LE[-1]

        # Generate a cosine-spaced list of points from 0 to 1
        s = cosspace(n_points=n_points_per_side)

        x_upper_func = sp_interp.PchipInterpolator(x=upper_distances_from_TE_normalized, y=upper_original_coors[:, 0])
        y_upper_func = sp_interp.PchipInterpolator(x=upper_distances_from_TE_normalized, y=upper_original_coors[:, 1])
        x_lower_func = sp_interp.PchipInterpolator(x=lower_distances_from_LE_normalized, y=lower_original_coors[:, 0])
        y_lower_func = sp_interp.PchipInterpolator(x=lower_distances_from_LE_normalized, y=lower_original_coors[:, 1])

        x_coors = np.hstack((x_upper_func(s), x_lower_func(s)[1:]))
        y_coors = np.hstack((y_upper_func(s), y_lower_func(s)[1:]))

        coordinates = np.column_stack((x_coors, y_coors))

        # Make a new airfoil with the coordinates
        name = self.name + ", repaneled to " + str(n_points_per_side) + " pts"
        new_airfoil = Airfoil(name=name, coordinates=coordinates, repanel=False)

        return new_airfoil 
开发者ID:peterdsharpe,项目名称:AeroSandbox,代码行数:44,代码来源:geometry.py


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