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


Python interpolate.InterpolatedUnivariateSpline方法代码示例

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


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

示例1: calc_fdmag

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import InterpolatedUnivariateSpline [as 别名]
def calc_fdmag(self, dMag, smin, smax):
        """Calculates probability density of dMag by integrating over projected
        separation
        
        Args:
            dMag (float ndarray):
                Planet delta magnitude(s)
            smin (float ndarray):
                Value of minimum projected separation (AU) from instrument
            smax (float ndarray):
                Value of maximum projected separation (AU) from instrument
        
        Returns:
            float:
                Value of probability density
        
        """
        
        f = np.zeros(len(smin))
        for k, dm in enumerate(dMag):
            f[k] = interpolate.InterpolatedUnivariateSpline(self.xnew,self.EVPOCpdf(self.xnew,dm),ext=1).integral(smin[k],smax[k])
            
        return f 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:25,代码来源:BrownCompleteness.py

示例2: __init__

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import InterpolatedUnivariateSpline [as 别名]
def __init__(self, scale_list, values, method='spline', extrapolate=False):
        # error checking
        if len(values.shape) != 1:
            raise ValueError('This class only works for 1D data.')
        elif len(scale_list) != 1:
            raise ValueError('input and output dimension mismatch.')

        if method == 'linear':
            k = 1
        elif method == 'spline':
            k = 3
        else:
            raise ValueError('Unsuppoorted interpolation method: %s' % method)

        offset, scale = scale_list[0]
        num_pts = values.shape[0]
        points = np.linspace(offset, (num_pts - 1) * scale + offset, num_pts)  # type: np.multiarray.ndarray

        DiffFunction.__init__(self, [(points[0], points[-1])], delta_list=None)

        ext = 0 if extrapolate else 2
        self.fun = interp.InterpolatedUnivariateSpline(points, values, k=k, ext=ext) 
开发者ID:ucb-art,项目名称:BAG_framework,代码行数:24,代码来源:interpolate.py

示例3: interpolate

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import InterpolatedUnivariateSpline [as 别名]
def interpolate(self, z, ext='zeros'):
        """ Interpoalte dndz as a function of redshift. 

            The interpolation acts as a band pass filter, removing small scale
            fluctuations in the estimator.

            Parameters
            ----------
            z : array_like
                redshift
            ext : 'extrapolate', 'zeros', 'raise', 'const'
                how to deal with values out of bound.

            Returns
            -------
            n : n(z)
        """
        nofz = InterpolatedUnivariateSpline(self.bin_centers, self.nbar, ext=ext)
        return nofz(z) 
开发者ID:bccp,项目名称:nbodykit,代码行数:21,代码来源:zhist.py

示例4: _make_riskneutral_df

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import InterpolatedUnivariateSpline [as 别名]
def _make_riskneutral_df(time_horizon):
  cols_of_interest = ['bakshiSkew', 'bakshiKurt', 'SVIX',]
  riskteural_measures = load_time_series_csv(RISKNEUTRAL_CSV, delimiter=';')
  riskteural_measures = riskteural_measures[['daystomaturity'] + cols_of_interest]
  riskteural_measures = riskteural_measures.dropna()
  interpolated_df = pd.DataFrame()
  for date in list(set(riskteural_measures.index)):
    # filter all row for respective date
    riskneutral_measures_per_day = riskteural_measures.ix[date]

    # filer out all option-implied measures with computed based on a maturity of less than 7 days
    riskneutral_measures_per_day = riskneutral_measures_per_day[riskneutral_measures_per_day['daystomaturity'] > 7]

    # interpolate / extrapolate to get estimate for desired time_horizon
    interpolated_values = [InterpolatedUnivariateSpline(np.array(riskneutral_measures_per_day['daystomaturity']),
                                 np.asarray(riskneutral_measures_per_day[col_of_interest]),
                                 k=1)(time_horizon) for col_of_interest in cols_of_interest]

    # create df with estimated option-implied risk measures
    update_dict = dict(zip(cols_of_interest, interpolated_values))
    update_dict.update({'daystomaturity': time_horizon})
    interpolated_df = interpolated_df.append(pd.DataFrame(update_dict, index=[date]))
  del interpolated_df['daystomaturity']
  return interpolated_df 
开发者ID:freelunchtheorem,项目名称:Conditional_Density_Estimation,代码行数:26,代码来源:load_dataset.py

