droplets.trackers module

Module defining classes for tracking droplets in simulations.

LengthScaleTracker

Tracker that stores length scales measured in simulations

DropletTracker

Detect droplets in a scalar field during simulations

class DropletTracker(interrupts=1, filename=None, *, emulsion_timecourse=None, source=None, threshold=0.5, minimal_radius=0, refine=False, refine_args=None, perturbation_modes=0, interval=None)[source]

Bases: TrackerBase

Detect droplets in a scalar field during simulations

This tracker is useful when only the parameters of actual droplets are needed, since it stores considerably less information compared to the full scalar field.

data

Contains the data of the tracked droplets after the simulation is done.

Type:

EmulsionTimeCourse

Example

To track droplets and determine their position, radii, and interfacial widths, the following tracker can be used

droplet_tracker = DropletTracker(
    1, refine=True, refine_args={'vmin': None, 'vmax': None}
)

field is the scalar field, in which the droplets are located. The refine_args set flexibel boundaries for the intensities inside and outside the droplet.

Parameters:
  • interrupts (InterruptData) – {ARG_TRACKER_INTERRUPTS}

  • filename (str, optional) – Determines the file to which the final data is written as an HDF5 file.

  • emulsion_timecourse (EmulsionTimeCourse, optional) – Can be an instance of EmulsionTimeCourse that is used to store the data.

  • source (int or callable, optional) – Determines how a field is extracted from fields. If None, fields is passed as is, assuming it is already a scalar field. This works for the simple, standard case where only a single ScalarField is treated. Alternatively, source can be an integer, indicating which field is extracted from an instance of FieldCollection. Lastly, source can be a function that takes fields as an argument and returns the desired field.

  • threshold (float or str) –

    The threshold for binarizing the image. If a value is given it is used directly. Otherwise, the following algorithms are supported:

    • extrema: take mean between the minimum and the maximum of the data

    • mean: take the mean over the entire data

    • otsu: use Otsu’s method implemented in threshold_otsu()

    The special value auto currently defaults to the extrema method.

  • minimal_radius (float) – Minimal radius of droplets that will be retained.

  • refine (bool) – Flag determining whether the droplet coordinates should be refined using fitting. This is a potentially slow procedure.

  • refine_args (dict) – Additional keyword arguments passed on to refine_droplet(). Only has an effect if refine=True.

  • perturbation_modes (int) – An option describing how many perturbation modes should be considered when refining droplets. Only has an effect if refine=True.

finalize(info=None)[source]

finalize the tracker, supplying additional information

Parameters:

info (dict) – Extra information from the simulation

Return type:

None

handle(field, t)[source]

handle data supplied to this tracker

Parameters:
  • field (FieldBase) – The current state of the simulation

  • t (float) – The associated time

Return type:

None

class LengthScaleTracker(interrupts=1, filename=None, *, method='structure_factor_mean', source=None, verbose=False, interval=None)[source]

Bases: TrackerBase

Tracker that stores length scales measured in simulations

times

The time points at which the length scales are stored

Type:

list

length_scales

The associated length scales

Type:

list

Parameters:
  • interrupts (InterruptData) – {ARG_TRACKER_INTERRUPTS}

  • filename (str, optional) – Determines the file to which the data is written in JSON format

  • method (str) – Method used for determining the length scale. Details are explained in the function get_length_scale().

  • source (int or callable, optional) – Determines how a field is extracted from fields. If None, fields is passed as is, assuming it is already a scalar field. This works for the simple, standard case where only a single ScalarField is treated. Alternatively, source can be an integer, indicating which field is extracted from an instance of FieldCollection. Lastly, source can be a function that takes fields as an argument and returns the desired field.

  • verbose (bool) – Determines whether errors in determining the length scales are logged.

finalize(info=None)[source]

finalize the tracker, supplying additional information

Parameters:

info (dict) – Extra information from the simulation

Return type:

None

handle(field, t)[source]

handle data supplied to this tracker

Parameters:
  • field (FieldBase) – The current state of the simulation

  • t (float) – The associated time