MCPcopy
hub / github.com/numpy/numpy / hanning

Function hanning

numpy/lib/_function_base_impl.py:3256–3354  ·  view source on GitHub ↗

Return the Hanning window. The Hanning window is a taper formed by using a weighted cosine. Parameters ---------- M : int Number of points in the output window. If zero or less, an empty array is returned. Returns ------- out : ndarray, shape(M,)

(M)

Source from the content-addressed store, hash-verified

3254
3255@set_module('numpy')
3256def hanning(M):
3257 """
3258 Return the Hanning window.
3259
3260 The Hanning window is a taper formed by using a weighted cosine.
3261
3262 Parameters
3263 ----------
3264 M : int
3265 Number of points in the output window. If zero or less, an
3266 empty array is returned.
3267
3268 Returns
3269 -------
3270 out : ndarray, shape(M,)
3271 The window, with the maximum value normalized to one (the value
3272 one appears only if `M` is odd).
3273
3274 See Also
3275 --------
3276 bartlett, blackman, hamming, kaiser
3277
3278 Notes
3279 -----
3280 The Hanning window is defined as
3281
3282 .. math:: w(n) = 0.5 - 0.5\\cos\\left(\\frac{2\\pi{n}}{M-1}\\right)
3283 \\qquad 0 \\leq n \\leq M-1
3284
3285 The Hanning was named for Julius von Hann, an Austrian meteorologist.
3286 It is also known as the Cosine Bell. Some authors prefer that it be
3287 called a Hann window, to help avoid confusion with the very similar
3288 Hamming window.
3289
3290 Most references to the Hanning window come from the signal processing
3291 literature, where it is used as one of many windowing functions for
3292 smoothing values. It is also known as an apodization (which means
3293 "removing the foot", i.e. smoothing discontinuities at the beginning
3294 and end of the sampled signal) or tapering function.
3295
3296 References
3297 ----------
3298 .. [1] Blackman, R.B. and Tukey, J.W., (1958) The measurement of power
3299 spectra, Dover Publications, New York.
3300 .. [2] E.R. Kanasewich, "Time Sequence Analysis in Geophysics",
3301 The University of Alberta Press, 1975, pp. 106-108.
3302 .. [3] Wikipedia, "Window function",
3303 https://en.wikipedia.org/wiki/Window_function
3304 .. [4] W.H. Press, B.P. Flannery, S.A. Teukolsky, and W.T. Vetterling,
3305 "Numerical Recipes", Cambridge University Press, 1986, page 425.
3306
3307 Examples
3308 --------
3309 >>> import numpy as np
3310 >>> np.hanning(12)
3311 array([0. , 0.07937323, 0.29229249, 0.57115742, 0.82743037,
3312 0.97974649, 0.97974649, 0.82743037, 0.57115742, 0.29229249,
3313 0.07937323, 0. ])

Callers 1

test_hanningMethod · 0.90

Calls 2

onesFunction · 0.90
arrayFunction · 0.50

Tested by 1

test_hanningMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…