gpt4 book ai didi

python - 使用 scipy 的 SmoothSphereBivariateSpline 进行插值

转载 作者:行者123 更新时间:2023-12-04 11:47:43 26 4
gpt4 key购买 nike

我想用scipy.interpolate.SmoothSphereBivariateSpline
在 map 上插值温度(我不熟悉数据插值,所以这可能不是一个好的选择,但我想试一试)。

这些是我所做的:

  • 从 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

    ...


  • Pandas
    data = pandas.read_table('temp.tsv')
  • 从 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)
  • 将它们输入 scipy:
    lut = SmoothSphereBivariateSpline(theta, phi, temps)

  • 然后函数抛出一个 ValueError:

    ValueError: The required storage space exceeds the available storage space: nxest or nyest too small, or s too small. The weighted least-squares spline corresponds to the current set of knots.



    我试图用不同的值调整 s 参数,从 1、2、3 到 7000、8000,它只是太小了。我应该怎么做才能使插值工作?

    最佳答案

    仅供记录:关注 the documentation有一个平滑参数 s被选中;默认值为 s=0 ,但有时按照文档中的建议手动选择它是至关重要的。

    关于python - 使用 scipy 的 SmoothSphereBivariateSpline 进行插值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21876084/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com