Scalar name (point data) undefined when using Calculator filter in Anaconda Prompt


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.

Function should be a string, so just add quotation marks around it, i.e.

pressure = Calculator(Input=normals, ResultArrayName='Force_Y', Function='p*Normals_Y')

Hi, thanks for your reply.

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?

After I use the calculator function, I try to display pressure by using these commands:


Is there possibly an error in these commands? Am I allowed to visualize the calculator-filtered data?

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?

Yes, p is the name of the scalar point data that is in the original file I am opening.

reader = TecplotReader(FileNames=['C:/Users/joyce/OneDrive/Documents/S4.5 UH REU Summer 2020/0.675Simple2Pitch_Regrid_Off_Simulation_Output_7-17-2020/0.675Simple-20Hz-0mms-p50.dat'])
if reader==0:
print('\n ** ERROR: Could not open file **\n')
print(' -- Successfully read .dat file --')

# Apply ExtractRegionSurface() filter to remove volume between swimmer and boundary
removeVolume = ExtractRegionSurface(reader)
print(' -- Successfully extracted region surface --')

# Select Swimmer
extraction = ExtractCellsByRegion(Input = removeVolume)
SetProperties(extraction, IntersectWith = 'Box')
extraction.IntersectWith.Position = BoxPosition
extraction.IntersectWith.Length = BoxLength
print(' -- Successfully selected swimmer --')

# Extract swimmer surface
swimmerSurface = ExtractRegionSurface(extraction)

# Generate normals
normals = GenerateSurfaceNormals(swimmerSurface)
pressure = Calculator(Input=removeVolume, ResultArrayName='Force_Y', Function='p*Normals_Y')


I also defined BoxPosition and BoxLength arrays earlier in my code but did not include it here.

Oh, sorry. I didn’t see that pressure was the name of the Calculator filter.

In any case, I think you’ll need to change the Input parameter of the Calculator filter to be normals instead of removeVolume.

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
11: /*=========================================================================
13:   Program:   Visualization Toolkit
14:   Module:    vtkPolyDataVS.glsl
16:   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
17:   All rights reserved.
18:   See Copyright.txt or for details.
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.
24: =========================================================================*/
26: in vec4 vertexMC;
30: // frag position in VC
31: out vec4 vertexVCVSOutput;
33: // optional normal declaration
34: in vec3 normalMC;
35: uniform mat3 normalMatrix;
36: out vec3 normalVCVSOutput;
38: // extra lighting parameters
39: //VTK::Light::Dec
41: // Texture coordinates
42: //VTK::TCoord::Dec
44: // material property values
45: //VTK::Color::Dec
47: // clipping plane vars
48: //VTK::Clip::Dec
50: // camera and actor matrix values
51: uniform mat4 MCDCMatrix;
52: uniform mat4 MCVCMatrix;
54: // Apple Bug
55: //VTK::PrimID::Dec
57: // Value raster
58: //VTK::ValuePass::Dec
60: // picking support
61: //VTK::Picking::Dec
63: void main()
64: {
65:   //VTK::Color::Impl
67:   normalVCVSOutput = normalMatrix * normalMC;
69:   //VTK::TCoord::Impl
71:   //VTK::Clip::Impl
73:   //VTK::PrimID::Impl
75:   vertexVCVSOutput = MCVCMatrix * vertexMC;
76:   gl_Position = MCDCMatrix * vertexMC;
79:   //VTK::ValuePass::Impl
81:   //VTK::Light::Impl
83:   //VTK::Picking::Impl
84: }

(   6.276s) [paraview        ]   vtkShaderProgram.cxx:438    ERR| vtkShaderProgram (0000021650459330): Could not create shader object.

That’s odd, it’s a rendering error. Your pipeline code looks fine.

Do you still see it if you remove the Interact() call?

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.