CZTs

Chirp Z Transformations: Allows Fourier-transformation and at the same time zooming into the result, which is why it is also called the Zoomed-FFT algorithm. The algorithm is loosely based on a publication [Rabiner, Schafer, Rader, The Chirp z-Transform Algorithm, IEEE Trans AU 17(1969) p. 86]. It needs three FFTs to perform its work but one can be precalculated by using plan_czt. Variable zooms, transform dimensions, array center positions as well as output sizes are supported along wiht a low-level interface by specifingy a and w.

FourierTools.cztFunction
czt(xin, scale, dims=1:ndims(xin), dsize=size(xin,d); a=nothing, w=nothing, damp=ones(ndims(xin)), 
    src_center=size(xin,d)÷2+1, dst_center=dsize÷2+1, remove_wrap=false, fft_flags=FFTW.ESTIMATE)

Chirp z transform of the ND array xin The tuple scale defines the zoom factors in the Fourier domain. Each has to be bigger than one.

See also: iczt, czt_1d

The code is based on Rabiner, Schafer & Rader 1969, IEEE Trans. on Audio and Electroacoustics, 17,86-92

Arguments:

  • xin: array to transform
  • scale: a tuple of factors (one for each dimension) to zoom into during the czt. Note that a factor of nothing (or 1.0) needs to be provided, if a dimension is not transformed.
  • dims: a tuple of dimensions over which to apply the czt.
  • dsize: a tuple specifying the destination size
  • a: defines the starting phase of the result CZT. This relates to the where the center of the destination array should be. The default is nothing which means it is calculated from the src_center argument.
  • w: defines the consecutive phases of the result array, i.e. the zoom. It is (default nothing) usually automatically calculated from the scaled and the damp argument. You only need to state it, if you want to use the low-level interface (e.g. for the Laplace transform).
  • damp: a multiplicative factor to apply as a damping coefficient to w.
  • src_center: position of the nominal central (zero-position) pixel in the source array. By default the Fourier-center size(src).÷2 .+1 is used.
  • dst_center: the center (zero-position) of the destination array. By default the Fourier-center size(dst).÷2 .+1 is used.
  • remove_wrap: if true, the positions that represent a wrap-around will be set to zero

Example:

julia> using IndexFunArrays

julia> sz = (10,10);

julia> xin = disc(sz,4)
10×10 Matrix{Float64}:
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  1.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  1.0  1.0  1.0  1.0  1.0  0.0  0.0
 0.0  0.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  0.0
 0.0  0.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  0.0
 0.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 0.0  0.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  0.0
 0.0  0.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  0.0
 0.0  0.0  0.0  1.0  1.0  1.0  1.0  1.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  1.0  0.0  0.0  0.0  0.0

julia> xft = czt(xin,(1.2,1.3));

julia> zoomed = real.(ift(xft))
10×10 Matrix{Float64}:
 -0.0197423    0.0233008  -0.0449251   0.00295724   0.205593  -0.166546   0.205593   0.00295724  -0.0449251   0.0233008
  0.0239759   -0.028264    0.0541186  -0.0116475   -0.261294   0.312719  -0.261294  -0.0116475    0.0541186  -0.028264
 -0.0569       0.0666104  -0.122277    0.140354     0.78259    1.34381    0.78259    0.140354    -0.122277    0.0666104
  0.00540611  -0.0117886   0.0837357   1.30651      1.8283     1.50127    1.8283     1.30651      0.0837357  -0.0117886
  0.11892     -0.147731    0.368046    1.76537      1.33218    1.66119    1.33218    1.76537      0.368046   -0.147731
 -0.00389861   0.0145979   1.21842     1.52989      1.67375    1.543      1.67375    1.52989      1.21842     0.0145979
  0.11892     -0.147731    0.368046    1.76537      1.33218    1.66119    1.33218    1.76537      0.368046   -0.147731
  0.00540611  -0.0117886   0.0837357   1.30651      1.8283     1.50127    1.8283     1.30651      0.0837357  -0.0117886
 -0.0569       0.0666104  -0.122277    0.140354     0.78259    1.34381    0.78259    0.140354    -0.122277    0.0666104
  0.0239759   -0.028264    0.0541186  -0.0116475   -0.261294   0.312719  -0.261294  -0.0116475    0.0541186  -0.028264
source
FourierTools.plan_cztFunction
plan_czt(xin, scale, dims, dsize=size(xin); a=nothing, w=nothing, damp=ones(ndims(xin)), 
         src_center=size(xin).÷2 .+1, dst_center=dsize.÷2 .+1, remove_wrap=false, fft_flags=FFTW.ESTIMATE)

creates a plan for an N-dimensional chirp z-transformation (CZT). The generated plan is then applied via muliplication. For details about the arguments, see czt().

source
FourierTools.icztFunction
iczt(xin ,scale, dims=1:length(size(xin)), dsize=size(xin,d); a=nothing, w=nothing, damp=1.0, 
     src_center=size(xin,d)÷2+1, dst_center=dsize÷2+1, remove_wrap=false, fft_flags=FFTW.ESTIMATE)

Inverse chirp z transform of the ND array xin The tuple scale defines the zoom factors in the Fourier domain. Each has to be bigger than one. The code is based on Rabiner, Schafer & Rader 1969, IEEE Trans. on Audio and Electroacoustics, 17,86-92

Arguments:

  • xin: array to transform
  • scaled: factor to zoom into during the 1-dimensional czt.
  • d: single dimension to transform (as a tuple)
  • dsize: size of the destination array
  • a: defines the starting phase of the result CZT. This relates to the where the center of the destination array should be. The default is nothing which means it is calculated from the src_center argument.
  • w: defines the consecutive phases of the result array, i.e. the zoom. It is (default nothing) usually automatically calculated from the scaled and the damp argument. You only need to state it, if you want to use the low-level interface (e.g. for the Laplace transform).
  • damp: a multiplicative factor to apply as a damping coefficient to w.
  • src_center: position of the nominal central (zero-position) pixel in the source array. By default the Fourier-center size(src).÷2 .+1 is used.
  • dst_center: the center (zero-position) of the destination array. By default the Fourier-center size(dst).÷2 .+1 is used.
  • remove_wrap: if true, the positions that represent a wrap-around will be set to zero
  • pad_value: the value to pad wrapped data with.

See also: czt, czt_1d

Example


julia> using IndexFunArrays

julia> sz = (10,10);

julia> xin = disc(sz,4)
10×10 Matrix{Float64}:
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  1.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  1.0  1.0  1.0  1.0  1.0  0.0  0.0
 0.0  0.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  0.0
 0.0  0.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  0.0
 0.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 0.0  0.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  0.0
 0.0  0.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  0.0
 0.0  0.0  0.0  1.0  1.0  1.0  1.0  1.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  1.0  0.0  0.0  0.0  0.0

julia> xft = ft(xin);

julia> iczt(xft,(1.2,1.3))
10×10 Matrix{ComplexF64}:
 0.00648614+0.0213779im  0.0165456+0.0357733im  0.0389356+0.0482465im  -0.235491-0.156509im    …  0.178484-0.0730099im  -0.245418-5.88331e-5im  0.0471654-0.0814548im  0.0141525+0.0734892im
  -0.104602-0.160481im   -0.163859-0.125535im    0.495205+0.135059im    0.660335+0.00736904im     0.764045-0.0497007im    0.67753+0.263814im      0.48095-0.0775406im  -0.159713-0.0637132im
   0.139304+0.111348im    0.454973+0.106869im    0.970263-0.0249785im    1.25999-0.166495im        1.07328-0.0481437im    1.24013-0.14664im      0.986722-0.0414382im   0.450186+0.111656im
  -0.035645-0.0311352im    1.03899-0.0589268im     1.1463-0.0940003im   0.790545+0.283668im       0.994255+0.134865im     0.80774-0.0124851im     1.13205+0.151519im     1.04314-0.130321im
   0.292575+0.0853233im   0.929883+0.0687029im    1.06514-0.0649952im   0.989483-0.019913im        1.02311+0.018235im    0.979555-0.136654im      1.07337+0.0317868im    0.92749+0.0405597im
    1.12254-0.0464723im    1.03467-0.0239316im    0.92709+0.0822984im     1.0521-0.0992709im   …  0.983655-0.0663123im     1.0521+0.0992709im     0.92709-0.0822984im    1.03467+0.0239316im
   0.287928-0.0306724im    0.92749-0.0405597im    1.07337-0.0317868im   0.979555+0.136654im        1.01648+0.0597475im   0.989483+0.019913im      1.06514+0.0649952im   0.929883-0.0687029im
 -0.0275957+0.169775im     1.04314+0.130321im     1.13205-0.151519im     0.80774+0.0124851im       1.00574+0.0629632im   0.790545-0.283668im       1.1463+0.0940003im    1.03899+0.0589268im
   0.130009-0.120643im    0.450186-0.111656im    0.986722+0.0414382im    1.24013+0.14664im         1.06002+0.0348813im    1.25999+0.166495im     0.970263+0.0249785im   0.454973-0.106869im
 -0.0965531+0.0404296im  -0.159713+0.0637132im    0.48095+0.0775406im    0.67753-0.263814im        0.77553-0.121603im    0.660335-0.00736904im   0.495205-0.135059im   -0.163859+0.125535im
source
FourierTools.czt_1dFunction
czt_1d(xin , scaled , d; remove_wrap=false, pad_value=zero(eltype(xin)))

Chirp z transform along a single direction d of an ND array xin. Note that the result type is defined by eltype(xin) and not by scales.

The code is based on Rabiner, Schafer & Rader 1969, IEEE Trans. on Audio and Electroacoustics, 17,86-92

Arguments:

  • xin: array to transform
  • scaled: factor to zoom into during the 1-dimensional czt.
  • d: single dimension to transform (as a tuple)
  • dsize: size of the destination array
  • a: defines the starting phase of the result CZT. This relates to the where the center of the destination array should be. The default is nothing which means it is calculated from the src_center argument.
  • w: defines the consecutive phases of the result array, i.e. the zoom. It is (default nothing) usually automatically calculated from the scaled and the damp argument. You only need to state it, if you want to use the low-level interface (e.g. for the Laplace transform).
  • damp: a multiplicative factor to apply as a damping coefficient to w.
  • src_center: position of the nominal central (zero-position) pixel in the source array. By default the F ourier-center size(src).÷2 .+1 is used.
  • dst_center: the center (zero-position) of the destination array. By default the Fourier-center size(dst).÷2 .+1 is used.
  • extra_phase: a phase ramp to apply to the final result relating to the srccenter. By default nothing which calculates this phase according to the `srccenter`.
  • global_phase: the initial phase of the destitation array. By default nothing which calculates this phase according to the centers.
  • remove_wrap: if true, the positions that represent a wrap-around will be set to zero
  • pad_value: the value to pad wrapped data with.
source
czt_1d(xin , plan::CZTPlan_1D)

Chirp z transform along a single direction d of an ND array xin. Note that the result type is defined by eltype(xin) and not by scales. The plan can also be applied via multiplication with xin.

The code is based on Rabiner, Schafer & Rader 1969, IEEE Trans. on Audio and Electroacoustics, 17,86-92

Arguments

`plan`:   A plan created via plan_czt_1d()
source
FourierTools.plan_czt_1dFunction
plan_czt_1d(xin, scaled, d, dsize=size(xin,d); a=nothing, w=nothing, damp=1.0, src_center=(size(xin,d)+1)/2, 
            dst_center=dsize÷2+1, remove_wrap=false, fft_flags=FFTW.ESTIMATE)

creates a plan for an one-dimensional chirp z-transformation (CZT). The generated plan is then applied via muliplication. For details about the arguments, see czt_1d().

source
FourierTools.CZTPlan_1DType
CZTPlan_1D{CT, D} # <: AbstractArray{T,D}

type used for the onedimensional plan of the chirp Z transformation (CZT). containing

Members:

`d`: dimension (only one!) to transform with this plan
`pad_value`: the value to pad wrapped data with (zero is already handled by the `wd` term, if wanted). 
`pad_ranges` :: tuple of two ranges of invalid positions, which can be replaced by pad values
`aw`: factor to multiply input with
`fft_fv`: fourier-transform (FFTW) of the convolutio kernel
`wd`: factor to multiply the result of the convolution by
`fftw_plan`: plan for the forward FFTW of the convolution kernel
`ifftw_plan`: plan for the inverse FFTW of the convolution kernel
source
FourierTools.CZTPlan_NDType
CZTPlan_ND{CT, D} # <: AbstractArray{T,D}

type used for the onedimensional plan of the chirp Z transformation (CZT). containing

Members:

`plans`: vector of CZTPlan_1D for each of the directions of the ND array to transform
source