aspsim.counter.PhaseCounter

class aspsim.counter.PhaseCounter(phase_lengths, verbose=False)

Bases: object

An index counter to keep track of non-overlapping continous phases.

The number is how many samples that each phase should be. The first phase will start at sample 0.

Example

A processor needs the first 2000 samples for an initialization, then must wait 5000 samples before beginning the real processing step. The class can be used by defining the phases as >>> phase_def = {‘init’ : 2000, ‘wait’ : 5000, ‘process’ : np.inf}

and then checking if either of the following is true >>> if phase_counter.phase == ‘init’ >>> if phase_counter.current_phase_is(‘init’)

Notes

np.inf represents an infinite length This should naturally only be used for the last phase If all phases has finished, the phase will be None.

first_sample will be True on the first sample of each phase, allowing running one-time functions in each phase

Extended implementation to block_size != 1 can be done later

__init__(phase_lengths, verbose=False)

Methods

__init__(phase_lengths[, verbose])

current_phase_is(phase_name)

next_phase()

progress()