Writers (ParaView export)¶
flowtracks.writers exports run results to ParaView-readable formats
via pyvista/vtk. It replaces the removed vtk_export module: the grid-type
rule — vtp for trajectories, vti for uniform Eulerian volumes,
vtr for non-uniform volumes, pvd for time series — is applied here.
flowtracks.writers.write_pvd() writes a .pvd time-series file.
flowtracks.writers.write_trajectories_vtp() writes trajectory polydata
(.vtp). flowtracks.writers.write_eulerian_series() writes a
sequence of Eulerian volume files plus a .pvd — the single entry point
for “export a run”. flowtracks.writers.export_run_to_paraview() does
the same from a run.zarr store, reading it with
ZarrScene.
Unified pyvista-based ParaView writers.
Lagrangian trajectories -> VTK PolyData (.vtp, polylines per trajid).
Eulerian grids -> VTK ImageData (.vti, uniform axis spacing) or
RectilinearGrid (.vtr, non-uniform), each written as a per-timestep
series plus one .pvd Collection.
See WRITERS_PLAN.md for the design rationale and the writers this module
replaces (vtk_export.py, eulerian.export_vtk,
eulerian.export_vtk_rectilinear_series).
- flowtracks.writers.write_pvd(path: Path, entries: list[tuple[float, Path | str]]) Path[source]¶
Write a ParaView Collection (.pvd) indexing time-series files.
entriesis a list of(timestep, file_path). Paths are stored relative topathso the output directory stays portable.
- flowtracks.writers.trajectory_units(source) dict[source]¶
Units recorded on a trajectories store ({pos, vel, time, …} units).
Zarr paths report what the writer recorded; anything else reports {} – the caller then labels without units rather than guessing.
- flowtracks.writers.trajectory_polydata(source, trajids=None, units=None)[source]¶
Lagrangian trajectories as VTK PolyData: points + one polyline per trajid.
sourceas forwrite_trajectories_vtp().trajidsoptionally keeps only those trajectories. Point data:trajid,time,velocity,speed.units(e.g.{"pos": "m"}) is stored as field data (units:<name>); when omitted andsourceis a Zarr path, whatever the writer recorded is carried over. Shared by the.vtpwriter andflowtracks.graphics.plot_trajectories_3d().
- flowtracks.writers.write_trajectories_vtp(source, out_path: Path) Path[source]¶
Write Lagrangian trajectories as VTK PolyData (points + polylines per trajid).
sourceis a zarr path holding atrajectories/group withpos/vel/time/trajidarrays (a flowtracks Zarr export or an openptv2 RunStore – no conversion needed, seeZarrScene), or any object exposing.collect(["pos", "velocity", "time", "trajid"])(ZarrScene/Scene).
- flowtracks.writers.write_eulerian_series(ds: Dataset, out_dir: Path, prefix: str = 'phase', time_dim: str = 'phase', dt: float = 1.0, units: dict | None = None, vectors: dict | None = None, tensors: dict | None = None, keep_nan: bool = False) Path[source]¶
Write one Eulerian grid file per
time_dimstep plus a.pvdseries.Grid type is chosen from axis spacing:
vtkImageData(.vti) when x, y and z are each uniformly spaced,vtkRectilinearGrid(.vtr) otherwise. Vector fields named byVEL_VARSare combined into a single “velocity” array; every other data variable is written as a scalar.vectorsmaps extra output names to three component variables ({"velocity_pooled": [u, v, w]});tensorsmaps output names to six variables of a symmetric tensor in VTK’s orderxx, yy, zz, xy, yz, xz({"reynolds_stress": [uu, vv, ww, uv, vw, uw]}), written as one 6-component array ParaView recognises. Grouped variables are not also written as scalars; a group with a missing variable is skipped. Boolean variables (e.g.valid) are written as 0/1uint8.keep_nan: write NaN (no data) as NaN — ParaView shows it in the NaN colour and Threshold/Contour skip it — instead of the default 0.0, which is indistinguishable from a measured zero. ±Inf becomes NaN too.unitsmaps array name to unit string (e.g.{"velocity": "m s-1"}) and is stored as grid field data (units:<name>); when omitted, the dataset’s ownunitsattrs are carried over where present. VTK has no unit system, so this is annotation, not enforcement — but the reader no longer has to guess.
- flowtracks.writers.export_run_to_paraview(zarr_path: Path, out_dir: Path, grid_params: dict | None = None, eulerian_ds: Dataset | None = None, **eulerian_grid_kwargs) dict[str, Path][source]¶
Convenience wrapper: write trajectories, and optionally an Eulerian grid series, for one run into
out_dir.Pass
eulerian_dsdirectly if you already built it (e.g. viaeulerian_grid()orxr.open_zarr); passgrid_params(pluseulerian_grid’s other required kwargs:first,last,cycletime, …) to have this function build it fromzarr_path.