Kevin
Kevin

Reputation: 15

I'm getting a "TypeError: 'int' object has no attribute '_getitem' and I'm not sure why

I'm trying to throw together a whole lot, but apparently that's not the problem my code has. But I'm not sure what it's talking about in the line of code it's ringing up. It's the very last line that's giving me an error.

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

Upvotes: 1

Views: 53

Answers (1)

mechanical_meat
mechanical_meat

Reputation: 169484

Your problem line is this:

QF = 0

And then you try to do:

QF[i][j] = ...

There is no way you can look up anything on an integer.

Also I noticed that you didn't define a sin function but you're trying to use it so I think your last line should read:

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

Also I noticed you're calling np.acos when it should be np.arccos.

Upvotes: 2

Related Questions