bundles / scipy 1.17.1 / scipy / signal / _czt / CZT
class
scipy.signal._czt:CZT
source: /scipy/signal/_czt.py :115
Signature
class CZT ( n , m = None , w = None , a = (1+0j) ) Members
Summary
Create a callable chirp z-transform function.
Extended Summary
Transform to compute the frequency response around a spiral. Objects of this class are callables which can compute the chirp z-transform on their inputs. This object precalculates the constant chirps used in the given transform.
Parameters
n: intThe size of the signal.
m: int, optionalThe number of output points desired. Default is
n.w: complex, optionalThe ratio between points in each step. This must be precise or the accumulated error will degrade the tail of the output sequence. Defaults to equally spaced points around the entire unit circle.
a: complex, optionalThe starting point in the complex plane. Default is 1+0j.
Returns
f: CZTCallable object
f(x, axis=-1)for computing the chirp z-transform onx.
Notes
The defaults are chosen such that f(x) is equivalent to fft.fft(x) and, if m > len(x), that f(x, m) is equivalent to fft.fft(x, m).
If w does not lie on the unit circle, then the transform will be around a spiral with exponentially-increasing radius. Regardless, angle will increase linearly.
For transforms that do lie on the unit circle, accuracy is better when using ZoomFFT, since any numerical error in w is accumulated for long data lengths, drifting away from the unit circle.
The chirp z-transform can be faster than an equivalent FFT with zero padding. Try it with your own array sizes to see.
However, the chirp z-transform is considerably less precise than the equivalent zero-padded FFT.
As this CZT is implemented using the Bluestein algorithm, it can compute large prime-length Fourier transforms in O(N log N) time, rather than the O(N**2) time required by the direct DFT calculation. (scipy.fft also uses Bluestein's algorithm'.)
(The name "chirp z-transform" comes from the use of a chirp in the Bluestein algorithm. It does not decompose signals into chirps, like other transforms with "chirp" in the name.)
Array API Standard Support
CZT has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.
==================== ==================== ==================== Library CPU GPU ==================== ==================== ==================== NumPy ✅ n/a CuPy n/a ⛔ PyTorch ⛔ ⛔ JAX ⛔ ⛔ Dask ⛔ n/a ==================== ==================== ====================
See
dev-arrayapifor more information.
Examples
Compute multiple prime-length FFTs:from scipy.signal import CZT import numpy as np a = np.random.rand(7) b = np.random.rand(7) c = np.random.rand(7) czt_7 = CZT(n=7) A = czt_7(a) B = czt_7(b) C = czt_7(c)✓
czt_7.points()
✗import matplotlib.pyplot as plt
✓plt.plot(czt_7.points().real, czt_7.points().imag, 'o') plt.gca().add_patch(plt.Circle((0,0), radius=1, fill=False, alpha=.3)) plt.axis('equal')✗
plt.show()
✓
See also
Aliases
-
scipy.signal.CZT