pathsim.blocks.fir module

class pathsim.blocks.fir.FIR(coeffs=[1.0], T=1, tau=0)[source]

Bases: Block

Models a discrete-time Finite-Impulse-Response (FIR) filter.

This block applies an FIR filter to an input signal sampled periodically. The output at each sample time is a weighted sum of the current and a finite number of past input samples. The operation is triggered by a scheduled event.

Functionality:

\[y[n] = b[0] x[n] + b[1] x[n-1] + \dots + b[N] x[n-N]\]

where b are the filter coefficients and N is the filter order (number of coefficients - 1).

  1. Samples the input inputs[0] at intervals of T, starting after delay tau.

  2. Stores the current and past len(coefficients) - 1 input samples in an internal buffer.

  3. Computes the filter output using the dot product of the coefficients and the buffered input samples.

  4. Outputs the result on outputs[0].

  5. Holds the output constant between updates.

Parameters:
  • coeffs (array_like) – List or numpy array of FIR filter coefficients [b0, b1, …, bN]. The number of coefficients determines the filter’s order and memory.

  • T (float, optional) – Sampling period (time between input samples and output updates). Default is 1.

  • tau (float, optional) – Initial delay before the first sample is processed. Default is 0.

  • Ports (Output)

  • -----------

  • inputs[0] (float) – Input signal sample at the current time step.

  • Ports

  • ------------

  • outputs[0] (float) – Filtered output signal sample.

buffer

Internal buffer storing the most recent input samples.

Type:

deque

events

Internal scheduled event triggering the filter calculation.

Type:

list[Schedule]

reset()[source]

Resets the filter state (buffer) and output.