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

SSB-42: definition of holography observation specification

parent 19869257
No related branches found
No related tags found
1 merge request!44Merge back holography to master
...@@ -11,6 +11,7 @@ CAL/CalibrationCommon/lib/__init__.py -text ...@@ -11,6 +11,7 @@ CAL/CalibrationCommon/lib/__init__.py -text
CAL/CalibrationCommon/lib/coordinates.py -text CAL/CalibrationCommon/lib/coordinates.py -text
CAL/CalibrationCommon/lib/datacontainers/__init__.py -text CAL/CalibrationCommon/lib/datacontainers/__init__.py -text
CAL/CalibrationCommon/lib/datacontainers/holography_dataset.py -text CAL/CalibrationCommon/lib/datacontainers/holography_dataset.py -text
CAL/CalibrationCommon/lib/datacontainers/holography_observation_specification.py -text
CAL/CalibrationCommon/lib/datacontainers/holography_specification.py -text CAL/CalibrationCommon/lib/datacontainers/holography_specification.py -text
CAL/CalibrationCommon/lib/datacontainers/measurementset.py -text CAL/CalibrationCommon/lib/datacontainers/measurementset.py -text
CAL/CalibrationCommon/lib/mshologextract.py -text CAL/CalibrationCommon/lib/mshologextract.py -text
......
from .holography_dataset import HolographyDataset from .holography_dataset import HolographyDataset
from .holography_specification import HolographySpecification, HolographyObservation from .holography_specification import HolographySpecification
from .holography_observation_specification import HolographyObservationSpecification
from .measurementset import MeasurementSet from .measurementset import MeasurementSet
__all__ = [HolographyDataset, HolographyObservation, HolographySpecification, MeasurementSet] __all__ = [HolographyDataset, HolographyObservationSpecification, HolographySpecification, MeasurementSet]
\ No newline at end of file \ No newline at end of file
import re
import os
from .measurementset import MeasurementSet
class HolographyObservationSpecification():
def __init__(self, path, sas_id, ms_for_a_given_beamlet, observation_start_datetime,
observation_end_datetime):
self.path = path
self.sas_id = sas_id
self.ms_for_a_given_beamlet = ms_for_a_given_beamlet
self.start_datetime = observation_start_datetime
self.end_datetime = observation_end_datetime
@staticmethod
def __compute_time_range_from_ms_list(ms_list):
observation_start, observation_end = ms_list[0].get_start_end_observation()
for ms in ms_list:
ms_start_time, ms_end_time = ms.get_start_end_observation()
if observation_start > ms_start_time:
observation_start = ms_start_time
if observation_end < ms_end_time:
observation_end = ms_end_time
return observation_start, observation_end
@staticmethod
def list_observations_in_path(path):
ms_dir_name_pattern = 'L(?P<sas_id>\d{6})'
ms_dirs_path_pattern = '^' + os.path.join(path, ms_dir_name_pattern, 'uv$')
observations_list = []
for root, dirnames, filenames in os.walk(path):
match = re.match(ms_dirs_path_pattern, root)
if match:
sas_id = int(match.group('sas_id'))
ms_indexed_per_beamlet_number = HolographyObservationSpecification.\
create_ms_dict_from_ms_name_list_and_path(dirnames, root)
start_datetime, end_datetime = HolographyObservationSpecification.\
__compute_time_range_from_ms_list(
ms_indexed_per_beamlet_number.values())
observations_list.append(
HolographyObservationSpecification(path, sas_id, ms_indexed_per_beamlet_number,
start_datetime, end_datetime))
return observations_list
@staticmethod
def create_ms_dict_from_ms_name_list_and_path(list_of_ms_names, path):
"""
Creates a dict measurement sets indexed by beamlet id
:param list_of_ms_names: a list of the ms to process
:param path: a path were the ms are stored
:return: a dict containing the map of the ms indexed by their beamlet number
ex. { 0 : ms_beam0 ....}
"""
filtered_list_of_ms_names = MeasurementSet.filter_valid_ms_names(list_of_ms_names)
ms_list = [MeasurementSet(ms_name, path) for ms_name in filtered_list_of_ms_names]
beamlet_ms_map = {ms.beamlet:ms for ms in ms_list}
return beamlet_ms_map
\ No newline at end of file
...@@ -3,8 +3,6 @@ from collections import defaultdict ...@@ -3,8 +3,6 @@ from collections import defaultdict
import re import re
import os import os
from .measurementset import MeasurementSet
class HolographySpecification(object): class HolographySpecification(object):
hs_name_pattern = r'Holog-(?P<date>\d{8})-(?P<comment>.*)-(?P<id>\d{3}).txt' hs_name_pattern = r'Holog-(?P<date>\d{8})-(?P<comment>.*)-(?P<id>\d{3}).txt'
...@@ -21,7 +19,6 @@ class HolographySpecification(object): ...@@ -21,7 +19,6 @@ class HolographySpecification(object):
self.rcu_mode = None self.rcu_mode = None
self.beam_set_interval = None self.beam_set_interval = None
def __repr__(self): def __repr__(self):
return 'HolographySpecification(%s, %s, %s, %s, %s)' % ( return 'HolographySpecification(%s, %s, %s, %s, %s)' % (
self.id, self.id,
...@@ -158,61 +155,4 @@ class HolographySpecification(object): ...@@ -158,61 +155,4 @@ class HolographySpecification(object):
return hs_id, date, comment return hs_id, date, comment
class HolographyObservation():
def __init__(self, path, sas_id, ms_for_a_given_beamlet, observation_start_datetime,
observation_end_datetime):
self.path = path
self.sas_id = sas_id
self.ms_for_a_given_beamlet = ms_for_a_given_beamlet
self.start_datetime = observation_start_datetime
self.end_datetime = observation_end_datetime
@staticmethod
def __compute_time_range_from_ms_list(ms_list):
observation_start, observation_end = ms_list[0].get_start_end_observation()
for ms in ms_list:
ms_start_time, ms_end_time = ms.get_start_end_observation()
if observation_start > ms_start_time:
observation_start = ms_start_time
if observation_end < ms_end_time:
observation_end = ms_end_time
return observation_start, observation_end
@staticmethod
def list_observations_in_path(path):
ms_dir_name_pattern = 'L(?P<sas_id>\d{6})'
ms_dirs_path_pattern = '^' + os.path.join(path, ms_dir_name_pattern, 'uv$')
observations_list = []
for root, dirnames, filenames in os.walk(path):
match = re.match(ms_dirs_path_pattern, root)
if match:
sas_id = int(match.group('sas_id'))
ms_indexed_per_beamlet_number = HolographyObservation.\
create_ms_dict_from_ms_name_list_and_path(dirnames, root)
start_datetime, end_datetime = HolographyObservation.\
__compute_time_range_from_ms_list(
ms_indexed_per_beamlet_number.values())
observations_list.append(
HolographyObservation(path, sas_id, ms_indexed_per_beamlet_number,
start_datetime, end_datetime))
return observations_list
@staticmethod
def create_ms_dict_from_ms_name_list_and_path(list_of_ms_names, path):
"""
Creates a dict measurement sets indexed by beamlet id
:param list_of_ms_names: a list of the ms to process
:param path: a path were the ms are stored
:return: a dict containing the map of the ms indexed by their beamlet number
ex. { 0 : ms_beam0 ....}
"""
filtered_list_of_ms_names = MeasurementSet.filter_valid_ms_names(list_of_ms_names)
ms_list = [MeasurementSet(ms_name, path) for ms_name in filtered_list_of_ms_names]
beamlet_ms_map = {ms.beamlet:ms for ms in ms_list}
return beamlet_ms_map
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