-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfftfreq.pro
More file actions
38 lines (30 loc) · 699 Bytes
/
fftfreq.pro
File metadata and controls
38 lines (30 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
FUNCTION fftfreq,n,d=d
;NAME: fftfreq
;
;PURPOSE: utility function for calculating frequency bins associated with an
;FFT
;
;INPUTS:
; n - length of the signal on which an FFT was performed
;
; d - sampling interval (default is 1)
;
;OUTPUT:
; f - array of frequency bins
;
;WRITTEN:
; A. Inglis 2013/11/27 - version 1 - copied from IDL help file
;
;default sampling interval is 1
default,d,1
x=(findgen((n-1)/2) + 1)
; l MOD n is equal to the remainder when l is divided by n. Remainder
; of an even number divided by 2 is zero.
is_n_even = (n MOD 2) EQ 0
IF (is_n_even) then begin
f= [0.0, x, n/2, -n/2+x]/(n*d)
ENDIF ELSE BEGIN
f= [0.0,x, -(n/2 + 1) + x]/(n*d)
ENDELSE
return,f
END