我想使用scipy.interpolate.SmoothSphereBivariateSpline在地图上插值温度(我不熟悉数据插值,所以这可能不是一个好选择,但我想试一试)。
我做了以下几步:
- 从tsv文件中加载数据,它看起来像这样: latitude longitude temperature city 30.22 120.14 39 2caves 30.26 120.13 39 3caves 30.23 120.13 39 Anlong 33.48 108.5 30 Anda 37.2 100.74 15 Anan ...
我做了以下几步:
- 从tsv文件中加载数据,它看起来像这样: latitude longitude temperature city 30.22 120.14 39 2caves 30.26 120.13 39 3caves 30.23 120.13 39 Anlong 33.48 108.5 30 Anda 37.2 100.74 15 Anan ...
into pandas
data = pandas.read_table('temp.tsv')
Get radians from lat, lon:
theta = numpy.array(data.latitude) / 180 * numpy.pi # the lat, lon domain is safe here so phi = numpy.array(data.longitude) / 180 * numpy.pi # I won't adjust for the output range temp = numpy.array(data.temperature)
Feed them into scipy:
lut = SmoothSphereBivariateSpline(theta, phi, temps)
然后该函数会引发ValueError错误:
ValueError: 所需存储空间超过可用存储空间:nxest或nyest太小,或s太小。 加权最小二乘样条对应于当前的节点集。
我尝试使用不同的值调整 s 参数,从 1、2、3 到 7000、8000,但它仍然太小。我应该怎么做才能使插值工作?