python - 使用 SciPy 进行插值
问题描述
我想使用 Scipy-> interpolate-> interp2d。插值结果是正确的,但为什么结果在列表中保存了三次?我使用了下一个脚本:
from scipy import interpolate
import numpy as np
def main():
x = np.array([1, 2, 3, 4])
y = np.array([1, 2])
z = np.array([[4,4,6,6],[6, 6,12, 12]])
f = interpolate.interp2d(x, y, z, kind='linear', copy = False)
xi = np.array([1.5, 2.5, 3.5])
yi = np.array([1.5,1.5,1.
结果是:
zi =[[ 5. 7. 9.][ 5. 7. 9.] [ 5. 7. 9.]]
请问你能帮我吗?
解决方案
Your input arrays x,y,z
need to be of identical shape. In your case one has four entries, one has two entries, and the other one is two dimensional with four entries. This will trigger numpy broadcasting. https://docs.scipy.org/doc/numpy/reference/generated/numpy.broadcast.html
推荐阅读
- microsoft-graph-api - Microsoft Graph 是否具有 lastModifiedDateTime 来检测最新的实体更改?
- reactjs - React Native 自动补全 IntelliJ
- sql-server - SSMS 无法识别加入语法
- typescript - 我可以在 Typescript 中提取类型的嵌套结构以使用它来声明新类型吗?
- nunit - 你如何设置 Visual Studio for Mac 和 NUnit
- kubernetes - 如何解决临时本地存储问题?
- java - 从 Spark 读取 Teradata 时出错。它加载了表并显示架构但未能给出数据集结果
- javascript - Vuejs v-for错误删除元素firebase
- javascript - 开玩笑将模拟类传递给构造函数
- ipfs - 超出上下文截止日期 - IPFS