2   :filename: gen_output.py 
    3   :synopsis: Main driver for dfnGen output report 
    5   :maintainer: Jeffrey Hyman  
    6   :moduleauthor: Jeffrey Hyman <jhyman@lanl.gov> 
    9 import matplotlib.pylab 
as plt
 
   14     """ Gathers information from the file 'rejections.dat' about FRAM and creates a bar-chart named fram_information.png  
   19             Output report dictionary containing general parameters. See output_report for more details 
   27         Output image is named fram_information.png in the network sub-directory 
   32         print(
"--> Plotting FRAM information")
 
   35     with open(
'rejections.dat', 
"r") 
as fp:
 
   36         for line 
in fp.readlines():
 
   37             parsed_line = line.split(
": ")
 
   38             variable = parsed_line[0]
 
   39             value = parsed_line[1].rstrip()
 
   40             rejections[variable] = int(value)
 
   41     total_number_of_rejections = float(sum(rejections.values()))
 
   42     fig, axs = plt.subplots(figsize=(16, 8))
 
   43     plt.title(
"FRAM information")
 
   47     for key 
in rejections.keys():
 
   49         cnts.append(rejections[key])
 
   51     cnts = np.asarray(cnts)
 
   52     sort_index = np.argsort(cnts)[::-1]
 
   53     cnts = cnts[sort_index]
 
   56         new_labels.append(labels[i])
 
   60     y_pos = np.arange(len(labels))
 
   62     horizBar = axs.barh(y_pos,
 
   70     axs.set_yticklabels(labels, fontsize=14)
 
   72     axs.set_xlabel(
'Number of re-samples', fontsize=14)
 
   73     axs.set_xticklabels(axs.get_xticks().astype(int), fontsize=16)
 
   75     axs.axis([0, 1.1 * max(cnts), axs.get_ylim()[0], axs.get_ylim()[1]])
 
   76     axs.set_title(
"Re-sampling Histogram", fontsize=18)
 
   80         width = bar.get_width()
 
   81         label = f
"  {int(width):d}\n  {100*width/total_number_of_rejections:0.2f}\%" 
   82         axs.text(bar.get_width() + 2,
 
   83                  bar.get_y() + 0.5 * h,
 
   87     plt.savefig(f
"{params['output_dir']}/network/fram_information.png")