Skip to content

Commit 38f4468

Browse files
better error checking in czt and documentation
1 parent 96aca89 commit 38f4468

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ makedocs(modules = [FourierTools],
1313
"Image Shearing with FFTs" => "shear.md",
1414
"Image Rotation with FFTs" => "rotate.md",
1515
"NFFT" => "nfft.md",
16+
"CZT" => "czt.md",
1617
"Fractional Fourier Transform" => "fractional.md",
1718
"Utility Functions" => "utils.md",
1819
]

docs/src/czt.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# CZTs
2+
Chirp Z Transformations:
3+
4+
```@docs
5+
FourierTools.czt
6+
FourierTools.iczt
7+
FourierTools.czt_1d
8+
```

src/czt.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ The tuple `scale` defines the zoom factors in the Fourier domain. Each has to be
9595
9696
# Arguments:
9797
+ `xin`: array to transform
98-
+ `scale`: a tuple of factors (one for each dimension) to zoom into during the czt.
98+
+ `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.
9999
+ `dims`: a tuple of dimensions over which to apply the czt.
100100
+ `remove_wrap`: if true, the wrapped places will be set to zero. Note that the `pad_value` argument is only allowed for 1d czts to not cause confusion.
101101
@@ -137,6 +137,14 @@ julia> zoomed = real.(ift(xft))
137137
function czt(xin::Array{T,N}, scale, dims=1:length(size(xin));
138138
remove_wrap=false)::Array{complex(T),N} where {T,N}
139139
xout = xin
140+
if length(scale) != ndims(xin)
141+
error("Every of the $(ndims(xin)) dimension needs exactly one corresponding scale (zoom) factor, which should be equal to 1.0 for dimensions not contained in the dims argument.")
142+
end
143+
for d = 1:ndims(xin)
144+
if !(d in dims) && scale[d] != 1.0 && !isnothing(scale[d])
145+
error("The scale factor $(scale[d]) needs to be nothing or 1.0, if this dimension is not in the list of dimensions to transform.")
146+
end
147+
end
140148
for d in dims
141149
xout = czt_1d(xout, scale[d], d; remove_wrap=remove_wrap)
142150
end
@@ -153,7 +161,7 @@ The tuple `scale` defines the zoom factors in the Fourier domain. Each has to be
153161
154162
# Arguments:
155163
+ `xin`: array to transform
156-
+ `scale`: a tuple of factors (one for each dimension) of the the inverse czt.
164+
+ `scale`: a tuple of factors (one for each dimension) of the the inverse czt. Note that a factor of nothing (or 1.0) needs to be provided, if a dimension is not transformed.
157165
+ `dims`: a tuple of dimensions over which to apply the inverse czt.
158166
+ `remove_wrap`: if true, the wrapped places will be set to zero.
159167
Note that the `pad_value` argument is only allowed for 1d czts to not cause confusion.

0 commit comments

Comments
 (0)