示例5: calculate_accelerations

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import InterpolatedUnivariateSpline [as 别名]
def calculate_accelerations(times, velocities):
    """
    Calculates the acceleration from velocity time series [m/s2].

    :param times:
        Time vector [s].
    :type times: numpy.array

    :param velocities:
        Velocity vector [km/h].
    :type velocities: numpy.array

    :return:
        Acceleration vector [m/s2].
    :rtype: numpy.array
    """
    from scipy.interpolate import InterpolatedUnivariateSpline as Spl
    acc = Spl(times, velocities / 3.6).derivative()(times)
    b = (velocities[:-1] == 0) & (velocities[1:] == velocities[:-1])
    acc[:-1][b] = 0
    if b[-1]:
        acc[-1] = 0
    return acc 
开发者ID:JRCSTU,项目名称:CO2MPAS-TA,代码行数:25,代码来源:vehicle.py

示例6: define_slope_model

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import InterpolatedUnivariateSpline [as 别名]
def define_slope_model(distances, elevations):
    """
    Returns the angle slope model [rad].

    :param distances:
        Cumulative distance vector [m].
    :type distances: numpy.array

    :param elevations:
        Elevation vector [m].
    :type elevations: numpy.array

    :return:
        Angle slope model [rad].
    :rtype: function
    """
    from scipy.interpolate import InterpolatedUnivariateSpline as Spl
    i = np.append([0], np.where(np.diff(distances) > dfl.EPS)[0] + 1)
    func = Spl(distances[i], elevations[i]).derivative()
    return lambda d: np.arctan(func(d)) 
开发者ID:JRCSTU,项目名称:CO2MPAS-TA,代码行数:22,代码来源:vehicle.py

示例7: dist_albedo

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import InterpolatedUnivariateSpline [as 别名]
def dist_albedo(self, p):
        """Probability density function for albedo
        
        Args:
            p (float ndarray):
                Albedo value(s)
        
        Returns:
            float ndarray:
                Albedo probability density
                
        """
        
        # if called for the first time, define distribution for albedo
        if self.dist_albedo_built is None:
            pgen = self.gen_albedo(int(1e6))
            pr = self.prange
            hp, pedges = np.histogram(pgen, bins=2000, range=(pr[0], pr[1]), density=True)
            pedges = 0.5*(pedges[1:] + pedges[:-1])
            pedges = np.hstack((pr[0], pedges, pr[1]))
            hp = np.hstack((0., hp, 0.))
            self.dist_albedo_built = interpolate.InterpolatedUnivariateSpline(pedges, 
                    hp, k=1, ext=1)
        
        f = self.dist_albedo_built(p)
        
        return f 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:29,代码来源:KeplerLike1.py

示例8: dist_sma

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import InterpolatedUnivariateSpline [as 别名]
def dist_sma(self, a):
        """Probability density function for semi-major axis.

        Note that this is a marginalized distribution.

        Args:
            a (float ndarray):
                Semi-major axis value(s)

        Returns:
            float ndarray:
                Semi-major axis probability density

        """

        # if called for the first time, define distribution for albedo
        if self.dist_sma_built is None:
            agen, _ = self.gen_sma_radius(int(1e6))
            ar = self.arange.to('AU').value
            ap, aedges = np.histogram(agen.to('AU').value, bins=2000, range=(ar[0], ar[1]), density=True)
            aedges = 0.5*(aedges[1:] + aedges[:-1])
            aedges = np.hstack((ar[0], aedges, ar[1]))
            ap = np.hstack((0., ap, 0.))
            self.dist_sma_built = interpolate.InterpolatedUnivariateSpline(aedges, ap, k=1, ext=1)

        f = self.dist_sma_built(a)

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

示例9: dist_radius

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import InterpolatedUnivariateSpline [as 别名]
def dist_radius(self, Rp):
        """Probability density function for planetary radius.

        Note that this is a marginalized distribution.

        Args:
            Rp (float ndarray):
                Planetary radius value(s)

        Returns:
            float ndarray:
                Planetary radius probability density

        """

        # if called for the first time, define distribution for albedo
        if self.dist_radius_built is None:
            _, Rgen = self.gen_sma_radius(int(1e6))
            Rpr = self.Rprange.to('earthRad').value
            Rpp, Rpedges = np.histogram(Rgen.to('earthRad').value, bins=2000, range=(Rpr[0], Rpr[1]), density=True)
            Rpedges = 0.5*(Rpedges[1:] + Rpedges[:-1])
            Rpedges = np.hstack((Rpr[0], Rpedges, Rpr[1]))
            Rpp = np.hstack((0., Rpp, 0.))
            self.dist_radius_built = interpolate.InterpolatedUnivariateSpline(Rpedges, Rpp, k=1, ext=1)

        f = self.dist_radius_built(Rp)

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

