You would have to use the numpy_support.vtk_to_numpy and numpy_support.numpy_to_vtk functions. <br><br>You can find this module in the directory<br><div style="margin-left: 40px;">ParaView-3.8.0-Linux-x86_64/lib/paraview-3.8/paraview<br>
</div><br>Then, you might write something like (for a StructuredGrid)<br><div style="margin-left: 40px;">array = numpy_support.vtk_to_numpy(Data.GetPointData().GetArray(1))<br>array = numpy.nan_to_num(array)<br>ArrayWithoutNan = numpy_support.numpy_to_vtk(array)<br>
ArrayWithoutNan.SetName(TheNameYouWant)<br>Data.GetPointData().AddArray(ArrayWithoutNan)<br></div><br>Maybe there are some mistakes, but here is the way I would do this, in a programmable filter.<br><br><div class="gmail_quote">
Le 20 août 2010 16:00, Aurélien Marsan <span dir="ltr"><<a href="mailto:aur.marsan@gmail.com">aur.marsan@gmail.com</a>></span> a écrit :<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi, <br><br>If you're using python, and if you can use the numpy library, you can use the function numpy.nan_to_num too. <br><a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.nan_to_num.html#numpy.nan_to_num" target="_blank">http://docs.scipy.org/doc/numpy/reference/generated/numpy.nan_to_num.html#numpy.nan_to_num</a><br>
<br>Regards, <br><br>Aurélien<br><br><div class="gmail_quote">2010/8/20 David E DeMarle <span dir="ltr"><<a href="mailto:dave.demarle@kitware.com" target="_blank">dave.demarle@kitware.com</a>></span><div><div></div>
<div class="h5"><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
That said, the same trick may work in the standard calculator filter<br>
with the expression:<br>
<br>
if(val=val, val, 0.0)<br>
<div><br>
David E DeMarle<br>
Kitware, Inc.<br>
R&D Engineer<br>
28 Corporate Drive<br>
Clifton Park, NY 12065-8662<br>
Phone: 518-371-3971 x109<br>
<br>
<br>
<br>
</div><div><div></div><div>On Fri, Aug 20, 2010 at 9:26 AM, David E DeMarle<br>
<<a href="mailto:dave.demarle@kitware.com" target="_blank">dave.demarle@kitware.com</a>> wrote:<br>
> You might write a python filter that iterates over all floating point arrays and<br>
> replaces nan's with 0.<br>
><br>
> According to <a href="http://stackoverflow.com/questions/944700/how-to-check-for-nan-in-python" target="_blank">http://stackoverflow.com/questions/944700/how-to-check-for-nan-in-python</a><br>
> The most py version robust way to check for nan is:<br>
><br>
> def isNaN(num):<br>
> return num != num<br>
><br>
> David E DeMarle<br>
> Kitware, Inc.<br>
> R&D Engineer<br>
> 28 Corporate Drive<br>
> Clifton Park, NY 12065-8662<br>
> Phone: 518-371-3971 x109<br>
><br>
><br>
><br>
> On Thu, Aug 19, 2010 at 11:24 PM, Moreland, Kenneth <<a href="mailto:kmorel@sandia.gov" target="_blank">kmorel@sandia.gov</a>> wrote:<br>
>> This might not be the best solution, but you can use the threshold filter to<br>
>> remove NANs. A NAN will always fall outside the threshold range.<br>
>><br>
>> -Ken<br>
>><br>
>><br>
>> On 8/19/10 6:28 PM, "Scott, W Alan" <<a href="mailto:wascott@sandia.gov" target="_blank">wascott@sandia.gov</a>> wrote:<br>
>><br>
>> Is there a way to convert nan’s to zeros in ParaView? I have a user that is<br>
>> trying to use the integrate data filter, and it is having troubles with<br>
>> NANs.<br>
>><br>
>> Thanks,<br>
>><br>
>> Alan<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>><br>
>> Visit other Kitware open-source projects at<br>
>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>><br>
>> Please keep messages on-topic and check the ParaView Wiki at:<br>
>> <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
>><br>
>> Follow this link to subscribe/unsubscribe:<br>
>> <a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
>><br>
>><br>
><br>
_______________________________________________<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/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/ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
</div></div></blockquote></div></div></div><br>
</blockquote></div><br>