Skip to content
Snippets Groups Projects
Commit 7cec2435 authored by Taya Snijder's avatar Taya Snijder
Browse files

Merge branch 'L2SS-920_make_statistics_writer_tolerant' into 'master'

Resolve L2SS-920 "Make statistics writer tolerant"

Closes L2SS-920

See merge request !421
parents 673aadb6 a0a198cc
No related branches found
No related tags found
1 merge request!421Resolve L2SS-920 "Make statistics writer tolerant"
...@@ -182,9 +182,9 @@ class TestStatisticsWriterSST(BaseIntegrationTestCase): ...@@ -182,9 +182,9 @@ class TestStatisticsWriterSST(BaseIntegrationTestCase):
self.assertIsNotNone(stat) self.assertIsNotNone(stat)
self.assertEqual(121, stat.data_id_signal_input_index) self.assertEqual(121, stat.data_id_signal_input_index)
# Test RECV attributes # Test RECV attributes
self.assertEqual(stat.rcu_attenuator_dB.tolist(), None) self.assertEqual(stat.rcu_attenuator_dB, None)
self.assertEqual(stat.rcu_band_select.tolist(), None) self.assertEqual(stat.rcu_band_select, None)
self.assertEqual(stat.rcu_dth_on.tolist(), None) self.assertEqual(stat.rcu_dth_on, None)
def test_SST_statistics_with_device_in_off(self): def test_SST_statistics_with_device_in_off(self):
self.setup_recv_proxy() self.setup_recv_proxy()
...@@ -222,6 +222,6 @@ class TestStatisticsWriterSST(BaseIntegrationTestCase): ...@@ -222,6 +222,6 @@ class TestStatisticsWriterSST(BaseIntegrationTestCase):
self.assertIsNotNone(stat) self.assertIsNotNone(stat)
self.assertEqual(121, stat.data_id_signal_input_index) self.assertEqual(121, stat.data_id_signal_input_index)
# Test RECV attributes # Test RECV attributes
self.assertEqual(stat.rcu_attenuator_dB.tolist(), None) self.assertEqual(stat.rcu_attenuator_dB, None)
self.assertEqual(stat.rcu_band_select.tolist(), None) self.assertEqual(stat.rcu_band_select, None)
self.assertEqual(stat.rcu_dth_on.tolist(), None) self.assertEqual(stat.rcu_dth_on, None)
...@@ -161,7 +161,7 @@ class statistics_data: ...@@ -161,7 +161,7 @@ class statistics_data:
"source_info_fsub_type", "source_info_beam_repositioning_flag", "source_info_antenna_band_index", "source_info__raw", "source_info_fsub_type", "source_info_beam_repositioning_flag", "source_info_antenna_band_index", "source_info__raw",
"observation_id", "nof_statistics_per_packet", "nof_signal_inputs", "nof_bytes_per_statistic", "marker", "integration_interval_raw", "observation_id", "nof_statistics_per_packet", "nof_signal_inputs", "nof_bytes_per_statistic", "marker", "integration_interval_raw",
"integration_interval", "data_id__raw", "block_serial_number", "block_period_raw", "block_period", "data_id_signal_input_index", "integration_interval", "data_id__raw", "block_serial_number", "block_period_raw", "block_period", "data_id_signal_input_index",
"data_id_subband_index", "data_id_first_baseline", "data_id_beamlet_index", "nof_valid_payloads", "nof_payload_errors", "values", "data_id_subband_index", "data_id_first_baseline", "data_id_beamlet_index", "nof_valid_payloads", "nof_payload_errors", "values",
"rcu_attenuator_dB", "rcu_band_select", "rcu_dth_on") "rcu_attenuator_dB", "rcu_band_select", "rcu_dth_on")
def __init__(self, file, group_key): def __init__(self, file, group_key):
...@@ -202,10 +202,25 @@ class statistics_data: ...@@ -202,10 +202,25 @@ class statistics_data:
# get SST specific stuff # get SST specific stuff
if self.marker == "S": if self.marker == "S":
self.data_id_signal_input_index = file[group_key].attrs["data_id_signal_input_index"] self.data_id_signal_input_index = file[group_key].attrs["data_id_signal_input_index"]
self.rcu_attenuator_dB = numpy.array(file.get(f"{group_key}/rcu_attenuator_dB"))
self.rcu_band_select = numpy.array(file.get(f"{group_key}/rcu_band_select")) # check if the dataset is empty or not. if empty, set to None, if not get the value
self.rcu_dth_on = numpy.array(file.get(f"{group_key}/rcu_dth_on"))
if file.get(f'{group_key}/rcu_attenuator_dB').shape is None:
self.rcu_attenuator_dB = None
else:
self.rcu_attenuator_dB = numpy.array(file.get(f"{group_key}/rcu_attenuator_dB"))
if file.get(f'{group_key}/rcu_band_select').shape is None:
self.rcu_band_select = None
else:
self.rcu_band_select = numpy.array(file.get(f"{group_key}/rcu_band_select"))
if file.get(f'{group_key}/rcu_dth_on').shape is None:
self.rcu_dth_on = None
else:
self.rcu_dth_on = numpy.array(file.get(f"{group_key}/rcu_dth_on"))
# get XST specific stuff # get XST specific stuff
if self.marker == "X": if self.marker == "X":
......
...@@ -332,32 +332,43 @@ class SstHdf5Writer(HDF5Writer): ...@@ -332,32 +332,43 @@ class SstHdf5Writer(HDF5Writer):
].astype(numpy.float32), ].astype(numpy.float32),
compression="gzip", compression="gzip",
) )
try: try:
current_group.create_dataset( current_group.create_dataset(
name="rcu_attenuator_dB", name="rcu_attenuator_dB",
data=self.current_matrix.parameters["rcu_attenuator_dB"].astype( data=self.current_matrix.parameters["rcu_attenuator_dB"].astype(numpy.int64),
numpy.int64
),
compression="gzip", compression="gzip",
) )
except AttributeError:
current_group.create_dataset(
name="rcu_attenuator_dB",
data=h5py.Empty("f"),
)
try:
current_group.create_dataset( current_group.create_dataset(
name="rcu_band_select", name="rcu_band_select",
data=self.current_matrix.parameters["rcu_band_select"].astype( data=self.current_matrix.parameters["rcu_band_select"].astype(numpy.int64),
numpy.int64
),
compression="gzip", compression="gzip",
) )
except AttributeError:
current_group.create_dataset(
name="rcu_band_select",
data=h5py.Empty("f"),
)
try:
current_group.create_dataset( current_group.create_dataset(
name="rcu_dth_on", name="rcu_dth_on",
data=self.current_matrix.parameters["rcu_dth_on"].astype( data=self.current_matrix.parameters["rcu_dth_on"].astype(numpy.bool_),
numpy.bool_
),
compression="gzip", compression="gzip",
) )
except AttributeError as e: except AttributeError:
logger.warning("Device values not written.") current_group.create_dataset(
except Exception as e: name="rcu_dth_on",
raise Exception from e data=h5py.Empty("f"),
)
class BstHdf5Writer(HDF5Writer): class BstHdf5Writer(HDF5Writer):
......
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