[Paraview] Using Value of Variable At Point in Calculator Filter

Jeremias Gonzalez jgonzalez49 at ucmerced.edu
Fri Jul 14 01:15:38 EDT 2017


On 7/6/2017 12:38 PM, Cory Quammen wrote:
> I would look at using the Python scripting capabilities within
> ParaView for this. You can write a Python script and run it with
> pvpython - this is especially useful for running an analysis in a
> batch fashion. Within your script you use the Probe filter to get the
> data value at a particular location and add that value to some
> Calculator expression as needed. Here's a quick example:
>
> from paraview.simple import *
>
> data = FindSource('MyDataSource')
> probe = ProbeLocation(Input=data, ProbeType='Fixed Radius Point Source')
> probe.ProbeType.Center = [1.0, 0.0, 0.0]
> probe.UpdatePipeline()
> probePoint = paraview.servermanager.Fetch(probe)
> value_at_probe = probePoint.GetPointData().GetArray('my array name').GetValue(0)
>
> calculator_expression = #... value_at_probe + other expression
> c1 = Calculator(Input=appendedData)
> c1.Function = calculator_expression
> ...
>
>
> I hope that helps get you started. Let us know if you have other
> questions about the scripting.
Thank you very much for your help, that helped a lot! Some notes for 
anyone else finding this and needing some help: Using the Trace feature 
is extremely useful for getting the majority of a script written, and 
then the above code can be inserted. However, two changes had to be made 
in at least my case:

 1. probePoint.GetPointData().GetArray('my array name').GetValue(0) had
    to be changed to probePoint.GetPointData().GetVectors('my vector
    name').GetValue(0) as the data type being probed was a vector.
 2. When using value_at_probe in my calculator_expression variable, it
    couldn't just be dropped in. Since my expression was a string like
    calcexp='(gradient_x*2/value_at_probe)^(1/2)', it needed to be
    changed to calcexp='(gradient_x*2/{})^(1/2)'.format(value_at_probe)
    so that the numerical value was passed in as a string, and then
    passed to the calculator filter.



More information about the ParaView mailing list