我试图把很多东西扔在一起,但显然这不是我的代码所带来的问题。但我不确定它正在响应的代码行中是什么。这是给我一个错误的最后一行。
import numpy as np
import matplotlib.pyplot as plt
phi = np.zeros(181)
for i in range(0,181):
phi[i] = i-90.
hF = np.zeros((181,321))
hM = np.zeros((181,321))
Ob = 23.5*3.131592/180
w = np.zeros(321)
e = 0.6
for j in range(0,321):
w[j] = 2*np.pi*j/320
SF = 3230.3
SM = np.zeros(321)
L = 283
decF = np.zeros(321)
for j in range(0,321):
decF[j] = Ob*np.sin(w[j])
dF = np.zeros(321)
dM = np.zeros(321)
QF = np.zeros((181,321))
for j in range(0,321):
dF[j] = (1+e*np.cos(w[j]-L*np.pi/320))/(1-e**2)
for i in range(0,181):
for j in range(0,321):
QF = 0
if np.abs(np.tan(phi[i]*np.pi/180)*np.tan(decF[j])) <=1:
hF[i][j] = np.acos(-np.tan(phi[i]*np.pi/180)*np.tan(decF[j]))
QF[i][j] = (SF/np.pi)*dF[j]*(hF[i][j]*np.sin(phi[i]*np.pi/180)*np.sin(decF[j])+np.cos(phi[i]*np.pi/180)*np.cos(decF[i])*sin(hF[i][j]))
答案 0 :(得分:2)
你的问题是:
QF = 0
然后你试着这样做:
QF[i][j] = ...
你无法在整数上查找任何内容。
另外我注意到你没有定义sin
函数,但是你正在尝试使用它,所以我认为你的最后一行应该是:
QF[i][j] = (SF/np.pi)*dF[j]*(hF[i][j]*np.sin(phi[i]*np.pi/180)*np.sin(decF[j])+np.cos(phi[i]*np.pi/180)*np.cos(decF[i])*np.sin(hF[i][j]))
此外,我注意到您应该np.acos
时调用np.arccos
。