diff --git a/CAL/CalibrationCommon/lib/datacontainers/holography_measurementset.py b/CAL/CalibrationCommon/lib/datacontainers/holography_measurementset.py index cd31cb991832e1609ea501899982543900488828..9ffc8c0f407429c273a2929f4b821d4f0c152e92 100644 --- a/CAL/CalibrationCommon/lib/datacontainers/holography_measurementset.py +++ b/CAL/CalibrationCommon/lib/datacontainers/holography_measurementset.py @@ -1,23 +1,26 @@ 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: