droplets.droplet_tracks module
Classes representing the time evolution of droplets
information about a single droplet over multiple time steps |
|
a list of instances of |
- class DropletTrack(droplets=None, times=None)[source]
Bases:
object
information about a single droplet over multiple time steps
- Parameters:
- append(droplet, time=None)[source]
append a new droplet with a time code
- Parameters:
droplet (
droplets.droplets.SphericalDroplet
) – The droplet to appendtime (float, optional) – The associated time point
- Return type:
None
- property first: SphericalDroplet
first droplet instance
- Type:
- classmethod from_file(path)[source]
create droplet track by reading from file
- get_trajectory(smoothing=0, *, attribute='position')[source]
return a the time-evolution of a droplet attribute (e.g., the position)
- Parameters:
- Returns:
- An array giving the position of the droplet at each
time instance
- Return type:
- property last: SphericalDroplet
last droplet instance
- Type:
- plot(attribute='radius', smoothing=0, t_max=None, *args, title=None, filename=None, action='auto', ax_style=None, fig_style=None, ax=None, **kwargs)[source]
plot the time evolution of the droplet
- Parameters:
attribute (str) – The attribute to plot. Typical values include radius and volume, but others might be defined on the droplet class.
smoothing (float) – Determines the scale for some gaussian smoothing of the trajectory. The default value of zero disables smoothing.
title (str) – Title of the plot. If omitted, the title might be chosen automatically.
filename (str, optional) – If given, the plot is written to the specified file.
action (str) – Decides what to do with the final figure. If the argument is set to show,
matplotlib.pyplot.show()
will be called to show the plot. If the value is none, the figure will be created, but not necessarily shown. The value close closes the figure, after saving it to a file when filename is given. The default value auto implies that the plot is shown if it is not a nested plot call.ax_style (dict) – Dictionary with properties that will be changed on the axis after the plot has been drawn by calling
matplotlib.pyplot.setp()
. A special item i this dictionary is use_offset, which is flag that can be used to control whether offset are shown along the axes of the plot.fig_style (dict) – Dictionary with properties that will be changed on the figure after the plot has been drawn by calling
matplotlib.pyplot.setp()
. For instance, using fig_style={‘dpi’: 200} increases the resolution of the figure.ax (
matplotlib.axes.Axes
) – Figure axes to be used for plotting. The special value “create” creates a new figure, while “reuse” attempts to reuse an existing figure, which is the default.**kwargs – All remaining parameters are forwarded to the ax.plot method. For example, passing color=None, will use different colors for different droplets.
t_max (float | None) –
- Returns:
Information about the plot
- Return type:
PlotReference
- plot_positions(grid=None, arrow=True, *args, title=None, filename=None, action='auto', ax_style=None, fig_style=None, ax=None, **kwargs)[source]
plot the droplet track
- Parameters:
grid (GridBase, optional) – The grid on which the droplets are defined. If given, periodic boundary conditions can be respected in the plotting.
arrow (bool, optional) – Flag determining whether an arrow head is shown to indicate the direction of the droplet drift.
title (str) – Title of the plot. If omitted, the title might be chosen automatically.
filename (str, optional) – If given, the plot is written to the specified file.
action (str) – Decides what to do with the final figure. If the argument is set to show,
matplotlib.pyplot.show()
will be called to show the plot. If the value is none, the figure will be created, but not necessarily shown. The value close closes the figure, after saving it to a file when filename is given. The default value auto implies that the plot is shown if it is not a nested plot call.ax_style (dict) – Dictionary with properties that will be changed on the axis after the plot has been drawn by calling
matplotlib.pyplot.setp()
. A special item i this dictionary is use_offset, which is flag that can be used to control whether offset are shown along the axes of the plot.fig_style (dict) – Dictionary with properties that will be changed on the figure after the plot has been drawn by calling
matplotlib.pyplot.setp()
. For instance, using fig_style={‘dpi’: 200} increases the resolution of the figure.ax (
matplotlib.axes.Axes
) – Figure axes to be used for plotting. The special value “create” creates a new figure, while “reuse” attempts to reuse an existing figure, which is the default.**kwargs – Additional keyword arguments are passed to the matplotlib plot function to affect the appearance. For example, passing color=None, will use different colors for different droplets.
- Returns:
Information about the plot
- Return type:
PlotReference
- time_overlaps(other)[source]
determine whether two DropletTrack instances overlaps in time
- Parameters:
other (
DropletTrack
) – The other droplet track- Returns:
True when both tracks contain droplets at the same time step
- Return type:
- to_file(path, info=None)[source]
store data in hdf5 file
The data can be read using the classmethod
DropletTrack.from_file()
.
- class DropletTrackList(iterable=(), /)[source]
Bases:
list
a list of instances of
DropletTrack
- classmethod from_emulsion_time_course(time_course, *, method='overlap', grid=None, progress=False, **kwargs)[source]
obtain droplet tracks from an emulsion time course
- Parameters:
time_course (
droplets.emulsions.EmulsionTimeCourse
) – A collection of temporally arranged emulsionsmethod (str) – The method used for tracking droplet identities. Possible methods are “overlap” (adding droplets that overlap with those in previous frames) and “distance” (matching droplets to minimize center-to-center distances).
grid (
GridBase
) – The grid on which the droplets are defined, which is necessary if periodic boundary conditions should be respected for measuring distancesprogress (bool) – Whether to show the progress of the process.
**kwargs – Additional parameters for the tracking algorithm. Currently, one can only specify a maximal distance (using max_dist) for the “distance” method.
- Returns:
the resulting droplet tracks
- Return type:
- classmethod from_file(path)[source]
create droplet track list by reading file
- classmethod from_storage(storage, *, method='overlap', refine=False, num_processes=1, progress=None)[source]
obtain droplet tracks from stored scalar field data
This method first determines an emulsion time course and than collects tracks by tracking droplets.
- Parameters:
storage (
StorageBase
) – The phase fields for many time instancesmethod (str) – The method used for tracking droplet identities. Possible methods are “overlap” (adding droplets that overlap with those in previous frames) and “distance” (matching droplets to minimize center-to-center distances).
refine (bool) – Flag determining whether the droplet properties should be refined using fitting. This is a potentially slow procedure.
num_processes (int or "auto") – Number of processes used for the refinement. If set to “auto”, the number of processes is choosen automatically.
progress (bool) – Whether to show the progress of the process. If None, the progress is not shown, except for the first step if refine is True.
- Returns:
the resulting droplet tracks
- Return type:
- plot(attribute='radius', *args, title=None, filename=None, action='auto', ax_style=None, fig_style=None, ax=None, **kwargs)[source]
plot the time evolution of all droplets
- Parameters:
attribute (str) – The attribute to plot. Typical values include radius and volume, but others might be defined on the droplet class.
title (str) – Title of the plot. If omitted, the title might be chosen automatically.
filename (str, optional) – If given, the plot is written to the specified file.
action (str) – Decides what to do with the final figure. If the argument is set to show,
matplotlib.pyplot.show()
will be called to show the plot. If the value is none, the figure will be created, but not necessarily shown. The value close closes the figure, after saving it to a file when filename is given. The default value auto implies that the plot is shown if it is not a nested plot call.ax_style (dict) – Dictionary with properties that will be changed on the axis after the plot has been drawn by calling
matplotlib.pyplot.setp()
. A special item i this dictionary is use_offset, which is flag that can be used to control whether offset are shown along the axes of the plot.fig_style (dict) – Dictionary with properties that will be changed on the figure after the plot has been drawn by calling
matplotlib.pyplot.setp()
. For instance, using fig_style={‘dpi’: 200} increases the resolution of the figure.ax (
matplotlib.axes.Axes
) – Figure axes to be used for plotting. The special value “create” creates a new figure, while “reuse” attempts to reuse an existing figure, which is the default.**kwargs – Additional keyword arguments are passed to the matplotlib plot function to affect the appearance. The special value color=”cycle” implies that the default color cycle is used for the tracks, using different colors for different tracks.
- Returns:
Information about the plot
- Return type:
PlotReference
- plot_positions(*args, title=None, filename=None, action='auto', ax_style=None, fig_style=None, ax=None, **kwargs)[source]
plot all droplet tracks
- Parameters:
title (str) – Title of the plot. If omitted, the title might be chosen automatically.
filename (str, optional) – If given, the plot is written to the specified file.
action (str) – Decides what to do with the final figure. If the argument is set to show,
matplotlib.pyplot.show()
will be called to show the plot. If the value is none, the figure will be created, but not necessarily shown. The value close closes the figure, after saving it to a file when filename is given. The default value auto implies that the plot is shown if it is not a nested plot call.ax_style (dict) – Dictionary with properties that will be changed on the axis after the plot has been drawn by calling
matplotlib.pyplot.setp()
. A special item i this dictionary is use_offset, which is flag that can be used to control whether offset are shown along the axes of the plot.fig_style (dict) – Dictionary with properties that will be changed on the figure after the plot has been drawn by calling
matplotlib.pyplot.setp()
. For instance, using fig_style={‘dpi’: 200} increases the resolution of the figure.ax (
matplotlib.axes.Axes
) – Figure axes to be used for plotting. The special value “create” creates a new figure, while “reuse” attempts to reuse an existing figure, which is the default.**kwargs – Additional keyword arguments are passed to the matplotlib plot function to affect the appearance.
- Returns:
Information about the plot
- Return type:
PlotReference
- remove_short_tracks(min_duration=0)[source]
remove tracks that a shorter than a minimal duration
- Parameters:
min_duration (float) – The minimal duration a droplet track must have in order to be retained. This is measured in actual time and not in the number of time steps stored in the track.
- Return type:
None
- to_file(path, info=None)[source]
store data in hdf5 file
The data can be read using the classmethod
DropletTrackList.from_file()
.