Commit 734b5f53 authored by Ivo Peterek's avatar Ivo Peterek

ENH: overall application evaluation table from csv files #13

parent 31abcfd4
......@@ -31,7 +31,7 @@ class DataLoad:
self.file_name_args = self.config_dic['file_name_args_tup']
self.all_nested_regs = self.config_dic['all_nested_regs']
self.data = {"plot_summary_data": [], "nested_regions_report_data": [], "config": self.config_dic}
self.data = {"plot_summary_data": [], "nested_regions_report_data": [], "config": self.config_dic, "overall_vals": []}
#TODO: Multiple keys
try:
......@@ -41,11 +41,13 @@ class DataLoad:
self.key_unit = ''
self.default_key = ''
self.default_funcLabel_val = str(round(float(self.config_dic['def_label_val'])*self.funcLabel_multiplier, 2))
self.default_funcLabel_val = self.config_dic['def_label_val']
self.default_funcLabel_str = str(round(float(self.default_funcLabel_val)*self.funcLabel_multiplier, 2))
self.funcLabel_unit = self.config_dic['func_label_unit']
self.default_xLabel_val = self.config_dic['def_x_val']
self.default_xLabel_unit = self.config_dic['x_val_unit']
self.xLabel_unit = self.config_dic['x_val_unit']
self.default_xLabel_str = str(round(float(self.default_xLabel_val) * self.funcLabel_multiplier, 2))
measurement_info_path = Path(self.data_path + '/measurementInfo.json')
if measurement_info_path.exists():
......@@ -55,10 +57,27 @@ class DataLoad:
self.measurement_params = measurement_info_file_data['DataFormat'].split("_")
except json.decoder.JSONDecodeError:
self.__print_error_msg('measurementInfo.json file is not in valid format')
print(self.measurement_params)
self.__load_data_from_csv()
# self.__load_data_from_hdf5()
self.__compute_overall_table()
def __compute_overall_table(self):
main_region_data = self.data["plot_summary_data"]
for y_label_data in main_region_data:
static_savings = y_label_data[1]['def_val'] - y_label_data[1]['optim_y_val']
static_savings_percentage = static_savings/(y_label_data[1]['def_val']*0.01)
table_line = (y_label_data[0]['arg']+',\n'+y_label_data[0]['category'],
self.default_key+self.key_unit+',\n'+self.default_funcLabel_str+
self.funcLabel_unit+',\n'+self.default_xLabel_str+self.xLabel_unit,
str(round(y_label_data[1]['def_val'],2))+y_label_data[0]['unit'],
y_label_data[1]['opt_key']+self.key_unit+',\n'+
str(round(float(y_label_data[1]['optim_func_label_value'])*self.funcLabel_multiplier, 2))
+self.funcLabel_unit+',\n'+
str(round(float(y_label_data[1]['optim_x_val'])*self.xLabel_multiplier, 2))+self.xLabel_unit,
str(round(static_savings,2))+y_label_data[0]['unit']+' ('+str(round(static_savings_percentage,2))+'%)',
'')#TODO dynamic savings
self.data['overall_vals'].append(table_line)
def __load_data_from_csv(self):
......@@ -131,12 +150,14 @@ class DataLoad:
'heat_data': [],
# list of lists one of lists contains tuples -> (xLabel, value_in_heatmap)
'key': (opt_key+';'+self.key_unit,), # optimal key from mericConfig, TODO: multiple keys
'opt_key': opt_key,
'lines': [], # funcLabel values
'optim_func_label_value': self.meric_config_energy_data[region][funcLabel_meric_param], # optim vals
'optim_x_val': self.meric_config_energy_data[region][xLabel_meric_param],
'optim_y_val': sys.maxsize,
'def_val': '',
'x_label_name': self.file_name_args[xLabel_pos][1],
'x_label_unit': self.config_dic['x_val_unit']}])
'x_label_unit': self.xLabel_unit}])
act_category = None
......@@ -159,7 +180,7 @@ class DataLoad:
new_dict_key = key + " " + val[0]
dict_plot_data_ylabel[new_dict_key] = 0
if key_val == opt_key:
if key_val == opt_key or key_val == self.default_key:
with open(csv_path) as csv_file:
reader = csv.reader(csv_file, delimiter=',')
for line in reader:
......@@ -191,20 +212,24 @@ class DataLoad:
#check if xlabel is existing in heat_data
new_xLabel_val = round(float(xlabel_val) * self.xLabel_multiplier, 2)
if len(data[1]['heat_data'][index_of_line]) > 0:
exists =False
val_exists =False
for num, xLabel_val_tup in enumerate(data[1]['heat_data'][index_of_line]):
if xLabel_val_tup[0] == new_xLabel_val:
exists = True
val_exists = True
new_xLabel_val_tup = (new_xLabel_val, (xLabel_val_tup[1] + value)/2)
data[1]['heat_data'][index_of_line][num] = new_xLabel_val_tup
print()
if not exists:
value = new_xLabel_val_tup[1]
if not val_exists:
data[1]['heat_data'][index_of_line].append(
(new_xLabel_val, value))
else:
data[1]['heat_data'][index_of_line].append(
(new_xLabel_val, value))
if xlabel_val == str(self.default_xLabel_val) and funclabel_val == str(self.default_funcLabel_val):
data[1]['def_val'] = value
if value < data[1]['optim_y_val']: #optimal value is just minimum
data[1]['optim_y_val'] = value
else:
......
......@@ -106,7 +106,10 @@ class MainMenu(QtWidgets.QFrame, design_main_menu.Ui_MainMenu):
break
def __plot(self):
self.plot_window = data_plot.Window(ownData=self.radar_data.raw_data)
if self.data_no_radar:
self.plot_window = data_plot.Window(ownData=self.data_no_radar.data,)
else:
self.plot_window = data_plot.Window(ownData=self.radar_data.raw_data)
self.plot_window.show()
self.plot_window.sendInfo.connect(partial(self.__getTeXInfo,'plots'))
self.sub_windows.append(self.plot_window)
......@@ -155,7 +158,10 @@ class MainMenu(QtWidgets.QFrame, design_main_menu.Ui_MainMenu):
self.sub_windows.append(self.nested_region_window)
def __overall(self):
self.overall_window = all_tables.IndicSelectWindow(table="overall", ownData=self.radar_data.raw_data)
if self.data_no_radar:
self.overall_window = all_tables.IndicSelectWindow(table="overall", ownData=self.data_no_radar.data)
else:
self.overall_window = all_tables.IndicSelectWindow(table="overall", ownData=self.radar_data.raw_data)
self.overall_window.createTable()
self.overall_window.show()
self.overall_window.sendInfo.connect(partial(self.__getTeXInfo,'overall'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment