Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/351.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python scipy.interpolate.SmoothSphereBivariateSpline不是';t在示例数据上的行为与预期一致_Python_Scipy_Interpolation - Fatal编程技术网

Python scipy.interpolate.SmoothSphereBivariateSpline不是';t在示例数据上的行为与预期一致

Python scipy.interpolate.SmoothSphereBivariateSpline不是';t在示例数据上的行为与预期一致,python,scipy,interpolation,Python,Scipy,Interpolation,我正在尝试使用scipy.interpolate.SmoothSphereBivariateSpline在球体上插值一组非均匀数据。在中的示例中,示例数据的设置与我的数据不同,下面是具有我需要的形状的测试数据集(theta,phi,和z都是1D数组)。我已经尝试过稍微改变一下z,但在任何情况下,插值都不能达到令人满意的效果。你知道我做错了什么,或者有更好的方法来做我需要的吗 import numpy as np from scipy.interpolate import SmoothSphere

我正在尝试使用
scipy.interpolate.SmoothSphereBivariateSpline
在球体上插值一组非均匀数据。在中的示例中,示例数据的设置与我的数据不同,下面是具有我需要的形状的测试数据集(
theta
phi
,和
z
都是1D数组)。我已经尝试过稍微改变一下
z
,但在任何情况下,插值都不能达到令人满意的效果。你知道我做错了什么,或者有更好的方法来做我需要的吗

import numpy as np
from scipy.interpolate import SmoothSphereBivariateSpline
import matplotlib.pyplot as plt

theta = np.array([0, 0.5, 1., 1.5, 2., 2.5, 3.])
phi = np.array([1., 2., 3., 3.5, 4., 5., 6.])
z = np.array([1, 1, 0, 0, 0, 1, 1])

lut = SmoothSphereBivariateSpline(theta,phi,z, s=len(theta))

theta_new = np.linspace(0,np.pi,50)
phi_new = np.linspace(0,2.*np.pi,50)

znew = lut(theta_new,phi_new)

theta_new_mesh, phi_new_mesh = np.meshgrid(theta_new, phi_new)

fig=plt.figure()
ax = fig.add_subplot(111,projection='mollweide')
im = ax.pcolormesh(phi_new_mesh-np.pi,theta_new_mesh-np.pi/2.,znew,vmin=0, vmax=1)
ax.scatter(phi-np.pi,theta-np.pi/2.,c=z, ec='k',vmin=0,vmax=1)