Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ountry into Test_CBT
  • Loading branch information
GaelleLeTreut committed Sep 6, 2019
2 parents 6b98179 + 8e9b239 commit 9e65341
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
18 changes: 13 additions & 5 deletions outputs_display/charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ def create_radar_charts(values, time_steps, title, colors, legend, nb_folds, ext
fig, axes = plt.subplots(figsize=(10, 10), nrows=nb_lines, ncols=nb_col,
subplot_kw=dict(projection='radar'))

if type(axes[0]) != type(axes):
if nb_lines == 1:
axes = [axes]

if nb_col == 1:
axes = [[ax] for ax in axes]

for i, ax_row in enumerate(axes):
Expand Down Expand Up @@ -147,7 +150,7 @@ def create_radar_charts(values, time_steps, title, colors, legend, nb_folds, ext
def build_charts(file_name, charts_to_draw, save_path, colors=['b', 'r', 'g', 'm', 'y'], type_chart='bar', norm_ref=None):

# Load data of files to read
outputs = ro.read_output_file(file_name)
outputs, name_of = ro.read_output_file(file_name)

# lines kept
lines_to_draw = []
Expand Down Expand Up @@ -214,10 +217,15 @@ def build_charts(file_name, charts_to_draw, save_path, colors=['b', 'r', 'g', 'm

nb_folds = len(list(outputs.keys()))

# Legend
ids = list(outputs.keys())
legend = [name_of[id] for id in ids]

# BAR CHARTS

if type_chart == 'bar':
create_bar_charts(time_steps, values_chart, chart, list(outputs.keys()), nb_folds)

create_bar_charts(time_steps, values_chart, chart, legend, nb_folds)

# RADAR CHARTS

Expand All @@ -229,7 +237,7 @@ def build_charts(file_name, charts_to_draw, save_path, colors=['b', 'r', 'g', 'm
end = min(len(time_steps), i+nb_max)
time_steps_part = time_steps[deb:end]

create_radar_charts(values_chart, time_steps_part, chart, colors, list(outputs.keys()), nb_folds,ext='_'+str(ext))
create_radar_charts(values_chart, time_steps_part, chart, colors, legend, nb_folds,ext='_'+str(ext))
ext += 1
else:
raise Exception('type_chart unknown')
Expand Down Expand Up @@ -304,5 +312,5 @@ def data_macro():
build_charts(work_file, charts_to_draw, save_path, type_chart='bar')

work_file, charts_to_draw2, save_path = data_macro()
build_charts(work_file, charts_to_draw, save_path, type_chart='radar', norm_ref='NDC')
build_charts(work_file, charts_to_draw, save_path, type_chart='radar')#, norm_ref='NDC')

6 changes: 3 additions & 3 deletions outputs_display/comp_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
def output_table(file_name, lines_to_remove, save_path):

# Load data of file_name
outputs = ro.read_output_file(file_name)
outputs, name_of = ro.read_output_file(file_name)

# Remove lines
for out_fold in outputs.keys():
Expand Down Expand Up @@ -43,8 +43,8 @@ def output_table(file_name, lines_to_remove, save_path):
file = outputs[out_fold][time]

# Legend for the column
table[0].append(out_fold)
table[1].append(time)
table[0].append(name_of[out_fold])
table[1].append(time[-4:])

# Data of the column
for i in range(len(file)):
Expand Down
19 changes: 13 additions & 6 deletions outputs_display/read_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def read_output_file(file_to_read):
file_to_read : *prefix* of a file to load."""

def fold_name(out_fold):
"""Record the name of the output out_foldectory."""
"""Record the name of the output directory."""
name = ''
if 'name.txt' in os.listdir(out_fold):
fichier = open(out_fold + 'name.txt', 'r')
Expand Down Expand Up @@ -85,18 +85,25 @@ def remove_empty_line(csv_file):
# Fill the data structure

outputs = dict()
name_of = dict()
dir_id = 0

for out_fold in list_outputs:

if not os.path.isdir(out_fold):
print('Warning : ' + out_fold + ' is not a out_foldectory')
print('Warning : ' + out_fold + ' is not a directory')

else:
# Name of the out_foldectory
# Name of the directory
name = fold_name(out_fold)

# ID of directory
dir_id += 1
id = 'ID_' + str(dir_id)

# Data structure
outputs[name] = dict()
outputs[id] = dict()
name_of[id] = name

# Read time sub-out_folders
for time in os.listdir(out_fold):
Expand All @@ -106,10 +113,10 @@ def remove_empty_line(csv_file):
time_path = out_fold + time + '/'

# Load the data
outputs[name][time] = load_data(file_to_read,
outputs[id][time] = load_data(file_to_read,
time_path)

return outputs
return outputs, name_of


def record_first_col(outputs, file_name):
Expand Down

0 comments on commit 9e65341

Please sign in to comment.