Importing OpenLPT / pyOpenLPT data

flowtracks.openlpt reads the track output of OpenLPT_GUI or the pyOpenLPT package (openlpt on PyPI) and converts it into flowtracks Trajectory objects — or directly into a trajectories Zarr store that ZarrScene reads natively, with no further conversion. pyOpenLPT is a packaging fork of the same software with an identical C++ core and identical output (verified), so there is exactly one reader for both: read_openlpt_tracks() plus read_pyopenlpt_tracks / convert_pyopenlpt_to_zarr aliases with source_format="pyopenlpt" provenance recorded.

OpenLPT writes each stage as a family of CSV files under Results/ConvergeTrack/ — named {LongTrackActive,ShortTrackActive,LongTrackInactive,ExitTrack}_{frame}.csv — with a header row and one row per track sample:

  • Tracer: [TrackID, FrameID, WorldX, WorldY, WorldZ, camX, camY, ...]

  • Bubble: [TrackID, FrameID, WorldX, WorldY, WorldZ, R3D, camX, camY, camRpx, ...]

Positions are millimetres. Frame IDs are integers. Velocity and acceleration are not stored in these files; the translator re-derives velocity as finite differences over the frame column (mm per frame). Acceleration is not guessed. Unparseable rows are skipped. Track ids are re-assigned in a running offset so they are unique across the whole directory, mirroring the GUI’s own post-processing. Because the offset advances by max_id + 1 per file, ids may not be contiguous when the source ids are sparse. Bubble files additionally surface a radius property (not projected into the Zarr store).

A self-contained example — synthetic tracks, run in a temporary directory:

python examples/openlpt_tracks_example.py
from flowtracks.openlpt import convert_openlpt_to_zarr
from flowtracks.graphics import plot_trajectories_3d
import pyvista as pv

convert_openlpt_to_zarr("ConvergeTrack", "openlpt_run.zarr")
plotter = pv.Plotter(off_screen=True)
plot_trajectories_3d("openlpt_run.zarr", context=1000, plotter=plotter, show=False)
plotter.screenshot("openlpt_tracks.png", window_size=(900, 600))
synthetic OpenLPT tracks, coloured by speed

Synthetic example — three tracks with drift and sinusoidal wander, converted by convert_openlpt_to_zarr() and rendered with flowtracks.graphics.plot_trajectories_3d().

OpenLPT track import: read ConvergeTrack CSVs as Trajectories.

Covers both OpenLPT_GUI (the GUI and C++ core, PyPI package openlpt) and pyOpenLPT — a packaging fork of the same software with identical code and identical output; read_pyopenlpt_tracks() and convert_pyopenlpt_to_zarr() are aliases with source_format="pyopenlpt" provenance recorded.

OpenLPT_GUI (https://github.com/JHU-NI-LAB/OpenLPT_GUI) writes each tracking stage as a family of CSV files under Results/ConvergeTrack/ — named {Outcome}_{frame}.csv where the outcomes are LongTrackActive, ShortTrackActive, LongTrackInactive and ExitTrack. Each file carries a header row and one row per track sample:

  • Tracer: [TrackID, FrameID, WorldX, WorldY, WorldZ, <camX, camY> * n_cam]

  • Bubble: [TrackID, FrameID, WorldX, WorldY, WorldZ, R3D, <camX, camY, camRpx> * n_cam]

(one 2D projection column per camera, camX/camY for tracers and camX/camY/camRpx for bubbles). Positions are millimetres (OpenLPT’s 3D error tolerance and volume scale are in mm). Frame IDs are integer frame numbers. Velocity and acceleration are NOT stored in these files; the translator re-derives velocity as finite differences over the frame column (mm per frame) — the same convention used by MyPTV’s smoothing and stitching stages. Acceleration is not guessed.

read_openlpt_tracks parses the directory into flowtracks Trajectory objects (with a radius property when the object type is Bubble). The file-to-track id assignment mirrors the GUI’s own post-processing: a running offset is added to each file’s TrackID so ids are unique across the whole directory. convert_openlpt_to_zarr additionally writes a trajectories store (the same layout openptv2’s RunStore and save_zarr_trajectories write) with source_format="openlpt" provenance.

flowtracks.openlpt._natsort_key(s)[source]
flowtracks.openlpt._finite_difference_velocity(pos, time)[source]

Forward-difference velocity from position over the frame column.

flowtracks.openlpt._detect_object_type(header_first_col_row)[source]

Return (‘Bubble’|’Tracer’, n_cam) from the header row.

flowtracks.openlpt._read_track_csv(path, obj_type)[source]

Parse one CSV file into (orig_id, rows) pairs; obj_type known or None.

rows

flowtracks.openlpt.read_openlpt_tracks(path, outcomes=None, sort=True)[source]

Read an OpenLPT_GUI ConvergeTrack directory into Trajectory objects.

Arguments

  • path: path to a ConvergeTrack directory (or a single track CSV file — in that case only that file is read).

  • outcomes: sequence of file-name prefixes to read (default: all four).

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

Returns

  • trajects: a list of Trajectory objects. velocity is re-derived by finite differences (mm per frame); radius is an extra property for Bubble files.

flowtracks.openlpt.convert_openlpt_to_zarr(path, zarr_path, group='trajectories', overwrite=True, units=None, sort=True, outcomes=None)[source]

Convert an OpenLPT_GUI ConvergeTrack directory into a Zarr store.

The store holds a trajectories group with pos, vel, time and trajid arrays — the same layout openptv2’s RunStore and save_zarr_trajectories write, so it is consumed by flowtracks’ Eulerian/phase-averaging pipeline directly.

Arguments

  • path: path to the ConvergeTrack directory (or a single track CSV 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 per-frame millimetre units ({"pos": "mm", "vel": "mm frame-1", "time": "frame"}) — the source file records neither, and OpenLPT volumes are conventionally in millimetres. Pass units= to state absolute units explicitly.

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

  • outcomes: file-name prefixes to read (default: all four).

Returns

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

flowtracks.openlpt.read_pyopenlpt_tracks(path, outcomes=None, sort=True)[source]

Alias for read_openlpt_tracks().

pyOpenLPT (https://github.com/alexlib/pyOpenLPT) is a packaging fork of OpenLPT_GUI — identical C++ core and identical ConvergeTrack/*.csv output, so the same reader covers both. openlpt is the installed package name of that fork.

flowtracks.openlpt.convert_pyopenlpt_to_zarr(path, zarr_path, group='trajectories', overwrite=True, units=None, sort=True, outcomes=None)[source]

Convert a pyOpenLPT ConvergeTrack directory into a Zarr store.

Same code path as convert_openlpt_to_zarr() (same file format, so identical store) — records source_format="pyopenlpt" on the group so the store is self-describing about where its data came from.