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

SSB-47: using the rcu used to determine the antenna involved during the observation

parent 8f30ad48
No related branches found
No related tags found
1 merge request!44Merge back holography to master
......@@ -332,6 +332,7 @@ class HolographyDataset():
rcu_list = set()
start_mjd = None
end_mjd = None
used_antennas = set()
for hbs, ho in list_of_hbs_ho_tuples:
target_stations.update(hbs.target_station_names)
......@@ -340,7 +341,7 @@ class HolographyDataset():
beam_specifications = hbs.get_beam_specifications_per_station_name(station_name)
for beam_specification in beam_specifications:
rcu_list.update(beam_specification.rcus_involved)
used_antennas.update(beam_specification.antennas_used)
mode.add(beam_specification.rcus_mode)
source_name.add(ho.source_name)
......@@ -402,8 +403,10 @@ class HolographyDataset():
get_station_position_tile_offsets_and_axes_coordinate_for_station_name(
station_name)
logger.debug('selecting used antenna ids %s', used_antennas)
self.antenna_field_position = [list(station_position - antenna_offset)
for antenna_offset in tile_offset]
for antenna_id, antenna_offset in enumerate(tile_offset)
if antenna_id in used_antennas]
self.target_station_position = list(station_position)
self.rotation_matrix = axes_coordinates
......
......@@ -163,11 +163,6 @@ class HolographyMeasurementSet(object):
station_position = antenna_field_table.getcell('POSITION', 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)
index_tiles_used = numpy.where(
(tiles_not_used[:, CASA_POLARIZATION_INDEX.X] == False) &
(tiles_not_used[:, CASA_POLARIZATION_INDEX.Y] == False))[0]
tile_offsets = tile_offsets[index_tiles_used, :]
axes_coordinate = antenna_field_table.getcell('COORDINATE_AXES', station_name_index)
......
......@@ -8,6 +8,46 @@ from glob import glob
logger = logging.getLogger(__file__)
MODE_TO_COMPONENT = {
1: 'LBL',
2: 'LBL',
3: 'LBH',
4: 'LBH',
5: 'HBA',
6: 'HBA',
7: 'HBA'
}
def antenna_id_polarization_from_rcu_type(rcu, type):
"""
Compute the antenna id for a given rcu, type and polarization
:param rcu: id of the rcu
:param type: type of the antenna
:return: the antenna id and polarization
:rtype: (int, str)
:rtype: int
"""
polarization_index = rcu % 2
if type in ['LBH', 'HBA']:
antenna_id = rcu - polarization_index
antenna_id /= 2.
elif type == 'LBL':
antenna_id = (rcu - polarization_index) / 2. + 48
else:
antenna_id = -1
return int(antenna_id)
def antenna_id_polarization_from_rcu_mode_polarization(rcu, mode):
if mode in MODE_TO_COMPONENT:
type = MODE_TO_COMPONENT[mode]
return antenna_id_polarization_from_rcu_type(rcu, type)
else:
raise Exception('Unrecognized mode %s' % mode)
class HolographyStationBeamSpecification(object):
"""
Contains the data regarding the beam specification for a single station.
......@@ -18,6 +58,7 @@ class HolographyStationBeamSpecification(object):
mode_description = None
rcus_involved = ()
beamlets = ()
antennas_used = ()
station_pointing = ()
virtual_pointing = ()
station_type = ()
......@@ -32,6 +73,7 @@ def _parse_line(split_line):
beam_specification = HolographyStationBeamSpecification()
beam_specification.rcus_mode = int(split_line['rcus_mode'])
beam_specification.sub_band_ids = [int(sub_band) for sub_band in
split_line['sub_band'].split(',')]
beam_specification.mode_description = split_line['mode_description']
......@@ -39,10 +81,15 @@ def _parse_line(split_line):
split_line['rcus'])
beam_specification.beamlets = split_line['beamlets']
beam_specification.antennas_used = [
antenna_id_polarization_from_rcu_mode_polarization(rcu,
beam_specification.rcus_mode)
for rcu in beam_specification.rcus_involved]
beam_specification.station_pointing = _parse_pointing(
split_line['station_pointing'])
beam_specification.virtual_pointing = _parse_pointing(
split_line['virtual_pointing'])
if len(beam_specification.sub_band_ids) == 1:
beam_specification.station_type = 'target'
else:
......
......@@ -110,11 +110,17 @@ def wait_for_processes_to_complete_execution(thread_pool,
:type future_results: list[multiprocess.pool.ApplyResult]
"""
all_done = False
print(
'dude'
)
try:
while not all_done:
all_done = True
for k in future_results:
all_done = all_done and k.ready()
print(k)
print(future_results)
time.sleep(sleep_time)
except KeyboardInterrupt:
thread_pool.terminate()
......@@ -168,6 +174,7 @@ def read_holography_datasets_and_store(holography_observation_path,
for station_name in target_station_names:
result = thread_pool.apply_async(read_and_store_single_target_station,
(station_name, matched_bsf_ms_pair, store_path))
results.append(result)
wait_for_processes_to_complete_execution(thread_pool, results, sleep_time)
......
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