<div dir="ltr">Dennis,<div><br></div><div>First, do you mean numpy.arctan2? I don't see that numpy.atan2 exists,but math.atan2 exists.<br><div><br></div><div>Second, I suspect you are looping over millions of points in Python and are calling numpy.arctan2 on single X, Y values. Looping in Python like that will be very slow. Instead, you can get all your X values into one numpy array and do the same with your Y values, then make a single call to numpy.atan2. Here's an example:</div><div><br></div><div>

<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:Courier;font-size:13pt;color:rgb(0,0,0)">>>> </span><span style="font-family:Courier;font-size:13pt;color:rgb(0,0,150)">from paraview.simple import *</span></p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:Courier;font-size:13pt;color:rgb(0,0,0)">>>> import numpy</span></p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:Courier;font-size:13pt;color:rgb(0,0,0)">>>> x = [1, 2, 3, 4]</span></p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:Courier;font-size:13pt;color:rgb(0,0,0)">>>> y = [5, 6, 7, 8]</span></p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:Courier;font-size:13pt;color:rgb(0,0,0)">>>> numpy.arctan2(y, x)</span></p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:Courier;font-size:13pt;color:rgb(0,150,0)">array([ 1.37340077,  1.24904577,  1.16590454,  1.10714872])</span></p><br></div></div><div>To get the X and Y arrays, you can use the numpy adapter:</div><div><br></div><div>

<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:Courier;font-size:13pt;color:rgb(0,0,0)">>>> from vtk.numpy_interface import dataset_adapter as dsa</span></p>

<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:Courier;font-size:13pt;color:rgb(0,0,0)"></span></p><p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:Courier;font-size:13pt;color:rgb(0,0,0)">>>> </span><span style="font-size:13pt">wrappedData = dsa.WrapDataObject(polydata)</span></p><p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-size:13pt"></span></p><p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:Courier;font-size:13pt;color:rgb(0,0,0)">>>> X = wrappedData.Points[:,0]</span></p><p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:Courier;font-size:13pt;color:rgb(0,0,0)">>>> Y = wrappedData.Points[:,1]</span></p><p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:Courier;font-size:13pt;color:rgb(0,0,0)">>>> result = numpy.arctan2(Y, X)</span></p><br><p></p><p></p>Hope that helps,</div><div>Cory</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 28, 2018 at 1:25 AM, kenichiro yoshimi <span dir="ltr"><<a href="mailto:rccm.kyoshimi@gmail.com" target="_blank">rccm.kyoshimi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi Dennis,</div><div><br></div><div>You can calculate cylindrical coordinates by utilizing vtkCylindricalTransform within the python programmable filter. It is something like below and faster than numpy.</div><div><br></div><div>---</div><div>import vtk</div><div><br></div><div>input = self.GetInput()</div><div>output = self.GetOutput()</div><div><br></div><div>transform = vtk.vtkCylindricalTransform()</div><div><br></div><div>transformFilter = vtk.vtkTransformFilter()</div><div>transformFilter.SetInputData(<wbr>input)</div><div>transformFilter.SetTransform(<wbr>transform.GetInverse())</div><div>transformFilter.Update()</div><div><br></div><div>output.ShallowCopy(<wbr>transformFilter.GetOutput())</div><div>---</div><div><br></div><div>This converts (x,y,z) coordinates to (r,theta,z) coordinates by GetInverse method, </div><div>where the angles are calculated by the following equation to change range to [0, 2*pi]:</div><div>  theta = pi + atan2(-y, -x).</div><div><br></div><div>Regards</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">2018-04-28 5:25 GMT+09:00 Dennis Conklin <span dir="ltr"><<a href="mailto:dennis_conklin@goodyear.com" target="_blank">dennis_conklin@goodyear.com</a>></span>:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">





<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="m_-7077847443180122926m_-8861069070008416718WordSection1">
<p class="MsoNormal">Alan,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Yes, I am calling it many times at the same angular location, but it’s tough to know you’re at the same angular location without calculating the angle.
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Also, C++ is definitely orders of magnitude quicker, but once I have to compile routines into Paravew life gets very complicated.   We barely survived compiling for cluster use and I haven’t written C++ for at least 20 years.  
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">So, if possible, I would like a clever external add-on that wouldn’t require us to re-compile PV everytime we update our version.   I have visions of library errors in my nightmares!<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Dennis<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Scott, W Alan [mailto:<a href="mailto:wascott@sandia.gov" target="_blank">wascott@sandia.gov</a>] <br>
<b>Sent:</b> Friday, April 27, 2018 4:00 PM<br>
<b>To:</b> Dennis Conklin <<a href="mailto:dennis_conklin@goodyear.com" target="_blank">dennis_conklin@goodyear.com</a>>; Paraview (<a href="mailto:paraview@paraview.org" target="_blank">paraview@paraview.org</a>) <<a href="mailto:paraview@paraview.org" target="_blank">paraview@paraview.org</a>><br>
<b>Subject:</b> [EXT] RE: [EXTERNAL] [Paraview] Calculating cylindrical coordinates<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<table class="m_-7077847443180122926m_-8861069070008416718MsoNormalTable" border="1" cellspacing="1" cellpadding="0" style="background:#f3e2a9;border:outset gray 1.0pt">
<tbody>
<tr>
<td style="padding:.6pt .6pt .6pt .6pt">
<p class="MsoNormal"> <strong><span style="font-family:"Calibri",sans-serif;color:#b18904">CAUTION:
</span></strong>EXTERNAL email. Please think before clicking on any links or attachments.<u></u><u></u></p>
</td>
</tr>
</tbody>
</table><div><div class="m_-7077847443180122926h5">
<p> <u></u><u></u></p>
<div>
<p class="MsoNormal">Are there places on the cylinder you are calling atan2 with the same inputs, returning the same data, lots of times?  Alternatively, could you calculate this in the simulation, and just add it to the simulation output?  I am speculating
 that a C++ call to atan2 may be faster than numpy?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Alan<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> ParaView [<a href="mailto:paraview-bounces@public.kitware.com" target="_blank">mailto:paraview-bounces@publi<wbr>c.kitware.com</a>]
<b>On Behalf Of </b>Dennis Conklin<br>
<b>Sent:</b> Friday, April 27, 2018 1:39 PM<br>
<b>To:</b> Paraview (<a href="mailto:paraview@paraview.org" target="_blank">paraview@paraview.org</a>) <<a href="mailto:paraview@paraview.org" target="_blank">paraview@paraview.org</a>><br>
<b>Subject:</b> [EXTERNAL] [Paraview] Calculating cylindrical coordinates<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">All,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">If I wanted to run atan2(X,Y) on millions and millions of nodes to calculate cylindrical coordinates, but found that numpy.atan2 in a Programmable Filter was taking 45 minutes to run,   what should I do to make it much faster?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks for any hints<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Dennis<u></u><u></u></p>
</div>
</div>
</div></div></div>
</div>

<br></div></div>______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" rel="noreferrer" target="_blank">http://paraview.org/Wiki/ParaV<wbr>iew</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=ParaView" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://public.kitware.com/mailman/listinfo/paraview" rel="noreferrer" target="_blank">https://public.kitware.com/mai<wbr>lman/listinfo/paraview</a><br>
<br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" rel="noreferrer" target="_blank">http://paraview.org/Wiki/<wbr>ParaView</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=ParaView" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://public.kitware.com/mailman/listinfo/paraview" rel="noreferrer" target="_blank">https://public.kitware.com/<wbr>mailman/listinfo/paraview</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Cory Quammen<br>Staff R&D Engineer<br>Kitware, Inc.</div>
</div>