Sequence Processing of non-HDF Formatted Particle Databases¶
-
class
flowtracks.sequence.Sequence(frange, frate, particle, part_tmpl, tracer_tmpl, smooth_tracers=False, traj_min_len=0.0)[source]¶ Tracks a dual particles database (for both inertial particles and tracers), allowing a number of underlying formats. Provides segment iteration and trajectory-mapping.
Arguments
frange: tuple, (first frame #, after last frame #)frate: the frame rate at which the scene was shot.particle: a Particle object representing the suspended particles’ properties.part_tmpl, tracer_tmpl: the filenames for particle- and tracer- databases respectively. Names must be as understood by :func:`flowtracks.io.trajectories’.smooth_tracers: if True, uses trajectory smoothing on the tracer trajectories when iterating over frames. Possibly out of date.traj_min_len: when reading trajectories (tracers and particles) discard trajectories shorter than this many frames.
-
__iter__()[source]¶ Iterate over frames. For each frame return the data for the tracers and particles in it, as a tuple containing two
ParticleSnapshotobjects corresponding to the current frame data and the next frame’s.Returns
A Python iteraor.
-
iter_subrange(first, last)[source]¶ The same as
__iter__(), except it changes the frame range for the duration of the iteration.Arguments
first, last: frame numbers of the first and last frames in the acting range of frames from the sequence.
Returns
A Python iteraor.
-
map_trajectories(func, subrange=None, history=False, args=())[source]¶ Iterate over frames, for each frame call a function that generates a per-trajectory result and add the results up in a per-trajectory time-series.
Arguments
func: the function to call. Returns a dictionary keyed by trajid. receives as arguments (self, particles, tracers) where particles, tracers are the sequence iteration results as given by __iter__.subrange: tuple (first, last). Iterate over a subrange of the sequence delimited by these frame numbers.history: true if the result of one frame depends on earlier results. If true, func receives a 4th argument, the accumulated results so far as a dictionary of time-series lists.args: a tuple of extra positional arguments to pass to the function after the usual arguments and the possible history argument.
Returns
a dictionary keyed by trajid, where for each trajectory a time series of results obtained during the trajectory’s lifetime is the value.
-
particle_trajectories()[source]¶ Return (and possibly generate and cache) the list of
Trajectoryobjects as selected by the particle selector.
-
save_config(cfg)[source]¶ Adds the keys necessary for recreating this sequence into a configuration object. It is the caller’s responsibility to do a writeback to file.
Arguments
cfg: a ConfigParser object.
-
set_particle_selector(selector)[source]¶ Sets a filter on the particle trajectories used in sequencing.
Arguments
selector: a function which receives a list ofTrajectoryobjects and returns a sublist thereof.
-
set_tracer_selector(selector)[source]¶ Sets a filter on the tracer trajectories used in sequencing.
Arguments
selector: a function which receives a list ofTrajectoryobjects and returns a sublist thereof.
-
subrange()[source]¶ Returns the earliest and latest time points covered by the subset of trajectories that the particle selector selects, bounded by the range restricting the overall sequence.
-
tracer_trajectories()[source]¶ Return (and possibly generate and cache) the list of
Trajectoryobjects corresponding to tracers.
-
flowtracks.sequence.read_sequence(conf_fname, smooth=None, traj_min_len=None)[source]¶ Read sequence-wide parameters, such as unchanging particle properties and frame range. Values are stored in an INI-format file.
Arguments
conf_fname: name of the config filesmooth: whether the sequence shoud use tracers trajectory-smoothing. Used to override the config value if present, and supply it if missing. If None and missing, default is False.traj_min_len: tells the sequence to ignore trajectories shorter than this many frames. Overrides file. If None and file has no value, default is 0.
Returns
a Sequence object initialized with the configuration values found.