Importing proPTV data

flowtracks.proptv reads proPTV track output and converts it into flowtracks Trajectory objects — or directly into a trajectories Zarr store that ZarrScene reads natively, with no further conversion. This is the interop bridge between proPTV (the probabilistic tracker) and flowtracks (the post-processing pipeline): proPTV tracks, postptv post-processes.

proPTV saves each pipeline stage as a float64 HDF5 file under data/{case}/output/tracks/tracks*.hdf5 (for example tracks.hdf5 or tracks_initial.hdf5). Each track is a dataset named track_{t}_{key} (t = last frame of the track, key = track index) with columns:

[frame, x, y, z, vx, vy, vz, ax, ay, az, <cx, cy> * n_cameras]

i.e. 10 + 2*n_cameras columns. Positions appear in millimetres (the track volumes in proPTV configs, e.g. [-2500, 2500] per axis). The file records no units of its own. Frame numbers are integers stored as floats. The per-camera 2D projection columns are ignored — only the 3D Lagrangian data enters the Zarr store.

from flowtracks.proptv import read_proptv_hdf5, convert_proptv_to_zarr

trajects = read_proptv_hdf5("tracks_initial.hdf5")
convert_proptv_to_zarr("tracks_initial.hdf5", "run.zarr")

# ZarrScene opens the converted store with no conversion step:
from flowtracks.zarr_scene import ZarrScene
scene = ZarrScene("run.zarr")

convert_proptv_to_zarr writes a trajectories group with pos, vel, time, trajid and accel — the same layout as the MyPTV import and openptv2’s RunStore, so it is consumed by flowtracks’ Eulerian/phase-averaging pipeline directly. Units default to honest per-frame units (mm frame-1, mm frame-2) — the source file records no units and no frame rate, so units= is passed to state absolute units explicitly. A source_format/source_file/source_path attribute pair is recorded on the group for provenance.

from flowtracks.proptv import convert_proptv_to_zarr
from flowtracks.graphics import plot_trajectories_3d, select_trajectories
import pyvista as pv

convert_proptv_to_zarr("tracksinitial.hdf5", "proptv_run.zarr")
sel = select_trajectories("proptv_run.zarr", by="length", n=22)
plotter = pv.Plotter(off_screen=True)
plot_trajectories_3d("proptv_run.zarr", trajids=sel, context=1000,
                     plotter=plotter, show=False)
plotter.screenshot("proptv_tracks.png", window_size=(900, 600))
3D view of proPTV example tracks, coloured by speed

proPTV’s own example tracks (tracksinitial.hdf5, 848 4-sample tracks), converted via convert_proptv_to_zarr() and rendered with flowtracks.graphics.plot_trajectories_3d(). 22 tracks spread across the volume, colored by speed in mm frame-1.

proPTV track import: read proPTV tracks as flowtracks Trajectories.

proPTV (https://github.com/RobinBarta/proPTV) saves every pipeline stage as a float64 HDF5 file at data/{case}/output/tracks/tracks*.hdf5 (for example tracks.hdf5, tracks_initial.hdf5 or tracks_broken{t}.hdf5). Each track is a dataset named track_{t}_{key} — t is the track’s last frame number and key is the track index assigned by proPTV — with columns:

[frame, x, y, z, vx, vy, vz, ax, ay, az, <cx, cy> * n_cameras]

(10 + 2*n_cameras columns). Positions appear in millimetres (track volumes in proPTV’s configs, e.g. [-2500, 2500] per axis, confirm the convention; the source file records no units of its own). Frame numbers are integers stored as floats. The per-camera 2D projection columns are ignored — only the 3D Lagrangian data enters the Zarr store.

read_proptv_hdf5 converts the file into flowtracks Trajectory objects. convert_proptv_to_zarr additionally writes a trajectories store (the same layout openptv2’s RunStore and save_zarr_trajectories write) so the results can be consumed by flowtracks directly — the interop bridge between the proPTV and flowtracks (openptv/openptv-cloud) pipelines.

flowtracks.proptv._track_id(key, fallback)[source]

Trajid for a track dataset: the numeric suffix in track_{t}_{key}.

flowtracks.proptv.read_proptv_hdf5(path, sort=True)[source]

Read a proPTV tracks*.hdf5 file into a list of Trajectories.

Arguments

  • path: path to the tracks HDF5 file.

  • sort: if True (default), return trajectories sorted by (trajid, frame).

Returns

  • trajects: a list of Trajectory objects, each with pos, velocity, accel and time.

flowtracks.proptv.convert_proptv_to_zarr(path, zarr_path, group='trajectories', overwrite=True, units=None, sort=True)[source]

Convert a proPTV tracks*.hdf5 file into a Zarr store.

The store holds a trajectories group with pos, vel, time, trajid and accel arrays — the layout flowtracks.zarr_scene.ZarrScene reads natively.

Arguments

  • path: path to the proPTV tracks HDF5 file.

  • zarr_path: target .zarr directory.

  • group: sub-group name inside the store (default "trajectories").

  • overwrite: if True, overwrite existing arrays in the group.

  • units: units dict recorded on the group. Defaults to {"pos": "mm", "vel": "mm frame-1", "time": "frame", "accel": "mm frame-2"} — per-frame units with a conventional millimetre positional unit, NOT recorded by proPTV itself (mm is the conventional scale of proPTV’s volume/camera configs; override with units= to state the source’s actual units).

  • sort: if True (default), trajectories are sorted by (trajid, frame).

Returns

  • trajects: the list of Trajectory objects that were written.