ParaView/Python/Dealing with time

From KitwarePublic
Jump to navigationJump to search

If a reader or a filter supports time, it is easy to request a certain time step from Python. All time requests are set on views, which then propagate them to the representations which then propagate them to the visualization pipeline. Here is an example demonstrating how a time request can be made.

<source lang="python"> >>> Show(ExodusIIReader(FileName=".../can.ex2")) >>> Render()

  1. Get a nice view angle

>>> cam = GetActiveCamera() >>> cam.Elevation(45) >>> Render()

  1. Check the current view time

>>> view = GetActiveView() >>> view.ViewTime 0.0 >>> reader = GetActiveSource() >>> reader.TimestepValues [0.0, 0.00010007373930420727, 0.00019990510190837085, 0.00029996439116075635, 0.00040008654468692839, ...] >>> tsteps = reader.TimestepValues

  1. Let’s be fancy and use a time annotation filter. This will show the
  2. current time value of the reader as text in the corner of the view.

>>> annTime = AnnotateTimeFilter(reader)

  1. Show the filter

>>> Show(annTime)

  1. Look at a few time steps. Note that the time value is requested not
  2. the time step index.

>>> view.ViewTime = tsteps[2] >>> Render() >>> view.ViewTime = tsteps[4] >>> Render() </source>