[Paraview] Using time in Python script

Elaine Tang lingdeer at gmail.com
Mon Aug 11 01:55:47 EDT 2014


Hi,

I have data in time that has time points like
{0.02124,0.04248,0.06372,0.08496, etc.}

I wrote a python script to loop through these time points with time
increment of 0.02124 and export as .csv.

----------------------------------------------

for x in range(1, 4):

currentT = x*deltaT
AnimationScene1 = GetAnimationScene()
 RenderView1 = GetRenderView()
AnimationScene1.AnimationTime = currentT
RenderView1.ViewTime = currentT
 RenderView1.CacheKey = currentT
RenderView1.UseCache = 1
RenderView1.UseCache = 0

 SetActiveSource(data)
writer = CreateWriter("output.csv")
 writer.FieldAssociation = "Points"
writer.UpdatePipeline()
del writer

Render()

------------------------------------------

When I played the macro, some time points were not correctly read. (e.g.
 the 4th time point spreadsheet saved data that belong to the 3rd time
point.)

I used "start trace" to see how paraview handles time, and here is what I
caught:

--------------------------------------------------------
try: paraview.simple
except: from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()

AnimationScene1 = GetAnimationScene()
RenderView1 = GetRenderView()
AnimationScene1.AnimationTime = 0.021239999681711197

RenderView1.ViewTime = 0.021239999681711197
RenderView1.CacheKey = 0.021239999681711197
RenderView1.UseCache = 1

AnimationScene1.AnimationTime = 0.042479999363422394

RenderView1.ViewTime = 0.042479999363422394
RenderView1.CacheKey = 0.042479999363422394
RenderView1.UseCache = 1

AnimationScene1.AnimationTime = 0.06372000277042389

RenderView1.ViewTime = 0.06372000277042389
RenderView1.CacheKey = 0.06372000277042389
RenderView1.UseCache = 1

AnimationScene1.AnimationTime = 0.08495999872684479

RenderView1.ViewTime = 0.08495999872684479
RenderView1.CacheKey = 0.08495999872684479
RenderView1.UseCache = 1

RenderView1.UseCache = 0

Render()
--------------------------------------------------------
Then I realized, if I tried to read data at 0.08496, it will read data from
the previous time point instead. If I explicitly specify in my script to
read data at time 0.08495999872684479, then it will read the correct data.

Anyone has any insights?
Thanks in advance!!!

-- 
Elaine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20140811/5d0eca16/attachment.html>


More information about the ParaView mailing list