Programmable filter script path

Hi all,

I have a script as follows:

merge_data =  MergeBlocks(nek3d)

# Extract selection of data for 1.0<T<7.5 in a range
#(temperature > 1.0) & (temperature < 7.5)
selection=SelectPoints()
selection.QueryString="(temperature >1.0) & (temperature <= 7.5)"
selection.FieldType = 'POINT'
selection.UpdatePipelineInformation()
mySelection = ExtractSelection(Input=merge_data, Selection=selection)
mySelection.UpdatePipeline()

# create new programmable filters
analysis = ProgrammableFilter(Input=mySelection)
analysis.Script = """
import numpy as np
import numpy.linalg as nl
from paraview import numpy
.
.
.

The script works fine.
However, the analysis script is so long and I prefer to have it in the separate (python) file for readability purposes.
Something like

analysis.Script('path_to_the_file')

Is it possible to do that?

Thanks in advance

You should be able to read your script, dump it into a string and pass it as an argument.

That being said, it would be nice to provide a file based api for the programmable filter.

Thanks. But what is the argument?
Something like

analysis.Script('./analysis.py')

Maybe I misexplained.

You need to read the file yourself using standard python file reading tools (open, file.read, …), then store the content into a string that will be passed as an argument.

2 Likes