-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkt2xf.py
34 lines (27 loc) · 913 Bytes
/
kt2xf.py
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
'''k-t space to x-f space.'''
import numpy as np
def kt2xf(kt, shift=False, time_axis=-1):
'''k-t space to x-f space.
Parameters
----------
kt : array_like
k-t space data.
shift: bool, optional
Perform fftshift when Fourier transforming.
time_axis : int, optional
Dimension that holds time data.
Returns
-------
xf : array_like
Corresponding x-f space data.
'''
# Do the transformin' (also move time axis to and fro)
if not shift:
return np.moveaxis(np.fft.fft(np.fft.ifft2(
np.moveaxis(kt, time_axis, -1),
axes=(0, 1)), axis=-1), -1, time_axis)
return np.moveaxis(np.fft.fftshift(np.fft.ifft2(np.fft.ifftshift(
np.fft.ifftshift(np.fft.fft(
np.moveaxis(kt, time_axis, -1),
axis=-1), axes=-1),
axes=(0, 1)), axes=(0, 1)), axes=(0, 1)), -1, time_axis)