示例10: dist_albedo

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import InterpolatedUnivariateSpline [as 别名]
def dist_albedo(self, p):
        """Probability density function for albedo

        Args:
            p (float ndarray):
                Albedo value(s)

        Returns:
            float ndarray:
                Albedo probability density

        """

        # if called for the first time, define distribution for albedo
        if self.dist_albedo_built is None:
            pgen = self.gen_albedo(int(1e6))
            pr = self.prange
            hp, pedges = np.histogram(pgen, bins=2000, range=(pr[0], pr[1]), density=True)
            pedges = 0.5*(pedges[1:] + pedges[:-1])
            pedges = np.hstack((pr[0], pedges, pr[1]))
            hp = np.hstack((0., hp, 0.))
            self.dist_albedo_built = interpolate.InterpolatedUnivariateSpline(pedges,
                                                                              hp, k=1, ext=1)

        f = self.dist_albedo_built(p)

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

示例11: minimal_rotation

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import InterpolatedUnivariateSpline [as 别名]
def minimal_rotation(R, t, iterations=2):
    """Adjust frame so that there is no rotation about z' axis

    The output of this function is a frame that rotates the z axis onto the same z' axis as the
    input frame, but with minimal rotation about that axis.  This is done by pre-composing the input
    rotation with a rotation about the z axis through an angle gamma, where

        dgamma/dt = 2*(dR/dt * z * R.conjugate()).w

    This ensures that the angular velocity has no component along the z' axis.

    Note that this condition becomes easier to impose the closer the input rotation is to a
    minimally rotating frame, which means that repeated application of this function improves its
    accuracy.  By default, this function is iterated twice, though a few more iterations may be
    called for.

    Parameters
    ==========
    R: quaternion array
        Time series describing rotation
    t: float array
        Corresponding times at which R is measured
    iterations: int [defaults to 2]
        Repeat the minimization to refine the result

    """
    from scipy.interpolate import InterpolatedUnivariateSpline as spline
    if iterations == 0:
        return R
    R = quaternion.as_float_array(R)
    Rdot = np.empty_like(R)
    for i in range(4):
        Rdot[:, i] = spline(t, R[:, i]).derivative()(t)
    R = quaternion.from_float_array(R)
    Rdot = quaternion.from_float_array(Rdot)
    halfgammadot = quaternion.as_float_array(Rdot * quaternion.z * np.conjugate(R))[:, 0]
    halfgamma = spline(t, halfgammadot).antiderivative()(t)
    Rgamma = np.exp(quaternion.z * halfgamma)
    return minimal_rotation(R * Rgamma, t, iterations=iterations-1) 
开发者ID:moble,项目名称:quaternion,代码行数:41,代码来源:quaternion_time_series.py

示例12: angular_velocity

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import InterpolatedUnivariateSpline [as 别名]
def angular_velocity(R, t):
    from scipy.interpolate import InterpolatedUnivariateSpline as spline
    R = quaternion.as_float_array(R)
    Rdot = np.empty_like(R)
    for i in range(4):
        Rdot[:, i] = spline(t, R[:, i]).derivative()(t)
    R = quaternion.from_float_array(R)
    Rdot = quaternion.from_float_array(Rdot)
    return quaternion.as_float_array(2*Rdot/R)[:, 1:] 
开发者ID:moble,项目名称:quaternion,代码行数:11,代码来源:quaternion_time_series.py

示例13: __init__

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import InterpolatedUnivariateSpline [as 别名]
def __init__(self, xname, yname, nullc_array, x_relative_scale=1):
        self.xname = xname
        self.yname = yname
        self.array = nullc_array
        # ensure monotonicity
        if not isincreasing(nullc_array[:,0]):
            raise AssertionError("x axis '%s' values must be monotonically increasing" % xname)
        self.spline = InterpolatedUnivariateSpline(nullc_array[:,0],
                                                   nullc_array[:,1])
        # store these precomputed values in advance for efficiency
        self.x_relative_scale_fac = x_relative_scale
        self.x_relative_scale_fac_2 = self.x_relative_scale_fac**2
        self.x_relative_scale_fac_3 = self.x_relative_scale_fac**3 
开发者ID:robclewley,项目名称:compneuro,代码行数:15,代码来源:phaseplane.py

示例14: spline_fitting

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import InterpolatedUnivariateSpline [as 别名]
def spline_fitting(x_data, y_data, order):
    return InterpolatedUnivariateSpline(x_data, y_data, k=order) 
开发者ID:arraystream,项目名称:fftoptionlib,代码行数:4,代码来源:helper.py

示例15: __init__

# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import InterpolatedUnivariateSpline [as 别名]
def __init__(self, xvec, yvec, xtol, order=3, ext=3):
        self._xvec = xvec
        self._yvec = yvec
        self._xtol = xtol
        self._order = order
        self._ext = ext
        self._fun = interp.InterpolatedUnivariateSpline(xvec, yvec, k=order, ext=ext) 
开发者ID:ucb-art,项目名称:BAG_framework,代码行数:9,代码来源:core.py


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