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 os
import re import re
from enum import Enum
import numpy import numpy
from astropy.time import Time from astropy.time import Time
from casacore.tables import table as MS_Table from casacore.tables import table as MS_Table
from lofar.calibration.common.coordinates import pqr_from_icrs from lofar.calibration.common.coordinates import pqr_from_icrs
from .holography_dataset_definitions import * 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): class HolographyMeasurementSet(object):
ms_name_pattern = r'L(?P<sas_id>\d{6})_SB(?P<sub_band_id>\d{3})_uv\.MS' 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): def __init__(self, ms_name, ms_path):
self.path = os.path.join(ms_path, ms_name) self.path = os.path.join(ms_path, ms_name)
...@@ -87,8 +90,8 @@ class HolographyMeasurementSet(object): ...@@ -87,8 +90,8 @@ class HolographyMeasurementSet(object):
tile_offsets = antenna_field_table.getcell('ELEMENT_OFFSET', station_name_index) tile_offsets = antenna_field_table.getcell('ELEMENT_OFFSET', station_name_index)
tiles_not_used = antenna_field_table.getcell('ELEMENT_FLAG', station_name_index) tiles_not_used = antenna_field_table.getcell('ELEMENT_FLAG', station_name_index)
index_tiles_used = numpy.where( index_tiles_used = numpy.where(
(tiles_not_used[:, HolographyMeasurementSet.CASA_X_INDEX] == False) & (tiles_not_used[:, CASA_POLARIZATION_INDEX.CASA_X_INDEX] == False) &
(tiles_not_used[:, HolographyMeasurementSet.CASA_Y_INDEX] == False))[0] (tiles_not_used[:, CASA_POLARIZATION_INDEX.CASA_Y_INDEX] == False))[0]
tile_offsets = tile_offsets[index_tiles_used, :] tile_offsets = tile_offsets[index_tiles_used, :]
axes_coordinate = antenna_field_table.getcell('COORDINATE_AXES', station_name_index) axes_coordinate = antenna_field_table.getcell('COORDINATE_AXES', station_name_index)
...@@ -193,16 +196,16 @@ class HolographyMeasurementSet(object): ...@@ -193,16 +196,16 @@ class HolographyMeasurementSet(object):
beams_crosscorrelations_array[reference_station_index, :]['XX'] = \ beams_crosscorrelations_array[reference_station_index, :]['XX'] = \
crosscorrelations[ crosscorrelations[
reference_station_index, :, HolographyMeasurementSet.CASA_XX_INDEX] reference_station_index, :, CASA_POLARIZATION_INDEX.CASA_XX_INDEX]
beams_crosscorrelations_array[reference_station_index, :]['XY'] = \ beams_crosscorrelations_array[reference_station_index, :]['XY'] = \
crosscorrelations[ crosscorrelations[
reference_station_index, :, HolographyMeasurementSet.CASA_XY_INDEX] reference_station_index, :, CASA_POLARIZATION_INDEX.CASA_XY_INDEX]
beams_crosscorrelations_array[reference_station_index, :]['YX'] = \ beams_crosscorrelations_array[reference_station_index, :]['YX'] = \
crosscorrelations[ crosscorrelations[
reference_station_index, :, HolographyMeasurementSet.CASA_YX_INDEX] reference_station_index, :, CASA_POLARIZATION_INDEX.CASA_YX_INDEX]
beams_crosscorrelations_array[reference_station_index, :]['YY'] = \ beams_crosscorrelations_array[reference_station_index, :]['YY'] = \
crosscorrelations[ crosscorrelations[
reference_station_index, :, HolographyMeasurementSet.CASA_YY_INDEX] reference_station_index, :, CASA_POLARIZATION_INDEX.CASA_YY_INDEX]
beams_crosscorrelations_array[reference_station_index, :]['flag'] = \ beams_crosscorrelations_array[reference_station_index, :]['flag'] = \
flags[reference_station_index, :] flags[reference_station_index, :]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment