FFT helpers

FourierTools.rfftsFunction
rffts(A [, dims])

Calculates a rfft(A, dims) and then shift the frequencies to the center. dims[1] is not shifted, because there is no negative and positive frequency. The shift is done with ShiftedArrays and therefore doesn't allocate memory.

See also: ft, ift, rft, irft, ffts, iffts, ffts!, rffts, irffts,

source
FourierTools.irfftsFunction
irffts(A, d, [, dims])

Calculates a irfft(A, d, dims) and then shift the frequencies back to the corner. dims[1] is not shifted, because there is no negative and positive frequency. The shift is done with ShiftedArrays and therefore doesn't allocate memory.

See also: ft, ift, rft, irft, ffts, iffts, ffts!, rffts, irffts,

source
FourierTools.rfftshift_viewFunction
rfftshift_view(A, dims)

Shifts the frequencies to the center expect for dims[1] because there os no negative and positive frequency.

source
FourierTools.irfftshift_viewFunction
irfftshift_view(A, dims)

Shifts the frequencies back to the corner except for dims[1] because there os no negative and positive frequency.

source
FourierTools.ftFunction
ft(A [, dims])

Digital Fourier-transformation centered in both spaces. The result is semantically equivalent to fftshift(fft(ifftshift(A, dims), dims), dims) This is a digital Fourier transformation with both coordinate systems in real and Fourier-space being centered at position CtrFT == size÷2+1

The following identities are true:

julia> sz = (5,5)
(5, 5)

julia> ft(ones(sz)) ≈ prod(sz) .* δ(sz)
true

julia> ft(δ(sz)) ≈ ones(sz)
true

See also: ft, ift, rft, irft, ffts, iffts, ffts!, rffts, irffts,

source
FourierTools.iftFunction
ift(A [, dims])

Digital inverse Fourier-transformation centered in both spaces. The result is semantically equivalent to fftshift(ifft(ifftshift(A, dims), dims), dims) This is a digital Fourier transformation with both coordinate systems in real and Fourier-space being centered at position CtrFT == size÷2+1

The following identities are true:

julia> sz = (5,6,7)
(5, 6, 7)

julia> ift(ones(sz)) ≈ δ(sz)
true

julia> ift(δ(sz)) ≈ ones(sz) ./ prod(sz)
true

See also: ft, ift, rft, irft, ffts, iffts, ffts!, rffts, irffts,

source
FourierTools.rftFunction
rft(A [, dims])

Digital real-valued Fourier-transformation centered in both spaces. The result is semantically equivalent to fftshift(rfft(ifftshift(A, dims), dims), dims) This is a digital Fourier transformation with the coordinate systems in real space centered at CtrFT == size÷2+1 and in (half) Fourier-space being centered at CtrRFT == setindex(size÷2 +1,1,1).

The following identities are true:

julia> sz = (6,6)
(6, 6)

julia> rft(δ(sz)) ≈ ones(rft_size(sz))
true

See also: ft, ift, rft, irft, ffts, iffts, ffts!, rffts, irffts,

source
FourierTools.irftFunction
irft(A, d, [, dims])

Digital real-valued inverse Fourier-transformation centered in both spaces. The result is semantically equivalent to fftshift(irfft(ifftshift(A, dims), dims), dims) This is a digital Fourier transformation with the coordinate systems in real space centered at CtrFT == size÷2+1 and in (half) Fourier-space being centered at CtrRFT == setindex(size÷2 +1,1,1). Note that the size d of the first transform direction [1] is a required argument.

The following identities are true:

julia> sz = (6,6)
(6, 6)

julia> irft(ones(rft_size(sz)),sz[1]) ≈ δ(sz)
true

See also: ft, ift, rft, irft, ffts, iffts, ffts!, rffts, irffts,

source

FFT Utils

FourierTools.fftposFunction
fftpos(L, N, around=CenterFirst::Center)

Construct a range from -L/2 to L/2 around around

However, we ensure that those positions are in a way which they are useful for FFT operations. This means, that depending on the center a small offset is subtracted.

See NDTools.Center for all center options. You need to load using NDTools to access all center options.

Examples

julia> collect(fftpos(1,4))
4-element Vector{Float64}:
 0.0
 0.2916666666666667
 0.5833333333333334
 0.875

julia> collect(fftpos(1,5))
5-element Vector{Float64}:
 0.0
 0.225
 0.45
 0.675
 0.9

julia> using NDTools

julia> collect(fftpos(1,4, CenterFirst))
4-element Vector{Float64}:
 0.0
 0.2916666666666667
 0.5833333333333334
 0.875

julia> collect(fftpos(1,4, CenterFT))
4-element Vector{Float64}:
 -0.5833333333333333
 -0.29166666666666663
  3.70074341541719e-17
  0.2916666666666667

julia> collect(fftpos(1,4, CenterMiddle))
4-element Vector{Float64}:
 -0.4375
 -0.14583333333333334
  0.14583333333333334
  0.4375
source
fftpos(l, N, around)

Another fftpos method where the range is constructed around around. around is here a number indicating the index position around the range is constructed

source
FourierTools.rft_sizeFunction
rft_size(sz::NTuple{Int})

Returns the size of an rft or rfft performed on the data x, without performing the rfft. sz: corresponding real space size to obtain the rft size for

source
rft_size(arr)

Returns the size of an rft or rfft performed on the data x, without performing the rfft.

arr: array to optain the corresponding rft size for

source
FourierTools.rfft_sizeFunction
rfft_size(size, dims)

Returns the size rfft would return if applied to a real array. size is the input size to rfft and dims the dimensions the rfft transforms over. Actually we only would need first(dims).

julia> using FFTW

julia> rfft((ones((4,3,2))), (2,3)) |> size
(4, 2, 2)

julia> FourierTools.rfft_size((4,3,2), (2, 3))
(4, 2, 2)
source
FourierTools.ft_center_diffFunction
ft_center_diff(s [, dims])

Calculates how much each dimension must be shifted that the center frequency is at the Fourier center. This if for a normal fft

source
FourierTools.rft_center_diffFunction
rft_center_diff(s [, dims])

Calculates how much each dimension must be shifted that the center frequency is at the Fourier center. This is for rfft. The dims[1] must be therefore not shifted!

source
FourierTools.center_posFunction
center_pos(x)

Calculate the position of the center frequency. Size of the array is x

Examples

julia> FourierTools.center_pos(3)
2
julia> FourierTools.center_pos(4)
3
source

FFT Helpers 2D

FourierTools.fftshift2dFunction
fftshift2d(mat::AbstractArray{T, N}) where {T, N}

Short-hand for fftshift(mat, (1,2)). See fftshift for details.

source
FourierTools.ifftshift2dFunction
ifftshift2d(mat::AbstractArray{T, N}) where {T, N}

Short-hand for ifftshift(mat, (1,2)). See ifftshift for details.

source
FourierTools.fftshift2d_viewFunction
fftshift2d_view(mat::AbstractArray{T, N}) where {T, N}

Short-hand for fftshift_view(mat, (1,2)). See fftshift_view for details.

source
FourierTools.ifftshift2d_viewFunction
ifftshift2d_view(mat::AbstractArray{T, N}) where {T, N}

Short-hand for ifftshift_view(mat, (1,2)) performing only a 2D inverse ft. See ifft for details.

source