Re: [Numpy-discussion] switching from Numeric to numpy

2013-10-18 Thread Raul Cota
John,


Just noticed this message,

We are already cleaning up all of our code to not be numpy based but for 
porting from Numeric to numpy:


In our C code we settled for the following,

#define NUMPY

#if !defined(NUMPY)
 #include "arrayobject.h"
#else
 #include "numpy/oldnumeric.h"
#endif


And this,

#ifdef NUMPY
 pyArray = (PyArrayObject *) PyArray_SimpleNew( 1, dims, 
PyArray_DOUBLE);
#else
 pyArray = (PyArrayObject *) PyArray_FromDims( 1, dims, PyArray_DOUBLE);
#endif


And I think that was all the changes we needed and while we were 
transitioning we could easily compile for Numeric or numpy.


Most of our headaches were on the python code because of very subtle 
things but even there, the bulk of the changes worked out rather nicely 
using the oldnumeric stuff.


Raul




On 07/10/2013 5:27 PM, john fernando wrote:
> I have the following C code which is an extension to my python code.
>
> The python and C code use
> #include 
>
> what is the equivalent I can use in numpy that causes the minimum code change?
>
> I did look through the old messages but didn't really find the answer-any 
> help to a novice just starting out in numpy/python/C is much appreciated.
>
> 
> FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
> family!
> Visit http://www.inbox.com/photosharing to find out more!
>
>
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] OT: How are SVG data converted into curves

2013-10-18 Thread Chris Barker
On Wed, Oct 16, 2013 at 4:23 PM, Daniele Nicolodi  wrote:

> the format is quite clearly documented. For the path data you can see
> http://www.w3.org/TR/SVG/paths.html. There are several open source
> libraries that implement SVG rendering, you may look at those to see how
> the rendering can be implemented in practice.

InkScape is particularly nice -- it's an open source desktop vector
drawing program, but can also be called on the command line and used
as a SVG renderer.

Someone wrote a minimal wxPython-based SVG renderer a while back --
not sure what happened to that.

-Chris




-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Equivalent to IDL's help function

2013-10-18 Thread Chris Barker
On Mon, Oct 7, 2013 at 10:15 AM, Siegfried Gonzi
 wrote:
> What is the equivalent to IDL its help function, e.g.
>
> ==
> IDL> a = make_array(23,23,)
>
> IDL> help,a
>
> will result in:
>
> A   FLOAT = Array[23, 23]

am I missing something, or is this what you get when you type a name
on the command line:

In [15]: a = np.ones((2,3), dtype=np.float32)

In [16]: a
Out[16]:
array([[ 1.,  1.,  1.],
   [ 1.,  1.,  1.]], dtype=float32)

or print a

etc...


-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] how to do scoring of random point to avoid overlapping in python

2013-10-18 Thread Pooja Gupta
Thanks Hanno
I got some idea.
How about the bin(grid)??



On Fri, Oct 18, 2013 at 8:21 PM, Hanno Klemm  wrote:

> On 18.10.2013 12:33, Pooja Gupta wrote:
> > I have generated random point around a object and then evaluate each
> > random point on certain criteria. But problem is that every time I am
> > getting new point. How i can resolve this problem so that my result
> > should be uniform. Is any way to evaluate the position of random
> > point.
> >
> > for arang in range(1000): # generate 1000 random point around object
> >  arang = arang + 1
> >  x,y,z = 9.251, 24.410, 64.133 # coordinates of objects (i have 500
> > object coordinates)
> >
> >  x1,y1,z1 =
> > (uniform(x-3.5,x+3.5),uniform(y-3.5,y+3.5),uniform(z-3.5,z+3.5))
> > #randompoint
> >  pacord = [x1,y1,z1] #random point coordinates
> >  dist_pap = euDist(uacoord, pacord) # check distance between object
> > and random points
> >
> >  if (dist_pap > 2.5): # if the random point far from obect
> >  dist_pap1 = dist_pap
> > vecpw = euvector(uacoord, pacord) # generate vectors b/w objject and
> > random point
> >
> > # angle between angle between object and random point
> > num1 = np.dot (vect1, vecpw)
> > denom1 = np.linalg.norm(vect1) * np.linalg.norm(vecpw)
> > ang1 = rad2deg(np.arccos(num1/denom1))
> >
> > if 140 > ang1 >100: # check angle
> >  ang2= ang1
> > print pacord
> >
> > Queries
> > every time i am getting new result (new positions of the random
> > point). How to fix it.
> > on above basis I want to score each random point and the two random
> > point should be 2.5 distance apart from each other. How I can avoid
> > overlapping of the random points.
> >
>
> I am not sure if i understand the question correctly but if you always
> want to get the same random number, every time you run the script, you
> can fix the random seed by using np.random.seed(). Regarding your second
> question, when I understand correctly, you somehow want to find two
> points that have a distance of 2.5. If you already have one of them, I
> would generate the second one using spherical coordinates and specifying
> the distance a priori. something like:
>
> def pt2(pt1, distance=2.5):
>  theta = np.random.rand()*np.pi
>  phi = np.random.rand()*2*np.pi
>  r = distance
>  x = r*np.sin(theta)*np.cos(phi)
>  y = r*np.sin(theta)*np.sin(phi)
>  z = r*np.cos(theta)
>  return pt1 + np.array((x,y,z))
>
>
> In [367]: pt1 = np.array([0,0,0])
>
> In [368]: pt2(pt1)
> Out[368]: a = array([-2.29954368, -0.57223342,  0.79664785])
>
> In [369]: np.linalg.norm(a)
> Out[369]: 2.5
>
> Hope this helps,
> Hanno
>
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
पूजा गुप्ता, पीएचडी
राष्ट्रीय कोशिका विज्ञान केंद्र

