Programmable source - Threshold Unstructured Grid update when changing time step

Hi All,

I am trying to write a programmable source which will update the range of a threshold when changing timesteps. Essentially what I want to do is plot the FWHM as an animation. I was looking back at a script I wrote for Paraview 4, but I thought I would give it a go for the latest version, and try using the paraview.simple module. However, I am getting stuck at the last line, where I need to shallow copy the data from the threshold to the sources output, as I get the error object has no attribute ‘GetOutput’ which I can see is the case from the paraview.simple documentation. However I am unsure which method I need to use instead!

Here is my script - there is a source called recon_* which I references specifically, which might not be the most portable way of doing it.

import paraview.simple






minthres= -10

maxval = -500

#maxval = DataRange[0]

fwhm=DataRange[0] * 0.5

print "fhwm : " + str(fwhm)

if fwhm < minthres:

current_min_thres = minthres



t.ThresholdRange=[maxval, current_min_thres]

print "current thres : " + str(current_min_thres)


Thanks for any help you can offer :slight_smile:

The script you are trying to build does not go in a Programmable Source (or Programmable Filter). ParaView UI scripts (those that use the paraview.simple bindings) are run from the Python Shell (View -> Python Shell) or bound to a macro.

These scripts do not have direct access to the data (unless you explicitly download it to the client, which is not a good idea). That is why GetOutput is not available. However, when a ParaView UI script creates a filter (like Threshold), it will be available in the Pipeline Browser, so its data will be available just like any other filter.

1 Like

Oh I see! Rookie error. Thanks for that. I got it working as a programmable filter with the following code
from vtk import vtkThreshold

inp = self.GetInputDataObject(0, 0)
outp = self.GetOutputDataObject(0)

#Get min/max values
aa = inputs[0].CellData
ai = aa[0]
Range = ai.GetRange(0)

#Define threshold filter
thresh = vtkThreshold()

minthres= -1
maxval = -500
#maxval = Range[0]
fwhm=Range[0] * 0.5
print "fhwm : " + str(fwhm)

if abs(fwhm) < abs(minthres):
    current_min_thres = minthres


#Set threshold to half min

print "current thres : " + str(current_min_thres)

It seems like paraview doesnt like the min function?