Programmable Sourceで時刻データにアクセスする方法についてはProducing Data with Timesteps (Source) | ParaView Wikiを参照のこと。
動作確認バージョン
ParaView 5.0.0 RC1
Output Data Set Type
vtkPolyData
Script
from paraview import vtk import numpy as np def GetUpdateTimestep(algorithm): """Returns the requested time value, or None if not present""" executive = algorithm.GetExecutive() outInfo = executive.GetOutputInformation(0) if not outInfo.Has(executive.UPDATE_TIME_STEP()): return None return outInfo.Get(executive.UPDATE_TIME_STEP()) rfl = GetUpdateTimestep(self) * 0.1 pdo = self.GetPolyDataOutput() # pdo = self.GetOutput() vp = vtk.vtkPoints() polys = vtk.vtkCellArray() arr_r = vtk.vtkTypeFloat32Array() pdo.GetCellData().AddArray(arr_r) arr_r.SetNumberOfComponents(1) arr_r.SetName('reflectivity') polygon = vtk.vtkPolygon() polygon.GetPointIds().SetNumberOfIds(4) vp.InsertNextPoint(np.array((-0.5, 0.0, 0.0))) vp.InsertNextPoint(np.array((0.5, 0.0, 0.0))) vp.InsertNextPoint(np.array((0.5, 1.0, 0.0))) vp.InsertNextPoint(np.array((-0.5, 1.0, 0.0))) polygon.GetPointIds().SetId(0, 0) polygon.GetPointIds().SetId(1, 1) polygon.GetPointIds().SetId(2, 2) polygon.GetPointIds().SetId(3, 3) polys.InsertNextCell(polygon) arr_r.InsertNextValue(rfl) pdo.SetPoints(vp) pdo.SetPolys(polys)
Script (RequestInformation)
import numpy as np def SetOutputTimesteps(algorithm, timesteps): executive = algorithm.GetExecutive() outInfo = executive.GetOutputInformation(0) outInfo.Remove(executive.TIME_STEPS()) for timestep in timesteps: outInfo.Append(executive.TIME_STEPS(), timestep) outInfo.Remove(executive.TIME_RANGE()) outInfo.Append(executive.TIME_RANGE(), timesteps[0]) outInfo.Append(executive.TIME_RANGE(), timesteps[-1]) SetOutputTimesteps(self, np.arange(0, 10, 0.2))
コメントを残す