pyCBD.tracers package

The tracers module provides an interface for tracing simulation data.

class pyCBD.tracers.Tracers(sim)[source]

Bases: object

Collection object for multiple tracers.

Parameters

sim (Simulator) – The CBD simulator of the trace object.

Note

This class will maintain and keep track of the UID of a tracer. Don’t set this yourself!

hasTracers()[source]

Checks that there are registered tracers.

thread_loop()[source]

Mainloop for tracing information. reduces the amount of threads created.

trace(event, args)[source]

Traces an event. :param event: The event to trace. :type event: callable :param args: The list of arguments for the event. :type args: iter

registerTracer(tracer, recover=False)[source]

Registers a specific tracer to use.

Parameters
  • tracer – Either a tuple of (file, classname, [args]), similar to PythonPDEVS; or an instance of a subclass of pyCBD.tracers.baseTracer.BaseTracer.

  • recover (bool) – Whether or not this is a recovered registration; i.e. whether or not the trace file should be appended. Defaults to False.

deregisterTracer(uid)[source]

Stops and removes a specific tracer.

Parameters

uid (int) – The tracer id to stop.

startTracers(interp=None, model_name='model')[source]

Starts the tracers.

Parameters
  • interp (pyCBD.tracers.interpolator.Interpolator) – The interpolator to use for the tracers.

  • model_name (str) – The name of the model.

Returns:

stopTracers(term_time)[source]

Stops all tracers.

Parameters

term_time (numeric) – The termination time.

getById(uid)[source]

Obtains a specific tracer.

Parameters

uid (int) – The tracer id to obtain.

Raises

ValueError – If the tracer does not exist.

traceStartNewIteration(curIt, time)[source]

Traces a new iteration start.

Parameters
  • curIt (int) – The current iteration.

  • time (numeric) – The current simulation time.

traceEndNewIteration(curIt, time)[source]

Traces a new iteration end.

Parameters
  • curIt (int) – The current iteration.

  • time (numeric) – The current simulation time.

traceCompute(curIteration, block)[source]

Traces the computation of a specific block.

Parameters
  • curIteration (int) – The current iteration.

  • block (CBD.Core.BaseBlock) – The block for which a compute just happened.

traceEndSimulation(stime)[source]

Traces the end of the simulation

Parameters

stime (numeric) – The final simulation time.

Submodules