[Paraview] nan

Eric E. Monson emonson at cs.duke.edu
Mon Aug 23 09:27:35 EDT 2010


Hey Aurélien,

Most of what I know about this new interface is from a couple of examples that Berk posted a while back (he may have written the interface...?), and from looking at the python module dataset_adapter.py in ParaView/Utilities/VTKPythonWrapping/paraview/vtk. I don't understand it all, but it basically seems to make it easier to go back and forth between VTK data sets (and data arrays) and numpy arrays. In the same directory, algorithms.py uses this data_adapter module, and data_adapter uses numpy_support, plus creates new classes which bundle together the VTK and numpy objects, and make them easy (and pythonic) to access.

I have never used it, but it looks like there is some support built in for multi-block data sets -- there are CompositeDataSet and CompositeDataIterator classes defined towards the end of dataset_adapter.py. It looks like there isn't the type of GetBlock() support you were expecting, but instead you can iterate through the blocks:

for block in inputs[0]:
  print block.Points

I haven't done that much with it, but it really seems to be a handy way to use numpy in the programmable filters!

Talk to you later,
-Eric


On Aug 23, 2010, at 8:44 AM, Aurélien Marsan wrote:

> Hello Eric, 
> 
> I'm very interested in what you call "super-spiffy-numpy-hidden-behind-the-scenes". 
> That would shorten most of my scripts ! 
> 
> But do you know if it can handle with MultiBlockDataSet ?... 
> 
> I would have like to do inputs[0].GetBlock(1).PointData[att_name]
> But it doesn't seem to work... 
> 
> Thanks, 
> 
> Aurélien 
> 
> 2010/8/20 Eric E. Monson <emonson at cs.duke.edu>
> If you can use numpy, and you're using a recent-enough version of ParaView, then you can also use the super-spiffy-numpy-hidden-behind-the-scenes programmable filter API to replace all of the attribute arrays with zero'd versions:
> 
> pdi = self.GetInputDataObject(0,0)
> pdo = self.GetOutputDataObject(0)
> pdo.CopyStructure(pdi)
> 
> for att_name in inputs[0].PointData.keys():
> 	naninc = inputs[0].PointData[att_name]
> 	zerod = numpy.nan_to_num(naninc)
> 	output.PointData.append(zerod, att_name)
> 
> Talk to you later,
> -Eric
> 
> ------------------------------------------------------
> Eric E Monson
> Duke Visualization Technology Group
> 
> 
> On Aug 20, 2010, at 10:00 AM, Aurélien Marsan wrote:
> 
>> 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
>> 
>> _______________________________________________
>> 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/20100823/e25a8a31/attachment-0001.htm>


More information about the ParaView mailing list