[vtkusers] Can vtkArrayCalculator handle NAN values?

Sean Ziegeler sean.ziegeler at nrlssc.navy.mil
Tue Aug 30 14:10:13 EDT 2011


Numpy has a few functions, like nansum that perform operations that ignore NaN's.  See:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.nansum.html

However, if you are simply subtracting two arrays, e.g., C=A-B, and A has NaN's in positions where B does not, you will have to decide how to treat the NaN's based on your application.  By default, the array values in C where A was NaN will be set to NaN.  If you want to do something else, I suggest replacing all NaNs with a value that makes sense for your application.  You can do that using the numpy isnan() function:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.isnan.html#numpy.isnan

-Sean

On 08/29/11 22:32, rakesh patil wrote:
> Hello,
> 
> I have two vtkDoubleArray objects. Say A and B. I need to perform A-B 
> operation and store the resultant in suppose C.
> 
> I use vtkArrayCalculator in order to do this. Now the problem is my 
> array A contains some NAN values or say bad values. which I obviously 
> want to avoid. And therefore I am not getting the expected results.
> 
> So is there any way out to handle NAN's in vtkArrayCalculator..???
> 
> Thanks
> 
> Regards
> Rakesh Patil
> 
> 
> 
> _______________________________________________
> 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 VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers



More information about the vtkusers mailing list