[Paraview] Python Calculator Filter

Adriano Gagliardi agagliardi at ara.co.uk
Wed Jun 24 04:05:47 EDT 2009


Ok, I've found what I was missing. ScalarVariable should accept a list with
three properties per variable ie:

calc1.ScalarVariable =
['x_velocity','x_velocity','0','y_velocity','y_velocity','0','z_velocity','z
_velocity','0']

I thought I had tried this, but I must have gotten the syntax wrong. So if
anyone else needs a pointer, then the working script is:

----------------------------------------------------------------------------
----
from paraview.simple import *

connection = servermanager.Connect('localhost',11111)

er = servermanager.sources.EnSightreader(CaseFileName='/.../data.case')
er.PointArrays =
['x_velocity','1','y_velocity','1','z_velocity','1','cp','1']
er.UpdatePipeline()

calc1 = servermanager.filters.Calculator(Input=er,
ResultArrayName='Velocity')
calc1.ScalarVariable =
['x_velocity','x_velocity','0','y_velocity','y_velocity','0','z_velocity','z
_velocity','0']
calc1.Function = 'x_velocity*iHat + y_velocity*jHat + z_velocity*kHat'
calc1.UpdatePipeline()
----------------------------------------------------------------------------
-----

===================================

Adriano Gagliardi MEng PhD
Project Scientist
Computational Aerodynamics
Aircraft Research Association Ltd.
Manton Lane
Bedford

----------------------------------------------------------------------

Message: 1
Date: Tue, 23 Jun 2009 18:06:07 +0100
From: "Adriano Gagliardi" <agagliardi at ara.co.uk>
Subject: [Paraview] Python Calculator Filter
To: <paraview at paraview.org>
Message-ID: <002201c9f424$e615d400$4f2810ac at win.ara>
Content-Type: text/plain; charset="us-ascii"

I have been trying to write a simple Python script that uses the Calculator
filter to take three scalars and produce a vector using the ParaView3.6
Python wrapping. This is trivial through the GUI Calculator Filter, but I am
having problems adding more than one scalar to the calculator object in my
script. From browsing the posts here and the C++ doxygen I've noticed the
use of AddScalarVariable and AddVectorVariable to accomplish this, but these
appear to be no longer available through the Python interface. Could someone
point out to me what I'm missing?

See below:

#-------------------------------------------------------------------------
from paraview.simple import *

connection = servermanager.Connect('localhost',11111)

er = servermanager.sources.EnSightreader(CaseFileName='/.../data.case')
er.PointArrays =
['x_velocity','1','y_velocity','1','z_velocity','1','cp','1']
er.UpdatePipeline()

calc1 = servermanager.filters.Calculator(Input=er,
ResultArrayName='Velocity')
calc1.ScalarVariable = ['x_velocity','x_velocity','0'] calc1.ScalarVariable
= ['y_velocity','y_velocity','0'] #This overwrites previous declaration
calc1.ScalarVariable = ['z_velocity','z_velocity','0'] #This overwrites
previous declaration calc1.Function = '(x_velocity)*iHat + (y_velocity)*jHat
+ (z_velocity)*kHat'
#Produces an error... Variable does not exist
calc1.UpdatePipeline()
#-------------------------------------------------------------------------


===================================

Adriano Gagliardi MEng PhD
Project Scientist
Computational Aerodynamics
Aircraft Research Association Ltd.
Manton Lane
Bedford

Tel: 01234 32 4644
E-mail: agagliardi at ara.co.uk
Url: www.ara.co.uk 


---------------------------
This email contains information that is private and confidential and is
intended only for the addressee.  If you are not the intended recipient
please delete it and notify us immediately by e-mailing the sender.
Note: All email sent to or from this address may be accessed by someone
other than the recipient, for system management and security reasons.
Aircraft Research Association Ltd.  Registered in England, Registration No
503668 Registered Office: Manton Lane, Bedford MK41 7PF England VAT No GB
196351245


---------------------------
This email contains information that is private and confidential and is intended only for the addressee.  If you are not the intended recipient please delete it and notify us immediately by e-mailing the sender.
Note: All email sent to or from this address may be accessed by someone other than the recipient, for system management and security reasons.
Aircraft Research Association Ltd.  Registered in England, Registration No 503668 Registered Office: Manton Lane, Bedford MK41 7PF England VAT No GB 196351245




More information about the ParaView mailing list