我正在尝试使用paraview的xdmf文件从hdf5文件中获取数据.
我有一个包含2个值的数组中的变量,我需要使用第一个.为此我尝试使用函数,但无法弄清楚如何使用它.
所以,如果我这样做:
<Attribute Name="rho" Center="Cell" AttributeType="Scalar">
<DataItem Format="HDF" Precision="8" Dimensions="2">
test.h5:/variables/rho_cell
</DataItem>
</Attribute>
Paraview发出警告,我有一个包含2个值的数组,而我只有一个单元格(预计会出现此警告).
所以我添加了一个类似的函数:
<Attribute Name="rho" Center="Cell" AttributeType="Scalar">
<DataItem ItemType="Function" Function="$0[1:2]" Dimensions="1">
<DataItem Format="HDF" Precision="8" Dimensions="2">
test.h5:/variables/rho_cell
</DataItem>
</DataItem>
</Attribute>
随着Paraview崩溃(没有错误信息).
说实话,我甚至不确定数组索引是否像在python中一样(从0开始,0:1表示只有第一个元素)…而且我找不到任何帮助.我几乎尝试了任何参数组合,但似乎没有任何效果.
为了确保我的函数语法没有完全错误,我试过了:
<Attribute Name="rho" Center="Cell" AttributeType="Scalar">
<DataItem ItemType="Function" Function="$0 + 1.5" Dimensions="2">
<DataItem Format="HDF" Precision="8" Dimensions="2">
test.h5:/variables/rho_cell
</DataItem>
</DataItem>
</Attribute>
并且它有效,但显然仍然会发出关于细胞数量的警告.
最佳答案 您是否尝试过使用Coordinates DataItem?
<Attribute Name="rho" Center="Cell" AttributeType="Scalar">
<DataItem ItemType="Coordinates" Dimensions="2" Type="Coordinates">
<DataItem Format="XML" Dimensions="1">
0
</DataItem>
<DataItem Format="HDF" Precision="8" Dimensions="2">
test.h5:/variables/rho_cell
</DataItem>
</DataItem>
</Attribute>