Changeset 2427 for TOOLS/ConsoGENCMIP6/bin/plot_bilan.py
- Timestamp:
- 03/02/15 17:43:15 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/ConsoGENCMIP6/bin/plot_bilan.py
r2426 r2427 39 39 #--------------------------------------- 40 40 def fill_data(self, filein): 41 data = np.genfromtxt( 42 filein, 43 skip_header=1, 44 converters={0: string_to_date, 45 1: string_to_float, 46 2: string_to_percent, 47 3: string_to_percent}, 48 missing_values="nan", 49 ) 41 """ 42 """ 43 try: 44 data = np.genfromtxt( 45 filein, 46 skip_header=1, 47 converters={0: string_to_date, 48 1: string_to_float, 49 2: string_to_percent, 50 3: string_to_percent}, 51 missing_values="nan", 52 ) 53 except: 54 print("Empty file {}".format(filein)) 55 exit(1) 50 56 51 57 for date, conso, real_use, theo_use in data: … … 226 232 227 233 228 ######################################## 229 def plot_save(img_name): 230 """ 231 """ 232 dpi = 200. 233 234 with PdfPages(img_name) as pdf: 235 pdf.savefig(dpi=dpi) 236 237 # pdf file's metadata 238 d = pdf.infodict() 239 d["Title"] = "Conso GENCMIP6" 240 d["Author"] = "plot_bilan.py" 241 # d["Subject"] = "Time spent over specific commands during create_ts \ 242 # jobs at IDRIS and four configurations at TGCC" 243 # d["Keywords"] = "bench create_ts TGCC IDRIS ncrcat" 244 # d["CreationDate"] = dt.datetime(2009, 11, 13) 245 # d["ModDate"] = dt.datetime.today() 234 # ######################################## 235 # def plot_save(img_name, titre): 236 # """ 237 # """ 238 # dpi = 200. 239 240 # img_in = os.path.join(DIR["PLOT"], "{}.pdf".format(img_name)) 241 242 # with PdfPages(img_in) as pdf: 243 # pdf.savefig(dpi=dpi) 244 245 # # pdf file's metadata 246 # d = pdf.infodict() 247 # d["Title"] = titre 248 # d["Author"] = os.path.basename(__file__) 249 # # d["Subject"] = "Time spent over specific commands during create_ts \ 250 # # jobs at IDRIS and four configurations at TGCC" 251 # # d["Keywords"] = "bench create_ts TGCC IDRIS ncrcat" 252 # # d["CreationDate"] = dt.datetime(2009, 11, 13) 253 # # d["ModDate"] = dt.datetime.today() 254 255 # if os.path.isdir(DIR["SAVEPLOT"]): 256 # img_out = os.path.join(DIR["SAVEPLOT"], 257 # "{}_{}.pdf".format(img_name, today)) 258 # shutil.copy(img_in, img_out) 246 259 247 260 … … 287 300 288 301 import matplotlib.pyplot as plt 289 from matplotlib.backends.backend_pdf import PdfPages302 # from matplotlib.backends.backend_pdf import PdfPages 290 303 291 304 if not args.show: … … 294 307 # ... Files and directories ... 295 308 # ----------------------------- 296 file_param = get_last_file(DIR["SAVEDATA"], OUT["PARAM"]) 297 file_utheo = get_last_file(DIR["SAVEDATA"], OUT["UTHEO"]) 298 file_bilan = get_last_file(DIR["SAVEDATA"], OUT["BILAN"]) 299 300 if file_param is None or \ 301 file_utheo is None or \ 302 file_bilan is None: 303 print("Missing one or more input files, we stop.") 304 print("=> PARAM: {}\n=> UTHEO: {}\n=> BILAN: {}".format( 305 file_param, file_utheo, file_bilan) 306 ) 307 exit(1) 309 (file_param, file_utheo, file_data) = \ 310 get_input_files(DIR["SAVEDATA"], 311 [OUT["PARAM"], OUT["UTHEO"], OUT["BILAN"]]) 308 312 309 313 img_name = "bilan" … … 313 317 print(file_param) 314 318 print(file_utheo) 315 print(file_ bilan)319 print(file_data) 316 320 print(img_name) 317 321 print(today) 318 print(DIR)319 print(OUT)320 322 321 323 # .. Get project info .. … … 333 335 # ... Extract data from file ... 334 336 # ------------------------------ 335 bilan.fill_data(file_ bilan)337 bilan.fill_data(file_data) 336 338 # ... Compute theoratical use from known data ... 337 339 # ------------------------------------------------ … … 401 403 # ... Save figure ... 402 404 # ------------------- 403 # plot_save(os.path.join(DIR["PLOT"], img_name))404 405 img_in = os.path.join(DIR["PLOT"], "{}.pdf".format(img_name)) 405 plot_save(img_in) 406 if os.path.isdir(DIR["SAVEPLOT"]): 407 img_out = os.path.join(DIR["SAVEPLOT"], 408 "{}_{}.pdf".format(img_name, today)) 409 shutil.copy(img_in, img_out) 406 img_out = os.path.join(DIR["SAVEPLOT"], 407 "{}_{}.pdf".format(img_name, today)) 408 409 plot_save(img_in, img_out, "Conso GENCMIP6") 410 410 411 411 # ... Publish figure on dods ...
Note: See TracChangeset
for help on using the changeset viewer.