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

L2SS-406: test masked values query with python

parent 75ffb1c2
No related branches found
No related tags found
1 merge request!190Resolve L2SS-406 "Grafana archiver"
...@@ -419,11 +419,11 @@ class Retriever(): ...@@ -419,11 +419,11 @@ class Retriever():
return result return result
def get_attribute_value_by_interval(self,attribute_fqname: str, start_time: datetime, stop_time: datetime): 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. 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"). The datetime format is pretty flexible (e.g. "YYYY-MM-dd hh:mm:ss").
Returns a list of timestamps and a list of values Returns a list of timestamps and a list of values
''' """
attr_id = self.get_attribute_id(attribute_fqname) attr_id = self.get_attribute_id(attribute_fqname)
attr_datatype = self.get_attribute_datatype(attribute_fqname) attr_datatype = self.get_attribute_datatype(attribute_fqname)
attr_table_name = 'att_'+str(attr_datatype) attr_table_name = 'att_'+str(attr_datatype)
...@@ -437,4 +437,33 @@ class Retriever(): ...@@ -437,4 +437,33 @@ class Retriever():
except AttributeError as e: except AttributeError as e:
raise Exception(f"Empty result! Attribute {attribute_fqname} not found") from e raise Exception(f"Empty result! Attribute {attribute_fqname} not found") from e
return result 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
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
"devices":{ "devices":{
"LTS/RECV/1": { "LTS/RECV/1": {
"environment": "development", "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"] "exclude": ["CLK_Enable_PWR_R","CLK_I2C_STATUS_R","CLK_PLL_error_R","CLK_PLL_locked_R","CLK_translator_busy_R"]
}, },
"LTS/SDP/1": { "LTS/SDP/1": {
"environment": "development", "environment": "development",
"include": [], "include": ["FPGA_temp_R","TR_fpga_mask_R"],
"exclude": [] "exclude": []
}, },
"LTS/SST/1": { "LTS/SST/1": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment