Bluestein FFT¶
bluestein ¶
fft_bluestein ¶
fft_bluestein(f, dx, dk, D_out=None, x0=0.0, k0=0.0, inverse=False)
Generalized 1D Fourier transform using Bluestein's algorithm (chirp-z transform).
Unlike a standard FFT, this evaluates the continuous Fourier
integral on arbitrary, independently chosen input/output sample
spacings (dx, dk) and offsets (x0, k0), and can change the
number of samples from D (input) to D_out (output). It works by
rewriting the transform as a linear convolution (via the standard
Bluestein/chirp-z trick) and evaluating that convolution with zero-
padded FFTs, so it costs O((D + D_out) log(D + D_out)) rather than
the O(D * D_out) of a direct sum.
Forward: F(k) = integral of f(x) * exp(-i k x) dx
Inverse: f(x) = 1/(2*pi) * integral of F(k) * exp(+i k x) dk
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
array_like
|
Input samples. The transform is taken along the last axis, so
|
required |
dx
|
float
|
Input sample spacing. Must be positive. In inverse mode, this
is the desired output spacing (of |
required |
dk
|
float
|
Output sample spacing. Must be nonzero. In inverse mode, this
is the input spacing (of |
required |
D_out
|
int
|
Number of output samples. Defaults to |
None
|
x0
|
float
|
Origin of the |
0.0
|
k0
|
float
|
Origin of the |
0.0
|
inverse
|
bool
|
If False (default), compute the forward transform
|
False
|
Returns:
| Name | Type | Description |
|---|---|---|
result |
ndarray
|
Forward mode: the transformed array |
coords |
ndarray
|
Forward mode: the output |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the input is empty, |
Reference
[1] Hu, Yanlei, et al. "Efficient full-path optical calculation of scalar and vector diffraction using the Bluestein method."
Light: Science & Applications 9.1 (2020): 119.
Source code in structured_optics\bluestein.py
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
fft2_bluestein ¶
fft2_bluestein(field, dx, dy, dkx, dky, Dx_out=None, Dy_out=None, x0=0.0, y0=0.0, kx0=0.0, ky0=0.0)
Generalized 2D (forward) Fourier transform using Bluestein's algorithm, applied separably along each axis.
Performs fft_bluestein along the last axis (x), then along the
remaining axis (y), i.e. a separable 2D chirp-z transform with
independently chosen sample spacing, sample count, and origin for
each axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
array_like
|
2D input array of shape |
required |
dx
|
float
|
Input sample spacing along x. |
required |
dy
|
float
|
Input sample spacing along y. |
required |
dkx
|
float
|
Output sample spacing along kx. Must be nonzero. |
required |
dky
|
float
|
Output sample spacing along ky. Must be nonzero. |
required |
Dx_out
|
int
|
Number of output samples along x. Defaults to |
None
|
Dy_out
|
int
|
Number of output samples along y. Defaults to |
None
|
x0
|
float
|
Origin of the input x grid. Defaults to 0.0. |
0.0
|
y0
|
float
|
Origin of the input y grid. Defaults to 0.0. |
0.0
|
kx0
|
float
|
Origin of the output kx grid. Defaults to 0.0. |
0.0
|
ky0
|
float
|
Origin of the output ky grid. Defaults to 0.0. |
0.0
|
Returns:
| Name | Type | Description |
|---|---|---|
F |
ndarray
|
Transformed array, of shape |
kx |
ndarray
|
Output kx grid, |
ky |
ndarray
|
Output ky grid, |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in structured_optics\bluestein.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |