I have no problem using the calculator filter in the ParaView GUI. Basically, my initial dataset consists of pressure ‘p’, velocity components ‘vxs’, ‘vys’, and ‘vzs’ - they are all point data. I applied many filters to the original dataset and then near the end I want to calculate p*Normals_Y. This is right after a GenerateSurfaceNormals filter which I called ‘normals’. It outputs ‘Normals_X’, ‘Normals_Y’, and ‘Normals_Z’. It works perfectly in the GUI, but I’m not sure how to do it in Python.
When scripting, I used this line of code: pressure = Calculator(Input=normals, ResultArrayName='Force_Y', Function= p*Normals_Y)
And I get this error: NameError: name 'p' is not defined
I also tried using my original dataset as the input to the Calculator filter because I can’t exactly tell what the exact input is from the GUI, but it gave the same error.
I tried that but I got this error: ( 3.532s) [paraview ] vtkFunctionParser.cxx:1227 ERR| vtkFunctionParser (0000022B0EBFE470): Syntax error: expecting a variable name; see position 2 ( 3.612s) [paraview ] vtkFunctionParser.cxx:1227 ERR| vtkFunctionParser (0000022B0EBFE470): Syntax error: expecting a variable name; see position 2 ( 3.665s) [paraview ] vtkArrayCalculator.cxx:348 WARN| vtkPVArrayCalculator (0000022B0FDE92D0): An error occurred when parsing the calculator's function. See previous errors.
I am wondering if it is because I haven’t used UpdatePipeline() at all in my script? I see it being used in the ParaView Guide, but do not quite understand what it does. What do you think?
Could you post some more of your script? I’m confused because in some places you have p but other places you mention pressure. Are you using the variable names consistently in the script?
Oh yes, you’re right… I was experimenting with different inputs and forgot to change it back. I used normals as the input, but still got a similar looking error.
( 5.028s) [paraview ] vtkOpenGLState.cxx:1380 WARN| Hardware does not support the number of textures defined.
( 5.104s) [paraview ] vtkOpenGLState.cxx:1380 WARN| Hardware does not support the number of textures defined.
( 5.138s) [paraview ] vtkShaderProgram.cxx:437 ERR| vtkShaderProgram (0000021650459330): 1: #version 150
2: #ifndef GL_ES
3: #define highp
4: #define mediump
5: #define lowp
6: #endif // GL_ES
7: #define attribute in
8: #define varying out
9:
10:
11: /*=========================================================================
12:
13: Program: Visualization Toolkit
14: Module: vtkPolyDataVS.glsl
15:
16: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
17: All rights reserved.
18: See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
19:
20: This software is distributed WITHOUT ANY WARRANTY; without even
21: the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
22: PURPOSE. See the above copyright notice for more information.
23:
24: =========================================================================*/
25:
26: in vec4 vertexMC;
27:
28:
29:
30: // frag position in VC
31: out vec4 vertexVCVSOutput;
32:
33: // optional normal declaration
34: in vec3 normalMC;
35: uniform mat3 normalMatrix;
36: out vec3 normalVCVSOutput;
37:
38: // extra lighting parameters
39: //VTK::Light::Dec
40:
41: // Texture coordinates
42: //VTK::TCoord::Dec
43:
44: // material property values
45: //VTK::Color::Dec
46:
47: // clipping plane vars
48: //VTK::Clip::Dec
49:
50: // camera and actor matrix values
51: uniform mat4 MCDCMatrix;
52: uniform mat4 MCVCMatrix;
53:
54: // Apple Bug
55: //VTK::PrimID::Dec
56:
57: // Value raster
58: //VTK::ValuePass::Dec
59:
60: // picking support
61: //VTK::Picking::Dec
62:
63: void main()
64: {
65: //VTK::Color::Impl
66:
67: normalVCVSOutput = normalMatrix * normalMC;
68:
69: //VTK::TCoord::Impl
70:
71: //VTK::Clip::Impl
72:
73: //VTK::PrimID::Impl
74:
75: vertexVCVSOutput = MCVCMatrix * vertexMC;
76: gl_Position = MCDCMatrix * vertexMC;
77:
78:
79: //VTK::ValuePass::Impl
80:
81: //VTK::Light::Impl
82:
83: //VTK::Picking::Impl
84: }
( 6.276s) [paraview ] vtkShaderProgram.cxx:438 ERR| vtkShaderProgram (0000021650459330): Could not create shader object.
No I don’t get the error when I remove Interact().
I’ll also add that when I do from paraview.simple import *, I get this error many times: #osp: INITIALIZATION ERROR --> could not open module lib ospray_module_ispc: The specified module could not be found.
and I think the error also generates in other parts of the code. I couldn’t find a solution for it and the functions seemed to work fine so I ignored it for now.
I’m also using Anaconda Prompt and Spyder to edit my script. Perhaps my paths are not configured correctly? I’m not too sure.