4.7.1. pde.trackers.base module

Base classes for trackers

exception FinishedSimulation[source]

Bases: StopIteration

exception for signaling that simulation finished successfully

class TrackerBase(interval: Union[InterruptsBase, float, str, Sequence[float], ndarray] = 1)[source]

Bases: object

base class for implementing trackers

Parameters

interval – Determines how often the tracker interrupts the simulation. Simple numbers are interpreted as durations measured in the simulation time variable. Alternatively, a string using the format ‘hh:mm:ss’ can be used to give durations in real time. Finally, instances of the classes defined in interrupts can be given for more control.

finalize(info: Optional[Dict[str, Any]] = None) None[source]

finalize the tracker, supplying additional information

Parameters

info (dict) – Extra information from the simulation

classmethod from_data(data: Union[TrackerBase, str], **kwargs) TrackerBase[source]

create tracker class from given data

Parameters

data (str or TrackerBase) – Data describing the tracker

Returns

An instance representing the tracker

Return type

TrackerBase

abstract handle(field: FieldBase, t: float) None[source]

handle data supplied to this tracker

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

  • t (float) – The associated time

initialize(field: FieldBase, info: Optional[Dict[str, Any]] = None) float[source]

initialize the tracker with information about the simulation

Parameters
  • field (FieldBase) – An example of the data that will be analyzed by the tracker

  • info (dict) – Extra information from the simulation

Returns

The first time the tracker needs to handle data

Return type

float

class TrackerCollection(trackers: Optional[List[TrackerBase]] = None)[source]

Bases: object

List of trackers providing methods to handle them efficiently

trackers

List of the trackers in the collection

Type

list

Parameters

trackers – List of trackers that are to be handled.

finalize(info: Optional[Dict[str, Any]] = None) None[source]

finalize the tracker, supplying additional information

Parameters

info (dict) – Extra information from the simulation

classmethod from_data(data: Optional[Union[Sequence[Union[TrackerBase, str]], TrackerBase, str]], **kwargs) TrackerCollection[source]

create tracker collection from given data

Parameters

data – Data describing the tracker collection

Returns

An instance representing the tracker collection

Return type

TrackerCollection

handle(state: FieldBase, t: float, atol: float = 1e-08) float[source]

handle all trackers

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

  • t (float) – The associated time

  • atol (float) – An absolute tolerance that is used to determine whether a tracker should be called now or whether the simulation should be carried on more timesteps. This is basically used to predict the next time to decided which one is closer.

Returns

The next time the simulation needs to be interrupted to handle a tracker.

Return type

float

initialize(field: FieldBase, info: Optional[Dict[str, Any]] = None) float[source]

initialize the tracker with information about the simulation

Parameters
  • field (FieldBase) – An example of the data that will be analyzed by the tracker

  • info (dict) – Extra information from the simulation

Returns

The first time the tracker needs to handle data

Return type

float

time_next_action: float

The time of the next interrupt of the simulation

Type

float

tracker_action_times: List[float]

Times at which the trackers need to be handled next

Type

list

get_named_trackers() Dict[str, Type[TrackerBase]][source]

returns all named trackers

Returns

a mapping of names to the actual tracker classes.

Return type

dict