Changeset 2417
- Timestamp:
- 02/25/15 15:18:06 (9 years ago)
- Location:
- TOOLS/ConsoGENCMIP6/bin
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/ConsoGENCMIP6/bin/conso_gencmip6.py
r2413 r2417 227 227 228 228 ######################################## 229 def write_store(filename, logins):229 def write_store(filename, today, logins): 230 230 """ 231 231 volume cree sur STORE … … 238 238 if conso > 0.) 239 239 240 for login in items: 241 storedir = get_storedir(login) 242 if not storedir: 243 break 244 igcm_out = os.path.join(storedir, "IGCM_OUT") 245 246 for dirname in os.listdir(igcm_out): 247 print(dirname, get_dirsize(dirname)) 240 title_str = "{:10s} {:10s} {:>7s} {:s}\n".format( 241 "date", 242 "login", 243 "dirsize", 244 "dirname", 245 ) 246 247 with open(filename, "w") as fileout: 248 if args.dryrun: 249 print(title_str.strip()) 250 else: 251 fileout.write(title_str) 252 253 for login in items: 254 if args.verbose: 255 print(login) 256 storedir = get_storedir(login) 257 if not storedir: 258 break 259 igcm_out = os.path.join(storedir, "IGCM_OUT") 260 261 for dirname in os.listdir(igcm_out): 262 print(dirname, get_dirsize(dirname)) 263 264 result_str = "{:%Y-%m-%d} {:10s} {:>7s} {:s}\n".format( 265 today, 266 login, 267 get_dirsize(dirname), 268 dirname 269 ) 270 if args.dryrun: 271 print(result_str.strip()) 272 else: 273 fileout.write(result_str) 274 275 276 ######################################## 277 def save_files(OUT, today): 278 279 if not args.dryrun: 280 suffix = "{:%Y%m%d}".format(today) 281 for filename in OUT.itervalues(): 282 filein = os.path.join(DIR["DATA"], filename) 283 if os.path.isfile(filein): 284 fileout = os.path.join(DIR["SAVE"], 285 "_".join((filename, suffix))) 286 shutil.copy(filein, fileout) 248 287 249 288 … … 273 312 print(args) 274 313 275 # # Files and directories 276 # # ===================== 277 # if where_we_run() == "curie": 278 # LOCAL_DIR = os.path.join( 279 # "/ccc", 280 # "cont003", 281 # "home", 282 # "dsm", 283 # "p86ipsl", 284 # "ConsoGENCMIP6", 285 # "output" 286 # ) 287 # SAVE_DIR = os.path.join( 288 # "/ccc", 289 # "work", 290 # "cont003", 291 # "dsm", 292 # "p86ipsl", 293 # "ConsoGENCMIP6", 294 # ) 295 # # elif where_we_run() == "ipsl": 296 # # LOCAL_DIR = os.path.join( 297 # # "/home_local", 298 # # "slipsl", 299 # # "ConsoGENCMIP6", 300 # # "output" 301 # # ) 302 # # SAVE_DIR = os.path.join( 303 # # "/home_local", 304 # # "slipsl", 305 # # "ConsoGENCMIP6", 306 # # "save" 307 # # ) 308 # else: 309 # LOCAL_DIR = os.path.join( 310 # "..", 311 # "output" 312 # ) 313 # SAVE_DIR = os.path.join( 314 # "..", 315 # "save" 316 # ) 317 318 # LOCAL_DIR = os.path.abspath(LOCAL_DIR) 319 # SAVE_DIR = os.path.abspath(SAVE_DIR) 320 321 OUT_PARAM = "OUT_CONSO_PARAM" 322 OUT_BILAN = "OUT_CONSO_BILAN" 323 OUT_UTHEO = "OUT_CONSO_UTHEO" 324 OUT_LOGIN = "OUT_CONSO_LOGIN" 325 OUT_STORE = "OUT_CONSO_STORE" 326 OUT_CCCMP = "ccc_myproject.dat" 327 328 if args.verbose: 329 # print(LOCAL_DIR) 330 # print(SAVE_DIR) 314 if args.bilan or args.login or args.store: 315 args.all = False 316 317 if args.verbose: 331 318 print(DIR["DATA"]) 332 319 print(DIR["SAVE"]) 333 320 334 321 (project, logins, today, total, utheo, ureal) = \ 335 parse_myproject(os.path.join(DIR["DATA"], OUT _CCCMP))322 parse_myproject(os.path.join(DIR["DATA"], OUT["CCCMP"])) 336 323 337 324 if args.verbose: … … 345 332 # 1- Parametres du projet 346 333 # ----------------------- 347 write_param(os.path.join(DIR["DATA"], OUT_PARAM), project) 334 if args.verbose: 335 print("=> write_param") 336 337 write_param(os.path.join(DIR["DATA"], OUT["PARAM"]), project) 348 338 349 339 # 2- Conso totale par jour 350 340 # ------------------------ 341 if args.verbose: 342 print("=> write_bilan") 343 351 344 write_bilan( 352 os.path.join(DIR["DATA"], OUT _BILAN),345 os.path.join(DIR["DATA"], OUT["BILAN"]), 353 346 today, 354 347 total, … … 359 352 # 2b- Conso théorique par jour 360 353 # ---------------------------- 361 write_utheo(os.path.join(DIR["DATA"], OUT_UTHEO), today, utheo) 354 if args.verbose: 355 print("=> write_utheo") 356 357 write_utheo(os.path.join(DIR["DATA"], OUT["UTHEO"]), today, utheo) 362 358 363 359 # 3- Conso par login (HOME) 364 360 # ------------------------- 365 write_login(os.path.join(DIR["DATA"], OUT_LOGIN), today, logins) 361 if args.verbose: 362 print("=> write_login") 363 364 write_login(os.path.join(DIR["DATA"], OUT["LOGIN"]), today, logins) 366 365 367 366 # 4- volume cree sur STORE 368 367 # ------------------------ 368 if args.verbose: 369 print("=> write_store") 370 369 371 # if where_we_run() == "curie": 370 # write_store(os.path.join(DIR["DATA"], OUT _STORE))371 write_store(os.path.join(DIR["DATA"], OUT _STORE), logins)372 # write_store(os.path.join(DIR["DATA"], OUT["STORE"])) 373 write_store(os.path.join(DIR["DATA"], OUT["STORE"]), today, logins) 372 374 373 375 # Save files (on WORKDIR) 374 376 # ======================= 377 if args.verbose: 378 print("=> Save files") 379 375 380 if not args.dryrun: 376 suffix = "{:%Y%m%d}".format(today) 377 file_list = [ 378 OUT_PARAM, 379 OUT_BILAN, 380 OUT_UTHEO, 381 OUT_LOGIN, 382 OUT_STORE 383 ] 384 for filename in file_list: 385 filein = os.path.join(DIR["DATA"], filename) 386 if os.path.isfile(filein): 387 fileout = os.path.join(DIR["SAVE"], "_".join((filename, suffix))) 388 shutil.copy(filein, fileout) 381 save_files(OUT, today) -
TOOLS/ConsoGENCMIP6/bin/gencmip6.py
r2413 r2417 111 111 missing_values="nan", 112 112 ) 113 print(data) 114 print(type(data)) 115 print(data.shape) 116 print(data.size) 113 117 dates, utheos = zip(*data) 114 118 -
TOOLS/ConsoGENCMIP6/bin/gencmip6_path.py.init
r2413 r2417 25 25 if __name__ == "__main__": 26 26 print(DIR, ) 27 2 -
TOOLS/ConsoGENCMIP6/bin/plot_bilan.py
r2413 r2417 9 9 import os 10 10 import os.path 11 # import glob12 11 import datetime as dt 13 12 import numpy as np … … 273 272 # ... Files and directories ... 274 273 # ----------------------------- 275 file_pattern = "OUT_CONSO_" 276 file_param = get_last_file(DIR["DATA"], file_pattern+"PARAM") 277 file_utheo = get_last_file(DIR["DATA"], file_pattern+"UTHEO") 278 file_bilan = get_last_file(DIR["DATA"], file_pattern+"BILAN") 279 file_login = get_last_file(DIR["DATA"], file_pattern+"LOGIN") 280 file_store = get_last_file(DIR["DATA"], file_pattern+"STORE") 274 file_param = get_last_file(DIR["DATA"], OUT["PARAM"]) 275 file_utheo = get_last_file(DIR["DATA"], OUT["UTHEO"]) 276 file_bilan = get_last_file(DIR["DATA"], OUT["BILAN"]) 281 277 img_name = "bilan.pdf" 282 278 … … 285 281 print(file_utheo) 286 282 print(file_bilan) 287 print(file_login) 288 print(file_store) 283 print(img_name) 289 284 290 285 # .. Get project info .. … … 309 304 # .. Extract data depending on C.L. arguments .. 310 305 # ============================================== 311 # args.range = [312 # string_to_date("2015-01-01"),313 # string_to_date("2015-01-31")314 # ]315 # args.full = True316 306 if args.full: 317 307 selected_items = bilan.get_items_in_full_range(args.inc) -
TOOLS/ConsoGENCMIP6/bin/plot_login.py
r2413 r2417 9 9 import os 10 10 import os.path 11 # import glob12 # import datetime as dt13 11 import numpy as np 14 12 import matplotlib.pyplot as plt … … 45 43 self[login] = Login(date, login, conso) 46 44 47 # #---------------------------------------48 # def get_items_in_full_range(self, inc=1):49 # """50 # """51 # items = (item for item in self.itervalues())52 # items = sorted(items, key=lambda item: item.date)53 54 # return items[::inc]55 56 45 #--------------------------------------- 57 46 def get_items(self): … … 84 73 def __repr__(self): 85 74 return "{} ({:.2}h)".format(self.login, self.conso) 86 87 # #---------------------------------------88 # def isfilled(self):89 # return self.filled90 91 # #---------------------------------------92 # def fill(self):93 # self.filled = True94 75 95 76 … … 181 162 # ... Files and directories ... 182 163 # ----------------------------- 183 file_pattern = "OUT_CONSO_" 184 file_param = get_last_file(DIR["DATA"], file_pattern+"PARAM") 185 file_utheo = get_last_file(DIR["DATA"], file_pattern+"UTHEO") 186 file_bilan = get_last_file(DIR["DATA"], file_pattern+"BILAN") 187 file_login = get_last_file(DIR["DATA"], file_pattern+"LOGIN") 188 file_store = get_last_file(DIR["DATA"], file_pattern+"STORE") 189 img_name = "login.pdf" 164 file_param = get_last_file(DIR["DATA"], OUT["PARAM"]) 165 file_utheo = get_last_file(DIR["DATA"], OUT["UTHEO"]) 166 file_login = get_last_file(DIR["DATA"], OUT["LOGIN"]) 167 img_name = "bilan.pdf" 168 169 if args.verbose: 170 print(file_param) 171 print(file_utheo) 172 print(file_login) 173 print(img_name) 190 174 191 175 # .. Get project info .. … … 233 217 plot_data(ax, ycoord, ylabels, consos) 234 218 235 # #... Tweak figure ...236 # #--------------------219 # ... Tweak figure ... 220 # -------------------- 237 221 title = "Consommation {} par login\n{:%d/%m/%Y}".format( 238 222 gencmip6.project.upper(), -
TOOLS/ConsoGENCMIP6/bin/plot_store.py
r2413 r2417 9 9 import os 10 10 import os.path 11 # import glob12 # import datetime as dt13 11 import numpy as np 14 12 import matplotlib.pyplot as plt … … 213 211 # ... Files and directories ... 214 212 # ----------------------------- 215 file_pattern = "OUT_CONSO_" 216 file_param = get_last_file(DIR["DATA"], file_pattern+"PARAM") 217 file_utheo = get_last_file(DIR["DATA"], file_pattern+"UTHEO") 218 file_bilan = get_last_file(DIR["DATA"], file_pattern+"BILAN") 219 file_login = get_last_file(DIR["DATA"], file_pattern+"LOGIN") 220 file_store = get_last_file(DIR["DATA"], file_pattern+"STORE") 221 img_name = "store.pdf" 213 file_param = get_last_file(DIR["DATA"], OUT["PARAM"]) 214 file_utheo = get_last_file(DIR["DATA"], OUT["UTHEO"]) 215 file_store = get_last_file(DIR["DATA"], OUT["STORE"]) 216 img_name = "bilan.pdf" 217 218 if args.verbose: 219 print(file_param) 220 print(file_utheo) 221 print(file_store) 222 print(img_name) 222 223 223 224 # .. Get project info ..
Note: See TracChangeset
for help on using the changeset viewer.