Skip to content
Snippets Groups Projects
Commit 50cd3883 authored by Stefano Di Frischia's avatar Stefano Di Frischia
Browse files

L2SS-869: fix bugs and integration test

parent 9f01cb79
Branches
Tags
1 merge request!426Resolve L2SS-869 "Improve querying in stats writer"
......@@ -15,6 +15,7 @@ from tangostationcontrol.statistics import reader
from tangostationcontrol.statistics.writer import entry
import sys
from h5py import Empty
from os.path import dirname, isfile, join
from tempfile import TemporaryDirectory
from unittest import mock
......@@ -182,9 +183,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.tolist(), Empty("f"))
self.assertEqual(stat.rcu_band_select.tolist(), Empty("f"))
self.assertEqual(stat.rcu_dth_on.tolist(), Empty("f"))
def test_SST_statistics_with_device_in_off(self):
self.setup_recv_proxy()
......@@ -222,6 +223,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.tolist(), Empty("f"))
self.assertEqual(stat.rcu_band_select.tolist(), Empty("f"))
self.assertEqual(stat.rcu_dth_on.tolist(), Empty("f"))
......@@ -203,9 +203,9 @@ 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"]
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"))
self.rcu_dth_on = numpy.array(file.get(f"{group_key}/rcu_dth_on"))
self.rcu_attenuator_dB = numpy.array(file[group_key].attrs["rcu_attenuator_dB"])
self.rcu_band_select = numpy.array(file[group_key].attrs["rcu_band_select"])
self.rcu_dth_on = numpy.array(file[group_key].attrs["rcu_dth_on"])
# get XST specific stuff
if self.marker == "X":
......
......@@ -87,7 +87,7 @@ class HDF5Writer(ABC):
# Set device if any, defaults to None
self.device = device
self.device_attributes = None
self.device_attributes = {}
@abstractmethod
def decoder(self, packet):
......@@ -120,10 +120,6 @@ class HDF5Writer(ABC):
# grab the timestamp
statistics_timestamp = statistics_packet.timestamp()
# device attributes
if self.mode == 'SST':
self.device_attributes = statistics_packet.device_attributes()
# ignore packets with no timestamp, as they indicate FPGA processing was
# disabled and are useless anyway.
if statistics_packet.block_serial_number == 0:
......@@ -337,10 +333,18 @@ class SstHdf5Writer(HDF5Writer):
].astype(numpy.float32),
compression="gzip",
)
# store the device attributes
self.device_attributes["rcu_attenuator_dB"] = self.current_matrix.parameters["rcu_attenuator_dB"].astype(numpy.int64)
self.device_attributes["rcu_band_select"] = self.current_matrix.parameters["rcu_band_select"].astype(numpy.int64)
self.device_attributes["rcu_dth_on"] = self.current_matrix.parameters["rcu_dth_on"].astype(numpy.bool_)
# write the device attributes
attribute_names = ["rcu_attenuator_dB", "rcu_band_select", "rcu_dth_on"]
attribute_types = {"rcu_attenuator_dB": numpy.int64, "rcu_band_select" : numpy.int64, "rcu_dth_on" : bool}
for a in attribute_names:
if self.current_matrix.parameters[a] is None:
self.device_attributes[a] = h5py.Empty("f")
else:
self.device_attributes[a] = self.current_matrix.parameters[a].astype(attribute_types[a])
for k,v in self.device_attributes.items():
current_group.attrs[k] = v
class BstHdf5Writer(HDF5Writer):
def __init__(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment