[Paraview] Newbie question on Python Programmable Filters

Andy Bauer andy.bauer at kitware.com
Wed Sep 5 16:01:54 EDT 2012


I'm not sure I completely understand about your inputs[0]. As for iterating
over time with the python programmable filter, inside the filter it will
only have access to values from a single time step at each invocation of
RequestData(). You can think of the order of operations if you have 5 time
steps as:
1) iterate over each of the 5 time steps (i.e. load a file and update the
pipeline with that data set)
2) update the python programmable filter output for the current data set
resulting from the loaded file

If you want time statistics for your variables I think you probably want to
use the calculator filter to square the value at each point and then use
the temporal statistics filter to get an average of those values. After
that you can just multiply the results by the number of time steps.

If I'm misunderstanding what you're trying to do, I'd suggest giving a
description of what you're trying to do and maybe there's a simpler way of
doing it.

Andy

On Wed, Sep 5, 2012 at 2:56 PM, Frank Horowitz
<frank.horowitz at cornell.edu>wrote:

>  OK Andy,
>
> Thanks for that!
>
> I've compiled and installed Paraview from git's release branch, and (a
> slight modification) of your code runs correctly. I think that means that
> my paraview/python integration is semi-sane.
>
> However, my problem still occurs. Recall that I have a time series of .vtu
> files (indexed by integers built-in to their filenames) being fed into
> inputs[0] (at least as I understand it).
>
> In my original code snippet, I assumed that the "m = x*x" statement would
> iterate not only over the point values of the spatial array, but also over
> all timeslices.  Is that a correct assumption? Is that the source of my
> problems???
>
> Thanks again for your help,
>     Frank Horowitz
>
>  ------------------------------
> *From:* Andy Bauer [andy.bauer at kitware.com]
> *Sent:* Tuesday, September 04, 2012 7:57 PM
> *To:* Frank Horowitz
> *Cc:* paraview at paraview.org
> *Subject:* Re: [Paraview] Newbie question on Python Programmable Filters
>
>  Hi Frank,
>
> I didn't have a problem with the following on my windows machine using the
> ParaView 3.14.1 installer.
> =======
> try: paraview.simple
>
> except: from paraview.simple import *
>
> paraview.simple._DisableFirstRenderCameraReset()
>
> Wavelet1 = Wavelet()
>
> RenderView1 = GetRenderView()
>
> ProgrammableFilter1 = ProgrammableFilter()
>
>  ProgrammableFilter1.PythonPath = ''
>
> ProgrammableFilter1.RequestInformationScript = ''
>
> ProgrammableFilter1.Script = 'x = inputs[0].PointData[\'RTData\']\nprint
> "x shape =",x.shape\n\nm = x*x # I _thought_ this should run at numpy
> speeds?\nprint "m shape=",m.shape\n\n# more debugging code to finish
> computation of the norm omitted\n\noutput.PointData.append(m,"Displacement
> Norm")'
>
> Show()
>
> Render()
>
> =============
>
> Does this work for you?  If it doesn't, I wonder if it's an issue with
> having multiple pythons and numpy or system environments causing problems.
> What version of paraview are you using and how did you get it
> built/installed on your machine?
>
> Andy
>
> On Tue, Sep 4, 2012 at 6:04 PM, Frank Horowitz <frank.horowitz at cornell.edu
> > wrote:
>
>> Hal Canary wrote on Tue Sep 4 15:22:01 EDT 2012:
>> > On 09/04/2012 02:20 PM, Frank Horowitz wrote:
>> > >
>> >  x = inputs[0].PointData['Scalars_']
>> >
>> >
>> >
>> > I thought one needs to convert a vtkarray to a numpy array with
>> >
>> >       x = numpy.array(inputs[0].PointData['Scalars_'])
>> >
>> > before doing anything with it.
>>
>>
>>  Computations after that style of construction hang too.  To my eye, the
>> results of such an expression should be 100% standard numpy, obeying 100%
>> standard numpy semantics.
>>
>> It appears that there is a bug in numpy integration to the Python
>> Programmable Filter.
>>
>> I'll re-compile from source and report back on the results.  Is the bug
>> tracking system evident from the homepage?
>>
>> Cheers,
>>         Frank Horowitz
>>
>>
>>
>>
>> _______________________________________________
>> 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/20120905/925c80ec/attachment.htm>


More information about the ParaView mailing list