Changeset 2843
- Timestamp:
- 05/12/16 15:42:41 (7 years ago)
- Location:
- TOOLS/ConsoGENCMIP6/bin
- Files:
-
- 1 added
- 2 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 ... -
TOOLS/ConsoGENCMIP6/bin/plot_store.py
r2717 r2843 150 150 151 151 ######################################## 152 def get_aliases(alias_file): 153 154 res = {} 155 156 if os.path.isfile(alias_file): 157 try: 158 data = np.genfromtxt( 159 os.path.join(alias_file), 160 skip_header=2, 161 converters={ 162 0: str, 163 1: str, 164 2: str, 165 3: str, 166 }, 167 missing_values="", 168 ) 169 except Exception as rc: 170 print("Empty file {}:\n{}".format(filein, rc)) 171 exit(1) 172 173 for alias, login, _, _ in data: 174 res[login] = alias 175 176 return res 177 178 179 ######################################## 152 180 def plot_init(): 153 181 paper_size = np.array([29.7, 21.0]) … … 168 196 169 197 ######################################## 170 def plot_config( ax, coords, ylabels, dirnames, title,198 def plot_config(fig, ax, coords, ylabels, dirnames, title, 171 199 tot_volume, tot_volume_init, delta): 172 200 """ … … 183 211 ax.ticklabel_format(axis="x", style="sci", scilimits=(0, 0)) 184 212 ax.set_yticks(coords, minor=False) 185 ax.set_yticklabels(ylabels, size="x -small", fontweight="bold")213 ax.set_yticklabels(ylabels, size="xx-small", fontweight="bold") 186 214 ax.invert_yaxis() 187 215 … … 197 225 # 3) Define axes title 198 226 ax.set_xlabel("$To$", fontweight="bold") 227 228 # 4) Define plot size 229 fig.subplots_adjust( 230 left=0.08, 231 bottom=0.09, 232 right=0.93, 233 top=0.93, 234 ) 199 235 200 236 # ... Main title and legend ... … … 264 300 get_input_files(DIR["DATA"], [OUT["SINIT"]]) 265 301 302 alias_file = os.path.join( 303 "bin", 304 "alias_catalog.dat", 305 ) 306 266 307 img_name = os.path.splitext( 267 308 os.path.basename(__file__) … … 279 320 print(fmt_str.format("file_init", file_init)) 280 321 print(fmt_str.format("img_name", img_name)) 322 323 # .. Get alias info .. 324 # ==================== 325 alias_dict = get_aliases(alias_file) 281 326 282 327 # .. Get project info .. … … 316 361 # .. Compute data to be plotted .. 317 362 # ================================ 318 ylabels = [item.login for item in selected_items] 363 ylabels = [ 364 alias_dict[item.login] 365 if item.login in alias_dict 366 else str(hash(item.login)) 367 for item in selected_items 368 ] 319 369 values = np.array( 320 370 [item.dirsize.convert_size("T").size for item in selected_items], … … 325 375 dtype=float 326 376 ) 327 dirnames = [item.dirname for item in selected_items] 377 dirnames = [ 378 "/".join(item.dirname.split("/")[6:]) for item in selected_items 379 ] 328 380 date = selected_items[0].date 329 381 … … 352 404 delta = tot_volume - tot_volume_init 353 405 354 plot_config( ax, coords, ylabels, dirnames, title,406 plot_config(fig, ax, coords, ylabels, dirnames, title, 355 407 SizeUnit(tot_volume, "T"), 356 408 SizeUnit(tot_volume_init, "T"),
Note: See TracChangeset
for help on using the changeset viewer.