fdtdx.export_vti

Contents

fdtdx.export_vti#

fdtdx.export_vti(cell_data, filename, resolution, offset=(0, 0, 0), grid_slice=None, compression_level=-1, grid=None)[source]#

Export a dictionary of arrays to a VTI (VTK ImageData) file.

Writes an XML-formatted VTI file with appended binary data. Supports both 3D scalar fields (x, y, z) and 4D vector fields (n, x, y, z). All arrays must share the same spatial dimensions.

Parameters:
  • cell_data (dict[str, jax.Array]) – Dictionary mapping field names to numpy arrays.

  • filename (Path | str) – Output file path.

  • resolution (float) – Voxel spacing for the grid.

  • offset (tuple[int, int, int], optional) – Global grid index offset (x, y, z). Useful when aligning multiple VTI files. Defaults to (0, 0, 0).

  • grid_slice (Slice3D | None, optional) – Slice for defining the offset, if provided. Useful when aligning multiple VTI files. Overrides offset. Defaults to None.

  • compression_level (int, optional) – zlib compression level. Use level 0 for no compression (fastest) and level 9 for highest compression (smallest file size). Defaults to -1, which currently corresponds to level 6 compression.

  • grid (RectilinearGrid | None) – Optional grid metadata. VTI is an image-data format and can only encode uniform spacing. Passing a non-uniform grid raises and callers should use export_vtr() instead.

Raises:

AssertionError – If arrays have mismatched shapes, invalid dimensions, or unsupported dtypes.