VTK Export¶
MicPy can export field data to the Visualization Toolkit (VTK) ImageData format (.vti). The resulting files can be visualized in applications such as ParaView or processed further using Python libraries built on VTK.
ParaView Plugin
MicPy also provides a dedicated ParaView plugin that can open MICRESS binary files directly, without converting them to VTK first. See the ParaView plugin documentation for details.
Exporting a Field¶
A Field can be converted into a vtkImageData object using Field.as_vti().
The data_mode parameter controls how the field values are represented in the VTK dataset.
Data Modes¶
Stores each field value (x0, x1, x2, x3) as VTK CellData, with one value per MICRESS cell. This preserves the field’s cell-based representation.
Converts the field to VTK PointData by averaging adjacent cell values at each grid point, e.g. p11 = average(x0, x1, x2, x3). Additional boundary points are generated so that the original spatial extent and dataset bounds are preserved.
Stores the field values (x0, x1, x2, x3) directly as VTK PointData, without averaging or generating additional boundary points. Consequently, the dataset contains one fewer cell along each non-degenerate axis, reducing its spatial extent by one grid spacing in those directions.
Creating a VTK ImageData object¶
from micpy.bin import read
# Read the last time step
field = read("A019_01_MgAl6_D_Dendritic_3D_TQ.frac", -1)
# Default: CellData
vti = field.as_vti()
# Averaged PointData
vti = field.as_vti(data_mode="point_average")
# Direct PointData
vti = field.as_vti(data_mode="point_direct")
Saving to a .vti File¶
# Save as CellData (default)
field.save_vti("A019_01_MgAl6_D_Dendritic_3D_TQ.vti")
# Save averaged PointData
field.save_vti("A019_01_MgAl6_D_Dendritic_3D_TQ.vti", data_mode="point_average")
# Save direct PointData
field.save_vti("A019_01_MgAl6_D_Dendritic_3D_TQ.vti", data_mode="point_direct")
Reference¶
micpy.bin.Field.as_vti(name='values', point_data=False) ¶
Convert the field to a VTK ImageData object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | Name of the data array. Defaults to | 'values' |
point_data | bool |
| False |
Returns: VTK ImageData object.
micpy.bin.Field.save_vti(filename, name='values', point_data=False) ¶
Save the field as a VTK ImageData file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename | str | Filename of the VTK ImageData file. | required |
name | str | Name of the data array. Defaults to | 'values' |
point_data | bool |
| False |
Returns: Filename of the VTK ImageData file.