dcmri.stepconv#

dcmri.stepconv(f, T, D, t=None, dt=1.0)[source]#

Convolve a 1D-array with a normalised step function.

Parameters:
  • f (array_like) – the 1D array to be convolved.

  • T (float) – the central time point of the step function.

  • D (float) – half-width of the step function, as a fraction of T. D must be less or equal to 1.

  • t (array_like, optional) – the time points where the values of f are defined, in the same units as T. If t=None, the time points are assumed to be uniformly spaced with spacing dt. Defaults to None.

  • dt (float, optional) – spacing between time points for uniformly spaced time points. This parameter is ignored if t is explicity provided. Defaults to 1.0.

Raises:

ValueError – if D > 1.

Returns:

a 1D numpy array of the same length as f.

Return type:

numpy.ndarray

Notes

stepconv implements the same convolution product as conv, but is more accurate and faster in the special case where one of the factors is known to be a step function.

Example

Import package, create a vector f and an array of time points:

>>> import dcmri as dc
>>> f = [5,4,3,6]
>>> t = [0,2,4,7]

Convolve f with a step function that is centered on t=3 with a half width of 1.5 = 0.5*3:

>>> dc.stepconv(f, 3, 0.5, t)
array([0.        , 0.8125    , 3.64583333, 3.5625    ])

Examples using dcmri.stepconv#

A comparison of convolution functions

A comparison of convolution functions