Changeset 2843 for TOOLS/ConsoGENCMIP6/bin/plot_login.py
- Timestamp:
- 05/12/16 15:42:41 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/ConsoGENCMIP6/bin/plot_login.py
r2632 r2843 81 81 82 82 ######################################## 83 def get_aliases(alias_file): 84 85 res = {} 86 87 if os.path.isfile(alias_file): 88 try: 89 data = np.genfromtxt( 90 os.path.join(alias_file), 91 skip_header=2, 92 converters={ 93 0: str, 94 1: str, 95 2: str, 96 3: str, 97 }, 98 missing_values="", 99 ) 100 except Exception as rc: 101 print("Empty file {}:\n{}".format(filein, rc)) 102 exit(1) 103 104 for alias, login, _, _ in data: 105 res[login] = alias 106 107 return res 108 109 110 ######################################## 83 111 def plot_init(): 84 112 paper_size = np.array([29.7, 21.0]) … … 97 125 98 126 ######################################## 99 def plot_config( ax, ycoord, ylabels, title):127 def plot_config(fig, ax, ycoord, ylabels, title): 100 128 """ 101 129 """ … … 111 139 ax.ticklabel_format(axis="x", style="sci", scilimits=(0, 0)) 112 140 ax.set_yticks(ycoord, minor=False) 113 ax.set_yticklabels(ylabels, size="x -small", fontweight="bold")141 ax.set_yticklabels(ylabels, size="xx-small", fontweight="bold") 114 142 ax.invert_yaxis() 115 143 … … 119 147 # 3) Define axes title 120 148 ax.set_xlabel("heures", fontweight="bold") 149 150 # 4) Define plot size 151 fig.subplots_adjust( 152 left=0.08, 153 bottom=0.09, 154 right=0.93, 155 top=0.93, 156 ) 121 157 122 158 # ... Main title and legend ... … … 167 203 project_name, DIR, OUT = parse_config("bin/config.ini") 168 204 169 (file_param, file_utheo, file_data) = \ 170 get_input_files(DIR["SAVEDATA"], 171 [OUT["PARAM"], OUT["UTHEO"], OUT["LOGIN"]]) 205 (file_param, file_utheo, file_data) = get_input_files( 206 DIR["SAVEDATA"], 207 [OUT["PARAM"], OUT["UTHEO"], OUT["LOGIN"]] 208 ) 209 210 alias_file = os.path.join( 211 "bin", 212 "alias_catalog.dat", 213 ) 172 214 173 215 img_name = os.path.splitext( … … 186 228 print(fmt_str.format("img_name", img_name)) 187 229 230 # .. Get alias info .. 231 # ==================== 232 alias_dict = get_aliases(alias_file) 233 188 234 # .. Get project info .. 189 235 # ====================== … … 213 259 214 260 ycoord = np.linspace(1, nb_items, num=nb_items) 215 ylabels = [item.login for item in selected_items] 261 ylabels = [ 262 alias_dict[item.login] 263 if item.login in alias_dict 264 else str(hash(item.login)) 265 for item in selected_items 266 ] 216 267 consos = np.array([item.conso for item in selected_items], 217 268 dtype=float) … … 234 285 date 235 286 ) 236 plot_config( ax, ycoord, ylabels, title)287 plot_config(fig, ax, ycoord, ylabels, title) 237 288 238 289 # ... Save figure ...
Note: See TracChangeset
for help on using the changeset viewer.