xsimlab.runtime_hook¶
-
xsimlab.
runtime_hook
(stage, level='model', trigger='post')¶ Decorator that allows to call a function or a method at one or more specific times during a simulation.
The decorated function / method must have the following signature:
func(model, context, state)
ormeth(self, model, context, state)
. It may return aRuntimeSignal
(optional).- Parameters
stage ({'initialize', 'run_step', 'finalize_step', 'finalize'}) – The simulation stage at which to call the function.
level ({'model', 'process'}) – Sets whether the simulation stage is treated model-wise (‘model’) or process-wise (‘process’). In the model-wise case (default), the function is called only once during the execution of the simulation stage. In the process-wise case, the function is executed as many times as there are processes in the model that provide an implementation of that simulation stage.
trigger ({'pre', 'post'}) – Sets when exactly to trigger the function call, i.e., just before (‘pre’) or just after (‘post’) the execution of the model’s or process’ simulation stage (default: after).