[Paraview] nan

Aurélien Marsan aur.marsan at gmail.com
Fri Aug 20 10:11:57 EDT 2010


You would have to use the numpy_support.vtk_to_numpy and
numpy_support.numpy_to_vtk functions.

You can find this module in the directory
ParaView-3.8.0-Linux-x86_64/lib/paraview-3.8/paraview

Then, you might write something like (for a StructuredGrid)
array = numpy_support.vtk_to_numpy(Data.GetPointData().GetArray(1))
array = numpy.nan_to_num(array)
ArrayWithoutNan = numpy_support.numpy_to_vtk(array)
ArrayWithoutNan.SetName(TheNameYouWant)
Data.GetPointData().AddArray(ArrayWithoutNan)

Maybe there are some mistakes, but here is the way I would do this, in a
programmable filter.

Le 20 août 2010 16:00, Aurélien Marsan <aur.marsan at gmail.com> a écrit :

> Hi,
>
> If you're using python, and if you can use the numpy library, you can use
> the function numpy.nan_to_num too.
>
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.nan_to_num.html#numpy.nan_to_num
>
> Regards,
>
> Aurélien
>
> 2010/8/20 David E DeMarle <dave.demarle at kitware.com>
>
> That said, the same trick may work in the standard calculator filter
>> with the expression:
>>
>> if(val=val, val, 0.0)
>>
>> David E DeMarle
>> Kitware, Inc.
>> R&D Engineer
>> 28 Corporate Drive
>> Clifton Park, NY 12065-8662
>> Phone: 518-371-3971 x109
>>
>>
>>
>> On Fri, Aug 20, 2010 at 9:26 AM, David E DeMarle
>> <dave.demarle at kitware.com> wrote:
>> > You might write a python filter that iterates over all floating point
>> arrays and
>> > replaces nan's with 0.
>> >
>> > According to
>> http://stackoverflow.com/questions/944700/how-to-check-for-nan-in-python
>> > The most py version robust way to check for nan is:
>> >
>> > def isNaN(num):
>> >    return num != num
>> >
>> > David E DeMarle
>> > Kitware, Inc.
>> > R&D Engineer
>> > 28 Corporate Drive
>> > Clifton Park, NY 12065-8662
>> > Phone: 518-371-3971 x109
>> >
>> >
>> >
>> > On Thu, Aug 19, 2010 at 11:24 PM, Moreland, Kenneth <kmorel at sandia.gov>
>> wrote:
>> >> This might not be the best solution, but you can use the threshold
>> filter to
>> >> remove NANs.  A NAN will always fall outside the threshold range.
>> >>
>> >> -Ken
>> >>
>> >>
>> >> On 8/19/10 6:28 PM, "Scott, W Alan" <wascott at sandia.gov> wrote:
>> >>
>> >> Is there a way to convert nan’s to zeros in ParaView?  I have a user
>> that is
>> >> trying to use the integrate data filter, and it is having troubles with
>> >> NANs.
>> >>
>> >> Thanks,
>> >>
>> >> Alan
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> _______________________________________________
>> >> Powered by www.kitware.com
>> >>
>> >> Visit other Kitware open-source projects at
>> >> http://www.kitware.com/opensource/opensource.html
>> >>
>> >> Please keep messages on-topic and check the ParaView Wiki at:
>> >> http://paraview.org/Wiki/ParaView
>> >>
>> >> Follow this link to subscribe/unsubscribe:
>> >> http://www.paraview.org/mailman/listinfo/paraview
>> >>
>> >>
>> >
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the ParaView Wiki at:
>> http://paraview.org/Wiki/ParaView
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.paraview.org/mailman/listinfo/paraview
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20100820/7d30d0fd/attachment.htm>


More information about the ParaView mailing list