Paraview 4.2를 사용하여 Python 스크립트로 슬라이스에서 데이터를 추출하려고합니다.Paraview 4.2에서 Python 스크립트로 데이터 추출 4.2
from paraview.numpy_support import vtk_to_numpy
from paraview.simple import *
import os
os.environ["DISPLAY"] = ":0"
paraview.simple._DisableFirstRenderCameraReset()
# create a new 'XDMF Reader'
xDMFtemporalFieldsxmf = XDMFReader(FileNames=['<pathtodata>/XDMF.temporalFields.xmf'])
# Properties modified on xDMFtemporalFieldsxmf
xDMFtemporalFieldsxmf.PointArrayStatus = ['DensityProperty-mesh', 'VelocityField']
xDMFtemporalFieldsxmf.CellArrayStatus = []
# create a new 'Slice'
slice1 = Slice(Input=xDMFtemporalFieldsxmf)
# create a new 'Clip'
clip1 = Clip(Input=slice1)
clip1.ClipType = 'Scalar'
clip1.Value = 1200.0
그래서 내가 원하는 모든 것이 바람직 각 데이터 포인트의 위치를 좌표 클립에서 VelocityField 데이터를 추출입니다 :이 같은 있습니다. -이 아니라 실제 데이터
>> print clip1
<paraview.servermanager.Clip object at 0x7f1a14e356d0>
>> print clip1.PointData.keys()
[]
>> print clip1.FieldData.keys()
[]
>> proxy = servermanager.Proxy(proxy=clip1.SMProxy)
>> for property in proxy:
>> print property
<paraview.servermanager.Scalar object at 0x7f1a4e346850>
<paraview.servermanager.Slice object at 0x7f1a14e35190>
None
0
0
[None, '']
0
1200.0
>> print paraview.numpy_support.vtk_to_numpy(clip1.SMProxy)
AttributeError Traceback (most recent call last)
<ipython-input-21-d5fe9e4e150c> in <module>()
----> 1 print paraview.numpy_support.vtk_to_numpy(clip1.SMProxy)
/home/luke/Programs/paraview4.2/lib/site-packages/paraview/numpy_support.pyc in vtk_to_numpy(vtk_array)
202
203 """
--> 204 typ = vtk_array.GetDataType()
205 assert typ in get_vtk_to_numpy_typemap().keys(), \
206 "Unsupported array type %s"%typ
AttributeError: GetDataType
>> data = servermanager.Fetch(clip1)
>> print data
vtkUnstructuredGrid (0x6276dc0)
Debug: Off
Modified Time: 37918079
Reference Count: 1
Registered Events: (none)
Information: 0x65f2f40
Data Released: False
Global Release Data: Off
UpdateTime: 0
Field Data:
Debug: Off
Modified Time: 37918063
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Number Of Points: 0
Number Of Cells: 0
Cell Data:
Debug: Off
Modified Time: 37918077
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Copy Tuple Flags: (1 1 1 1 1 0 1 1)
Interpolate Flags: (1 1 1 1 1 0 0 1)
Pass Through Flags: (1 1 1 1 1 1 1 1)
Scalars: (none)
Vectors: (none)
Normals: (none)
TCoords: (none)
Tensors: (none)
GlobalIds: (none)
PedigreeIds: (none)
EdgeFlag: (none)
Point Data:
Debug: Off
Modified Time: 37918079
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Copy Tuple Flags: (1 1 1 1 1 0 1 1)
Interpolate Flags: (1 1 1 1 1 0 0 1)
Pass Through Flags: (1 1 1 1 1 1 1 1)
Scalars: (none)
Vectors: (none)
Normals: (none)
TCoords: (none)
Tensors: (none)
GlobalIds: (none)
PedigreeIds: (none)
EdgeFlag: (none)
Bounds:
Xmin,Xmax: (1, -1)
Ymin,Ymax: (1, -1)
Zmin,Zmax: (1, -1)
Compute Time: 0
Number Of Points: 0
Point Coordinates: 0
Locator: 0
Number Of Pieces: 1
Piece: -1
Ghost Level: 0
더 이상의 탐사 항상 FieldDataInformation 또는 PointDataInformation 객체에 날 다시 이어질 것으로 보인다
:
은 여기 내 탐험의 일부입니다!
점 XYZ 위치를 추출하기위한 일 이전의 방법이 있었다 :
data = servermanager.Fetch(clip1)
d2 = data.GetPoints()
xyz = zeros((d2.GetNumberOfPoints(), 3))
for i in range(d2.GetNumberOfPoints()):
xyz[i,:] = data.GetPoint(i)
편집 -이의 출력은 다음과 같습니다
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-11-e34f36729df1> in <module>()
1 data = servermanager.Fetch(clip1)
2 d2 = data.GetPoints()
----> 3 xyz = zeros((d2.GetNumberOfPoints(), 3))
4 for i in range(d2.GetNumberOfPoints()):
5 xyz[i,:] = data.GetPoint(i)
AttributeError: 'NoneType' object has no attribute 'GetNumberOfPoints'
하지만 그래, 더 이상 작동하지 않는 것 , 그리고 나는이 Numpy 통합으로 조금 더 깔끔한 것이있을 것이라고 생각했습니다.
EDIT2가 : Utkarsh의 질문에 대한 출력은 :
>> clip1.UpdatePipeline()
>> rawData = servermanager.Fetch(clip1)
>> import vtk.numpy_interface.dataset_adapter as dsa
>> # Wrap the raw data object to access NumPy friendly API
>> data = dsa.WrapDataObject(rawData) # Note I changed this from Utkarsh's "data" to "rawData"
>> print data.Points
>> print data.PointData["VelocityField"]
준다 : 당신이 이전 방법지고있어 오류가 무엇
None
<vtk.numpy_interface.dataset_adapter.VTKNoneArray object at 0x7f57c4a75390>
참고로, 해당 이름이 데이터 세트에있는 배열이없는 상태로 VTKNoneArray가 반환됩니다. – Utkarsh