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

SSB-44: using enums to specify indexes

parent c0ecd8d7
No related branches found
No related tags found
1 merge request!44Merge back holography to master
import os
import re
from enum import Enum
import numpy
from astropy.time import Time
from casacore.tables import table as MS_Table
from lofar.calibration.common.coordinates import pqr_from_icrs
from .holography_dataset_definitions import *
class CASA_POLARIZATION_INDEX(Enum):
XX = 0
XY = 1
YX = 2
YY = 3
X = 0
Y = 0
class HolographyMeasurementSet(object):
ms_name_pattern = r'L(?P<sas_id>\d{6})_SB(?P<sub_band_id>\d{3})_uv\.MS'
CASA_XX_INDEX = 0
CASA_XY_INDEX = 1
CASA_YX_INDEX = 2
CASA_YY_INDEX = 3
CASA_X_INDEX = 0
CASA_Y_INDEX = 1
def __init__(self, ms_name, ms_path):
self.path = os.path.join(ms_path, ms_name)
......@@ -87,8 +90,8 @@ class HolographyMeasurementSet(object):
tile_offsets = antenna_field_table.getcell('ELEMENT_OFFSET', station_name_index)
tiles_not_used = antenna_field_table.getcell('ELEMENT_FLAG', station_name_index)
index_tiles_used = numpy.where(
(tiles_not_used[:, HolographyMeasurementSet.CASA_X_INDEX] == False) &
(tiles_not_used[:, HolographyMeasurementSet.CASA_Y_INDEX] == False))[0]
(tiles_not_used[:, CASA_POLARIZATION_INDEX.CASA_X_INDEX] == False) &
(tiles_not_used[:, CASA_POLARIZATION_INDEX.CASA_Y_INDEX] == False))[0]
tile_offsets = tile_offsets[index_tiles_used, :]
axes_coordinate = antenna_field_table.getcell('COORDINATE_AXES', station_name_index)
......@@ -193,16 +196,16 @@ class HolographyMeasurementSet(object):
beams_crosscorrelations_array[reference_station_index, :]['XX'] = \
crosscorrelations[
reference_station_index, :, HolographyMeasurementSet.CASA_XX_INDEX]
reference_station_index, :, CASA_POLARIZATION_INDEX.CASA_XX_INDEX]
beams_crosscorrelations_array[reference_station_index, :]['XY'] = \
crosscorrelations[
reference_station_index, :, HolographyMeasurementSet.CASA_XY_INDEX]
reference_station_index, :, CASA_POLARIZATION_INDEX.CASA_XY_INDEX]
beams_crosscorrelations_array[reference_station_index, :]['YX'] = \
crosscorrelations[
reference_station_index, :, HolographyMeasurementSet.CASA_YX_INDEX]
reference_station_index, :, CASA_POLARIZATION_INDEX.CASA_YX_INDEX]
beams_crosscorrelations_array[reference_station_index, :]['YY'] = \
crosscorrelations[
reference_station_index, :, HolographyMeasurementSet.CASA_YY_INDEX]
reference_station_index, :, CASA_POLARIZATION_INDEX.CASA_YY_INDEX]
beams_crosscorrelations_array[reference_station_index, :]['flag'] = \
flags[reference_station_index, :]
......@@ -275,7 +278,7 @@ class HolographyMeasurementSet(object):
return_value = numpy.empty(n_samples, dtype=return_value_dtype)
l_m_arrays = pqr_from_icrs(numpy.array((ra, dec)), astropy_times, rotation_matrix)
return_value['l'][:] = l_m_arrays[:, 0]
return_value['m'][:] = l_m_arrays[:, 1]
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment