[Paraview] Determining the ParaView pipeline via Python

Scott Wittenburg scott.wittenburg at kitware.com
Wed Jul 16 17:34:31 EDT 2014


On Wed, Jul 16, 2014 at 3:07 PM, Andy Bauer <andy.bauer at kitware.com> wrote:

> Hi Bill,
>
> A couple of hopefully helpful hints:
>
>    - Maybe using a filter's Input object is enough to get the pipeline
>    connections you want (i.e. aa = bb.Input). This though assumes you're
>    working from the sink in the pipeline as opposed to a source.
>
>
I have recently added something like this to the server side protocols for
ParaViewWeb, though it's not yet in master.  Effectively, it just does what
you recommended, Andy, but doesn't require starting at the sink, and is a
complete example.  Here's how I got the pipeline connections:

proxies = servermanager.ProxyManager().GetProxiesInGroup("sources")
proxyList = []
for key in proxies:
    listElt = {}
    listElt['name'] = key[0]
    listElt['id'] = key[1]
    proxy = proxies[key]
    parentId = '0'
    if hasattr(proxy, 'Input'):
        parentId = proxy.Input.GetGlobalIDAsString()
    listElt['parent'] = parentId
    proxyList.append(listElt)

After this code finishes, proxyList contains all the sources and filters in
the pipeline and identifies each one's Input proxy id with the key 'parent'.
 The actual source (reader or whatever has no Input), has 'parent': '0'.
 Perhaps modifying this code so it builds a dictionary (mapping each proxy
id to the appropriate listElt object) instead of a list, and then making a
note of the proxy which does not have an Input property when it is
encountered, this would allow Bill to efficiently build the ascii map he is
looking for?

Cheers,
Scott


