Skip to content
Snippets Groups Projects
Commit ad1e35eb authored by Mattia Mancini's avatar Mattia Mancini
Browse files

SSB-47: refactored dft function

parent 880635c1
No related branches found
No related tags found
1 merge request!44Merge back holography to master
......@@ -28,9 +28,15 @@ __MHZ_IN_HZ = 1.e6
@jit()
def dft2_numba(x:numpy.ndarray, y:numpy.ndarray, l:numpy.ndarray, m:numpy.ndarray, freq_hz, v:numpy.ndarray, fourier_sign):
arg_factor = (fourier_sign * 2 * numpy.pi * freq_hz / 299792458.0)
def dft2_numba(x: numpy.ndarray,
y: numpy.ndarray,
l: numpy.ndarray,
m: numpy.ndarray,
freq_hz,
v: numpy.ndarray,
fourier_sign):
arg_factor = (fourier_sign * 2 * numpy.pi * freq_hz / light_speed)
result = numpy.zeros((len(x), len(y)), dtype=numpy.complex64)
x_down = x.astype(numpy.float32)
y_down = y.astype(numpy.float32)
......@@ -60,7 +66,7 @@ def dft2_numba_loop(x, y, l, m, v, arg_factor, result):
for j in range(x_len):
for k in range(v.shape[0]):
result[i, j] += (v[k] * real_factor[i, j, k] + 1.j * imag_factor[i, j, k])
result[i, j] += v[k] * (real_factor[i, j, k] + 1.j * imag_factor[i, j, k])
def complex_value_to_color(complex_array: numpy.ndarray, abs_max=None, abs_min=None, log=True):
......@@ -129,11 +135,14 @@ def _fft_visibilities_lm_plane(l, m, v, sampling):
return fft_vis
def _dft_visibilities_lm_plane(l, m, v, sampling, frequency):
x = numpy.linspace(-30, 30, sampling)
y = numpy.linspace(-30, 30, sampling)
def _dft_visibilities_lm_plane(l, m, v, sampling, frequency, array_size):
fft_vis = dft2_numba(x, y, l, m, frequency, v, 1)
x = numpy.linspace(-array_size, array_size, sampling)
y = numpy.linspace(-array_size, array_size, sampling)
l = numpy.array(l)
m = numpy.array(m)
v = numpy.array(v)
fft_vis = dft2_numba(x, y, l, m, frequency, v, -1)
return fft_vis
......@@ -164,22 +173,24 @@ def _plot_station_averaged_visibilities_station_plane_single_frequency(figure: F
for index, polarization in enumerate(('XX', 'XY', 'YX', 'YY')):
v_pol = numpy.array(list(map(lambda x: x[polarization], v)))
fft_vis = _dft_visibilities_lm_plane(l, m, v_pol, sampling, frequency)
array_size = 30
fft_vis = _dft_visibilities_lm_plane(l=l, m=m, v=v_pol,
sampling=sampling,
frequency=frequency,
array_size=array_size)
canvas = figure.add_subplot(2, 2, index + 1)
canvas.set_xlim(-30, 30)
canvas.set_ylim(-30, 30)
canvas.set_xlim(-array_size, array_size)
canvas.set_ylim(-array_size, array_size)
canvas.set_xlabel('x [m]')
canvas.set_ylabel('y [m]')
antenna_array_length = light_speed / frequency * sampling / 2. / 2.
color_mapped_fft = complex_value_to_color(fft_vis, log=False)
canvas.imshow(color_mapped_fft[:, ::-1], origin='lower', extent=[-1 * antenna_array_length,
1 * antenna_array_length,
-1 * antenna_array_length,
1 * antenna_array_length],
canvas.imshow(color_mapped_fft[:, ::-1], origin='lower', extent=[-1 * array_size,
1 * array_size,
-1 * array_size,
1 * array_size],
resample = True)
canvas.set_title(polarization)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment