Ignore:
Timestamp:
04/02/15 12:12:26 (9 years ago)
Author:
labetoulle
Message:
  • Use an INI config file
  • reaname "gencmip6" variables
Location:
TOOLS/ConsoGENCMIP6/bin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/ConsoGENCMIP6/bin

    • Property svn:ignore
      •  

        old new  
        1 gencmip6_path.py 
         1*.pyc 
  • TOOLS/ConsoGENCMIP6/bin/plot_bilan.py

    r2448 r2460  
    1313 
    1414# Application library imports 
    15 from gencmip6 import * 
    16 from gencmip6_path import * 
     15from libconso import * 
    1716 
    1817 
     
    204203    line_width = 0.1 
    205204 
    206   ax_conso.bar(xcoord, consos, width=1, align="center", color="linen", 
    207                linewidth=line_width, label="conso (heures)") 
    208  
    209   ax_theo.plot(xcoord, theo_equs, "--", 
    210                color="firebrick", linewidth=0.5, 
    211                solid_capstyle="round", solid_joinstyle="round") 
    212   ax_theo.plot(xcoord, theo_uses, line_style, color="firebrick", 
    213                linewidth=1, markersize=8, 
    214                solid_capstyle="round", solid_joinstyle="round", 
    215                label="conso\nthéorique (%)") 
    216   ax_theo.plot(xcoord, real_uses, line_style, color="forestgreen", 
    217                linewidth=1, markersize=8, 
    218                solid_capstyle="round", solid_joinstyle="round", 
    219                label="conso\nréelle (%)") 
    220  
    221  
    222 ######################################## 
    223 def plot_config(fig, ax_conso, ax_theo, xcoord, dates, title, conso_per_day): 
     205  ax_conso.bar( 
     206    xcoord, consos, width=1, align="center", color="linen", 
     207    linewidth=line_width, label="conso (heures)" 
     208  ) 
     209 
     210  ax_theo.plot( 
     211    xcoord, theo_equs, "--", 
     212    color="firebrick", linewidth=0.5, 
     213    solid_capstyle="round", solid_joinstyle="round" 
     214  ) 
     215  ax_theo.plot( 
     216    xcoord, theo_uses, line_style, color="firebrick", 
     217    linewidth=1, markersize=8, 
     218    solid_capstyle="round", solid_joinstyle="round", 
     219    label="conso\nthéorique (%)" 
     220  ) 
     221  ax_theo.plot( 
     222    xcoord, real_uses, line_style, color="forestgreen", 
     223    linewidth=1, markersize=8, 
     224    solid_capstyle="round", solid_joinstyle="round", 
     225    label="conso\nréelle (%)" 
     226  ) 
     227 
     228 
     229######################################## 
     230def plot_config(fig, ax_conso, ax_theo, xcoord, dates, title, 
     231                conso_per_day): 
    224232  """ 
    225233  """ 
     
    273281  ax_conso.set_xticks(xcoord, minor=True) 
    274282  ax_conso.set_xticks(maj_xticks, minor=False) 
    275   ax_conso.set_xticklabels(maj_xlabs, rotation="vertical", size="x-small") 
     283  ax_conso.set_xticklabels( 
     284    maj_xlabs, rotation="vertical", size="x-small" 
     285  ) 
    276286 
    277287  yticks = list(ax_conso.get_yticks()) 
     
    365375  # ... Files and directories ... 
    366376  # ----------------------------- 
     377  project_name, DIR, OUT = parse_config("bin/config.ini") 
     378 
    367379  (file_param, file_utheo, file_data) = \ 
    368380      get_input_files(DIR["SAVEDATA"], 
     
    381393  # .. Get project info .. 
    382394  # ====================== 
    383   gencmip6 = Project() 
    384   gencmip6.fill_data(file_param) 
    385   gencmip6.get_date_init(file_utheo) 
     395  projet = Project() 
     396  projet.fill_data(file_param) 
     397  projet.get_date_init(file_utheo) 
    386398 
    387399  # .. Fill in data .. 
     
    390402  # ---------------------- 
    391403  bilan = DataDict() 
    392   bilan.init_range(gencmip6.date_init, gencmip6.deadline) 
     404  bilan.init_range(projet.date_init, projet.deadline) 
    393405  # ... Extract data from file ... 
    394406  # ------------------------------ 
     
    423435  consos    = np.array(consos, dtype=float) 
    424436 
    425   conso_per_day = gencmip6.alloc / gencmip6.days 
     437  conso_per_day = projet.alloc / projet.days 
    426438 
    427439  theo_uses = np.array([100.*item.theo_use for item in selected_items], 
     
    456468  # -------------------- 
    457469  title = "Consommation {}\n({:%d/%m/%Y} - {:%d/%m/%Y})".format( 
    458     gencmip6.project.upper(), 
    459     gencmip6.date_init, 
    460     gencmip6.deadline 
    461   ) 
    462  
    463   plot_config(fig, ax_conso, ax_theo, xcoord, dates, title, conso_per_day) 
     470    projet.project.upper(), 
     471    projet.date_init, 
     472    projet.deadline 
     473  ) 
     474 
     475  plot_config( 
     476    fig, ax_conso, ax_theo, xcoord, dates, title, conso_per_day 
     477  ) 
    464478 
    465479  # ... Save figure ... 
     
    469483                         "{}_{}.pdf".format(img_name, today)) 
    470484 
    471   plot_save(img_in, img_out, title) 
     485  plot_save(img_in, img_out, title, DIR) 
    472486 
    473487  # ... Publish figure on dods ... 
    474488  # ------------------------------ 
    475489  if args.dods: 
    476     dods_cp(img_in) 
     490    dods_cp(img_in, DIR) 
    477491 
    478492  if args.show: 
Note: See TracChangeset for help on using the changeset viewer.