[Paraview] Python + ParaView

Nico Schlömer nico.schloemer at gmail.com
Thu Jun 16 09:45:50 EDT 2011


Also, when

======================== *snip* ========================
>>>
>>> import paraview.simple
paraview version 3.10.1, Date: 2011-01-28
>>> calc1 = paraview.simple.servermanager.filters.Calculator()
>>> help( calc1 )
>>>
======================== *snip* ========================

I don't see how to apply math.atan2() to two components of an input
vector: Exactly those functions appear to be documented which are
available in the GUI. Hmm...

--Nico



On Thu, Jun 16, 2011 at 3:24 PM, Nico Schlömer <nico.schloemer at gmail.com> wrote:
>> See the manual for the syntax.
>
> Where can I find that? The ParaView User's Guide
> <www.paraview.org/files/v1.6/ParaViewUsersGuide.PDF> isn't too verbose
> on any of that.
> The Wiki, on the other hand, seems to contain a fair amount of
> examples. Specifically, I've looked at
> <http://www.paraview.org/Wiki/Python_Programmable_Filter> to see about
> programmable filters.
>
> Unfortunately, this hasn't gotten me very far, as I'm lacking
> understanding of the entities used in the examples.
> Questions I asked myself were:
>  * What do I need to do to fetch my point data:
> self.GetPolyDataInput()? self.GetInputDataObject(0, 0)? Or simply
> self.GetInput()?
>  * How do I access point data then?
>  * Do I have to create a new vector and feed this into some sort of
> output thing?
>
> Is there a documentation as to what methods are available for those types?
>
> The input file is Exodus, if that makes any difference.
>
> If there's a tutorial for this kind of stuff, I'll be happy to go
> through it; otherwise I'd appreciate your help here.
>
> Cheers,
> Nico
>
>
>
>
>
>
> On Wed, Jun 8, 2011 at 6:17 PM, David E DeMarle
> <dave.demarle at kitware.com> wrote:
>> Also the standard calculator does have conditionals, there just isn't a
>> button corresponding to them on the UI. See the manual for the syntax.
>> David E DeMarle
>> Kitware, Inc.
>> R&D Engineer
>> 28 Corporate Drive
>> Clifton Park, NY 12065-8662
>> Phone: 518-371-3971 x109
>>
>>
>> On Wed, Jun 8, 2011 at 12:16 PM, David E DeMarle <dave.demarle at kitware.com>
>> wrote:
>>>
>>> The python programmable filter (and the easier to use python programmable
>>> calculator variant of that) will get you beyond all of those limitations.
>>> David E DeMarle
>>> Kitware, Inc.
>>> R&D Engineer
>>> 28 Corporate Drive
>>> Clifton Park, NY 12065-8662
>>> Phone: 518-371-3971 x109
>>>
>>>
>>> On Wed, Jun 8, 2011 at 12:11 PM, Nico Schlömer <nico.schloemer at gmail.com>
>>> wrote:
>>>>
>>>> > If you want to do arbitrary arithmetic, you will have to first
>>>> > generate the array using something like a "Calculator" filter and then
>>>> > color using the generated array.
>>>>
>>>> Oh, if I remember correctly I did look into this before, and found the
>>>> calculator filter too limited on the arithmetics that you could
>>>> perform. Is it still the case that you have a set of like ten
>>>> functions (add, multiply, sine, cosine,...) to mix and match? I need
>>>> to to something like
>>>>
>>>> for x in data_values:
>>>>    if x[0] > 0 and x[1] > 0
>>>>        return bla
>>>>    elseif ...
>>>>
>>>> -- atan2() that is.
>>>>
>>>>
>>>> > Yes, RGBPoints defines the mapping between scalar and color. It's a
>>>> > list of 4 tuples (scalar, r, g, b), repeated sequentially.
>>>>
>>>> Hm, I'll look into it. Where's the proper spot for documentation of this?
>>>>
>>>> Cheers,
>>>> Nico
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Wed, Jun 8, 2011 at 5:25 PM, Utkarsh Ayachit
>>>> <utkarsh.ayachit at kitware.com> wrote:
>>>> > Magnitude corresponds to the magnitude of a vector, so yes, it takes
>>>> > the square root.
>>>> >
>>>> > If you want to do arbitrary arithmetic, you will have to first
>>>> > generate the array using something like a "Calculator" filter and then
>>>> > color using the generated array.
>>>> >
>>>> > Yes, RGBPoints defines the mapping between scalar and color. It's a
>>>> > list of 4 tuples (scalar, r, g, b), repeated sequentially.
>>>> >
>>>> > Utkarsh
>>>> >
>>>> > On Wed, Jun 8, 2011 at 11:19 AM, Nico Schlömer
>>>> > <nico.schloemer at gmail.com> wrote:
>>>> >> Thanks for the hints.
>>>> >>
>>>> >> The Trace function in indeed quite useful in that it get you where you
>>>> >> want to be. When looking at the code there's still a lot of me to
>>>> >> understand though, the GetLookupTableForArray() call seems to be
>>>> >> crucial for example.
>>>> >>
>>>> >>  * The VectorMode='Magnitude' parameter seems to be responsible for
>>>> >> merging the two components into one scalar, but I'm not quite sure how
>>>> >> this is done: with a sqrt() or without? Is is possible to customize
>>>> >> this? I'd like to have something like ATAN2 there as well.
>>>> >>
>>>> >>  * Is the RGBPoints=[0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0],
>>>> >> parameter responsible for the colormap?
>>>> >>
>>>> >> Cheers,
>>>> >> Nico
>>>> >>
>>>> >>
>>>> >>
>>>> >>
>>>> >>
>>>> >> On Wed, Jun 8, 2011 at 3:13 PM, Utkarsh Ayachit
>>>> >> <utkarsh.ayachit at kitware.com> wrote:
>>>> >>> The following wiki page talks about how to color using arrays:
>>>> >>>
>>>> >>> http://www.paraview.org/Wiki/ParaView/Python_Scripting#Representations_and_Views
>>>> >>>
>>>> >>> The easiest way to figure out Python code equivalents is to use the
>>>> >>> Trace functionality to generate python trace files for actions
>>>> >>> performed in the GUI (accessible from Tools menu). You "Start Trace",
>>>> >>> do a set of actions and then "Stop Trace" and you should be able to
>>>> >>> view the resulting Python code.
>>>> >>>
>>>> >>> Utkarsh
>>>> >>>
>>>> >>>
>>>> >>>
>>>> >>> On Wed, Jun 8, 2011 at 9:05 AM, Nico Schlömer
>>>> >>> <nico.schloemer at gmail.com> wrote:
>>>> >>>> Hi,
>>>> >>>>
>>>> >>>> I'm just taking first steps with ParaView's Python interface and
>>>> >>>> figured out so far that
>>>> >>>>
>>>> >>>> ================ *snip* ================
>>>> >>>> exodusReader = ExodusIIReader( FileName="solution.e" )
>>>> >>>> Show( exodusReader )
>>>> >>>> Render()
>>>> >>>> ================ *snap* ================
>>>> >>>>
>>>> >>>> would plot the mesh that is stored in the ExodusII file solution.e,
>>>> >>>> and that can play around with GetActiveView() to adjust camera
>>>> >>>> angles
>>>> >>>> and such.
>>>> >>>>
>>>> >>>> What I haven't found out though is how to plot actual point data. I
>>>> >>>> get
>>>> >>>>
>>>> >>>>
>>>> >>>>>>> exodusReader.PointData[:]
>>>> >>>> [Array: GlobalNodeId, Array: PedigreeNodeId, Array: A, Array: psi,
>>>> >>>> Array: thickness]
>>>> >>>>
>>>> >>>> and l'm looking at the 2-component array "psi". For example, I'd
>>>> >>>> like
>>>> >>>> to do something like
>>>> >>>>
>>>> >>>>    res =  sqrt( component1**2 + component2**2 )
>>>> >>>>
>>>> >>>> and have res[:] rendered on the mesh with a certain color map.
>>>> >>>>
>>>> >>>> Any hints?
>>>> >>>>
>>>> >>>> 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
>>>
>>
>>
>


More information about the ParaView mailing list