Changeset 2517


Ignore:
Timestamp:
05/20/15 16:30:57 (9 years ago)
Author:
labetoulle
Message:

Add to bilan a line that shows the theoratical two months under-consumption

Location:
TOOLS/ConsoGENCMIP6/bin
Files:
3 edited

Legend:

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

    r2464 r2517  
    249249    n = np.array([utheos[x1], utheos[x2]]) 
    250250 
     251    poly_ok = True 
    251252    try: 
    252       (a, b) = np.linalg.solve(m, n) 
     253      polynome = np.poly1d(np.linalg.solve(m, n)) 
    253254    except np.linalg.linalg.LinAlgError: 
    254       (a, b) = (None, None) 
    255  
    256     if a and b: 
    257       delta = int(round((-b/a)-x1 + 1)) 
    258  
    259       d1 = dates[x1] 
     255      poly_ok = False 
     256 
     257    if poly_ok: 
     258      delta = int(round(polynome.r[0] + 1)) 
     259 
     260      d1 = dates[0] 
    260261      self.date_init = d1 + dt.timedelta(days=delta) 
    261262    else: 
  • TOOLS/ConsoGENCMIP6/bin/plot_bilan.py

    r2464 r2517  
    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: 
     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 
    119121      for date in dates: 
    120         self[date].theo_equ = date.timetuple().tm_yday*a + b 
     122        self.poly_theo = poly_theo 
     123        self.poly_delay = poly_delay 
    121124 
    122125  #--------------------------------------- 
     
    161164    self.real_use = real_use 
    162165    self.theo_use = theo_use 
    163     self.theo_equ = np.nan 
     166    # self.theo_equ = np.nan 
    164167    self.run_mean = run_mean 
    165168    self.pen_mean = pen_mean 
     
    192195######################################## 
    193196def plot_data(ax_conso, ax_theo, xcoord, dates, 
    194               consos, theo_uses, real_uses, theo_equs, 
     197              consos, theo_uses, real_uses, theo_equs, theo_delay, 
    195198              run_mean, pen_mean, run_std, pen_std): 
    196199  """ 
     
    209212 
    210213  ax_theo.plot( 
     214    xcoord, real_uses, line_style, 
     215    color="forestgreen", linewidth=1, markersize=8, 
     216    solid_capstyle="round", solid_joinstyle="round", 
     217    label="conso\nréelle (%)" 
     218  ) 
     219  ax_theo.plot( 
    211220    xcoord, theo_equs, "--", 
    212221    color="firebrick", linewidth=0.5, 
     
    214223  ) 
    215224  ax_theo.plot( 
    216     xcoord, theo_uses, line_style, color="firebrick", 
    217     linewidth=1, markersize=8, 
     225    xcoord, theo_uses, line_style, 
     226    color="firebrick", linewidth=1, markersize=8, 
    218227    solid_capstyle="round", solid_joinstyle="round", 
    219228    label="conso\nthéorique (%)" 
    220229  ) 
    221230  ax_theo.plot( 
    222     xcoord, real_uses, line_style, color="forestgreen", 
    223     linewidth=1, markersize=8, 
     231    xcoord, theo_delay, ":", 
     232    color="firebrick", linewidth=0.5, 
    224233    solid_capstyle="round", solid_joinstyle="round", 
    225     label="conso\nréelle (%)" 
     234    label="retard de\ndeux mois (%)" 
    226235  ) 
    227236 
     
    439448  theo_uses = np.array([100.*item.theo_use for item in selected_items], 
    440449                       dtype=float) 
     450 
    441451  real_uses = np.array([100.*item.real_use for item in selected_items], 
    442452                       dtype=float) 
    443   theo_equs = np.array([100.*item.theo_equ for item in selected_items], 
    444                        dtype=float) 
     453  theo_equs = np.array( 
     454    [100. * bilan.poly_theo(date.timetuple().tm_yday) 
     455      for date in dates], 
     456    dtype=float 
     457  ) 
     458  theo_delay = np.array( 
     459    [100. * bilan.poly_delay(date.timetuple().tm_yday) 
     460      for date in dates], 
     461    dtype=float 
     462  ) 
    445463 
    446464  run_mean = np.array([item.run_mean for item in selected_items], 
     
    462480  # ----------------- 
    463481  plot_data(ax_conso, ax_theo, xcoord, dates, 
    464             consos, theo_uses, real_uses, theo_equs, 
     482            consos, theo_uses, real_uses, theo_equs, theo_delay, 
    465483            run_mean, pen_mean, run_std, pen_std) 
    466484 
     
    494512 
    495513  exit(0) 
    496  
  • TOOLS/ConsoGENCMIP6/bin/plot_jobs.py

    r2464 r2517  
    351351  bilan = DataDict() 
    352352  bilan.init_range(projet.date_init, projet.deadline) 
    353  
    354353  # ... Extract data from file ... 
    355354  # ------------------------------ 
Note: See TracChangeset for help on using the changeset viewer.