Re: [Numpy-discussion] help on fast slicing on a grid

2009-01-30 Thread frank wang
Hi, Bob, Thanks. This solution works great. It really helps me a lot. Frank> Date: Fri, 30 Jan 2009 23:08:35 -0600> From: robert.k...@gmail.com> To: numpy-discussion@scipy.org> Subject: Re: [Numpy-discussion] help on fast slicing on a grid> > On Fri, Jan 30, 2009 at

Re: [Numpy-discussion] help on fast slicing on a grid

2009-01-30 Thread Robert Kern
On Fri, Jan 30, 2009 at 22:41, frank wang wrote: > Thanks for the correction. I will learn the ravel() function since I do not > know it. Moving from Matlab world into python is tricky sometime. > > Your output > In [22]: out >> Out[22]: array([ 1.+3.j, -5.+9.j]) >> >> In [23]: error >> Out[23]: a

Re: [Numpy-discussion] help on fast slicing on a grid

2009-01-30 Thread frank wang
However, if my data set is large, this solution takes long time to run. Are there any python/numpy magic to speed it up? Thanks Frank> Date: Fri, 30 Jan 2009 14:52:27 -0600> From: robert.k...@gmail.com> To: numpy-discussion@scipy.org> Subject: Re: [Numpy-discussion] help on fast

Re: [Numpy-discussion] help on fast slicing on a grid

2009-01-30 Thread Robert Kern
On Fri, Jan 30, 2009 at 12:58, frank wang wrote: > 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 200 data. > > However, I have the problem to run the code, the Out[i]=cnstl[j] line gives > me error says:

Re: [Numpy-discussion] help on fast slicing on a grid

2009-01-30 Thread frank wang
) Thanks Frank> Date: Thu, 29 Jan 2009 00:15:48 -0600> From: robert.k...@gmail.com> To: numpy-discussion@scipy.org> Subject: Re: [Numpy-discussion] help on fast slicing on a grid> > On Thu, Jan 29, 2009 at 00:09, frank wang wrote:> > Here is the for loop that I am think about

Re: [Numpy-discussion] help on fast slicing on a grid

2009-01-28 Thread frank wang
the where command is the same as: aa = np.where((real(X)<4) & (real(X)>2 )& (imag(X)<6) & (imag(X)>4)) Thanks Frank> Date: Thu, 29 Jan 2009 00:15:48 -0600> From: robert.k...@gmail.com> To: numpy-discussion@scipy.org> Subject: Re: [Numpy-discussion] help on f

Re: [Numpy-discussion] help on fast slicing on a grid

2009-01-28 Thread Robert Kern
On Thu, Jan 29, 2009 at 00:09, frank wang wrote: > Here is the for loop that I am think about. Also, I do not know whether the > where commands can handle the complicated logic. > The where command basically find the data in the square around the point > cnstl[j]. cnstl is a 2D array from your pr

Re: [Numpy-discussion] help on fast slicing on a grid

2009-01-28 Thread frank wang
ipy.org> Subject: Re: [Numpy-discussion] help on fast > slicing on a grid> > On Wed, Jan 28, 2009 at 23:52, frank wang > wrote:> >> > Hi,> >> > I have to buidl a grid with 256 > point by the command:> > a = arange(-15,16,2)> > L = len(a)&g

Re: [Numpy-discussion] help on fast slicing on a grid

2009-01-28 Thread Robert Kern
On Wed, Jan 28, 2009 at 23:52, frank wang wrote: > > Hi, > > I have to buidl a grid with 256 point by the command: > a = arange(-15,16,2) > L = len(a) > cnstl = a.reshape(L,1)+1j*a > > My problem is that I have a big data array that contains the data round the > points in cnstl. I want to slice th

[Numpy-discussion] help on fast slicing on a grid

2009-01-28 Thread frank wang
Hi, I have to buidl a grid with 256 point by the command: a = arange(-15,16,2) L = len(a) cnstl = a.reshape(L,1)+1j*a My problem is that I have a big data array that contains the data round the points in cnstl. I want to slice the point to the closest cnstl point and also compute the error.