Changeset 2427
- Timestamp:
- 03/02/15 17:43:15 (9 years ago)
- Location:
- TOOLS/ConsoGENCMIP6
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/ConsoGENCMIP6/bin/gencmip6.py
r2421 r2427 96 96 os.chdir(current_dir) 97 97 return res 98 99 100 ######################################## 101 def get_input_files(dir_data, file_list): 102 """ 103 """ 104 res = [] 105 106 for filename in file_list: 107 res.append(get_last_file(dir_data, filename)) 108 109 if None in res: 110 print("\nMissing one or more input files, we stop.") 111 for f_in, f_out in zip(file_list, res): 112 print("=> {}: {}".format(f_in, f_out)) 113 exit(1) 114 115 return res 116 117 118 ######################################## 119 def plot_save(img_in, img_out, title): 120 """ 121 """ 122 from matplotlib.backends.backend_pdf import PdfPages 123 124 dpi = 200. 125 126 # img_in = os.path.join(DIR["PLOT"], "{}.pdf".format(img_name)) 127 128 with PdfPages(img_in) as pdf: 129 pdf.savefig(dpi=dpi) 130 131 # pdf file's metadata 132 d = pdf.infodict() 133 d["Title"] = title 134 d["Author"] = os.path.basename(__file__) 135 # d["Subject"] = "Time spent over specific commands during create_ts \ 136 # jobs at IDRIS and four configurations at TGCC" 137 # d["Keywords"] = "bench create_ts TGCC IDRIS ncrcat" 138 # d["CreationDate"] = dt.datetime(2009, 11, 13) 139 # d["ModDate"] = dt.datetime.today() 140 141 if os.path.isdir(DIR["SAVEPLOT"]): 142 # img_out = os.path.join(DIR["SAVEPLOT"], 143 # "{}_{}.pdf".format(img_name, suffix)) 144 shutil.copy(img_in, img_out) 98 145 99 146 -
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 ... -
TOOLS/ConsoGENCMIP6/bin/plot_login.py
r2425 r2427 10 10 import os.path 11 11 import numpy as np 12 # import matplotlib.pyplot as plt13 # from matplotlib.backends.backend_pdf import PdfPages14 12 15 13 # Application library imports … … 26 24 #--------------------------------------- 27 25 def fill_data(self, filein): 28 data = np.genfromtxt( 29 filein, 30 skip_header=1, 31 converters={0: string_to_date, 32 1: str}, 33 missing_values="nan", 34 ) 26 """ 27 """ 28 try: 29 data = np.genfromtxt( 30 filein, 31 skip_header=1, 32 converters={0: string_to_date, 33 1: str}, 34 missing_values="nan", 35 ) 36 except: 37 print("Empty file {}".format(filein)) 38 exit(1) 35 39 36 40 for date, login, conso in data: … … 87 91 """ 88 92 """ 89 print(ycoord)90 print(consos)91 92 93 ax.barh(ycoord, consos, align="center", color="linen", 93 94 linewidth=0.2, label="conso (heures)") … … 119 120 120 121 121 ######################################## 122 def plot_save(img_name): 123 """ 124 """ 125 dpi = 200. 126 127 with PdfPages(img_name) as pdf: 128 pdf.savefig(dpi=dpi) 129 130 # pdf file's metadata 131 d = pdf.infodict() 132 d["Title"] = "Conso GENCMIP6 par login" 133 d["Author"] = "plot_bilan.py" 134 # d["Subject"] = "Time spent over specific commands during create_ts \ 135 # jobs at IDRIS and four configurations at TGCC" 136 # d["Keywords"] = "bench create_ts TGCC IDRIS ncrcat" 137 # d["CreationDate"] = dt.datetime(2009, 11, 13) 138 # d["ModDate"] = dt.datetime.today() 122 # ######################################## 123 # def plot_save(img_name): 124 # """ 125 # """ 126 # dpi = 200. 127 128 # img_in = os.path.join(DIR["PLOT"], "{}.pdf".format(img_name)) 129 130 # with PdfPages(img_in) as pdf: 131 # pdf.savefig(dpi=dpi) 132 133 # # pdf file's metadata 134 # d = pdf.infodict() 135 # d["Title"] = "Conso GENCMIP6 par login" 136 # d["Author"] = "plot_bilan.py" 137 # # d["Subject"] = "Time spent over specific commands during create_ts \ 138 # # jobs at IDRIS and four configurations at TGCC" 139 # # d["Keywords"] = "bench create_ts TGCC IDRIS ncrcat" 140 # # d["CreationDate"] = dt.datetime(2009, 11, 13) 141 # # d["ModDate"] = dt.datetime.today() 142 143 # if os.path.isdir(DIR["SAVEPLOT"]): 144 # img_out = os.path.join(DIR["SAVEPLOT"], 145 # "{}_{}.pdf".format(img_name, today)) 146 # shutil.copy(img_in, img_out) 139 147 140 148 … … 173 181 174 182 import matplotlib.pyplot as plt 175 from matplotlib.backends.backend_pdf import PdfPages183 # from matplotlib.backends.backend_pdf import PdfPages 176 184 177 185 if not args.show: … … 180 188 # ... Files and directories ... 181 189 # ----------------------------- 182 file_param = get_last_file(DIR["SAVE"], OUT["PARAM"]) 183 file_utheo = get_last_file(DIR["SAVE"], OUT["UTHEO"]) 184 file_login = get_last_file(DIR["SAVE"], OUT["LOGIN"]) 185 img_name = "bilan.pdf" 190 (file_param, file_utheo, file_data) = \ 191 get_input_files(DIR["SAVEDATA"], 192 [OUT["PARAM"], OUT["UTHEO"], OUT["LOGIN"]]) 193 194 img_name = "login" 195 today = os.path.basename(file_param).strip(OUT["PARAM"]) 186 196 187 197 if args.verbose: 188 198 print(file_param) 189 199 print(file_utheo) 190 print(file_ login)200 print(file_data) 191 201 print(img_name) 202 print(today) 192 203 193 204 # .. Get project info .. … … 202 213 # ---------------------- 203 214 logins = LoginDict() 204 logins.fill_data(file_ login)215 logins.fill_data(file_data) 205 216 206 217 # .. Extract data depending on C.L. arguments .. … … 245 256 # ... Save figure ... 246 257 # ------------------- 247 plot_save( os.path.join(DIR["PLOT"], img_name))258 plot_save(img_name, today, "Conso GENCMIP6 par login") 248 259 249 260 # ... Publish figure on dods ... … … 255 266 plt.show() 256 267 257 exit( )268 exit(0) -
TOOLS/ConsoGENCMIP6/bin/plot_store.py
r2425 r2427 40 40 #--------------------------------------- 41 41 def fill_data(self, filein): 42 data = np.genfromtxt( 43 filein, 44 skip_header=1, 45 converters={0: string_to_date, 46 1: str, 47 2: string_to_size_unit, 48 3: str}, 49 missing_values="nan", 50 ) 42 """ 43 """ 44 try: 45 data = np.genfromtxt( 46 filein, 47 skip_header=1, 48 converters={0: string_to_date, 49 1: str, 50 2: string_to_size_unit, 51 3: str}, 52 missing_values="nan", 53 ) 54 except: 55 print("Empty file {}".format(filein)) 56 exit(1) 51 57 52 58 for date, login, dirsize, dirname in data: … … 161 167 plt.figtext(x=0.95, y=0.93, s=tot_label, backgroundcolor="linen", 162 168 ha="right", va="bottom", fontsize="small") 163 164 165 ########################################166 def plot_save(img_name):167 """168 """169 dpi = 200.170 171 with PdfPages(img_name) as pdf:172 pdf.savefig(dpi=dpi)173 174 # pdf file's metadata175 d = pdf.infodict()176 d["Title"] = "Occupation GENCMIP6 sur STORE par login"177 d["Author"] = "plot_bilan.py"178 # d["Subject"] = "Time spent over specific commands during create_ts \179 # jobs at IDRIS and four configurations at TGCC"180 # d["Keywords"] = "bench create_ts TGCC IDRIS ncrcat"181 # d["CreationDate"] = dt.datetime(2009, 11, 13)182 # d["ModDate"] = dt.datetime.today()183 169 184 170 … … 220 206 221 207 import matplotlib.pyplot as plt 222 from matplotlib.backends.backend_pdf import PdfPages208 # from matplotlib.backends.backend_pdf import PdfPages 223 209 224 210 if not args.show: … … 227 213 # ... Files and directories ... 228 214 # ----------------------------- 229 file_param = get_last_file(DIR["SAVE"], OUT["PARAM"]) 230 file_utheo = get_last_file(DIR["SAVE"], OUT["UTHEO"]) 231 file_store = get_last_file(DIR["SAVE"], OUT["STORE"]) 232 img_name = "bilan.pdf" 215 (file_param, file_utheo, file_data) = \ 216 get_input_files(DIR["SAVEDATA"], 217 [OUT["PARAM"], OUT["UTHEO"], OUT["STORE"]]) 218 219 img_name = "store" 220 today = os.path.basename(file_param).strip(OUT["PARAM"]) 233 221 234 222 if args.verbose: 235 223 print(file_param) 236 224 print(file_utheo) 237 print(file_ store)225 print(file_data) 238 226 print(img_name) 227 print(today) 239 228 240 229 # .. Get project info .. … … 247 236 # ======================= 248 237 stores = StoreDict() 249 stores.fill_data(file_ store)238 stores.fill_data(file_data) 250 239 251 240 # .. Extract data depending on C.L. arguments .. … … 301 290 # ... Save figure ... 302 291 # ------------------- 303 plot_save( os.path.join(DIR["PLOT"], img_name))292 plot_save(img_name, today, "Occupation GENCMIP6 sur STORE par login") 304 293 305 294 # ... Publish figure on dods ... … … 311 300 plt.show() 312 301 313 exit( )302 exit(0) -
TOOLS/ConsoGENCMIP6/launch_conso.sh
r2424 r2427 23 23 # Main script to get data 24 24 # ======================= 25 bin/conso_gencmip6.py 25 script="conso_gencmip6" 26 printf "${script}\n" 27 echo "--------------------" 28 bin/${script}.py 29 rc=$? 30 if [ ${rc} -ne 0 ] ; then 31 echo "${script} terminated abnormally" 32 exit 33 else 34 echo "${script} OK" 35 fi 26 36 27 37 # Plot daily consumption … … 29 39 # -f : plot the whole period of the project 30 40 # -d : copy plot on dods 31 bin/plot_bilan.py -fd 41 script="plot_bilan" 42 printf "\n${script}\n" 43 echo "--------------------" 44 bin/${script}.py -fd 45 rc=$? 46 if [ ${rc} -ne 0 ] ; then 47 echo "${script} terminated abnormally" 48 else 49 echo "${script} OK" 50 fi 51 52 script="plot_login" 53 printf "\n${script}\n" 54 echo "--------------------" 55 bin/${script}.py -d 56 rc=$? 57 if [ ${rc} -ne 0 ] ; then 58 echo "${script} terminated abnormally" 59 else 60 echo "${script} OK" 61 fi 62 63 script="plot_store" 64 printf "\n${script}\n" 65 echo "--------------------" 66 bin/${script}.py -d 67 rc=$? 68 if [ ${rc} -ne 0 ] ; then 69 echo "${script} terminated abnormally" 70 else 71 echo "${script} OK" 72 fi 73 74 printf "\nEnd of script OK\n"
Note: See TracChangeset
for help on using the changeset viewer.