# Developers Planet

user5893252 February 2016

### TypeError: 'Quantity' object is not callable

I am attempting to understand the quantity error.
I am using Python version 2.7.1 and numpy with the quantities package. I have posted the defined variables and equations and the subsequent error. I am attempting to generate an array with values of Teffpv that vary with theta (th). Can somebody explain why I am creating an error?

``````a = q.Quantity(0.2,'au').simplified
e = 0.2
r = q.Quantity(0.4,'Rsun').simplified # Radius of blackbody
t = q.Quantity(3500,'K').simplified #temperature for Teff of the star
al = 0.3
N = 100
th = np.linspace(0.,4*np.pi,N)
def d(a,e,th):
return a*(1-e**2)/(1+e*np.cos(th))
def Teffp(al,t,r,d):
return ((1.- al)**(1/4))*t*(r/d(a,e,th))**(1/2)
Teffpv = np.zeros(N) # make arrays to store results
for i in range(N-1):
Teffpv=Teffp(al,t,r,d(a,e,th[i]))
``````

Error message

``````TypeError                                 Traceback (most recent call last)
<ipython-input-17-bdcc9550c9ae> in <module>()
14 Teffpv = np.zeros(N) # make arrays to store results
15 for i in range (N-1):
---> 16     Teffpv=Teffp(al,t,r,d(a,e,th[i]))

<ipython-input-17-bdcc9550c9ae> in Teffp(al, t, r, d)
11     return a*(1-e**2)/(1+e*np.cos(th))
12 def Teffp(al,t,r,d):
---> 13     return ((1.- al)**(1/4))*t*(r/d(a,e,th))**(1/2)
14 Teffpv = np.zeros(N) # make arrays to store results
15 for i in range (N-1):

TypeError: 'Quantity' object is not callable
``````

cromod February 2016

Your code has some mistakes :

• No need to initialize `Teffpv` with `np.zeros(N)` and to use a loop.
• Replace `d(a,e,th)` by `d` in the formula of `Teffp` -> this explains your error message
• Use float for your rational exponents, especially in `Teffp` function

This code should do what you want :

``````import quantities as q
import numpy as np

a = q.Quantity(0.2,'au').simplified
e = 0.2
Rsun = q.UnitQuantity('solar radius', q.m*6.9599e8, symbol='Rsun')
r = q.Quantity(0.4,'Rsun').simplified # Radius of blackbody
t = q.Quantity(3500.,'K').simplified #temperature for Teff of the star
al = 0.3
N = 100
th = np.linspace(0.,4.*np.pi,N)

def d(a,e,th):
return a*(1-e**2)/(1+e*np.cos(th))

def Teffp(al,t,r,d):
return ((1.- al)**(0.25))*t*(r/d)**(0.5)

Teffpv = Teffp(al,t,r,d(a,e,th))
print Teffpv
``````

NB:

I added a definition of Rsun unit in this code otherwise my quantities package doesn't recognize it.

I'm not an astrophysicist but I found that here ;)