numpy - Unsupported operand type(s) for ** or pow(): 'generator' and 'int' -


what want: trying read list of 6,000 coordinates (ra, , dec) , each 1 of coordinates they're 78 points around them. applying angle (ang) , trying find new ra , dec. there seems problem z_sq=(x2 + y2) because got error unsupported operand type(s) ** or pow(): 'generator' , 'int'.

import matplotlib.pyplot plt import numpy np import pylab py  coords=np.genfromtxt('hetdex_reg.txt',dtype=none,usecols=(0,1,2),names=      ('ra','dec','ang')) ra=coords['ra'] dec=coords['dec'] ang=coords['ang']  coords=np.genfromtxt('ifus_78_base.txt', dtype=none, usecols=(0,1),       names=('xx', 'yy')) xx=coords['xx'] yy=coords['yy']  in range(len(ang)):     ang_new=360-ang[i]     x= (xx[j] j in range(len(xx)))     y= (yy[j] j in range(len(yy)))     z_sq=(x**2 + y**2)     z=np.sqrt(z_sq)     x_new=(np.deg2rad(x))     y_new=(np.deg2rad(y))     theta=py.arctan(x_new/y_new)     tau=90-ang[i]-theta     tau_rad=np.deg2rad(tau)     delta_dec=z*py.sin(tau_rad)     dec=dec[i]+delta_dec     delta_ra=z*py.cos(tau_rad)     ra=ra[i]+delta_ra/(py.cos(dec/206205))      print dec     print ra 

i should getting new set of ra , dec 78 times (bc there 78 x , y points), each original ra , dec.

so problem in:

x= (xx[j] j in range(len(xx))) y= (yy[j] j in range(len(yy))) z_sq=(x**2 + y**2) 

try

in [29]: x=(j j in range(10))  in [30]: z=x**2+x --------------------------------------------------------------------------- typeerror                                 traceback (most recent call last) <ipython-input-30-c8ea7ceba90f> in <module>() ----> 1 z=x**2+x  typeerror: unsupported operand type(s) ** or pow(): 'generator' , 'int'  in [31]: x out[31]: <generator object <genexpr> @ 0xb2b411e4> 

see error - x generator, created () expression

x=[j j in range(10)] list (list comprehension), still not work. x needs array, has ** method.

in [34]: x=np.array([j j in range(10)]) in [35]: x**2 out[35]: array([ 0,  1,  4,  9, 16, 25, 36, 49, 64, 81]) 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -