I have created a test example for the question using for loop and hope someone can help me to get fast solution. My data set is about 2000000 data.
However, I have the problem to run the code, the Out[i]=cnstl[j] line gives me error says:
In [107]: Out[0]=cnstl[0]---------------------------------------------------------------------------TypeError Traceback (most recent call last)
C:\Frank_share\qamslicer.py in <module>()----> 1 2 3 4 5
TypeError: can't convert complex to float; use abs(z)
In [108]: cnstl.dtypeOut[108]: dtype('complex128')
I do not know why that my data is complex128 already. Can anyone help to figure why?
Thanks
Frank
from numpy import *a = arange(-15,16,2)cnstl=a.reshape(16,1)+1j*acnstl=cnstl.reshape(256,1)
X = array([1.4 + 1j*2.7, -4.9 + 1j*8.3])
Out = array(X)error =array(X)for i in xrange(2): for j in xrange(256): a0 = real(X[i]) < (real(cnstl[j])+1) a1 = real(X[i]) > (real(cnstl[j])-1) a2 = imag(X[i]) > (imag(cnstl[j])-1) a3 = imag(X[i]) < (imag(cnstl[j])+1) if (a0 & a1 & a2 &a3): Out[i] = cnstl[j] error[i] = X[i] - cnstl[j]
From: f.yw@hotmail.comTo: numpy-discussion@scipy.orgSubject: RE: [Numpy-discussion] help on fast slicing on a gridDate: Wed, 28 Jan 2009 23:28:47 -0700
Hi, Bob, Thanks for your help. I am sorry for my type error. qam array is the X array in my example. cntl is a complex array contains the point (x,y) axises. I will try to make a workable example. Also I will try to find out the zeros_like function. However, I guess that zeros_like(X) will create an array the same size as X. It it is. Then the two line Out=X and error=X should be Out=zeros_like(X) and error=zeros(X). Also, can where command handel the logic command? aa = np.where((real(X)