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

SSB-47: redefinition of l, m before solving for the gains

parent 4e945cdd
No related branches found
No related tags found
1 merge request!44Merge back holography to master
...@@ -20,7 +20,7 @@ def _rotate_antenna_coordinates(dataset): ...@@ -20,7 +20,7 @@ def _rotate_antenna_coordinates(dataset):
station_position = numpy.array(dataset.target_station_position) station_position = numpy.array(dataset.target_station_position)
antenna_field_position = numpy.array(dataset.antenna_field_position) antenna_field_position = numpy.array(dataset.antenna_field_position)
antenna_position_offset = numpy.array([antenna_position - station_position for antenna_position_offset = numpy.array([station_position - antenna_position for
antenna_position in antenna_field_position]) antenna_position in antenna_field_position])
station_rotation_matrix = dataset.rotation_matrix station_rotation_matrix = dataset.rotation_matrix
...@@ -42,7 +42,8 @@ def _compute_expected_phase_delay(l, m, x, y, frequency): ...@@ -42,7 +42,8 @@ def _compute_expected_phase_delay(l, m, x, y, frequency):
return phase return phase
def _compute_pointing_matrices_per_station_frequency_beam(dataset, datatable, frequency): def _compute_pointing_matrices_per_station_frequency_beam(dataset, datatable, central_beam,
frequency):
""" """
Compute the pointing matrix of a given station, at a given frequency and for a specific beam. Compute the pointing matrix of a given station, at a given frequency and for a specific beam.
:param dataset: datatable's dataset :param dataset: datatable's dataset
...@@ -51,6 +52,8 @@ def _compute_pointing_matrices_per_station_frequency_beam(dataset, datatable, fr ...@@ -51,6 +52,8 @@ def _compute_pointing_matrices_per_station_frequency_beam(dataset, datatable, fr
:type datatable: dict(dict(numpy.ndarray)) :type datatable: dict(dict(numpy.ndarray))
:param frequency: frequency at which to compute the pointing matrix :param frequency: frequency at which to compute the pointing matrix
:type frequency: float :type frequency: float
:param central_beam: central beam
:type central_beam: str
:return: the pointing matrix :return: the pointing matrix
:rtype: numpy.matrix :rtype: numpy.matrix
""" """
...@@ -64,8 +67,8 @@ def _compute_pointing_matrices_per_station_frequency_beam(dataset, datatable, fr ...@@ -64,8 +67,8 @@ def _compute_pointing_matrices_per_station_frequency_beam(dataset, datatable, fr
for i in range(n_beams): for i in range(n_beams):
for j in range(n_antennas): for j in range(n_antennas):
l = datatable[str(i)]['mean']['l'][0] l = datatable[central_beam]['mean']['l'][0] - datatable[str(i)]['mean']['l'][0]
m = datatable[str(i)]['mean']['m'][0] m = datatable[central_beam]['mean']['m'][0] - datatable[str(i)]['mean']['m'][0]
x, y = rotated_coordinates[j, 0:2] x, y = rotated_coordinates[j, 0:2]
phase = _compute_expected_phase_delay(l, m, x, y, frequency) phase = _compute_expected_phase_delay(l, m, x, y, frequency)
...@@ -229,7 +232,7 @@ def _solve_gains(visibilities, matrix, **kwargs): ...@@ -229,7 +232,7 @@ def _solve_gains(visibilities, matrix, **kwargs):
return __empty return __empty
def _solve_gains_per_frequency(dataset, datatable, frequency, direct_complex=False, **kwargs): def _solve_gains_per_frequency(dataset, datatable, frequency, direct_complex=True, **kwargs):
""" """
SOLVE THE EQUATION M * G = V FOR G SOLVE THE EQUATION M * G = V FOR G
:param dataset: :param dataset:
...@@ -239,13 +242,27 @@ def _solve_gains_per_frequency(dataset, datatable, frequency, direct_complex=Fal ...@@ -239,13 +242,27 @@ def _solve_gains_per_frequency(dataset, datatable, frequency, direct_complex=Fal
:type frequency: float :type frequency: float
:return: :return:
""" """
matrix = _compute_pointing_matrices_per_station_frequency_beam(dataset, datatable, frequency)
central_beam = dataset.central_beamlets[str(frequency)]
matrix = _compute_pointing_matrices_per_station_frequency_beam(dataset,
datatable,
central_beam,
frequency)
n_beams = len(datatable) n_beams = len(datatable)
result = dict() result = dict()
#flags = numpy.array(
# [datatable[str(i)]['mean']['flag'] for i in range(n_beams)])
#__empty = dict(gains=numpy.array(numpy.nan),
# residual=numpy.array(numpy.nan),
# relative_error=numpy.array(numpy.nan),
# flag=numpy.array(True))
#is_frequency_flagged = flags
for polarization in ['XX', 'XY', 'YX', 'YY']: for polarization in ['XX', 'XY', 'YX', 'YY']:
visibilities = numpy.matrix( visibilities = numpy.matrix(
[datatable[str(i)]['mean'][polarization] for i in range(n_beams)]) [datatable[str(i)]['mean'][polarization] for i in range(n_beams)])
if direct_complex is True: if direct_complex is True:
result[polarization] = _solve_gains(visibilities, matrix, **kwargs) result[polarization] = _solve_gains(visibilities, matrix, **kwargs)
else: else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment