Skip to content

Commit f020154

Browse files
committed
use np.fft.rfftfreq to get 1-sided periodogram freqs
This is to fix issue #191 Also noticed that `np.fft.rfftfreq(N)` gives different results as `scipy.fftpack.rfftfreq(N`). The former gives the positive freqs.
1 parent 8b83797 commit f020154

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

nitime/algorithms/spectral.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ def periodogram(s, Fs=2 * np.pi, Sk=None, N=None,
249249
Fl = (N + 1) // 2
250250
pshape[-1] = Fn
251251
P = np.zeros(pshape, 'd')
252-
freqs = np.linspace(0, Fs // 2, Fn)
252+
#freqs = np.linspace(0, Fs // 2, Fn)
253+
freqs = np.fft.rfftfreq(N)
253254
P[..., 0] = (Sk[..., 0] * Sk[..., 0].conj()).real
254255
P[..., 1:Fl] = 2 * (Sk[..., 1:Fl] * Sk[..., 1:Fl].conj()).real
255256
if Fn > Fl:

0 commit comments

Comments
 (0)