使用python numpy的梯度与二维场梯度的点积

2024-10-06 12:38:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我在xy平面上有一个尺寸为748x1500的二维温度场“t”。尝试用python numpy编写此函数:

f=Gt点G | Gt | see image for symbolic representation

其中G是梯度(倒三角形表示法) 即Gt是t的梯度

Gt=np.gradient(t)  # results in a list of two 748x1500 arrays
magGt=np.sqrt(np.power(Gt[0],2),np.power(Gt[1],2))  # |Gt|  the magnitude of Gt results in 748x1500 array 
GGt=np.gradient(magGt) # G|Gt| results in a list of two 748x1500 arrays
f=np.dot(Gt,GGt) # Gt dot G|Gt|   # ValueError: shapes (2,748,1500) and (2,748,1500) not aligned: 1500 (dim 2) != 748 (dim 1)

Tags: ofingtnpresultsdotlist梯度