PlotOverLine for specific time step

Hello,
I’m trying to extract x-y data from a PlotOverLine in a Python script (below). I’m able to plot data from the zeroth step index, but I cannot figure out how to change the time step. The following still writes x-y data from the zeroth step index, but I would expect it to write data from step index 19. Any ideas?

from paraview.simple import *

fileName = 'output_data/steps.pvd'
x0 = [-0.5, 0, 0]
x1 = [0.5, 0, 0]
variableName = 'Temperature'

# create a new 'PVD Reader'
stepspvd = PVDReader(FileName=fileName)

# create a new 'Extract Time Steps'
extractTimeSteps1 = ExtractTimeSteps(Input=stepspvd)
extractTimeSteps1.TimeStepIndices = [19]
extractTimeSteps1.TimeStepRange = [19, 19]

# create a new 'Plot Over Line'
plotOverLine1 = PlotOverLine(Input=extractTimeSteps1, Source='High Resolution Line Source')

# Properties modified on plotOverLine1
plotOverLine1.Tolerance = 2.22044604925031e-16

# Properties modified on plotOverLine1.Source
plotOverLine1.Source.Point1 = x0
plotOverLine1.Source.Point2 = x1

fetchData = paraview.servermanager.Fetch(plotOverLine1)
pointData = fetchData.GetPointData()
fieldData = pointData.GetArray(variableName)
posData = pointData.GetArray('arc_length')
y_Data = [fieldData.GetValue(i) for i in range(fieldData.GetSize())]
x_Data = [posData.GetValue(i) for i in range(posData.GetSize())]

I can’t find the view in your script, but usually, time is changed by using view.ViewTime = time

Thanks for your response. I’m using Paraview to compute the PlotOverLine filter and then extract the result into a python array, so there’s not really a view that’s readily apparent. I tried using the trace functionality in Paraview to tease out how the time step is changed before writing to the filesystem, but there doesn’t appear to be a view there either. The function below is what I’m actually using, and it works great as long as the data of interest are in the first time step. I guess I could reorder the steps in the pvd file before loading, but that seems really hacky just to change a time step.

#### import the simple module from the paraview
from paraview.simple import *

def getLineData(fileName, x0, x1, variableName):

  # create a new 'PVD Reader'
  stepspvd = PVDReader(FileName=fileName)

  # create a new 'Plot Over Line'
  plotOverLine1 = PlotOverLine(Input=stepspvd, Source='High Resolution Line Source')

  # Properties modified on plotOverLine1
  plotOverLine1.Tolerance = 2.22044604925031e-16

  # Properties modified on plotOverLine1.Source
  plotOverLine1.Source.Point1 = x0
  plotOverLine1.Source.Point2 = x1

  fetchData = paraview.servermanager.Fetch(plotOverLine1)
  pointData = fetchData.GetPointData()
  fieldData = pointData.GetArray(variableName)
  posData = pointData.GetArray('arc_length')
  y_Data = [fieldData.GetValue(i) for i in range(fieldData.GetSize())]
  x_Data = [posData.GetValue(i) for i in range(posData.GetSize())]

  return x_Data, y_Data

Then you can use UpdatePipeline(time) method on any source.

1 Like

Awesome. That did the trick. Thank you!