Changeset 2526 for TOOLS


Ignore:
Timestamp:
05/21/15 11:50:57 (9 years ago)
Author:
labetoulle
Message:
  • plot_bilan_jobs.py : add two month delay curve
  • homogenise all plots
Location:
TOOLS/ConsoGENCMIP6/bin
Files:
4 edited

Legend:

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

    r2524 r2526  
    163163    self.real_use = real_use 
    164164    self.theo_use = theo_use 
     165    self.poly_theo = np.poly1d([]) 
     166    self.poly_delay = np.poly1d([]) 
    165167    self.run_mean = run_mean 
    166168    self.pen_mean = pen_mean 
     
    364366  # ------------------------------ 
    365367  args = get_arguments() 
    366   if args.verbose: 
    367     print(args) 
    368368 
    369369  # ... Turn interactive mode off ... 
     
    387387                      [OUT["PARAM"], OUT["UTHEO"], OUT["BILAN"]]) 
    388388 
    389   img_name = "bilan" 
     389  img_name = os.path.splitext( 
     390               os.path.basename(__file__) 
     391             )[0].replace("plot_", "") 
     392 
    390393  today = os.path.basename(file_param).strip(OUT["PARAM"]) 
    391394 
    392395  if args.verbose: 
    393     print(file_param) 
    394     print(file_utheo) 
    395     print(file_data) 
    396     print(img_name) 
    397     print(today) 
     396    fmt_str = "{:10s} : {}" 
     397    print(fmt_str.format("args", args)) 
     398    print(fmt_str.format("today", today)) 
     399    print(fmt_str.format("file_param", file_param)) 
     400    print(fmt_str.format("file_utheo", file_utheo)) 
     401    print(fmt_str.format("file_data", file_data)) 
     402    print(fmt_str.format("img_name", img_name)) 
    398403 
    399404  # .. Get project info .. 
     
    506511  # ------------------------------ 
    507512  if args.dods: 
     513    if args.verbose: 
     514      print("Publish figure on dods") 
    508515    dods_cp(img_in, DIR) 
    509516 
     
    512519 
    513520  exit(0) 
     521 
  • TOOLS/ConsoGENCMIP6/bin/plot_bilan_jobs.py

    r2464 r2526  
    1010import os.path 
    1111import datetime as dt 
     12from dateutil.relativedelta import relativedelta 
    1213import numpy as np 
    1314 
     
    102103    y2 = theo_uses[idx_max] 
    103104 
    104     m = np.array([ 
    105       [x1, 1.], 
    106       [x2, 1.] 
    107     ], dtype="float") 
    108     n = np.array([ 
    109       y1, 
    110       y2 
    111     ], dtype="float") 
    112  
     105    m = np.array([[x1, 1.], [x2, 1.]], dtype="float") 
     106    n = np.array([y1, y2], dtype="float") 
     107 
     108    poly_ok = True 
    113109    try: 
    114       (a, b) = np.linalg.solve(m, n) 
     110      poly_theo = np.poly1d(np.linalg.solve(m, n)) 
    115111    except np.linalg.linalg.LinAlgError: 
    116       (a, b) = (None, None) 
    117  
    118     if a and b: 
    119       for date in dates: 
    120         self[date].theo_equ = date.timetuple().tm_yday*a + b 
     112      poly_ok = False 
     113 
     114    if poly_ok: 
     115      delta = (dates[0] + relativedelta(months=2) - dates[0]).days 
     116 
     117      poly_delay = np.poly1d( 
     118        [poly_theo[1], poly_theo[0] - poly_theo[1] * delta] 
     119      ) 
     120 
     121      self.poly_theo = poly_theo 
     122      self.poly_delay = poly_delay 
    121123 
    122124  #--------------------------------------- 
     
    161163    self.real_use = real_use 
    162164    self.theo_use = theo_use 
    163     self.theo_equ = np.nan 
     165    self.poly_theo = np.poly1d([]) 
     166    self.poly_delay = np.poly1d([]) 
    164167    self.run_mean = run_mean 
    165168    self.pen_mean = pen_mean 
     
    198201######################################## 
    199202def plot_data(ax_conso, ax_theo, ax_jobs, xcoord, dates, 
    200               consos, theo_uses, real_uses, theo_equs, 
     203              consos, theo_uses, real_uses, theo_equs, theo_delay, 
    201204              run_mean, pen_mean, run_std, pen_std): 
    202205  """ 
     
    206209    line_width = 0.05 
    207210  else: 
    208     # line_style = "+-" 
    209211    line_width = 0.1 
    210212 
     
    214216  ) 
    215217 
     218  ax_theo.plot( 
     219    xcoord, real_uses, line_style, 
     220    color="forestgreen", linewidth=1, markersize=8, 
     221    solid_capstyle="round", solid_joinstyle="round", 
     222    label="conso\nréelle (%)" 
     223  ) 
    216224  ax_theo.plot( 
    217225    xcoord, theo_equs, "--", 
     
    220228  ) 
    221229  ax_theo.plot( 
    222     xcoord, theo_uses, line_style, color="firebrick", 
    223     linewidth=1, markersize=8, 
     230    xcoord, theo_uses, line_style, 
     231    color="firebrick", linewidth=1, markersize=8, 
    224232    solid_capstyle="round", solid_joinstyle="round", 
    225233    label="conso\nthéorique (%)" 
    226234  ) 
    227235  ax_theo.plot( 
    228     xcoord, real_uses, line_style, color="forestgreen", 
    229     linewidth=1, markersize=8, 
     236    xcoord, theo_delay, ":", 
     237    color="firebrick", linewidth=0.5, 
    230238    solid_capstyle="round", solid_joinstyle="round", 
    231     label="conso\nréelle (%)" 
     239    label="retard de\ndeux mois (%)" 
    232240  ) 
    233241 
     
    389397  # ------------------------------ 
    390398  args = get_arguments() 
    391   if args.verbose: 
    392     print(args) 
    393399 
    394400  # ... Turn interactive mode off ... 
     
    412418                      [OUT["PARAM"], OUT["UTHEO"], OUT["BILAN"]]) 
    413419 
    414   img_name = "bilan_jobs" 
     420  img_name = os.path.splitext( 
     421               os.path.basename(__file__) 
     422             )[0].replace("plot_", "") 
     423 
    415424  today = os.path.basename(file_param).strip(OUT["PARAM"]) 
    416425 
    417426  if args.verbose: 
    418     print(file_param) 
    419     print(file_utheo) 
    420     print(file_data) 
    421     print(img_name) 
    422     print(today) 
     427    fmt_str = "{:10s} : {}" 
     428    print(fmt_str.format("args", args)) 
     429    print(fmt_str.format("today", today)) 
     430    print(fmt_str.format("file_param", file_param)) 
     431    print(fmt_str.format("file_utheo", file_utheo)) 
     432    print(fmt_str.format("file_data", file_data)) 
     433    print(fmt_str.format("img_name", img_name)) 
    423434 
    424435  # .. Get project info .. 
     
    456467  nb_items = len(selected_items) 
    457468 
    458   xcoord    = np.linspace(1, nb_items, num=nb_items) 
    459   dates   = [item.date for item in selected_items] 
    460  
    461   cumul     = np.array([item.conso for item in selected_items], 
     469  xcoord = np.linspace(1, nb_items, num=nb_items) 
     470  dates = [item.date for item in selected_items] 
     471 
     472  cumul = np.array([item.conso for item in selected_items], 
    462473                        dtype=float) 
    463   consos    = [] 
     474  consos = [] 
    464475  consos.append(cumul[0]) 
    465476  consos[1:nb_items] = cumul[1:nb_items] - cumul[0:nb_items-1] 
    466   consos    = np.array(consos, dtype=float) 
     477  consos = np.array(consos, dtype=float) 
    467478 
    468479  conso_per_day = projet.alloc / projet.days 
    469480 
    470   theo_uses = np.array([100.*item.theo_use for item in selected_items], 
    471                        dtype=float) 
    472   real_uses = np.array([100.*item.real_use for item in selected_items], 
    473                        dtype=float) 
    474   theo_equs = np.array([100.*item.theo_equ for item in selected_items], 
    475                        dtype=float) 
     481  theo_uses = np.array( 
     482    [100.*item.theo_use for item in selected_items], 
     483    dtype=float 
     484  ) 
     485  real_uses = np.array( 
     486    [100.*item.real_use for item in selected_items], 
     487    dtype=float 
     488  ) 
     489  theo_equs = np.array( 
     490    [100. * bilan.poly_theo(date.timetuple().tm_yday) 
     491      for date in dates], 
     492    dtype=float 
     493  ) 
     494  theo_delay = np.array( 
     495    [100. * bilan.poly_delay(date.timetuple().tm_yday) 
     496      for date in dates], 
     497    dtype=float 
     498  ) 
    476499 
    477500  run_mean = np.array([item.run_mean for item in selected_items], 
     
    493516  # ----------------- 
    494517  plot_data(ax_conso, ax_theo, ax_jobs, xcoord, dates, 
    495             consos, theo_uses, real_uses, theo_equs, 
     518            consos, theo_uses, real_uses, theo_equs, theo_delay, 
    496519            run_mean, pen_mean, run_std, pen_std) 
    497520 
     
    520543  # ------------------------------ 
    521544  if args.dods: 
     545    if args.verbose: 
     546      print("Publish figure on dods") 
    522547    dods_cp(img_in, DIR) 
    523548 
  • TOOLS/ConsoGENCMIP6/bin/plot_login.py

    r2464 r2526  
    125125  parser = ArgumentParser() 
    126126  parser.add_argument("-v", "--verbose", action="store_true", 
    127                       help="Verbose mode") 
     127                      help="verbose mode") 
    128128  parser.add_argument("-f", "--full", action="store_true", 
    129129                      help="plot all the logins" + 
     
    145145  # ------------------------------ 
    146146  args = get_arguments() 
    147   if args.verbose: 
    148     print(args) 
    149147 
    150148  # ... Turn interactive mode off ... 
     
    168166                      [OUT["PARAM"], OUT["UTHEO"], OUT["LOGIN"]]) 
    169167 
    170   img_name = "login" 
     168  img_name = os.path.splitext( 
     169               os.path.basename(__file__) 
     170             )[0].replace("plot_", "") 
     171 
    171172  today = os.path.basename(file_param).strip(OUT["PARAM"]) 
    172173 
    173174  if args.verbose: 
    174     print(file_param) 
    175     print(file_utheo) 
    176     print(file_data) 
    177     print(img_name) 
    178     print(today) 
     175    fmt_str = "{:10s} : {}" 
     176    print(fmt_str.format("args", args)) 
     177    print(fmt_str.format("today", today)) 
     178    print(fmt_str.format("file_param", file_param)) 
     179    print(fmt_str.format("file_utheo", file_utheo)) 
     180    print(fmt_str.format("file_data", file_data)) 
     181    print(fmt_str.format("img_name", img_name)) 
    179182 
    180183  # .. Get project info .. 
     
    184187  projet.get_date_init(file_utheo) 
    185188 
    186   # .. Fill in data dict .. 
    187   # ======================= 
    188   # ... Initialization ... 
    189   # ---------------------- 
     189  # .. Fill in data .. 
     190  # ================== 
    190191  logins = LoginDict() 
    191192  logins.fill_data(file_data) 
     
    241242  # ------------------------------ 
    242243  if args.dods: 
     244    if args.verbose: 
     245      print("Publish figure on dods") 
    243246    dods_cp(img_in, DIR) 
    244247 
  • TOOLS/ConsoGENCMIP6/bin/plot_store.py

    r2524 r2526  
    209209  parser = ArgumentParser() 
    210210  parser.add_argument("-v", "--verbose", action="store_true", 
    211                       help="Verbose mode") 
     211                      help="verbose mode") 
    212212  parser.add_argument("-f", "--full", action="store_true", 
    213213                      help="plot all the directories in IGCM_OUT" + 
     
    278278  projet.get_date_init(file_utheo) 
    279279 
    280   # .. Fill in data dict .. 
    281   # ======================= 
     280  # .. Fill in data .. 
     281  # ================== 
    282282  stores = StoreDict() 
    283283  stores.fill_data(file_data, file_init) 
Note: See TracChangeset for help on using the changeset viewer.