本文简要介绍 python 语言中 scipy.interpolate.SmoothSphereBivariateSpline
的用法。
用法:
class scipy.interpolate.SmoothSphereBivariateSpline(theta, phi, r, w=None, s=0.0, eps=1e-16)#
球坐标中的平滑二元样条近似。
- theta, phi, r: array_like
一维数据点序列(顺序不重要)。坐标必须以弧度表示。 Theta 必须位于区间
[0, pi]
内,而 phi 必须位于区间[0, 2pi]
内。- w: 数组,可选
正的一维权重序列。
- s: 浮点数,可选
为估计条件定义的正平滑因子:
sum((w(i)*(r(i) - s(theta(i), phi(i))))**2, axis=0) <= s
默认s=len(w)
如果1/w[i]
是对r[i]
的标准偏差的估计,则该值应该是一个不错的值。- eps: 浮点数,可选
用于确定over-determined 线性方程组的有效等级的阈值。每股收益应该在开区间内有一个值
(0, 1)
,默认为 1e-16。
参数 ::
注意:
有关详细信息,请参阅有关此函数的FITPACK 站点。
例子:
假设我们在粗网格上有全局数据(输入数据不必在网格上):
>>> import numpy as np >>> theta = np.linspace(0., np.pi, 7) >>> phi = np.linspace(0., 2*np.pi, 9) >>> data = np.empty((theta.shape[0], phi.shape[0])) >>> data[:,0], data[0,:], data[-1,:] = 0., 0., 0. >>> data[1:-1,1], data[1:-1,-1] = 1., 1. >>> data[1,1:-1], data[-2,1:-1] = 1., 1. >>> data[2:-2,2], data[2:-2,-2] = 2., 2. >>> data[2,2:-2], data[-3,2:-2] = 2., 2. >>> data[3,3:-2] = 3. >>> data = np.roll(data, 4, 1)
我们需要设置插值器对象
>>> lats, lons = np.meshgrid(theta, phi) >>> from scipy.interpolate import SmoothSphereBivariateSpline >>> lut = SmoothSphereBivariateSpline(lats.ravel(), lons.ravel(), ... data.T.ravel(), s=3.5)
作为第一个测试,我们将看到算法在输入坐标上运行时返回什么
>>> data_orig = lut(theta, phi)
最后,我们将数据插入到更精细的网格中
>>> fine_lats = np.linspace(0., np.pi, 70) >>> fine_lons = np.linspace(0., 2 * np.pi, 90)
>>> data_smth = lut(fine_lats, fine_lons)
>>> import matplotlib.pyplot as plt >>> fig = plt.figure() >>> ax1 = fig.add_subplot(131) >>> ax1.imshow(data, interpolation='nearest') >>> ax2 = fig.add_subplot(132) >>> ax2.imshow(data_orig, interpolation='nearest') >>> ax3 = fig.add_subplot(133) >>> ax3.imshow(data_smth, interpolation='nearest') >>> plt.show()
相关用法
- Python SciPy interpolate.make_interp_spline用法及代码示例
- Python SciPy interpolate.krogh_interpolate用法及代码示例
- Python SciPy interpolate.InterpolatedUnivariateSpline用法及代码示例
- Python SciPy interpolate.BSpline用法及代码示例
- Python SciPy interpolate.LSQSphereBivariateSpline用法及代码示例
- Python SciPy interpolate.griddata用法及代码示例
- Python SciPy interpolate.splder用法及代码示例
- Python SciPy interpolate.LinearNDInterpolator用法及代码示例
- Python SciPy interpolate.PPoly用法及代码示例
- Python SciPy interpolate.NdBSpline用法及代码示例
- Python SciPy interpolate.pade用法及代码示例
- Python SciPy interpolate.barycentric_interpolate用法及代码示例
- Python SciPy interpolate.RegularGridInterpolator用法及代码示例
- Python SciPy interpolate.NdPPoly用法及代码示例
- Python SciPy interpolate.interp2d用法及代码示例
- Python SciPy interpolate.approximate_taylor_polynomial用法及代码示例
- Python SciPy interpolate.RectSphereBivariateSpline用法及代码示例
- Python SciPy interpolate.sproot用法及代码示例
- Python SciPy interpolate.splantider用法及代码示例
- Python SciPy interpolate.CloughTocher2DInterpolator用法及代码示例
- Python SciPy interpolate.interp1d用法及代码示例
- Python SciPy interpolate.BPoly用法及代码示例
- Python SciPy interpolate.BarycentricInterpolator用法及代码示例
- Python SciPy interpolate.splrep用法及代码示例
- Python SciPy interpolate.make_smoothing_spline用法及代码示例
注:本文由纯净天空筛选整理自scipy.org大神的英文原创作品 scipy.interpolate.SmoothSphereBivariateSpline。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。