From 4d01748983598ca02227de6992d1815f05b20cb2 Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Thu, 3 Mar 2022 14:57:06 +0100
Subject: [PATCH] L2SS-674: Fix statistics_writer for multiple subbands in XST

---
 .../statistics_writer/hdf5_writer.py                   | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tangostationcontrol/tangostationcontrol/statistics_writer/hdf5_writer.py b/tangostationcontrol/tangostationcontrol/statistics_writer/hdf5_writer.py
index d2bdbad1c..9e65f4e51 100644
--- a/tangostationcontrol/tangostationcontrol/statistics_writer/hdf5_writer.py
+++ b/tangostationcontrol/tangostationcontrol/statistics_writer/hdf5_writer.py
@@ -253,7 +253,10 @@ class xst_hdf5_writer(hdf5_writer):
 
     def write_values_matrix(self, current_group):
         # requires a function call to transform the xst_blocks in to the right structure
-        current_group.create_dataset(name="values", data=self.current_matrix.xst_values([self.subband_index])[0].astype(numpy.cfloat), compression="gzip")
+        #
+        # since we have a dedicated writer per subband_index, they all end up in slot 0
+        # in their writer, so we only need to store the first set of xst_values.
+        current_group.create_dataset(name="values", data=self.current_matrix.xst_values([0])[0].astype(numpy.cfloat), compression="gzip")
 
 
 class parallel_xst_hdf5_writer:
@@ -265,15 +268,12 @@ class parallel_xst_hdf5_writer:
 
         # function to create a new writer, to avoid having to store
         # all the init parameters just for this purpose.
-        #
         def new_writer(subband):
-            # Since we use a dedicated writer per subband, the data will end
-            # up at subband_index == 0 in each of them.
             return xst_hdf5_writer(
                        new_file_time_interval,
                        file_location,
                        decimation_factor,
-                       0)
+                       subband)
 
         self.new_writer = new_writer
 
-- 
GitLab