I have a time-series data file in python and I am asked to apply a Hanning window $w_n=1-\cos\Big(\frac{2\pi n}{N}\Big), 0\leq n\leq N=\text{file length}$ to the data given. I am very new to this subject so I have no idea how to apply this window function to the data. Any instruction? Thanks in advance.
Asked
Active
Viewed 466 times
1 Answers
1
If you're asking what "applying" means, it means multiplying the window samples $w[n]$ with the time-series samples $x[n]$: $$x_{\texttt{windowed}}[n] = w[n] \times x[n]$$ where $\times$ is the sample by sample multiplication operator:
x_windowed[0] = w[0] * x[0]
x_windowed[1] = w[1] * x[1]
...
If you're asking how to do this in Python, or how to generate the window samples $w[n]$, it's outside the scope of this website (coding questions should be asked on Stack Overflow), but since we're already half-way there, it should look something like:
n = np.arange(0, N)
w = 1 - np.cos(2*np.pi*n/N)
x_windowed = x * w
Jdip
- 5,980
- 3
- 7
- 29
-
My data is given over the frequency domain, so you mean I should get $x_{\text{windowed}}(f)=x(f)\times w(f)$ where $f$ stands for the frequency, right? – LianNuo Apr 04 '23 at 22:02
-
1Your question states "I have a time-series data file". Which is it? Windowing is in most cases used in the time domain... – Jdip Apr 04 '23 at 22:06