<div dir="ltr"><div><div><div><div>The Gradient of Unstructured Dataset does increase the tensor dimension. So a scalar, or 1 component array in VTK/PV, becomes a vector, or a 3 components array. Similarly, a vector becomes a 2nd order tensor, or 9 component array.<br><br></div>Andrea: could you try upgrading to ParaView 5.5 (available at <a href="http://paraview.org/download">paraview.org/download</a>) ? Some of the numpy support has been improved since 5.3. I tried your original Programmable Filter script and I got an eigenvectors and eigenvalues array:<br>
<p class="MsoNormal" style="margin-top:9pt"><b><span style="font-size:10pt;font-family:"Courier New";color:green">import</span></b><span style="font-size:10pt;font-family:"Courier New"">
<b><span style="color:blue">numpy</span></b> <b><span style="color:green">as</span></b>
<b><span style="color:blue">np</span></b><u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:"Courier New";color:green">from</span></b><span style="font-size:10pt;font-family:"Courier New"">
<b><span style="color:blue">numpy</span></b> <b><span style="color:green">import</span></b> linalg
<b><span style="color:green">as</span></b> LA<u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:"Courier New";color:green">from</span></b><span style="font-size:10pt;font-family:"Courier New"">
<b><span style="color:blue">paraview</span></b> <b><span style="color:green">import</span></b> numpy_support<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New";color:green">input</span><span style="font-size:10pt;font-family:"Courier New"">
<span style="color:rgb(102,102,102)">=</span> inputs[<span style="color:rgb(102,102,102)">0</span>]<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">numPoints
<span style="color:rgb(102,102,102)">=</span> <span style="color:green">input</span><span style="color:rgb(102,102,102)">.</span>GetNumberOfPoints()<u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:"Courier New";color:green">print</span></b><span style="font-size:10pt;font-family:"Courier New"">
<span style="color:rgb(186,33,33)">"number of points"</span>,numPoints<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">tensors
<span style="color:rgb(102,102,102)">=</span> <span style="color:green">input</span><span style="color:rgb(102,102,102)">.</span>PointData[<span style="color:rgb(186,33,33)">'Gradients'</span>]<u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:"Courier New";color:green">print</span></b><span style="font-size:10pt;font-family:"Courier New"">
<span style="color:rgb(186,33,33)">"tensors[0:3]"</span>,tensors[<span style="color:rgb(102,102,102)">0</span>:<span style="color:rgb(102,102,102)">3</span>]<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">eigenvalues,eigenvectors
<span style="color:rgb(102,102,102)">=</span> LA<span style="color:rgb(102,102,102)">.</span>eig(tensors)<u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:"Courier New";color:green">print</span></b><span style="font-size:10pt;font-family:"Courier New"">
<span style="color:rgb(186,33,33)">'eigenvalues'</span>, eigenvalues[<span style="color:rgb(102,102,102)">0</span>]<u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:"Courier New";color:green">print</span></b><span style="font-size:10pt;font-family:"Courier New"">
<span style="color:rgb(186,33,33)">'eigenvectors'</span>,eigenvectors[<span style="color:rgb(102,102,102)">0</span>]<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">output<span style="color:rgb(102,102,102)">.</span>PointData<span style="color:rgb(102,102,102)">.</span>append(<wbr>eigenvalues,<span style="color:rgb(186,33,33)">'eigenvalues'</span>)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman","serif"">output<span style="color:rgb(102,102,102)">.</span>PointData<span style="color:rgb(102,102,102)">.</span>append(<wbr>eigenvectors,<span style="color:rgb(186,33,33)">'eigenvectors'</span>)</span></p>
<br><br></div>Once you get PV 5.5, you can try loading the attached eigen.pvsm state file which worked for me if you want to test it out. Note that since I used the Gradient of Unstructured Dataset filter twice to go from a scalar array to a second order tensor before doing the programmable filter, I used Gradients2 for the output array name for the second order tensor.<br><br></div>Best,<br></div>Andy<br><br><div><div><div><div><br></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 19, 2018 at 1:03 AM, Caffagni, Andrea <span dir="ltr"><<a href="mailto:Andrea.Caffagni@ferrari.com" target="_blank">Andrea.Caffagni@ferrari.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div link="blue" vlink="purple" lang="EN-US">
<div class="m_4058480906308904695WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">If I add simply the code suggested from you Oscar, my filters becomes:<u></u><u></u></span></p><span class="">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-top:9.0pt"><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">import</span></b><span style="font-size:10.0pt;font-family:"Courier New"">
<b><span style="color:blue">numpy</span></b> <b><span style="color:green">as</span></b>
<b><span style="color:blue">np</span></b><u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">from</span></b><span style="font-size:10.0pt;font-family:"Courier New"">
<b><span style="color:blue">numpy</span></b> <b><span style="color:green">import</span></b> linalg
<b><span style="color:green">as</span></b> LA<u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">from</span></b><span style="font-size:10.0pt;font-family:"Courier New"">
<b><span style="color:blue">paraview</span></b> <b><span style="color:green">import</span></b> numpy_support<u></u><u></u></span></p>
</span><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">from</span></b><span style="font-size:10.0pt;font-family:"Courier New"">
<b><span style="color:blue">vtk.util</span></b> <b><span style="color:green">import</span></b> numpy_support<u></u><u></u></span></p><span class="">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:green">input</span><span style="font-size:10.0pt;font-family:"Courier New"">
<span style="color:#666666">=</span> inputs[<span style="color:#666666">0</span>]<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">numPoints
<span style="color:#666666">=</span> <span style="color:green">input</span><span style="color:#666666">.</span>GetNumberOfPoints()<u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">print</span></b><span style="font-size:10.0pt;font-family:"Courier New"">
<span style="color:#ba2121">"number of points"</span>,numPoints<u></u><u></u></span></p>
</span><p class="MsoNormal"><i><span style="font-size:10.0pt;font-family:"Courier New";color:#408080">#print "keys",input.GetPointData().<wbr>keys()</span></i><span style="font-size:10.0pt;font-family:"Courier New""><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">tensorsVTK
<span style="color:#666666">=</span> <span style="color:green">input</span><span style="color:#666666">.</span>PointData[<span style="color:#ba2121">'Gradients'</span>]<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">tensorsNP<span style="color:#666666">=</span>numpy_support<span style="color:#666666">.</span>vtk_<wbr>to_numpy(tensorsVTK)<u></u><u></u></span></p>
<p class="MsoNormal"><i><span style="font-size:10.0pt;font-family:"Courier New";color:#408080">#tensors[0,:,:]=np.diag((1,2,<wbr>3))</span></i><span style="font-size:10.0pt;font-family:"Courier New""><u></u><u></u></span></p>
<p class="MsoNormal"><i><span style="font-size:10.0pt;font-family:"Courier New";color:#408080">#tensors[0,:,:]=[[1,-1,2],[2,-<wbr>1,3],[0,0,1]]</span></i><span style="font-size:10.0pt;font-family:"Courier New""><u></u><u></u></span></p><span class="">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">print</span></b><span style="font-size:10.0pt;font-family:"Courier New"">
<span style="color:#ba2121">"tensors[0:3]"</span>,tensors[<span style="color:#666666">0</span>:<span style="color:#666666">3</span>]<u></u><u></u></span></p>
</span><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">eigenvalues,eigenvectors
<span style="color:#666666">=</span> LA<span style="color:#666666">.</span>eig(tensorsNP)<u></u><u></u></span></p><span class="">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">print</span></b><span style="font-size:10.0pt;font-family:"Courier New"">
<span style="color:#ba2121">'eigenvalues'</span>, eigenvalues[<span style="color:#666666">0</span>]<u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">print</span></b><span style="font-size:10.0pt;font-family:"Courier New"">
<span style="color:#ba2121">'eigenvectors'</span>,eigenvectors[<span style="color:#666666">0</span>]<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">output<span style="color:#666666">.</span>PointData<span style="color:#666666">.</span>append(<wbr>eigenvalues,<span style="color:#ba2121">'eigenvalues'</span>)<u></u><u></u></span></p>
<p class="MsoNormal">output<span style="color:#666666">.</span>PointData<span style="color:#666666">.</span>append(<wbr>eigenvectors,<span style="color:#ba2121">'eigenvectors'</span>)<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</span><p class="MsoNormal">I obtain the following Output:<u></u><u></u></p><span class="">
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p style="margin:0cm;margin-bottom:.0001pt"><span style="font-size:8.5pt;font-family:Courier;color:maroon">Traceback (most recent call last):</span><u></u><u></u></p>
<p style="margin:0cm;margin-bottom:.0001pt"><span style="font-size:8.5pt;font-family:Courier;color:maroon">File "<string>", line 22, in <module></span><u></u><u></u></p>
</span><p style="margin:0cm;margin-bottom:.0001pt"><span style="font-size:8.5pt;font-family:Courier;color:maroon">File "<string>", line 8, in RequestData</span><u></u><u></u></p>
<p style="margin:0cm;margin-bottom:.0001pt"><span style="font-size:8.5pt;font-family:Courier;color:maroon">UnboundLocalError: local variable 'NumPy_data' referenced before assignment</span><u></u><u></u></p><span class="">
<p style="margin:0cm;margin-bottom:.0001pt"><span style="font-size:8.5pt;font-family:Courier;color:maroon">Traceback (most recent call last):</span><u></u><u></u></p>
<p style="margin:0cm;margin-bottom:.0001pt"><span style="font-size:8.5pt;font-family:Courier;color:maroon">File "<string>", line 22, in <module></span><u></u><u></u></p>
</span><p style="margin:0cm;margin-bottom:.0001pt"><span style="font-size:8.5pt;font-family:Courier;color:maroon">File "<string>", line 12, in RequestData</span><u></u><u></u></p>
<p style="margin:0cm;margin-bottom:.0001pt"><span style="font-size:8.5pt;font-family:Courier;color:maroon">File "C:\Program Files\ParaView 5.3.0-Qt5-OpenGL2-Windows-<wbr>64bit\bin\lib\site-packages\<wbr>vtk\util\numpy_support.py", line 213, in vtk_to_numpy</span><u></u><u></u></p>
<p style="margin:0cm;margin-bottom:.0001pt"><span style="font-size:8.5pt;font-family:Courier;color:maroon">typ = vtk_array.GetDataType()</span><u></u><u></u></p>
<p style="margin:0cm;margin-bottom:.0001pt"><span style="font-size:8.5pt;font-family:Courier;color:maroon">AttributeError: 'VTKCompositeDataArray' object has no attribute 'GetDataType'</span><u></u><u></u></p>
<p style="margin:0cm;margin-bottom:.0001pt"><span style="font-size:8.5pt;font-family:Courier;color:green">number of points 1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I need to reshape the vector or define the type?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Best Regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Andrea<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Oscar Wilsby [mailto:<a href="mailto:ow222@cam.ac.uk" target="_blank">ow222@cam.ac.uk</a>]
<br>
<b>Sent:</b> Wednesday, April 18, 2018 21:14<br>
<b>To:</b> Cory Quammen<br>
<b>Cc:</b> Caffagni, Andrea; Andy Bauer; <a href="mailto:paraview@public.kitware.com" target="_blank">paraview@public.kitware.com</a></span></p><div><div class="h5"><br>
<b>Subject:</b> Re: [Paraview] Problem with numpy array<u></u><u></u></div></div><p></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Hi Andy,<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I haven’t verified, but at a glance it looks like what you are passing to the the LA.eig function is not a 2D numpy array. Can you try doing np.asarray(tensors) or <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<pre style="background:#eff0f1;vertical-align:baseline;line-height:inherit;box-sizing:inherit;max-height:600px;word-wrap:normal;overflow:auto"><span class="m_4058480906308904695kwd"><span style="font-family:"inherit","serif";color:#101094;border:none windowtext 1.0pt;padding:0cm">from</span></span><span class="m_4058480906308904695pln"><span style="font-family:"inherit","serif";color:#303336;border:none windowtext 1.0pt;padding:0cm"> vtk</span></span><span class="m_4058480906308904695pun"><span style="font-family:"inherit","serif";color:#303336;border:none windowtext 1.0pt;padding:0cm">.</span></span><span class="m_4058480906308904695pln"><span style="font-family:"inherit","serif";color:#303336;border:none windowtext 1.0pt;padding:0cm">util</span></span><span class="m_4058480906308904695pun"><span style="font-family:"inherit","serif";color:#303336;border:none windowtext 1.0pt;padding:0cm">.</span></span><span class="m_4058480906308904695pln"><span style="font-family:"inherit","serif";color:#303336;border:none windowtext 1.0pt;padding:0cm">numpy_support </span></span><span class="m_4058480906308904695kwd"><span style="font-family:"inherit","serif";color:#101094;border:none windowtext 1.0pt;padding:0cm">import</span></span><span class="m_4058480906308904695pln"><span style="font-family:"inherit","serif";color:#303336;border:none windowtext 1.0pt;padding:0cm"> vtk_to_numpy</span></span><span style="font-family:Consolas;color:#393318"><u></u><u></u></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline;line-height:inherit;box-sizing:inherit;max-height:600px;word-wrap:normal;overflow:auto"><span style="font-family:Consolas;color:#303336">tensors = vtk_to_numpy(tensors)</span><span style="font-family:Consolas"><u></u><u></u></span></pre>
<div>
<p class="MsoNormal">and then pass that to LA.eig?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Kind regards,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Oscar<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On 18 Apr 2018, at 16:33, Cory Quammen <<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.com</a>> wrote:<u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">Hey Andy,<br>
<br>
Does the GradientOfUnstructuredDataSet filter produce a tensor from an input vector field? My testing in ParaView indicates it doesn't , but I'm not super familiar with it.<u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">Thanks,<u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">Cory<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""><u></u> <u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">On Wed, Apr 18, 2018 at 11:14 AM, Caffagni, Andrea<span class="m_4058480906308904695apple-converted-space"> </span><<a href="mailto:Andrea.Caffagni@ferrari.com" target="_blank">Andrea.Caffagni@<wbr>ferrari.com</a>><span class="m_4058480906308904695apple-converted-space"> </span>wrote:<u></u><u></u></span></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Dear Cory,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">This is the complete message that I have obtained like output:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon">Traceback (most recent call last):</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon">File "<string>", line 22, in <module></span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon">File "<string>", line 14, in RequestData</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon">File "C:\Program Files\ParaView 5.3.0-Qt5-OpenGL2-Windows-<wbr>64bit\bin\lib\site-packages\<wbr>numpy\linalg\linalg.py", line
1095, in eig</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon">_assertRankAtLeast2(a)</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon">File "C:\Program Files\ParaView 5.3.0-Qt5-OpenGL2-Windows-<wbr>64bit\bin\lib\site-packages\<wbr>numpy\linalg\linalg.py", line
202, in _assertRankAtLeast2</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon">'at least two-dimensional' % len(a.shape))</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon">numpy.linalg.linalg.<wbr>LinAlgError: 0-dimensional array given. Array must be at least two-dimensional</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:green">number of points 1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:green">tensors[0:3] [VTKArray([[[ 8.34616375, -23.89611435, 2.00894117],</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:green">[ 0.67995167, -23.11237526, 289.07113647],</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:green">[ 27.26550674, -231.06710815, 16.90883636]]], dtype=float32)]</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:green"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:green"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:green">From this, I have thought about the vtk array.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:green"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:green">Best regards,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:green">Andrea</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span class="m_4058480906308904695apple-converted-space"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> </span></span><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">Cory
Quammen [mailto:<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.<wbr>com</a>]<span class="m_4058480906308904695apple-converted-space"> </span><br>
<b>Sent:</b><span class="m_4058480906308904695apple-converted-space"> </span>Wednesday, April 18, 2018 15:11<br>
<b>To:</b><span class="m_4058480906308904695apple-converted-space"> </span>Caffagni, Andrea<br>
<b>Cc:</b><span class="m_4058480906308904695apple-converted-space"> </span><a href="mailto:paraview@public.kitware.com" target="_blank">paraview@public.kitware.<wbr>com</a><br>
<b>Subject:</b><span class="m_4058480906308904695apple-converted-space"> </span>Re: [Paraview] Problem with numpy array</span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">Hi Andrea,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<p class="MsoNormal">Besides the error message, what does your script print?<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Cory<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Wed, Apr 18, 2018 at 2:14 AM, Caffagni, Andrea <<a href="mailto:Andrea.Caffagni@ferrari.com" target="_blank">Andrea.Caffagni@ferrari.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">Dear Users,<u></u><u></u></p>
<p class="MsoNormal">I need to solve an eigenproblem in a point of a CFD field.<u></u><u></u></p>
<p class="MsoNormal">Using the GradientOfUnstructuredDataSet I calculate the velocity gradient of my velocity field, than I isolate may point of interest and I have written the following ProgrammableFilter:<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal" style="margin-top:9.0pt"><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">import</span></b><span class="m_4058480906308904695apple-converted-space"><span style="font-size:10.0pt;font-family:"Courier New""> </span></span><b><span style="font-size:10.0pt;font-family:"Courier New";color:blue">numpy</span></b><span class="m_4058480906308904695apple-converted-space"><span style="font-size:10.0pt;font-family:"Courier New""> </span></span><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">as</span></b><span class="m_4058480906308904695apple-converted-space"><span style="font-size:10.0pt;font-family:"Courier New""> </span></span><b><span style="font-size:10.0pt;font-family:"Courier New";color:blue">np</span></b><u></u><u></u></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">from</span></b><span class="m_4058480906308904695apple-converted-space"><span style="font-size:10.0pt;font-family:"Courier New""> </span></span><b><span style="font-size:10.0pt;font-family:"Courier New";color:blue">numpy</span></b><span class="m_4058480906308904695apple-converted-space"><span style="font-size:10.0pt;font-family:"Courier New""> </span></span><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">import</span></b><span class="m_4058480906308904695apple-converted-space"><span style="font-size:10.0pt;font-family:"Courier New""> </span></span><span style="font-size:10.0pt;font-family:"Courier New"">linalg<span class="m_4058480906308904695apple-converted-space"> </span><b><span style="color:green">as</span></b><span class="m_4058480906308904695apple-converted-space"> </span>LA</span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">from</span></b><span class="m_4058480906308904695apple-converted-space"><span style="font-size:10.0pt;font-family:"Courier New""> </span></span><b><span style="font-size:10.0pt;font-family:"Courier New";color:blue">paraview</span></b><span class="m_4058480906308904695apple-converted-space"><span style="font-size:10.0pt;font-family:"Courier New""> </span></span><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">import</span></b><span class="m_4058480906308904695apple-converted-space"><span style="font-size:10.0pt;font-family:"Courier New""> </span></span><span style="font-size:10.0pt;font-family:"Courier New"">numpy_<wbr>support</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:green">input</span><span class="m_4058480906308904695apple-converted-space"><span style="font-size:10.0pt;font-family:"Courier New""> </span></span><span style="font-size:10.0pt;font-family:"Courier New";color:#666666">=</span><span class="m_4058480906308904695apple-converted-space"><span style="font-size:10.0pt;font-family:"Courier New""> </span></span><span style="font-size:10.0pt;font-family:"Courier New"">inputs[<span style="color:#666666">0</span>]</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">numPoints<span class="m_4058480906308904695apple-converted-space"> </span><span style="color:#666666">=</span><span class="m_4058480906308904695apple-converted-space"> </span><span style="color:green">input</span><span style="color:#666666">.</span>GetNumberOfP<wbr>oints()</span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">print</span></b><span class="m_4058480906308904695apple-converted-space"><span style="font-size:10.0pt;font-family:"Courier New""> </span></span><span style="font-size:10.0pt;font-family:"Courier New";color:#ba2121">"number
of points"</span><span style="font-size:10.0pt;font-family:"Courier New"">,numPoints</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">tensors<span class="m_4058480906308904695apple-converted-space"> </span><span style="color:#666666">=</span><span class="m_4058480906308904695apple-converted-space"> </span><span style="color:green">input</span><span style="color:#666666">.</span>PointData[<span style="color:#ba2121">'<wbr>Gradients'</span>]</span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">print</span></b><span class="m_4058480906308904695apple-converted-space"><span style="font-size:10.0pt;font-family:"Courier New""> </span></span><span style="font-size:10.0pt;font-family:"Courier New";color:#ba2121">"tensors[0:3]"</span><span style="font-size:10.0pt;font-family:"Courier New"">,tensors[<span style="color:#666666">0</span><wbr>:<span style="color:#666666">3</span>]</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">eigenvalues,eigenvectors<span class="m_4058480906308904695apple-converted-space"> </span><span style="color:#666666">=</span><span class="m_4058480906308904695apple-converted-space"> </span>LA<span style="color:#666666">.</span><wbr>eig(tensors)</span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">print</span></b><span class="m_4058480906308904695apple-converted-space"><span style="font-size:10.0pt;font-family:"Courier New""> </span></span><span style="font-size:10.0pt;font-family:"Courier New";color:#ba2121">'eigenvalues'</span><span style="font-size:10.0pt;font-family:"Courier New"">,
eigenvalues[<span style="color:#666666">0</span>]</span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Courier New";color:green">print</span></b><span class="m_4058480906308904695apple-converted-space"><span style="font-size:10.0pt;font-family:"Courier New""> </span></span><span style="font-size:10.0pt;font-family:"Courier New";color:#ba2121">'eigenvectors'</span><span style="font-size:10.0pt;font-family:"Courier New"">,<wbr>eigenvectors[<span style="color:#666666">0</span>]</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">output<span style="color:#666666">.</span>PointData<span style="color:#666666">.</span>append(<wbr>eigenvalues,<span style="color:#ba2121">'eigenvalues'</span>)</span><u></u><u></u></p>
<p class="MsoNormal">output<span style="color:#666666">.</span>PointData<span style="color:#666666">.</span>append(<wbr>eigenvectors,<span style="color:#ba2121">'eigenvectors'</span>)<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I have obtained the following error message:<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon">Traceback (most recent call last):</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon">File "<string>", line 22, in <module></span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon">File "<string>", line 14, in RequestData</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon">File "C:\Program Files\ParaView 5.3.0-Qt5-OpenGL2-Windows-<wbr>64bit\bin\lib\site-packages\<wbr>numpy\linalg\linalg.py", line
1095, in eig</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon">_assertRankAtLeast2(a)</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon">File "C:\Program Files\ParaView 5.3.0-Qt5-OpenGL2-Windows-<wbr>64bit\bin\lib\site-packages\<wbr>numpy\linalg\linalg.py", line
202, in _assertRankAtLeast2</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon">'at least two-dimensional' % len(a.shape))</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon">numpy.linalg.linalg.<wbr>LinAlgError: 0-dimensional array given. Array must be at least two-dimensional</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier;color:maroon"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier">I imagine that the problem is linked to the vtk array, I need to convert my ‘Gradients’ matrix in a nparray?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier">Someone have the same problem?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier">Best Regards,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8.5pt;font-family:Courier">Andrea</span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">______________________________<wbr>______________________________<wbr>______________________________<wbr>_______________________<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""> <u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">Questo messaggio è da intendersi esclusivamente ad uso del destinatario e può contenere informazioni che sono
di natura privilegiata, confidenziale o non divulgabile secondo le leggi vigenti. Se il lettore del presente messaggio non è il destinatario designato, o il dipendente/agente responsabile per la consegna del messaggio al destinatario designato, si informa
che ogni disseminazione, distribuzione o copiatura di questa comunicazione è vietata anche ai sensi della normativa vigente in materia di protezione dei dati personali. Se avete ricevuto questo messaggio per errore, vi preghiamo di notificarcelo immediatamente
a mezzo e-mail di risposta e successivamente di procedere alla cancellazione di questa e-mail e relativi allegati dal vostro sistema.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">______________________________<wbr>______________________________<wbr>______________________________<wbr>_______________________<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""> <u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">This message is intended only for the use of the addressee and may contain information that is privileged, confidential
and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution
or copying of this communication is prohibited under the applicable data protection law. If you have received this e-mail by mistake, please notify us immediately by return e-mail and delete this e-mail and all attachments from your system.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""> <u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">______________________________<wbr>______________________________<wbr>______________________________<wbr>_______________________ <u></u><u></u></span></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
______________________________<wbr>_________________<br>
Powered by<span class="m_4058480906308904695apple-converted-space"> </span><a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<span class="m_4058480906308904695apple-converted-space"> </span><a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at:<span class="m_4058480906308904695apple-converted-space"> </span><a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/<wbr>ParaView</a><br>
<br>
Search the list archives at:<span class="m_4058480906308904695apple-converted-space"> </span><a href="http://markmail.org/search/?q=ParaView" target="_blank">http://markmail.org/<wbr>search/?q=ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://public.kitware.com/mailman/listinfo/paraview" target="_blank">https://public.kitware.com/<wbr>mailman/listinfo/paraview</a><u></u><u></u></p>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<p class="MsoNormal">--<span class="m_4058480906308904695apple-converted-space"> </span><u></u><u></u></p>
<div>
<p class="MsoNormal">Cory Quammen<br>
Staff R&D Engineer<br>
Kitware, Inc.<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">______________________________<wbr>______________________________<wbr>______________________________<wbr>_______________________<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""> <u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">Questo messaggio è da intendersi esclusivamente ad uso del destinatario e può contenere informazioni che sono
di natura privilegiata, confidenziale o non divulgabile secondo le leggi vigenti. Se il lettore del presente messaggio non è il destinatario designato, o il dipendente/agente responsabile per la consegna del messaggio al destinatario designato, si informa
che ogni disseminazione, distribuzione o copiatura di questa comunicazione è vietata anche ai sensi della normativa vigente in materia di protezione dei dati personali. Se avete ricevuto questo messaggio per errore, vi preghiamo di notificarcelo immediatamente
a mezzo e-mail di risposta e successivamente di procedere alla cancellazione di questa e-mail e relativi allegati dal vostro sistema.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">______________________________<wbr>______________________________<wbr>______________________________<wbr>_______________________<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""> <u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">This message is intended only for the use of the addressee and may contain information that is privileged, confidential
and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution
or copying of this communication is prohibited under the applicable data protection law. If you have received this e-mail by mistake, please notify us immediately by return e-mail and delete this e-mail and all attachments from your system.<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""> <u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">______________________________<wbr>______________________________<wbr>______________________________<wbr>_______________________ <u></u><u></u></span></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""><br>
<br clear="all">
<br>
--<span class="m_4058480906308904695apple-converted-space"> </span><u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">Cory Quammen<br>
Staff R&D Engineer<br>
Kitware, Inc.<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif"">______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" 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" target="_blank">
http://paraview.org/Wiki/<wbr>ParaView</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=ParaView" 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" target="_blank">https://public.kitware.com/<wbr>mailman/listinfo/paraview</a></span><u></u><u></u></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div></div><div><div class="h5">
<p>______________________________<wbr>______________________________<wbr>______________________________<wbr>_______________________</p>
<p> </p>
<p>Questo messaggio è da intendersi esclusivamente ad uso del destinatario e può contenere informazioni che sono di natura privilegiata, confidenziale o non divulgabile secondo le leggi vigenti. Se il lettore del presente messaggio non è il destinatario designato,
o il dipendente/agente responsabile per la consegna del messaggio al destinatario designato, si informa che ogni disseminazione, distribuzione o copiatura di questa comunicazione è vietata anche ai sensi della normativa vigente in materia di protezione dei
dati personali. Se avete ricevuto questo messaggio per errore, vi preghiamo di notificarcelo immediatamente a mezzo e-mail di risposta e successivamente di procedere alla cancellazione di questa e-mail e relativi allegati dal vostro sistema.</p>
<p>______________________________<wbr>______________________________<wbr>______________________________<wbr>_______________________</p>
<p> </p>
<p>This message is intended only for the use of the addressee and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, or the employee or agent
responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is prohibited under the applicable data protection law. If you have received this e-mail by mistake,
please notify us immediately by return e-mail and delete this e-mail and all attachments from your system.</p>
<p> </p>
<p>______________________________<wbr>______________________________<wbr>______________________________<wbr>_______________________ </p>
</div></div></div>
</blockquote></div><br></div>