>> I would like to get an average over an entire cut plane (over time).
David
This sounds like a perfect case for a Python Programmable Filter, looping over
timesteps, accumulating data, doing the average, and setting it as a new field.
Here is a script I have tested on a single block of data with multiple
timesteps.
There is an init phase, to get the number of timesteps, their values (from
upstream), and the first dataset at the 0-th timestep.
There is an accumulate phase, where the filter pulls all timesteps, adding to
the already existing numpy array.
There is a finish phase, where we do the average and assign it to a new field.
I am doing it for Pressure, you'll have to adapt it to your fieldnames and
block structures.
-----------------
Jean M. Favre
Swiss National Supercomputing Center
CH-6900 Lugano
Switzerland
# Demonstration script for paraview version 5.0
# written by Jean M. Favre, Swiss National Supercomputing Centre
# tested Tue Feb 16 08:43:13 CET 2016
#
# Cut-plane average data over time?
# this script assumes a scalar filed named "PRES" is available at the nodes
# it gets the values of all timesteps, iterates over time, accumulating
# data in a temporary numpy array.
# at the end of the time loop, it sets a new field equal to the numpy array
# divided by the number of timesteps.
#
Stats_ReqData = """
import numpy as np
from vtk.numpy_interface import dataset_adapter as dsa
executive = self.GetExecutive()
outInfo = executive.GetOutputInformation(0)
data = inputs[0].PointData[\'PRES\']
if self.CurrentTimeIndex == 0:
self.temp_data = data
print " INIT: CurrentTimeIndex = ", self.CurrentTimeIndex, ", tlen = ", self.tlen
else:
print " ACCUMULATE: Accumulate"
#self.temp_data = np.maximum(data, self.temp_data)
self.temp_data = data + self.temp_data
self.CurrentTimeIndex = self.CurrentTimeIndex + 1
if self.CurrentTimeIndex < self.tlen:
request.Set(vtk.vtkStreamingDemandDrivenPipeline.CONTINUE_EXECUTING(), 1)
else:
# finish
request.Remove(vtk.vtkStreamingDemandDrivenPipeline.CONTINUE_EXECUTING())
self.CurrentTimeIndex = 0
output.PointData.append(self.temp_data/self.tlen, "avg_PRES")
print " FINISH: Finish"
"""
Stats_ReqInfo = """
executive = self.GetExecutive ()
outInfo = executive.GetOutputInformation(0)
self.CurrentTimeIndex = 0
self.tlen = outInfo.Length(executive.TIME_STEPS())
self.ts = [executive.TIME_STEPS().Get(outInfo, i) for i in xrange(self.tlen)]
print "ReqInf: ts = ", self.ts
print "ReqInf: tlen = ", self.tlen
outInfo.Remove(executive.TIME_STEPS())
outInfo.Remove(executive.TIME_RANGE())
print "Stats_ReqInfo: remove TIME_STEPS and TIME_RANGE"
"""
Stats_ReqExtents = """
executive = self.GetExecutive()
outInfo = executive.GetOutputInformation(0)
if self.tlen > 0:
print " ProgrammableFilter: set UPDATE_TIME_STEP = ", self.ts[self.CurrentTimeIndex]
outInfo.Set(executive.UPDATE_TIME_STEP(), self.ts[self.CurrentTimeIndex])
"""
# we assume here the cut planes is a pipeline object called "ExtractBlock1"
# adapt it to your time-aware input.
inp1 = FindSource('ExtractBlock1')
programmableFilter1 = ProgrammableFilter(Input = inp1)
programmableFilter1.Script = Stats_ReqData
programmableFilter1.RequestInformationScript = Stats_ReqInfo
programmableFilter1.RequestUpdateExtentScript = Stats_ReqExtents
programmableFilter1.PythonPath = ''
programmableFilter1Display = Show(programmableFilter1)
programmableFilter1Display.Representation = 'Outline'
programmableFilter1Display.ColorArrayName = ['POINTS', '']
Render()
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the ParaView Wiki at:
http://paraview.org/Wiki/ParaView
Search the list archives at: http://markmail.org/search/?q=ParaView
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview