2017-04-21 62 views
1

我想一起扔了一大堆,但顯然這不是我的代碼有問題,但。我不知道它的代碼它響了線談論它是一個的給我一個錯誤,最後一行我得到一個「類型錯誤:‘詮釋’對象有沒有屬性‘_getitem’,我不知道爲什麼

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])) 

回答

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

相關問題