pykappa.analysis¶
Various model and simulation analysis tools.
- class pykappa.analysis.Monitor(system)[source]¶
Records the history of the values of observables in a system.
- Parameters:
system (System)
- history: dict[str, list[float | None]]¶
Maps observable names to their history
- property dataframe: DataFrame¶
The history of observable values as a pandas DataFrame.
- measure(observable_name, time=None)[source]¶
Get the value of an observable at a specific time.
- Raises:
AssertionError – If simulation hasn’t reached the specified time.
- Parameters:
observable_name (str)
time (float | None)
- equilibration_start(observable_name, **kwargs)[source]¶
Return the index of the history at which equilibration is detected, or
None.- Parameters:
observable_name (str) – Name of the observable to check. If None, checks all observables.
**kwargs – Arguments passed to the equilibration detection function.
- Return type:
int | None
- plot(observables=None, combined=False, figsize=None)[source]¶
Make a plot of all observables over time.
- Parameters:
combined (bool) – Whether to plot all observables on the same axes.
figsize (tuple[float, float] | None) – The figure size (width, height) in inches.
observables (list[str] | None) – Specific observables to plot. If None, plots all observables.
- Return type:
Figure
- pykappa.analysis.equilibration_start(values, times=None, tail_fraction=0.1, tolerance=0.01)[source]¶
Checks whether the magnitude of the slope of the tail of the series relative to the mean is sufficiently small (below tolerance), and if so returns the first index of the stable tail. Time can be provided to account for non-uniform sampling intervals. The tail_fraction argument specifies the fraction of the time series to consider as the tail.
- Parameters:
values (list[float])
times (list[float] | None)
tail_fraction (float)
tolerance (float)
- Return type:
int | None