>
>    - As for getting the available arrays for a filter, you can do
>    something like:
>
> for da in range(aa.PointData.NumberOfArrays):
>   bb.PointData.GetArray(da)
>
>
>    - There was work on only writing out Python scripts with non-default
>    values which made the scripts much shorter. Somewhere there was an option
>    to specify whether to write out all values of the objects for trace and
>    python state or just the non-defaults but I can't find it now. It looks
>    like what you have already works but just wanted to mention that.
>
> Does this answer your questions?
>
>
> Regards,
>
> Andy
>
>
> On Wed, Jul 16, 2014 at 12:51 AM, Bill Sherman <shermanw at indiana.edu>
> wrote:
>
>> Community,
>>
>> I've been creating some simple python scripts that help me see a
>> simple representation of the state of ParaView.
>>
>> One thing I wanted was to be able to see what changes had been
>> made such that a value was no longer the default.  Then, I'm going
>> to print this out at the beginning of my batch animation jobs, which
>> will then go into the log file generated by the queuing system.
>>
>> So here is my function to do that for an object:
>>
>> ----------
>> def altered(object):
>>     if (object == None):
>>         return
>>     dup = object.__class__()
>>     for prop in dup.ListProperties():
>>         if (hasattr(object.GetProperty(prop), 'GetData')):
>>             if (dup.GetProperty(prop).GetData() !=
>> object.GetProperty(prop).GetData()):
>>                 print prop + ": " + str(object.GetProperty(prop))[:80] +
>> " [" + str(dup.GetProperty(prop)) + "]"
>>     del(dup)
>>     del(prop)
>> ----------
>>
>> And then I can loop over all the sources to get a handy list:
>>
>> ----------
>> for src in GetSources():
>>   srcp = FindSource(src[0])
>>   print "********************"
>>   print "    " + src[0] + " -- " + srcp.GetXMLLabel()
>>   altered(srcp)
>>   print "    ---------------"
>>   print "    Representation:"
>>   altered(GetDisplayProperties(srcp))
>> ----------
>>
>> So the main missing feature for me is trying to show how the sources
>> are linked together -- basically recreating the pipeline display,
>> except as ASCII text.  But I haven't yet figured out how to
>> programmatically determine which "sources" are connected to which.
>>
>>
>> The other thing I'd like to be able to do is report what other
>> field data is available from a file reader -- I can see by looking
>> in the .pvsm file that that data was saved, so I hope it might
>> be somehow available via the Python interface.
>>
>>
>>
>> So here's some sample output from a state file I'm experimenting
>> with:
>>
>> ********************
>>     Glyph1 -- Glyph
>> GlyphTransform: <paraview.servermanager.Transform2 object at 0x163
>> [<paraview.servermanager.Transform2 object at 0x1632910>]
>> Input: <paraview.servermanager.TemporalParticlesToPathlin [None]
>> MaximumNumberofPoints: 50000 [5000]
>> Scalars: ['POINTS', 'mass'] [[None, '']]
>> Vectors: ['POINTS', 'velocity'] [[None, '']]
>> SetScaleFactor: 0.462090686322849 [1.0]
>> GlyphType: <paraview.servermanager.Sphere object at 0x16f24d0
>> [<paraview.servermanager.Arrow object at 0x1632190>]
>> MaskPoints: 0 [1]
>>     ----------------
>>     Representations
>> Input: <paraview.servermanager.Glyph object at 0x162e890> [None]
>> SelectionPointFieldDataArrayName: 'mass' ['vtkOriginalPointIds']
>> ColorArrayName: ('POINT_DATA', 'mass') [('POINT_DATA', '')]
>> DataBounds: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] [[5.6965768965495727e-321,
>> 4.7846668906873337e-316, 4.7559715579768741e-316, 9.3872472709836843e-323,
>> 0.0, 5.6490774253583952e-318]]
>> LookupTable: <paraview.servermanager.PVLookupTable object at 0x [None]
>> ScaleFactor: 0.68949565887451203 [1.0]
>> ********************
>>     TemporalParticlesToPathlines1 -- Temporal Particles To Pathlines
>> Input: <paraview.servermanager.LegacyVTKReader object at  [None]
>> MaskPoints: 1 [100]
>>     ----------------
>>     Representations
>> Input: <paraview.servermanager.TemporalParticlesToPathlin [None]
>> SelectionPointFieldDataArrayName: 'TrailId' ['vtkOriginalPointIds']
>> Visibility: 0 [1]
>> DataBounds: [0.0, nan, nan, nan, nan, 4.243991581436479e-314]
>> [[2.0018638793749296e-316, 2.0020954973496999e-316,
>> 4.7763681688472674e-316, 2.0021053786626168e-316, 2.0021022166424834e-316,
>> 2.0001733843611191e-316]]
>> LookupTable: <paraview.servermanager.PVLookupTable object at 0x [None]
>> ScaleFactor: 0.45304816961288502 [1.0]
>> ********************
>>     Tube1 -- Tube
>> Capping: 0 [1]
>> Input: <paraview.servermanager.TemporalParticlesToPathlin [None]
>> NumberofSides: 5 [6]
>> Radius: 0.0060000000000000001 [1.0]
>> Scalars: ['POINTS', 'TrailId'] [[None, '']]
>> Vectors: ['POINTS', 'velocity'] [[None, '']]
>>     ----------------
>>     Representations
>> Input: <paraview.servermanager.Tube object at 0x162e090> [None]
>> SelectionPointFieldDataArrayName: 'TrailId' ['vtkOriginalPointIds']
>> DataBounds: [0.0, 1.2648080533535912e-321, 1.5810100666919889e
>> [[5.0085616312819197e-316, 3.1620201333839779e-321,
>> 3.9525251667299724e-322, 5.0084066922953839e-316, 2.3176438028922704e-310,
>> 0.0]]
>> DiffuseColor: [1.0, 0.66666666666666696, 1.0] [[1.0, 1.0, 1.0]]
>> LookupTable: <paraview.servermanager.PVLookupTable object at 0x [None]
>> Opacity: 0.0 [1.0]
>> ScaleFactor: 0.76622586250305202 [1.0]
>> ********************
>>     vectors.vrml -- VRML Reader
>> FileName: '/N/dc2/scratch/shermanw/BinaryStars/Run_30k/Initi ['']
>>     ----------------
>>     Representations
>> Input: <paraview.servermanager.VRMLReader object at 0x162 [None]
>> SelectionPointFieldDataArrayName: 'VRMLColor' ['vtkOriginalPointIds']
>> ColorArrayName: ('POINT_DATA', 'VRMLColor') [('POINT_DATA', '')]
>> DataBounds: [2.3715151000379834e-322, 2.7872298394991417e-316,
>> [[4.7835752032362829e-316, 2.0008125076805794e-316,
>> 2.4209216646221081e-322, 2.0009002537392808e-316, 2.0006433396034433e-316,
>> 0.0]]
>> LookupTable: <paraview.servermanager.PVLookupTable object at 0x [None]
>> MapScalars: 0 [1]
>> ScaleFactor: 1.16120505332947 [1.0]
>> ********************
>>     AnnotateTime1 -- Annotate Time
>> Format: 'I-V2F: %.1f' ['Time: %f']
>>     ----------------
>>     Representations
>> Input: <paraview.servermanager.AnnotateTime object at 0x1 [None]
>> Opacity: 0.5 [1.0]
>> ********************
>>     jhdata_* -- Legacy VTK Reader
>> FileNameInfo: '/N/dc2/scratch/shermanw/BinaryStars/Run_30k/Initi [None]
>> FileNames: ['/N/dc2/scratch/shermanw/BinaryStars/Run_30k/Init [['']]
>> TimestepValues: [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, [[]]
>>     ----------------
>>     Representations
>> Input: <paraview.servermanager.LegacyVTKReader object at  [None]
>> SelectionPointFieldDataArrayName: 'mass' ['vtkOriginalPointIds']
>> Visibility: 0 [1]
>> ColorArrayName: ('POINT_DATA', 'mass') [('POINT_DATA', '')]
>> DataBounds: [2.3177925133422193e-310, 0.0, 0.0, 0.0, 0.0, 0.0]
>> [[4.738173337151089e-316, 0.0, 0.0, 0.0, 0.0, 0.0]]
>> InterpolateScalarsBeforeMapping: 0 [1]
>> LookupTable: <paraview.servermanager.PVLookupTable object at 0x [None]
>> ScaleFactor: 0.74854731559753396 [1.0]
>>
>> ------------------------------------------------------------
>> --------------
>>
>>
>> Thanks for any advice.  I'll report back when I figure out a script that
>> does something more complete.
>>
>>         Bill
>>
>> --
>> Bill Sherman
>> Sr. Technology Advisor
>> Advanced Visualization Lab
>> Pervasive Technology Inst
>> Indiana University
>>
>> _______________________________________________
>> 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://public.kitware.com/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://public.kitware.com/mailman/listinfo/paraview
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20140716/b9dc269d/attachment-0001.html>


More information about the ParaView mailing list