pathsim.blocks.rf.noise module
- class pathsim.blocks.rf.noise.WhiteNoise(spectral_density=1, sampling_rate=None)[source]
Bases:
BlockWhite noise source with uniform spectral density. Samples from distribution with ‘sampling_rate’ and holds noise values constant for time bins.
If no ‘sampling_rate’ (None) is specified, every simulation timestep gets a new noise values. This is the default setting.
- Parameters:
- reset()[source]
Reset the blocks inputs and outputs and also its internal solver, if the block has a solver instance.
- sample(t)[source]
Sample from a normal distribution after successful timestep
- Parameters:
t (float) – evaluation time for sampling
- class pathsim.blocks.rf.noise.PinkNoise(spectral_density=1, num_octaves=16, sampling_rate=None)[source]
Bases:
BlockPink noise (1/f) source using the Voss-McCartney algorithm.
Samples from distribution with ‘sampling_rate’ and generates noise with a power spectral density inversely proportional to frequency.
- Parameters:
- octaves_values
internal random numbers for octaves in the Voss-McCartney algorithm
- Type:
array[float]
- reset()[source]
Reset the blocks inputs and outputs and also its internal solver, if the block has a solver instance.
- sample(t)[source]
Generate a new pink noise sample at ‘t’ using the Voss-McCartney algorithm.
- Parameters:
t (float) – evaluation time for sampling
- class pathsim.blocks.rf.noise.SinusoidalPhaseNoiseSource(frequency=1, amplitude=1, phase=0, sig_cum=0, sig_white=0, sampling_rate=10)[source]
Bases:
BlockSinusoidal source with cumulative and white phase noise
- Parameters:
frequency (float) – frequency of the sinusoid
amplitude (float) – amplitude of the sinusoid
phase (float) – phase of the sinusoid
sig_cum (float) – weight for cumulative phase noise contribution
sig_white (float) – weight for white phase noise contribution
sampling_rate (float) – number of samples per unit time for the internal RNG
- set_solver(Solver, **solver_kwargs)[source]
Initialize the numerical integration engine with local truncation error tolerance if required.
If the block already has an integration engine, it is changed, if it does not require an integration engine, this method just passes.
- reset()[source]
Reset the blocks inputs and outputs and also its internal solver, if the block has a solver instance.
- update(t)[source]
The ‘update’ method is called iteratively for all blocks BEFORE the timestep to resolve algebraic loops (fixed-point iteraion).
It is meant for instant time blocks (blocks that dont have a delay due to the timestep, such as Amplifier, etc.) and updates the ‘outputs’ of the block directly based on the ‘inputs’ and possibly internal states.
It computes and returns the relative difference between the new output and the previous output (before the step) to track convergence of the fixed-point iteration.
Note
The implementation of the ‘update’ method in the base ‘Block’ class is intended as a fallback and is not performance optimized. Special blocks might reimplement this method differently for higher performance, for example SISO or MISO blocks.
- solve(t, dt)[source]
The ‘solve’ method performes one iterative solution step that is required to solve the implicit update equation of the solver if an implicit solver (numerical integrator) is used.
It returns the relative difference between the new updated solution and the previous iteration of the solution to track convergence within an outer loop.
This only has to be implemented by blocks that have an internal integration engine with an implicit solver.
- step(t, dt)[source]
The ‘step’ method is used in transient simulations and performs an action (numeric integration timestep, recording data, etc.) based on the current inputs and the current internal state.
It performes one timestep for the internal states. For instant time blocks, the ‘step’ method does not has to be implemented specifically.
The method handles timestepping for dynamic blocks with internal states such as ‘Integrator’, ‘StateSpace’, etc.