當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。