- Timestamp:
- 02/03/16 11:14:35 (9 years ago)
- Location:
- TOOLS/ConsoGENCMIP6/bin
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/ConsoGENCMIP6/bin/libconso.py
r2517 r2717 167 167 168 168 ######################################## 169 def get_input_files(dir_data, file_list ):169 def get_input_files(dir_data, file_list, date=None): 170 170 """ 171 171 """ 172 172 res = [] 173 173 174 for filename in file_list: 174 for filebase in file_list: 175 if date: 176 filename = "_".join((filebase, date)) 177 else: 178 filename = filebase 179 175 180 res.append(get_last_file(dir_data, filename)) 176 181 … … 244 249 dates, utheos = zip(*data) 245 250 246 (x1, x2) = (np.nanargmin(utheos), np.nanargmax(utheos)) 251 x2 = len(utheos) - 1 252 for nb, elem in enumerate(utheos[-2::-1]): 253 if elem >= utheos[x2]: 254 break 255 x1 = x2 - nb + 1 247 256 248 257 m = np.array([[x1, 1.], [x2, 1.]]) … … 256 265 257 266 if poly_ok: 258 delta = int(round(polynome.r[0] + 1)) 259 260 d1 = dates[0] 261 self.date_init = d1 + dt.timedelta(days=delta) 267 delta = x1 - int(round(polynome.r[0])) 268 d1 = dates[x1] 269 self.date_init = d1 - dt.timedelta(days=delta) 262 270 else: 263 271 self.date_init = dt.datetime(self.deadline.year, 1, 1) -
TOOLS/ConsoGENCMIP6/bin/plot_bilan.py
r2633 r2717 242 242 from matplotlib.ticker import AutoMinorLocator 243 243 244 # ... Compute useful stuff ... 245 # ---------------------------- 246 multialloc = False 247 if conso_per_day_2: 248 date_inter = projet.date_init + dt.timedelta(days=projet.days//2) 249 if projet.date_init in dates: 250 xi = dates.index(projet.date_init) 251 else: 252 xi = 0 253 254 if projet.deadline in dates: 255 xf = dates.index(projet.deadline) 256 else: 257 xf = len(dates) + 1 258 259 if date_inter in dates: 260 xn = dates.index(date_inter) 261 yi = conso_per_day 262 yf = conso_per_day_2 263 multialloc = True 264 else: 265 if dates[-1] < date_inter: 266 xn = xf 267 yi = conso_per_day 268 yf = conso_per_day 269 elif dates[0] > date_inter: 270 xn = xi 271 yi = conso_per_day_2 272 yf = conso_per_day_2 273 244 274 # ... Config axes ... 245 275 # ------------------- … … 249 279 ymax = conso_max # + conso_max*.1 250 280 else: 251 ymax = 3. * max(conso_per_day, conso_per_day_2) 281 if multialloc: 282 ymax = 3. * max(yi, yf) 283 else: 284 ymax = 3. * yi 252 285 253 286 if conso_max > ymax: … … 274 307 ax_theo.set_ylim(0., 100) 275 308 276 # 2) Ticks labels 309 # 2) Plot ideal daily consumption in hours 310 line_color = "blue" 311 line_alpha = 0.5 312 line_label = "conso journaliÚre\nidéale (heures)" 313 ax_conso.plot( 314 [xi, xn, xn, xf], [yi, yi, yf, yf], 315 color=line_color, alpha=line_alpha, label=line_label, 316 ) 317 318 # 3) Ticks labels 277 319 (date_beg, date_end) = (dates[0], dates[-1]) 278 320 date_fmt = "{:%d-%m}" … … 300 342 yticks = list(ax_conso.get_yticks()) 301 343 yticks.append(conso_per_day) 302 if conso_per_day_2:344 if multialloc: 303 345 yticks.append(conso_per_day_2) 304 346 ax_conso.set_yticks(yticks) … … 307 349 ax_theo.tick_params(colors="firebrick") 308 350 ax_theo.yaxis.label.set_color("firebrick") 309 310 ax_conso.axhline(y=conso_per_day, color="blue", alpha=0.5,311 label="conso journaliÚre\nidéale (heures)")312 313 if conso_per_day_2:314 ax_conso.axhline(y=conso_per_day_2, color="blue", alpha=0.5)315 351 316 352 for x, d in zip(xcoord, dates): … … 319 355 linewidth=0.5, linestyle=":") 320 356 321 # 3) Define axes title357 # 4) Define axes title 322 358 for ax, label in ( 323 359 (ax_conso, "heures"), … … 327 363 ax.tick_params(axis="y", labelsize="small") 328 364 329 # 4) Define plot size365 # 5) Define plot size 330 366 fig.subplots_adjust( 331 367 left=0.08, … … 358 394 type=string_to_date, 359 395 help="date range: ssaa-mm-jj ssaa-mm-jj") 396 parser.add_argument("--date", action="store", 397 help="date to plot: ssaammjj") 360 398 parser.add_argument("-m", "--max", action="store_true", 361 399 help="plot with y_max = allocation") … … 394 432 395 433 (file_param, file_utheo, file_data) = \ 396 get_input_files(DIR["SAVEDATA"], 397 [OUT["PARAM"], OUT["UTHEO"], OUT["BILAN"]]) 434 get_input_files( 435 DIR["SAVEDATA"], 436 [OUT["PARAM"], OUT["UTHEO"], OUT["BILAN"]], 437 args.date 438 ) 398 439 399 440 img_name = os.path.splitext( … … 457 498 458 499 if projet.project == "gencmip6": 459 alloc1 = 5.e6460 alloc2 = projet.alloc - alloc1500 alloc1 = (1 * projet.alloc) / 3 501 alloc2 = (2 * projet.alloc) / 3 461 502 conso_per_day = 2 * alloc1 / projet.days 462 503 conso_per_day_2 = 2 * alloc2 / projet.days … … 520 561 # ... Save figure ... 521 562 # ------------------- 522 img_in = os.path.join(DIR["PLOT"], "{}.pdf".format(img_name)) 523 img_out = os.path.join(DIR["SAVEPLOT"], 524 "{}_{}.pdf".format(img_name, today)) 563 if args.date: 564 img_in = os.path.join( 565 DIR["PLOT"], "{}_{}.pdf".format(img_name, today) 566 ) 567 else: 568 img_in = os.path.join( 569 DIR["PLOT"], "{}.pdf".format(img_name) 570 ) 571 img_out = os.path.join( 572 DIR["SAVEPLOT"], 573 "{}_{}.pdf".format(img_name, today) 574 ) 525 575 526 576 plot_save(img_in, img_out, title, DIR) -
TOOLS/ConsoGENCMIP6/bin/plot_bilan_jobs.py
r2632 r2717 268 268 # 1) Range 269 269 conso_max = np.nanmax(consos) 270 jobs_max = np.nanmax(run_mean) 270 271 if args.max: 271 ymax = conso_max # + conso_max*.1 272 ymax = conso_max # * 1.1 273 ymax_jobs = jobs_max # * 1.1 272 274 else: 273 275 ymax = 3. * max(conso_per_day, conso_per_day_2) 276 ymax_jobs = max(conso_per_day, conso_per_day_2)/24. 274 277 275 278 if conso_max > ymax: … … 295 298 ax_conso.set_xlim(xmin, xmax) 296 299 ax_conso.set_ylim(0., ymax) 300 ax_jobs.set_ylim(0., ymax_jobs) 297 301 ax_theo.set_ylim(0., 100) 298 302 299 # 2) Ticks labels 303 # 2) Plot ideal daily consumption in hours 304 line_color = "blue" 305 line_alpha = 0.5 306 line_label = "conso journaliÚre\nidéale ({})" 307 for ax, y_div, label in ( 308 (ax_conso, 1., line_label.format("heures")), 309 (ax_jobs, 24., line_label.format("cÅurs")), 310 ): 311 if conso_per_day_2: 312 list_x = [0, xmax/2, xmax/2, xmax] 313 list_y = np.array( 314 [conso_per_day, conso_per_day, conso_per_day_2, conso_per_day_2], 315 dtype=float 316 ) 317 ax.plot( 318 list_x, list_y/y_div, 319 color=line_color, alpha=line_alpha, label=label, 320 ) 321 else: 322 ax.axhline( 323 y=conso_per_day/y_div, 324 color=line_color, alpha=line_alpha, label=label, 325 ) 326 327 # 3) Ticks labels 300 328 (date_beg, date_end) = (dates[0], dates[-1]) 301 329 date_fmt = "{:%d-%m}" … … 328 356 yticks.append(y) 329 357 ax.set_yticks(yticks) 330 ax.axhline(y=y, color="blue", alpha=0.5,331 label="conso journaliÚre\nidéale ({})".format(label))332 358 333 359 if conso_per_day_2: 334 360 yticks.append(conso_per_day_2) 335 ax_conso.axhline(y=conso_per_day_2, color="blue", alpha=0.5)336 ax_jobs.axhline(y=conso_per_day_2 / 24., color="blue", alpha=0.5)337 361 338 362 ax_theo.spines["right"].set_color("firebrick") … … 346 370 linewidth=0.5, linestyle=":") 347 371 348 # 3) Define axes title372 # 4) Define axes title 349 373 for ax, label in ( 350 374 (ax_conso, "heures"), … … 355 379 ax.tick_params(axis="y", labelsize="small") 356 380 357 # 4) Define plot size381 # 5) Define plot size 358 382 fig.subplots_adjust( 359 383 left=0.08, … … 488 512 489 513 if projet.project == "gencmip6": 490 alloc1 = 5.e6491 alloc2 = projet.alloc - alloc1514 alloc1 = (1 * projet.alloc) / 3 515 alloc2 = (2 * projet.alloc) / 3 492 516 conso_per_day = 2 * alloc1 / projet.days 493 517 conso_per_day_2 = 2 * alloc2 / projet.days -
TOOLS/ConsoGENCMIP6/bin/plot_jobs.py
r2632 r2717 122 122 """ 123 123 items = (item for item in self.itervalues() 124 if item.date.hour == 0) 124 if item.date >= projet.date_init and 125 item.date <= projet.deadline and 126 item.date.hour == 0) 125 127 items = sorted(items, key=lambda item: item.date) 126 128 … … 218 220 from matplotlib.ticker import AutoMinorLocator 219 221 222 # ... Compute useful stuff ... 223 # ---------------------------- 224 multialloc = False 225 if conso_per_day_2: 226 date_inter = projet.date_init + dt.timedelta(days=projet.days//2) 227 if projet.date_init in dates: 228 xi = dates.index(projet.date_init) 229 else: 230 xi = 0 231 232 if projet.deadline in dates: 233 xf = dates.index(projet.deadline) 234 else: 235 xf = len(dates) 236 237 if date_inter in dates: 238 xn = dates.index(date_inter) 239 yi = conso_per_day 240 yf = conso_per_day_2 241 multialloc = True 242 else: 243 if dates[-1] < date_inter: 244 xn = xf 245 yi = conso_per_day 246 yf = conso_per_day 247 elif dates[0] > date_inter: 248 xn = xi 249 yi = conso_per_day_2 250 yf = conso_per_day_2 251 220 252 # ... Config axes ... 221 253 # ------------------- 222 254 # 1) Range 223 255 xmin, xmax = xcoord[0]-1, xcoord[-1]+1 256 if multialloc: 257 ymax = 4. * max(yi, yf) 258 else: 259 ymax = 4. * yi 224 260 ax.set_xlim(xmin, xmax) 225 226 # 2) Ticks labels 261 ax.set_ylim(0, ymax) 262 263 # 2) Plot ideal daily consumption 264 line_color = "blue" 265 line_alpha = 0.5 266 line_label = "conso journaliÚre idéale" 267 ax.plot( 268 [xi, xn, xn, xf], [yi, yi, yf, yf], 269 color=line_color, alpha=line_alpha, label=line_label, 270 ) 271 272 # 3) Ticks labels 227 273 (date_beg, date_end) = (dates[0], dates[-1]) 228 274 … … 249 295 yticks = list(ax.get_yticks()) 250 296 yticks.append(conso_per_day) 251 if conso_per_day_2:297 if multialloc: 252 298 yticks.append(conso_per_day_2) 253 299 ax.set_yticks(yticks) 254 300 255 ax.axhline(y=conso_per_day, color="blue", alpha=0.5,256 label="conso journaliÚre idéale")257 258 if conso_per_day_2:259 ax.axhline(y=conso_per_day_2, color="blue", alpha=0.5)260 301 261 302 for x, d in zip(xcoord, dates): … … 263 304 ax.axvline(x=x, color="black", linewidth=1., linestyle=":") 264 305 265 # 3) Define axes title306 # 4) Define axes title 266 307 ax.set_ylabel("cÅurs", fontweight="bold") 267 308 ax.tick_params(axis="y", labelsize="small") 268 309 269 # 4) Define plot size310 # 5) Define plot size 270 311 fig.subplots_adjust( 271 312 left=0.08, … … 420 461 421 462 if projet.project == "gencmip6": 422 alloc1 = 5.e6423 alloc2 = projet.alloc - alloc1463 alloc1 = (1 * projet.alloc) / 3 464 alloc2 = (2 * projet.alloc) / 3 424 465 conso_per_day = 2 * alloc1 / (projet.days * 24.) 425 466 conso_per_day_2 = 2 * alloc2 / (projet.days * 24.) -
TOOLS/ConsoGENCMIP6/bin/plot_store.py
r2632 r2717 143 143 self.listdir.append(DirVolume(date, login, dirname, dirsize, 144 144 date_init, dirsize_init)) 145 self.add_to_total(dirsize) 145 if isinstance(dirsize, SizeUnit): 146 self.add_to_total(dirsize) 147 elif args.verbose: 148 print("No size for {}, {}".format(login, dirname)) 146 149 147 150
Note: See TracChangeset
for help on using the changeset viewer.