<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hey Aurélien,<div><br></div><div>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.</div><div><br></div><div>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:</div><div><br></div><div>for block in inputs[0]:</div><div> print block.Points</div><div><br></div><div>I haven't done that much with it, but it really seems to be a handy way to use numpy in the programmable filters!</div><div><br></div><div>Talk to you later,</div><div>-Eric</div><div><br></div><div><br><div><div>On Aug 23, 2010, at 8:44 AM, Aurélien Marsan wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hello Eric, <br><br>I'm very interested in what you call "super-spiffy-numpy-hidden-behind-the-scenes". <br>That would shorten most of my scripts ! <br><br>But do you know if it can handle with MultiBlockDataSet ?... <br>
<br>I would have like to do inputs[0].GetBlock(1).PointData[att_name]<br>But it doesn't seem to work... <br><br>Thanks, <br><br>Aurélien <br><br><div class="gmail_quote">2010/8/20 Eric E. Monson <span dir="ltr"><<a href="mailto:emonson@cs.duke.edu">emonson@cs.duke.edu</a>></span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;">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:<div>
<br></div><div><div style="margin: 0px; text-indent: 0px;">pdi = self.GetInputDataObject(0,0)</div><div style="margin: 0px; text-indent: 0px;">pdo = self.GetOutputDataObject(0)</div><div style="margin: 0px; text-indent: 0px;">
pdo.CopyStructure(pdi)</div><p style="margin: 0px; text-indent: 0px;"></p><div style="margin: 0px; text-indent: 0px;"><br></div><div style="margin: 0px; text-indent: 0px;">for att_name in inputs[0].PointData.keys():</div>
<div style="margin: 0px; text-indent: 0px;"><span style="white-space: pre-wrap;">        </span>naninc = inputs[0].PointData[att_name]</div><div style="margin: 0px; text-indent: 0px;"><span style="white-space: pre-wrap;">        </span>zerod = numpy.nan_to_num(naninc)</div>
<div style="margin: 0px; text-indent: 0px;"><span style="white-space: pre-wrap;">        </span>output.PointData.append(zerod, att_name)</div><div style="margin: 0px; text-indent: 0px;"><br></div><div style="margin: 0px; text-indent: 0px;">
Talk to you later,</div><div class="im"><div style="margin: 0px; text-indent: 0px;">-Eric</div><div style="margin: 0px; text-indent: 0px;"><br></div><div>
<span style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div>
------------------------------------------------------</div><div>Eric E Monson</div><div>Duke Visualization Technology Group</div><div><span style="font-size: medium;"><br></span></div></span>
</div>
<br></div><div><div></div><div class="h5"><div><div>On Aug 20, 2010, at 10:00 AM, Aurélien Marsan wrote:</div><br><blockquote type="cite">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><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><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>
</blockquote></div><br></div></div></div></div></blockquote></div><br>
</blockquote></div><br></div></body></html>