Ignore:
Timestamp:
03/02/15 17:43:15 (9 years ago)
Author:
labetoulle
Message:

Move common functions to common module

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/ConsoGENCMIP6/bin/plot_store.py

    r2425 r2427  
    4040  #--------------------------------------- 
    4141  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) 
    5157 
    5258    for date, login, dirsize, dirname in data: 
     
    161167  plt.figtext(x=0.95, y=0.93, s=tot_label, backgroundcolor="linen", 
    162168              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 metadata 
    175     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() 
    183169 
    184170 
     
    220206 
    221207  import matplotlib.pyplot as plt 
    222   from matplotlib.backends.backend_pdf import PdfPages 
     208  # from matplotlib.backends.backend_pdf import PdfPages 
    223209 
    224210  if not args.show: 
     
    227213  # ... Files and directories ... 
    228214  # ----------------------------- 
    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"]) 
    233221 
    234222  if args.verbose: 
    235223    print(file_param) 
    236224    print(file_utheo) 
    237     print(file_store) 
     225    print(file_data) 
    238226    print(img_name) 
     227    print(today) 
    239228 
    240229  # .. Get project info .. 
     
    247236  # ======================= 
    248237  stores = StoreDict() 
    249   stores.fill_data(file_store) 
     238  stores.fill_data(file_data) 
    250239 
    251240  # .. Extract data depending on C.L. arguments .. 
     
    301290  # ... Save figure ... 
    302291  # ------------------- 
    303   plot_save(os.path.join(DIR["PLOT"], img_name)) 
     292  plot_save(img_name, today, "Occupation GENCMIP6 sur STORE par login") 
    304293 
    305294  # ... Publish figure on dods ... 
     
    311300    plt.show() 
    312301 
    313   exit() 
     302  exit(0) 
Note: See TracChangeset for help on using the changeset viewer.