Difference between revisions of "ParaView/Tricks"
(→Difference Between Two Timesteps) |
|||
Line 10: | Line 10: | ||
Example script: relative change in eddy viscosity<br> | Example script: relative change in eddy viscosity<br> | ||
− | s = 'EV' | + | <nowiki> |
− | a = inputs[0].PointData[s] | + | s = 'EV' |
− | b = inputs[1].PointData[s] | + | a = inputs[0].PointData[s] |
− | tmp = (a-b)/b | + | b = inputs[1].PointData[s] |
− | output.PointData.append(tmp, 'delta') | + | tmp = (a - b) / b |
+ | output.PointData.append(tmp, 'delta')</nowiki> | ||
+ | |||
+ | ==Stepping Forward in Time== | ||
+ | Let's say you load your ParaView file (for PHASTA, *.pht or *.phts) as <code>phtFile</code>. The times associated with each timestep referenced by the file are given by <code>phtFile.TimestepValues</code>. | ||
+ | |||
+ | To step forward in time, set the time of the current view. For example, <code>GetActiveView().ViewTime = myTime</code>. When you save an image, all visible sources will be rendered using data from that time (<code>myTime</code>). | ||
+ | |||
+ | ==Saving Data at a Given Time== | ||
+ | It turns out the data fields you access through Python are not updated simply by setting the active view's <code>ViewTime</code> property. For example, if you're trying to extract data from a probe location or along a line, simply saving that pipeline object does not reflect the updated timestep. Instead, you need to call the <code>UpdatePipeline(time=myTime)</code> method of your <code>ProbeLocation</code>, <code>Slice</code>, or other pipeline object. This method is inherited from <code>SourceProxy</code>. |
Revision as of 18:00, 27 November 2017
This page contains a list of tips and tricks for ParaView, which may be useful for others.
Difference Between Two Timesteps
To look at the "delta" between two timesteps, follow these steps.
- Load your data file twice, so your pipeline browser has two separate instances of "flow.pht" or whatever file you open.
- Apply one Force Time filter to each input file, and specify the physical time (not time index) for each. This will force the time for each and make them independent of the global ParaView time control in the upper toolbar.
- Select both Force Time filters simultaneously, and apply a Programmable Filter. Your pipeline browser will now show arrows representing multiple inputs to the single programmable filter.
- Populate the programmable filter with the following code:
tmp = inputs[0].PointData['myAvailableFieldName'] - inputs[1].PointData['myAvailableFieldName']
output.PointData.append(tmp, 'delta of myAvailableFieldName') - You can now view the field, "delta of myAvailableFieldName," and change the time steps it uses to compute the time-delta by modifying the Force Time filter properties.
Example script: relative change in eddy viscosity
s = 'EV' a = inputs[0].PointData[s] b = inputs[1].PointData[s] tmp = (a - b) / b output.PointData.append(tmp, 'delta')
Stepping Forward in Time
Let's say you load your ParaView file (for PHASTA, *.pht or *.phts) as phtFile
. The times associated with each timestep referenced by the file are given by phtFile.TimestepValues
.
To step forward in time, set the time of the current view. For example, GetActiveView().ViewTime = myTime
. When you save an image, all visible sources will be rendered using data from that time (myTime
).
Saving Data at a Given Time
It turns out the data fields you access through Python are not updated simply by setting the active view's ViewTime
property. For example, if you're trying to extract data from a probe location or along a line, simply saving that pipeline object does not reflect the updated timestep. Instead, you need to call the UpdatePipeline(time=myTime)
method of your ProbeLocation
, Slice
, or other pipeline object. This method is inherited from SourceProxy
.