"जीवन को खुल कर मुस्कुराने दो, खोल दो बाहे अवसर आने दो ।
पग बढाओ हर पथ तुम्हारा है, पथ कंटक मंजिलो का इशारा है।।"
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] how to do scoring of random point to avoid overlapping in python

2013-10-18 Thread Hanno Klemm
On 18.10.2013 12:33, Pooja Gupta wrote:
> I have generated random point around a object and then evaluate each
> random point on certain criteria. But problem is that every time I am
> getting new point. How i can resolve this problem so that my result
> should be uniform. Is any way to evaluate the position of random
> point.
> 
> for arang in range(1000): # generate 1000 random point around object
>  arang = arang + 1
>  x,y,z = 9.251, 24.410, 64.133 # coordinates of objects (i have 500
> object coordinates)
> 
>  x1,y1,z1 =
> (uniform(x-3.5,x+3.5),uniform(y-3.5,y+3.5),uniform(z-3.5,z+3.5))
> #randompoint
>  pacord = [x1,y1,z1] #random point coordinates
>  dist_pap = euDist(uacoord, pacord) # check distance between object
> and random points
> 
>  if (dist_pap > 2.5): # if the random point far from obect
>  dist_pap1 = dist_pap
> vecpw = euvector(uacoord, pacord) # generate vectors b/w objject and
> random point
> 
> # angle between angle between object and random point
> num1 = np.dot (vect1, vecpw)
> denom1 = np.linalg.norm(vect1) * np.linalg.norm(vecpw)
> ang1 = rad2deg(np.arccos(num1/denom1))
> 
> if 140 > ang1 >100: # check angle
>  ang2= ang1
> print pacord
> 
> Queries
> every time i am getting new result (new positions of the random
> point). How to fix it.
> on above basis I want to score each random point and the two random
> point should be 2.5 distance apart from each other. How I can avoid
> overlapping of the random points.
> 

I am not sure if i understand the question correctly but if you always 
want to get the same random number, every time you run the script, you 
can fix the random seed by using np.random.seed(). Regarding your second 
question, when I understand correctly, you somehow want to find two 
points that have a distance of 2.5. If you already have one of them, I 
would generate the second one using spherical coordinates and specifying 
the distance a priori. something like:

def pt2(pt1, distance=2.5):
 theta = np.random.rand()*np.pi
 phi = np.random.rand()*2*np.pi
 r = distance
 x = r*np.sin(theta)*np.cos(phi)
 y = r*np.sin(theta)*np.sin(phi)
 z = r*np.cos(theta)
 return pt1 + np.array((x,y,z))


In [367]: pt1 = np.array([0,0,0])

In [368]: pt2(pt1)
Out[368]: a = array([-2.29954368, -0.57223342,  0.79664785])

In [369]: np.linalg.norm(a)
Out[369]: 2.5

Hope this helps,
Hanno

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] how to do scoring of random point to avoid overlapping in python

2013-10-18 Thread Pooja Gupta
I have generated random point around a object and then evaluate each random
point on certain criteria. But problem is that every time I am getting new
point. How i can resolve this problem so that my result should be uniform.
Is any way to evaluate the position of random point.


for arang in range(1000):# generate 1000 random point
around object
arang = arang + 1
x,y,z = 9.251, 24.410, 64.133   # coordinates of objects (i
have 500 object coordinates)

x1,y1,z1 = (uniform(x-3.5,x+3.5),uniform(y-3.5,y+3.5),uniform(z-3.5,z+3.5))
#randompoint
pacord = [x1,y1,z1]   #random point coordinates
dist_pap = euDist(uacoord, pacord)  # check distance between
object and random points

if  (dist_pap > 2.5):   # if the random point far from obect
dist_pap1 = dist_pap
vecpw = euvector(uacoord, pacord)  # generate vectors b/w objject
and random point

# angle between angle between object and random point
num1 = np.dot (vect1, vecpw)
denom1 = np.linalg.norm(vect1) * np.linalg.norm(vecpw)
ang1 = rad2deg(np.arccos(num1/denom1))
if 140 > ang1 >100:# check angle
ang2= ang1print pacord


Queries
every time i am getting new result (new positions of the random
point). How to fix it.
on above basis I want to score each random point and the two random
point should be 2.5 distance apart from each other. How I can avoid
overlapping of the random points.



-- 
पूजा गुप्ता, पीएचडी
राष्ट्रीय कोशिका विज्ञान केंद्र

"जीवन को खुल कर मुस्कुराने दो, खोल दो बाहे अवसर आने दो ।
पग बढाओ हर पथ तुम्हारा है, पथ कंटक मंजिलो का इशारा है।।"
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion