bundles / scipy latest / scipy / signal / windows / _windows / get_window
function
scipy.signal.windows._windows:get_window
Signature
def get_window ( window , Nx , fftbins = True , * , xp = None , device = None ) Summary
Convenience function for creating various windows.
Extended Summary
This function is a wrapper for the window functions provided in the scipy.signal.windows namespace.
Parameters
window: str | tuple | floatEither a string with the window name or a tuple consisting of window name and window parameters. If it is a float, a
~scipy.singal.kaiserwindow is created withwindowbeing the shape parameter. Consult the Notes below for more details.Nx: intThe number of samples in the window.
fftbins: bool, optionalIf
True(default), create a periodic window, ready to use withifftshiftand be multiplied by the result of an FFT (see also fftfreq). IfFalse, create a symmetric window, for use in filter design. This parameter is ignored, if the window name in thewindowparameter has a suffix'_periodic'or'_symmetric'appended to it (e.g.,'hann_symmetric').xp: array_namespace, optionalOptional array namespace. Should be compatible with the array API standard, or supported by array-api-compat. Default:
numpydevice: anyoptional device specification for output. Should match one of the supported device specification in
xp.
Returns
get_window: ndarrayReturns the created window as a one-dimensional array made of
Nxsamples.
Raises
: ValueErrorIf the provided parameters do not allow to choose a valid window function with valid parameters.
Notes
Note that by default this function returns a periodic window, whereas the wrapped window functions return a symmetric window by default. This is caused by the fftbins parameter having the inverse meaning of the sym parameter of the wrapped function, which are both True by default.
The following list shows the wrapped window functions with the respective settings of the window parameter followed by a short description. Aliases for alternative window names are given in parenthesis.
barthann /
'barthann':Modified Bartlett-Hann window (aliases:
'brthan', 'bth')bartlett/'bartlett':Bartlett window (aliases:
'bart', 'brt')blackman/
'blackman':Blackman window (aliases:
'black', 'blk')blackmanharris /
'blackmanharris':4-term Blackman-Harris window (aliases:
'blackharr', 'bkh')bohman /
'bohman':Bohman window (aliases:
'bman', 'bmn')boxcar /
'boxcar':Rectangular window (aliases:
'box', 'ones', 'rect', 'rectangular')chebwin /
('chebwin', at):Dolph-Chebyshev window with at dB attenuation (aliases:
'cheb')cosine/'cosine':Cosine window (aliases:
'halfcosine')dpss /
('dpss', NW):First window of discrete prolate spheroidal sequence with standardized half bandwidth
NWand "approximate" norm.exponential /
'exponential'/('exponential', center, tau):Exponential / Poisson window centered at
center(default:None) with deacytau(default:1) (aliases:'poisson')flattop/
'flattop':Flat top window (aliases:
'flat', 'flt')gaussian/('gaussian', std):Gaussian with standard deviation
std(aliases:'gauss', 'gss')general_cosine /
('general cosine', a):Generic weighted sum of cosine terms with weighting coefficients
a(aliases:'general_cosine')general_gaussian /
('general gaussian', p, sig):Generalized Gaussian with shape parameter
pand standard deviationsig(aliases:'general_gaussian', 'general gauss', 'general_gauss', 'ggs')general_hamming /
('general hamming', alpha):Generalized Hamming window with coefficent
alpha(aliases:'general_hamming')hamming/'hamming':Hamming window (aliases:
'hamm', 'ham')hann /
'hann':Hann window (aliases:
'han')kaiser /
('kaiser', beta):Kaiser window with shape parameter
beta(aliases:'ksr')kaiser_bessel_derived /
('kaiser bessel derived', beta):Kaiser-Bessel derived window with shape parameter
beta(aliases:'kaiser_bessel_derived', 'kbd')lanczos /
'lanczos':Lanczos / sinc window (aliases:
'sinc')nuttall/
'nuttall':Minimum 4-term Blackman-Harris window according to Nuttall (aliases:
'nutl', 'nut')parzen /
'parzen':Parzen window (aliases:
'parz', 'par')taylor /
'taylor'/ ('taylor', nbar, sll, norm):Taylor window with
nbaradjascent sidelobes (default:4)),slldB suppression level (default:30) and boolean valuenorm(default:True) (aliases:taylorwin)triang/
'triangle':Triangle window (aliases:
'triang', 'tri')tukey /
'tukey'/('tukey', alpha):Tukey window with shape parameter
alpha(default:0.5) (aliases:'tuk')
Array API Standard Support
get_window 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.
Array API Standard Support
get_window 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
This example shows different usages of the `window` parameter:from scipy.signal import get_window
✓get_window('triang', 7) get_window(('exponential', None, 1.), 9) get_window(('kaiser', 4.0), 9) get_window(4.0, 9) # same as previous call✗
from scipy.signal import get_window, windows windows.bartlett(5) # Parameter `sym` defaults to True get_window('bartlett', 5, fftbins=False) get_window('bartlett_symmetric', 5) windows.bartlett(4, sym=False) get_window('bartlett', 4) # Parameter `fftbins` defaults to True get_window('bartlett_periodic', 4) get_window('bartlett_periodic', 4, fftbins=False)✓
Aliases
-
scipy.signal.get_window