Monitor
: A process to monitor other processes
- class epydemic.Monitor
Add progress monitoring to a process. This class captures the sizes of all loci in the process at regular intervals, returning them as time series. Each time series appears as an array in the results dict, keyed by
OBSERVATIONS
(for the simulation times at which the observations were taken) or by a name related to the locus name, generated bytimeSeriesForLocus()
. This means that each locus has its own time series tracking its evolving size.
A monitor process is intended to be composed with another process on
which it collects data as the process progresses. This allows
monitoring to be added automatically to any epydemic
process
The monitor works by periodically running an observation event,
defined by observe()
(which may be overridden or extended). The
cookbook contains an article on Monitoring the progress of a simulation.
Parameters
-
Monitor.DELTA:
Final
[str
] = 'epydemic.monitor.time_delta' Parameter for the time interval for observations.
Results
Monitor
stores its results as time series, one (tagged with
Monitor.OBSERVATIONS
) holding the simulation times, and then
one for each locus in the model holding the size of the locus at each
sample time. (All these time series therefore have the same length.)
The names of the time series for the loci are derived from the locus names.
- static Monitor.timeSeriesForLocus(l)
Generate the name of the time series corresponding to the given locus.
- Parameters:
l (
str
) – the locus- Return type:
str
- Returns:
the result name
-
Monitor.OBSERVATIONS:
Final
[str
] = 'epydemic.monitor.observations' Result holding the times of the observations.
Building the process
- Monitor.reset()
Reset the process.
- Monitor.build(params)
Build the observation process.
- Parameters:
params (
Dict
[str
,Any
]) – the experimental parameters
- Monitor.results()
Return the time series tagged as specified by
timeSeriesForLocus()
. There is one time series per locus, plus one for the sequence of times at which the observations were made.- Return type:
Dict
[str
,Any
]- Returns:
the results
Events
- Monitor.observe(t, e)
Observe the network, capturing the sizes of all loci which are then stored into individual time series. Another time series, tagged
OBSERVATIONS
, is created to store the sequence of times at which observations were made.- Parameters:
t (
float
) – the current simulation timee (
Any
) – the element (ignored)