[Paraview] unstructured grid, programmable filters: extract, process array data

Nico Schlömer nico.schloemer at gmail.com
Wed Feb 16 12:49:28 EST 2011


> the math.atan2 function (it's not listed in the web page of python
> calculator functions)

So the Python Calculator only allows for the functions listed on the
webpage? That'd be quite limiting, really.

The expression

   dot( psi_, psi_ )

works, for example (and 'dot' is listed, too).
Well well. What would be needed then is access to the individual
components of each of the 2-component vectors in psi_, as well as
access to a wider range of Python functions.

--Nico




On Wed, Feb 16, 2011 at 5:39 PM, Andy Bauer <andy.bauer at kitware.com> wrote:
> Hmm, I tried extracting out the components using the Calculator filter and
> then using the PythonCalculator filter to do that math.atan2 function.
> Underneath the covers I believe there is a conversion from a vtkDataArray to
> a numpy array and then back again.  I don't think this is getting done for
> the math.atan2 function (it's not listed in the web page of python
> calculator functions) so you may be stuck here unless someone else has an
> idea.
>
> Andy
>
> On Wed, Feb 16, 2011 at 10:25 AM, Nico Schlömer <nico.schloemer at gmail.com>
> wrote:
>>
>> That sounds *exactly* like what I need. Great!
>> I'm having problems selecting the data sets though: Where
>> "atan(psi__Y/psi__X)" works with the calculator filter, "math.atan2(
>> psi__Y, psi__X)" fails in the PythonCalculator with
>>
>> ============== *snip* ==============
>> Traceback (most recent call last):
>>  File "<string>", line 19, in <module>
>>  File "<string>", line 27, in RequestData
>> NameError: name 'psi__Y' is not defined
>> ============== *snap* ==============
>>
>> I looked at http://www.paraview.org/Wiki/Python_Calculator but
>> couldn't figure out what's wrong.
>>
>> --Nico
>>
>>
>>
>> On Wed, Feb 16, 2011 at 2:43 PM, Tim Gallagher <tim.gallagher at gatech.edu>
>> wrote:
>> > You can use the Python Calculator, which will let you use any valid
>> > Python expression -- such as math.atan2().
>> >
>> > Tim
>> >
>> > ----- Original Message -----
>> > From: "Nico Schlömer" <nico.schloemer at gmail.com>
>> > To: "Andy Bauer" <andy.bauer at kitware.com>
>> > Cc: paraview at paraview.org
>> > Sent: Wednesday, February 16, 2011 8:29:02 AM
>> > Subject: Re: [Paraview] unstructured grid, programmable filters:
>> > extract, process array data
>> >
>> > Almost there!
>> >
>> >> atan(coordsX/coordsY)
>> >
>> > If instead of coordsX I use psi__{X,Y}, things work. However, I need
>> > something slightly different than atan: I'd like to get the complex
>> > argument of a complex number X+iY (i.e., the angle with the positive
>> > real axis). It's quite ~similar~ to what atan does, see for example
>> > <http://gcc.gnu.org/onlinedocs/gcc-4.0.4/gfortran/ATAN2.html>. In
>> > Python, the function is called math.atan2() as well.
>> > ParaView's  calculator filter does however not support atan2(), and
>> > that was my original motivation to look at programmable filters
>> > actually. Well, it'd be much nicer if the same thing could be done
>> > with the calculator of course!
>> > Workarounds?
>> >
>> > --Nico
>> >
>> >
>> >
>> >
>> >
>> > On Tue, Feb 15, 2011 at 6:56 PM, Andy Bauer <andy.bauer at kitware.com>
>> > wrote:
>> >> This sounds like a job for the calculator filter.
>> >> "coordsX^2+coordsY^2" for
>> >> your first example (or "psi__X^2+psi__Y^2" for the psi variables) and
>> >> "atan(coordsX/coordsY)" for the second example.
>> >>
>> >> It can operate on point or cell data (set in the Attribute Model
>> >> drop-down
>> >> menu), replace invalid numbers with a specified value, and you can name
>> >> the
>> >> resulting array as well.
>> >>
>> >> Andy
>> >>
>> >> 2011/2/15 Nico Schlömer <nico.schloemer at gmail.com>
>> >>>
>> >>> Hi all,
>> >>>
>> >>> I've been looking at
>> >>> <http://www.paraview.org/Wiki/Python_Programmable_Filter> to create a
>> >>> programmable filter, but I'm a bit lost as to whether or not I need
>> >>> GetPolyData, CopyAttributes,...
>> >>>
>> >>> Essentially, I have an unstructured grid in an ExodusII file (like the
>> >>> attached file actually) with point data "psi" in it that has two
>> >>> components (X,Y). I can plot psi:X, psi:Y, and psi:magnitude alright
>> >>> with the default GUI options, but what I would really like to have
>> >>> plotted is X^2+Y^2 (no sqrt()) and something along the lines of
>> >>> arctan(Y/X).
>> >>>
>> >>> Is there simple code somewhere some that takes array data off of an
>> >>> unstructured grid, does something with it and returns the extra array
>> >>> from the filter?
>> >>>
>> >>> Cheers,
>> >>> Nico
>> >>>
>> >>> _______________________________________________
>> >>> 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
>> >
>> _______________________________________________
>> 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
>
>


More information about the ParaView mailing list