[Paraview-developers] Carrying calculated array through to the last time step in programmable filter

mp maik.pohl87 at gmx.de
Thu Mar 10 05:32:23 EST 2016


Hey,

I have to write a programmable filter, that takes the values of an array
from a source in the pipeline and calculates the difference of it's values
at different times.

Here is what i have so far:

from paraview.simple import *
filter = ProgrammableFilter()
RenameSource("Diference between time steps" , filter)
filter.Script = """
import os
#Number of Array to be subtracted
arr = 2
# tStart is the time that contains the minuend
tStart = 0
# tEnd is the time that contains the subtrahend
tEnd = 900

tempFilePath = ""
tCurrent =
inputs[0].GetInformation().Get(vtk.vtkDataObject.DATA_TIME_STEP())
if tCurrent == tStart:
    f = open(tempFilePath + "test.txt" , 'w')
    for i in range(self.GetInput().GetCellData().GetArray(arr).GetSize()):
        f.write(str(self.GetInput().GetCellData().GetArray(arr).GetValue(i))
+ "\\n")
elif tCurrent==tEnd:
    subtrahend = list()
    for i in range(self.GetInput().GetCellData().GetArray(arr).GetSize()):
       
subtrahend.append(float(self.GetInput().GetCellData().GetArray(arr).GetValue(i)))
    f = open(tempFilePath + "test.txt" , 'r')
    minuend = [line.rstrip("\\n") for line in f]
    for j in range(len(minuend)):
        minuend[j] = float(minuend[j])
    difference = vtk.vtkDoubleArray()
    difference.SetNumberOfComponents(0)
    difference.SetName("difference")
    d = map(lambda x,y: x-y,minuend,subtrahend)
    for k in range(len(d)):
        difference.InsertNextValue(d[k])
    self.GetOutput().GetCellData().AddArray(difference)
    f.close()
    os.remove(tempFilePath + "test.txt")
"""
filter_repr = Show()




In this example, the difference between the 3rd array at 0 and 900 is
calculated. Now the user has to go back to the time step, where "difference"
was calculated.

Is there a way to display the array, that was calculated in another time
step, after the last time step?

Thank you, mp



--
View this message in context: http://the-unofficial-paraview-developers-forum.34153.x6.nabble.com/Carrying-calculated-array-through-to-the-last-time-step-in-programmable-filter-tp4213.html
Sent from the The Unofficial ParaView Developers Forum mailing list archive at Nabble.com.


More information about the Paraview-developers mailing list