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):
self.assertIsNotNone(stat)
self.assertEqual(121, stat.data_id_signal_input_index)
# Test RECV attributes
self.assertEqual(stat.rcu_attenuator_dB.tolist(), None)
self.assertEqual(stat.rcu_band_select.tolist(), None)
self.assertEqual(stat.rcu_dth_on.tolist(), None)
self.assertEqual(stat.rcu_attenuator_dB, None)
self.assertEqual(stat.rcu_band_select, None)
self.assertEqual(stat.rcu_dth_on, None)
def test_SST_statistics_with_device_in_off(self):
self.setup_recv_proxy()
......@@ -222,6 +222,6 @@ class TestStatisticsWriterSST(BaseIntegrationTestCase):
self.assertIsNotNone(stat)
self.assertEqual(121, stat.data_id_signal_input_index)
# Test RECV attributes
self.assertEqual(stat.rcu_attenuator_dB.tolist(), None)
self.assertEqual(stat.rcu_band_select.tolist(), None)
self.assertEqual(stat.rcu_dth_on.tolist(), None)
self.assertEqual(stat.rcu_attenuator_dB, None)
self.assertEqual(stat.rcu_band_select, None)
self.assertEqual(stat.rcu_dth_on, None)
......@@ -202,9 +202,24 @@ class statistics_data:
# get SST specific stuff
if self.marker == "S":
self.data_id_signal_input_index = file[group_key].attrs["data_id_signal_input_index"]
# check if the dataset is empty or not. if empty, set to None, if not get the value
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
......
......@@ -332,32 +332,43 @@ class SstHdf5Writer(HDF5Writer):
].astype(numpy.float32),
compression="gzip",
)
try:
current_group.create_dataset(
name="rcu_attenuator_dB",
data=self.current_matrix.parameters["rcu_attenuator_dB"].astype(
numpy.int64
),
data=self.current_matrix.parameters["rcu_attenuator_dB"].astype(numpy.int64),
compression="gzip",
)
except AttributeError:
current_group.create_dataset(
name="rcu_attenuator_dB",
data=h5py.Empty("f"),
)
try:
current_group.create_dataset(
name="rcu_band_select",
data=self.current_matrix.parameters["rcu_band_select"].astype(
numpy.int64
),
data=self.current_matrix.parameters["rcu_band_select"].astype(numpy.int64),
compression="gzip",
)
except AttributeError:
current_group.create_dataset(
name="rcu_band_select",
data=h5py.Empty("f"),
)
try:
current_group.create_dataset(
name="rcu_dth_on",
data=self.current_matrix.parameters["rcu_dth_on"].astype(
numpy.bool_
),
data=self.current_matrix.parameters["rcu_dth_on"].astype(numpy.bool_),
compression="gzip",
)
except AttributeError as e:
logger.warning("Device values not written.")
except Exception as e:
raise Exception from e
except AttributeError:
current_group.create_dataset(
name="rcu_dth_on",
data=h5py.Empty("f"),
)
class BstHdf5Writer(HDF5Writer):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment