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

SSB-47: skipping invalid observations

parent cf75a296
No related branches found
No related tags found
1 merge request!44Merge back holography to master
......@@ -24,6 +24,8 @@ def _mjd_to_datetime(mjd_time_seconds):
def _compute_time_range_from_ms_list(ms_list):
assert len(ms_list) > 0
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()
......@@ -108,44 +110,49 @@ def list_observations_in_path(path):
if match:
sas_id = match.group('sas_id')
ms_indexed_per_beamlet_number = create_ms_dict_from_ms_name_list_and_path(dirnames,
root)
start_mjd_in_seconds, end_mjd_in_seconds = _compute_time_range_from_ms_list(
list(ms_indexed_per_beamlet_number.values()))
unique_frequencies = extract_unique_reference_frequencies_from_ms_list(
list(ms_indexed_per_beamlet_number.values()))
if len(unique_frequencies) == 1:
frequency = unique_frequencies.pop()
else:
raise ValueError(
'Multiple reference _frequencies per observation are not supported')
unique_source_names = extract_unique_source_names_from_ms_list(
list(ms_indexed_per_beamlet_number.values()))
if len(unique_source_names) == 1:
source_name = unique_source_names.pop()
else:
raise ValueError(
'Multiple source target per observation are not supported')
unique_subband = extract_unique_subband_from_ms_list(
list(ms_indexed_per_beamlet_number.values()))
if len(unique_subband) == 1:
sub_band = unique_subband.pop()
else:
raise ValueError(
'Multiple subband per observation are not supported')
try:
ms_indexed_per_beamlet_number = create_ms_dict_from_ms_name_list_and_path(dirnames,
root)
start_mjd_in_seconds, end_mjd_in_seconds = _compute_time_range_from_ms_list(
list(ms_indexed_per_beamlet_number.values()))
unique_frequencies = extract_unique_reference_frequencies_from_ms_list(
list(ms_indexed_per_beamlet_number.values()))
if len(unique_frequencies) == 1:
frequency = unique_frequencies.pop()
else:
raise ValueError(
'Multiple reference _frequencies per observation are not supported')
unique_source_names = extract_unique_source_names_from_ms_list(
list(ms_indexed_per_beamlet_number.values()))
if len(unique_source_names) == 1:
source_name = unique_source_names.pop()
else:
raise ValueError(
'Multiple source target per observation are not supported')
unique_subband = extract_unique_subband_from_ms_list(
list(ms_indexed_per_beamlet_number.values()))
if len(unique_subband) == 1:
sub_band = unique_subband.pop()
else:
raise ValueError(
'Multiple subband per observation are not supported')
observations_list.append(
HolographyObservation(path, sas_id, ms_indexed_per_beamlet_number,
start_mjd_in_seconds, end_mjd_in_seconds, sub_band,
frequency,
source_name))
except Exception as e:
logger.error('Observation in %s is invalid skipping... ', root)
logger.exception(e)
observations_list.append(
HolographyObservation(path, sas_id, ms_indexed_per_beamlet_number,
start_mjd_in_seconds, end_mjd_in_seconds, sub_band,
frequency,
source_name))
logger.info("Holography observations were successfully loaded from \"%s\".", path)
return observations_list
......
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