# The Basic Analysis Machinery¶

Infrastructure for running a frame-by-frame analysis on a DualScene object. The main point of interest here is analysis(), which performs a segment iteration over a DualScene and applies to each a user-selected list of analyzers. Analysers are instances of a GeneralAnalyser subclass which implements the necessary methods, as described in the base class documentation.

There is one base class supplied here, FluidVelocitiesAnalyser, which ties in the flowtracks.interpolation module for analysing the fluid velocity around a particle from its surrounding tracers.

class flowtracks.analysis.FluidVelocitiesAnalyser(interp)[source]

Finds, for each particle in the particles set of a frame, the so-called undisturbed fluid velocity at the particle’s position, by interpolating from nearby particles in the tracers set.

Arguments

• interp: the Interpolant object to use for finding velocities.
analyse(frame, next_frame)[source]

Arguments

• frame, next_frame: the Frame object for the currently-analysed frame and the one after it, respectively.

Returns

a list of two arrays, each of shape (f,3) where f is the number of particles in the current frame. 1st array - fluid velocity. 2nd array - relative velocity.

descr()[source]

Return a list of two tuples, each of the form (name, data type, row length), describing the arrays returned by analyse() for fluid velocity and relative velocity.

class flowtracks.analysis.GeneralAnalyser[source]

This is the parent class for all analysers to be used by analysis(). It does not do anything but define and document the methods that must be implenmented by the child class (in other words, this class is abstract). Attempting to use its methods will result in a NotImplementedError.

analyse(frame, next_frame)[source]

Arguments

• frame, next_frame: the Frame object for the currently-analysed frame and the one after it, respectively.

Returns

a list of arrays, each of shape (f,d) where f is the number of particles in the current frame, and d is the row length of the corresponding item returned by self.descr(). Each array’s dtype also corresponds to the dtype given to it by self.descr().

descr()[source]

Need to return a list of tuples, each of the form (name, data type, row length), e.g. (‘trajid’, int, 1)

flowtracks.analysis.analysis(scene, analysis_file, conf_file, analysers, frame_range=-1)[source]

Generate the analysis table for a given scene with separate data for inertial particles and tracers.

Arguments

• scene: a DualScene object representing an experiment with coordinated particles and tracers data streams.
• analysis_file: path to the file where analysis should be saved. If the file exists, it will be cloberred.
• conf_file: name of config file used for creating the analysis.
• analysers: a list of GeneralAnalyser subclasses that do the actual analysis work and know all that is needed about output shape.
• frame_range: if -1 no adjustment is necessary, otherwise see DualScene.iter_segments()
flowtracks.analysis.companion_indices(trids, companions)[source]

Return an array giving for each companion its respective index in the trajectory ID array, or a negative number if not found.