Changeset 2524
- Timestamp:
- 05/20/15 17:47:20 (9 years ago)
- Location:
- TOOLS/ConsoGENCMIP6
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/ConsoGENCMIP6/bin/config.ini.init
r2464 r2524 18 18 LOGIN: OUT_CONSO_LOGIN 19 19 STORE: OUT_CONSO_STORE 20 SINIT: OUT_CONSO_STORE_INIT 20 21 CCCMP: ccc_myproject.dat 21 22 JOBS: OUT_JOBS_PENDING -
TOOLS/ConsoGENCMIP6/bin/conso_gencmip6.py
r2462 r2524 259 259 if conso > 0.) 260 260 261 title_str 262 263 264 265 266 261 title_str = "{:10s} {:10s} {:>7s} {:s}\n".format( 262 "date", 263 "login", 264 "dirsize", 265 "dirname", 266 ) 267 267 268 268 with open(filename, "w") as fileout: … … 277 277 storedir = get_storedir(login) 278 278 if not storedir: 279 print("storedir not found for {}".format(storedir)) 279 280 break 280 281 igcm_out = os.path.join(storedir, "IGCM_OUT") 281 282 282 283 if not os.path.isdir(igcm_out): 283 break 284 print("no {}".format(igcm_out)) 285 continue 284 286 285 287 dirlist = [] … … 405 407 exit(1) 406 408 407 if len(data) == 24: 408 run_mean = np.nanmean( 409 np.array([run for _, run, _ in data]) 410 ) 411 pen_mean = np.nanmean( 412 np.array([pen for _, _, pen in data]) 413 ) 414 415 run_std = np.nanstd( 416 np.array([run for _, run, _ in data]) 417 ) 418 pen_std = np.nanstd( 419 np.array([pen for _, _, pen in data]) 420 ) 409 run_mean = np.nanmean( 410 np.array([run for _, run, _ in data]) 411 ) 412 pen_mean = np.nanmean( 413 np.array([pen for _, _, pen in data]) 414 ) 415 416 run_std = np.nanstd( 417 np.array([run for _, run, _ in data]) 418 ) 419 pen_std = np.nanstd( 420 np.array([pen for _, _, pen in data]) 421 ) 421 422 422 423 if args.verbose: -
TOOLS/ConsoGENCMIP6/bin/plot_bilan.py
r2522 r2524 201 201 line_width = 0.05 202 202 else: 203 # line_style = "+-"204 203 line_width = 0.1 205 204 … … 432 431 nb_items = len(selected_items) 433 432 434 xcoord 435 dates 436 437 cumul 433 xcoord = np.linspace(1, nb_items, num=nb_items) 434 dates = [item.date for item in selected_items] 435 436 cumul = np.array([item.conso for item in selected_items], 438 437 dtype=float) 439 consos 438 consos = [] 440 439 consos.append(cumul[0]) 441 440 consos[1:nb_items] = cumul[1:nb_items] - cumul[0:nb_items-1] 442 consos 441 consos = np.array(consos, dtype=float) 443 442 444 443 conso_per_day = projet.alloc / projet.days … … 448 447 dtype=float 449 448 ) 450 451 449 real_uses = np.array( 452 450 [100.*item.real_use for item in selected_items], -
TOOLS/ConsoGENCMIP6/bin/plot_store.py
r2464 r2524 20 20 class DirVolume(object): 21 21 #--------------------------------------- 22 def __init__(self, date, login, dirname, size ):23 self.date 22 def __init__(self, date, login, dirname, size, date_init, dirsize_init): 23 self.date = date 24 24 self.login = login 25 25 self.dirname = dirname 26 26 self.dirsize = size 27 self.date_init = date_init 28 self.dirsize_init = dirsize_init 27 29 28 30 #--------------------------------------- 29 31 def __repr__(self): 30 return "{}={} ".format(self.dirname, self.dirsize)32 return "{}={}-{}".format(self.dirname, self.dirsize, self.dirsize_init) 31 33 32 34 … … 38 40 39 41 #--------------------------------------- 40 def fill_data(self, filein ):42 def fill_data(self, filein, fileinit): 41 43 """ 42 44 """ … … 53 55 missing_values="nan", 54 56 ) 55 except :56 print(" Empty file {}, nothing to plot".format(filein))57 except Exception as rc: 58 print("Problem with file {} :\n{}".format(filein, rc)) 57 59 exit(1) 58 60 59 for date, login, dirsize, dirname in data: 60 self.add_item(date, login, dirsize, dirname) 61 62 #--------------------------------------- 63 def add_item(self, date, login, dirsize, dirname): 61 try: 62 init = np.genfromtxt( 63 fileinit, 64 skip_header=1, 65 converters={ 66 0: string_to_date, 67 1: str, 68 2: string_to_size_unit, 69 3: str, 70 }, 71 missing_values="nan", 72 ) 73 except Exception as rc: 74 print("Problem with file {} :\n{}".format(filein, rc)) 75 exit(1) 76 77 for (date, login, dirsize, dirname), \ 78 (date_init, _, dirsize_init, _) in zip(data, init): 79 self.add_item( 80 date, login, dirsize, dirname, 81 date_init, dirsize_init 82 ) 83 84 #--------------------------------------- 85 def add_item(self, date, login, dirsize, dirname, date_init, dirsize_init): 64 86 """ 65 87 """ 66 88 if login not in self: 67 89 self[login] = Login(date, login) 68 self[login].add_directory(date, login, dirsize, dirname) 90 self[login].add_directory( 91 date, login, dirsize, dirname, 92 date_init, dirsize_init 93 ) 69 94 70 95 #--------------------------------------- … … 112 137 113 138 #--------------------------------------- 114 def add_directory(self, date, login, dirsize, dirname): 115 """ 116 """ 117 self.listdir.append(DirVolume(date, login, dirname, dirsize)) 139 def add_directory(self, date, login, dirsize, dirname, 140 date_init, dirsize_init): 141 """ 142 """ 143 self.listdir.append(DirVolume(date, login, dirname, dirsize, 144 date_init, dirsize_init)) 118 145 self.add_to_total(dirsize) 119 146 … … 128 155 129 156 ######################################## 130 def plot_data(ax, coords, ylabels, values ):157 def plot_data(ax, coords, ylabels, values, values_init): 131 158 """ 132 159 """ 133 ax.barh(coords, values, align="center", color="linen", 134 linewidth=0.2, label="volume sur STORE ($To$)") 135 136 137 ######################################## 138 def plot_config(ax, coords, ylabels, dirnames, title, tot_volume): 160 ax.barh(coords, values, align="center", color="orange", 161 linewidth=0.1, label="volume sur STORE ($To$)") 162 ax.barh(coords, values_init, align="center", color="linen", 163 linewidth=0.1, label="volume initial sur STORE ($To$)") 164 165 166 ######################################## 167 def plot_config(ax, coords, ylabels, dirnames, title, 168 tot_volume, tot_volume_init, delta): 139 169 """ 140 170 """ … … 165 195 ax.legend(loc="best", fontsize="x-small", frameon=False) 166 196 167 tot_label = "volume total = {}".format(tot_volume) 197 tot_label = "prod {} = {}\n({} - {})".format( 198 projet.project.upper(), 199 delta, 200 tot_volume, 201 tot_volume_init, 202 ) 168 203 plt.figtext(x=0.95, y=0.93, s=tot_label, backgroundcolor="linen", 169 204 ha="right", va="bottom", fontsize="small") … … 197 232 # ------------------------------ 198 233 args = get_arguments() 199 if args.verbose:200 print(args)201 234 202 235 # ... Turn interactive mode off ... … … 220 253 [OUT["PARAM"], OUT["UTHEO"], OUT["STORE"]]) 221 254 222 img_name = "store" 255 (file_init, ) = \ 256 get_input_files(DIR["DATA"], [OUT["SINIT"]]) 257 258 img_name = os.path.splitext( 259 os.path.basename(__file__) 260 )[0].replace("plot_", "") 261 223 262 today = os.path.basename(file_param).strip(OUT["PARAM"]) 224 263 225 264 if args.verbose: 226 print(file_param) 227 print(file_utheo) 228 print(file_data) 229 print(img_name) 230 print(today) 265 fmt_str = "{:10s} : {}" 266 print(fmt_str.format("args", args)) 267 print(fmt_str.format("today", today)) 268 print(fmt_str.format("file_param", file_param)) 269 print(fmt_str.format("file_utheo", file_utheo)) 270 print(fmt_str.format("file_data", file_data)) 271 print(fmt_str.format("file_init", file_init)) 272 print(fmt_str.format("img_name", img_name)) 231 273 232 274 # .. Get project info .. … … 239 281 # ======================= 240 282 stores = StoreDict() 241 stores.fill_data(file_data )283 stores.fill_data(file_data, file_init) 242 284 243 285 # .. Extract data depending on C.L. arguments .. … … 250 292 if args.verbose: 251 293 for item in selected_items: 294 fmt_str = "{:8s} " + 2*"{:%F} {} {:>18s} " + "{} " 252 295 print( 253 "{:8s} {:%F} {} {:>18s} {} ".format(296 fmt_str.format( 254 297 item.login, 255 298 item.date, 256 299 item.dirsize, 257 300 item.dirsize.convert_size("K"), 301 item.date_init, 302 item.dirsize_init, 303 item.dirsize_init.convert_size("K"), 258 304 item.dirname, 259 305 ) … … 263 309 # ================================ 264 310 ylabels = [item.login for item in selected_items] 265 values = np.array([item.dirsize.convert_size("T").size 266 for item in selected_items], 267 dtype=float) 311 values = np.array( 312 [item.dirsize.convert_size("T").size for item in selected_items], 313 dtype=float 314 ) 315 values_init = np.array( 316 [item.dirsize_init.convert_size("T").size for item in selected_items], 317 dtype=float 318 ) 268 319 dirnames = [item.dirname for item in selected_items] 269 320 date = selected_items[0].date … … 280 331 # ... Plot data ... 281 332 # ----------------- 282 plot_data(ax, coords, ylabels, values )333 plot_data(ax, coords, ylabels, values, values_init) 283 334 284 335 # ... Tweak figure ... … … 288 339 date 289 340 ) 341 342 tot_volume = np.sum(values) 343 tot_volume_init = np.sum(values_init) 344 delta = tot_volume - tot_volume_init 345 290 346 plot_config(ax, coords, ylabels, dirnames, title, 291 SizeUnit(np.sum(values), "T")) 347 SizeUnit(tot_volume, "T"), 348 SizeUnit(tot_volume_init, "T"), 349 SizeUnit(delta, "T")) 292 350 293 351 # ... Save figure ... … … 302 360 # ------------------------------ 303 361 if args.dods: 362 if args.verbose: 363 print("Publish figure on dods") 304 364 dods_cp(img_in, DIR) 305 365 -
TOOLS/ConsoGENCMIP6/launch_conso.sh
r2460 r2524 78 78 printf "\n${script}\n" 79 79 echo "--------------------" 80 #Â Last STORE file produced 81 data_file="OUT_CONSO_STORE" 82 OUTDIR="${HOME}/ConsoGENCMIP6/output" 83 #Â Directories in last file 84 dirlist=$( gawk '{if ($4 != "dirname") print $4}' ${OUTDIR}/${data_file} ) 85 # Where to find the saved files 86 SAVEDIR="${WORKDIR}/ConsoGENCMIP6/data" 87 # Previous STORE files 88 filelist=$( ls ${SAVEDIR}/${data_file}_* ) 89 fileout="${data_file}_INIT" 90 echo "date login dirsize dirname" > ${OUTDIR}/${fileout} 91 for dir in ${dirlist} ; do 92 grep -h "$dir\$" ${filelist} | head -1 93 grep -h "$dir\$" ${filelist} | head -1 >> ${OUTDIR}/${fileout} 94 done 95 80 96 bin/${script}.py -v 81 97 rc=$? -
TOOLS/ConsoGENCMIP6/launch_jobs.sh
r2461 r2524 50 50 51 51 printf "\nEnd of script OK\n" 52
Note: See TracChangeset
for help on using the changeset viewer.