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

Cory Quammen cory.quammen at kitware.com
Fri Mar 11 08:34:56 EST 2016


While this isn't a direct answer to your question, this blog post may
have some answers for you.

https://blog.kitware.com/the-multiple-uses-of-the-new-forcetime-filter/

On Thu, Mar 10, 2016 at 5:32 AM, mp <maik.pohl87 at gmx.de> wrote:
> 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.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Search the list archives at: http://markmail.org/search/?q=Paraview-developers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview-developers



-- 
Cory Quammen
R&D Engineer
Kitware, Inc.


More information about the Paraview-developers mailing list