comparison scripts/score_plot.py @ 1066:a2a245542ae6

Scripts: test if folder name (default or provided via command line) exists
author Brecht De Man <BrechtDeMan@users.noreply.github.com>
date Tue, 11 Aug 2015 10:15:17 +0200
parents b2492aeafe8b
children 8d0061336b90
comparison
equal deleted inserted replaced
1065:b2492aeafe8b 1066:a2a245542ae6
53 print " Enables the confidence interval plot" 53 print " Enables the confidence interval plot"
54 print " ind | individual | -i" 54 print " ind | individual | -i"
55 print " Enables plot of individual ratings" 55 print " Enables plot of individual ratings"
56 print "" 56 print ""
57 print "PLOT OPTIONS" 57 print "PLOT OPTIONS"
58 print " legend | -l" 58 print " leg | legend | -l"
59 print " For individual plot: show legend with individual file names" 59 print " For individual plot: show legend with individual file names"
60 print " " 60 print " numeric value between 0 and 1, e.g. 0.95"
61 print " For confidence interval plot: confidence value"
61 assert False, ""# stop immediately after showing help #TODO cleaner way 62 assert False, ""# stop immediately after showing help #TODO cleaner way
62 63
63 # PLOT TYPES 64 # PLOT TYPES
64 elif arg == 'box' or arg == 'boxplot' or arg == '-b': 65 elif arg == 'box' or arg == 'boxplot' or arg == '-b':
65 enable_boxplot = True # show box plot 66 enable_boxplot = True # show box plot
79 if not enable_confidence: 80 if not enable_confidence:
80 print "WARNING: The numeric confidence value is only relevant when "+\ 81 print "WARNING: The numeric confidence value is only relevant when "+\
81 "confidence plot is enabled" 82 "confidence plot is enabled"
82 if float(arg)>0 and float(arg)<1: 83 if float(arg)>0 and float(arg)<1:
83 confidence = float(arg) 84 confidence = float(arg)
85 else:
86 print "WARNING: The confidence value needs to be between 0 and 1"
84 87
85 # FOLDER NAME 88 # FOLDER NAME
86 else: 89 else:
87 # assume it's the folder name 90 # assume it's the folder name
88 rating_folder = arg 91 rating_folder = arg
90 93
91 # at least one plot type should be selected: box plot by default 94 # at least one plot type should be selected: box plot by default
92 if not enable_boxplot and not enable_confidence and not enable_individual: 95 if not enable_boxplot and not enable_confidence and not enable_individual:
93 enable_boxplot = True 96 enable_boxplot = True
94 97
98 # check if folder_name exists
99 if not os.path.exists(rating_folder):
100 #the file is not there
101 print "Folder '"+rating_folder+"' does not exist."
102 sys.exit() # terminate script execution
103 elif not os.access(os.path.dirname(rating_folder), os.W_OK):
104 #the file does exist but write rating_folder are not given
105 print "No write privileges in folder '"+rating_folder+"'."
106
107
95 # CONFIGURATION 108 # CONFIGURATION
96
97 # Enter folder where rating CSV files are (generated with score_parser.py or same format).
98 rating_folder = '../saves/ratings/' # folder with rating csv files
99 109
100 # Font settings 110 # Font settings
101 font = {'weight' : 'bold', 111 font = {'weight' : 'bold',
102 'size' : 10} 112 'size' : 10}
103 plt.rc('font', **font) 113 plt.rc('font', **font)