Skip to content

Commit

Permalink
use np.fft.rfftfreq to get 1-sided periodogram freqs
Browse files Browse the repository at this point in the history
This is to fix issue nipy#191

Also noticed that `np.fft.rfftfreq(N)` gives different results as
`scipy.fftpack.rfftfreq(N`). The former gives the positive freqs.
  • Loading branch information
Xunius committed Sep 30, 2021
1 parent 8b83797 commit f020154
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nitime/algorithms/spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ def periodogram(s, Fs=2 * np.pi, Sk=None, N=None,
Fl = (N + 1) // 2
pshape[-1] = Fn
P = np.zeros(pshape, 'd')
freqs = np.linspace(0, Fs // 2, Fn)
#freqs = np.linspace(0, Fs // 2, Fn)
freqs = np.fft.rfftfreq(N)
P[..., 0] = (Sk[..., 0] * Sk[..., 0].conj()).real
P[..., 1:Fl] = 2 * (Sk[..., 1:Fl] * Sk[..., 1:Fl].conj()).real
if Fn > Fl:
Expand Down

0 comments on commit f020154

Please sign in to comment.