droplets.trackers module
Module defining classes for tracking droplets in simulations.
Tracker that stores length scales measured in simulations |
|
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. The file written when filename is supplied can be read in later using
from_file()
.- data
Contains the data of the tracked droplets after the simulation is done.
- Type:
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) – Determines when the tracker interrupts the simulation. A single numbers determines an interval (measured in the simulation time unit) of regular interruption. A string is interpreted as a duration in real time assuming the format ‘hh:mm:ss’. A list of numbers is taken as explicit simulation time points. More fine- grained contol is possible by passing an instance of classes defined in
interrupts
.filename (str, optional) – Determines the path to the HDF5 file to which the
EmulsionTimeCourse
data is written.emulsion_timecourse (
EmulsionTimeCourse
, optional) – Can be an instance ofEmulsionTimeCourse
that is used to store the data. If omitted, an empty class is initiated.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.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.
- 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
- 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 ofFieldCollection
. 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.