From c61066b9fc39a11ec4a23a93bf5d993a4c0ffc7e Mon Sep 17 00:00:00 2001 From: stedif <stefano.difrischia@inaf.it> Date: Mon, 18 Oct 2021 11:21:19 +0200 Subject: [PATCH] L2SS-406: test masked values query with python --- devices/toolkit/archiver.py | 35 +++++++++++++++++++-- devices/toolkit/archiver_config/lofar2.json | 4 +-- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/devices/toolkit/archiver.py b/devices/toolkit/archiver.py index 0991b05c6..9d3d18cb9 100644 --- a/devices/toolkit/archiver.py +++ b/devices/toolkit/archiver.py @@ -419,11 +419,11 @@ class Retriever(): return result def get_attribute_value_by_interval(self,attribute_fqname: str, start_time: datetime, stop_time: datetime): - ''' + """ Takes as input the attribute name and a certain starting and ending point-time. The datetime format is pretty flexible (e.g. "YYYY-MM-dd hh:mm:ss"). Returns a list of timestamps and a list of values - ''' + """ attr_id = self.get_attribute_id(attribute_fqname) attr_datatype = self.get_attribute_datatype(attribute_fqname) attr_table_name = 'att_'+str(attr_datatype) @@ -437,4 +437,33 @@ class Retriever(): except AttributeError as e: raise Exception(f"Empty result! Attribute {attribute_fqname} not found") from e return result - + + def get_masked_fpga_temp(self,start_time: datetime, stop_time: datetime,temp_attr_name:str='LTS/SDP/1/fpga_temp_r', + mask_attr_name:str='LTS/SDP/1/tr_fpga_mask_r'): + """ + Returns a list of SDP/fpga_temp_r values, but only if SDP/tr_fpga_mask_r values are TRUE + """ + mask_values = self.get_attribute_value_by_interval(mask_attr_name,start_time,stop_time) + temp_values = self.get_attribute_value_by_interval(temp_attr_name,start_time,stop_time) + # Since timestamps can be not syncrhonized, remove first or last element from arrays + if len(mask_values)==len(temp_values): + first_mask_datatime = mask_values[0].data_time + first_temp_datatime = temp_values[0].data_time + if (first_mask_datatime>first_temp_datatime): + mask_values = mask_values[:-int(mask_values[0].dim_x_r)] + temp_values = temp_values[int(temp_values[0].dim_x_r):] + elif (first_mask_datatime<first_temp_datatime): + mask_values = mask_values[int(mask_values[0].dim_x_r)] + temp_values = temp_values[:-int(temp_values[0].dim_x_r):] + else: + raise Exception + # Convert DB Array records into Python lists + mask_data = build_array_from_record(mask_values,mask_values[0].dim_x_r) + temp_data = build_array_from_record(temp_values,temp_values[0].dim_x_r) + # Extract only the value from the array + mask_array_values = get_values_from_record(mask_data) + temp_array_values = get_values_from_record(temp_data) + # Multiply the matrix + #masked_values = np.multiply(temp_array_values,mask_array_values) + masked_values = np.ma.masked_array(temp_array_values,mask=np.invert(mask_array_values.astype(bool))) + return masked_values, mask_values, temp_values diff --git a/devices/toolkit/archiver_config/lofar2.json b/devices/toolkit/archiver_config/lofar2.json index f0b189701..914fe15b7 100644 --- a/devices/toolkit/archiver_config/lofar2.json +++ b/devices/toolkit/archiver_config/lofar2.json @@ -6,12 +6,12 @@ "devices":{ "LTS/RECV/1": { "environment": "development", - "include": ["rcu_temperature_r"], + "include": [], "exclude": ["CLK_Enable_PWR_R","CLK_I2C_STATUS_R","CLK_PLL_error_R","CLK_PLL_locked_R","CLK_translator_busy_R"] }, "LTS/SDP/1": { "environment": "development", - "include": [], + "include": ["FPGA_temp_R","TR_fpga_mask_R"], "exclude": [] }, "LTS/SST/1": { -- GitLab