Ignore:
Timestamp:
02/10/15 12:25:07 (9 years ago)
Author:
labetoulle
Message:

Move all scripts to the same dir to use common configuration files

File:
1 moved

Legend:

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

    r2411 r2413  
    99import os 
    1010import os.path 
    11 import glob 
    12 import datetime as dt 
     11# import glob 
     12# import datetime as dt 
    1313import numpy as np 
    1414import matplotlib.pyplot as plt 
    1515from matplotlib.backends.backend_pdf import PdfPages 
    1616 
     17# Application library imports 
    1718from gencmip6 import * 
    18  
    19  
    20 # ######################################## 
    21 # def string_to_percent(x): 
    22 #   """ 
    23 #   """ 
    24 #   return float(x.strip("%"))/100. 
    25  
    26  
    27 # ######################################## 
    28 # def string_to_float(x): 
    29 #   """ 
    30 #   """ 
    31 #   return float(x.strip("h")) 
    32  
    33  
    34 # ######################################## 
    35 # def string_to_date(ssaammjj, fmt="%Y-%m-%d"): 
    36 #   """ 
    37 #   """ 
    38 #   return dt.datetime.strptime(ssaammjj, fmt) 
    39  
    40  
    41 # ######################################## 
    42 # def date_to_string(dtdate, fmt="%Y-%m-%d"): 
    43 #   """ 
    44 #   """ 
    45 #   return dt.datetime.strftime(dtdate, fmt) 
    46  
    47  
    48 # ######################################## 
    49 # def get_last_file(dir_data, pattern): 
    50 #   """ 
    51 #   """ 
    52 #   current_dir = os.getcwd() 
    53 #   os.chdir(dir_data) 
    54 #   filename = pattern + "*" 
    55 #   return_value = sorted(glob.glob(os.path.join(dir_data, filename)))[-1] 
    56 #   os.chdir(current_dir) 
    57 #   return return_value 
    58  
    59  
    60 # ######################################## 
    61 # class Project(object): 
    62  
    63 #   #--------------------------------------- 
    64 #   def __init__(self): 
    65 #     self.project   = "" 
    66 #     self.date_init = "" 
    67 #     self.deadline  = "" 
    68 #     self.alloc     = 0 
    69  
    70 #   #--------------------------------------- 
    71 #   def fill_data(self, filein): 
    72 #     import json 
    73 #     dico = json.load(open(filein, "r")) 
    74 #     self.project = dico["project"] 
    75 #     self.deadline = string_to_date(dico["deadline"]) + \ 
    76 #                     dt.timedelta(days=-1) 
    77 #     self.alloc = dico["alloc"] 
    78  
    79 #   #--------------------------------------- 
    80 #   def get_date_init(self, filein): 
    81 #     data = np.genfromtxt( 
    82 #       filein, 
    83 #       skip_header=1, 
    84 #       converters={0: string_to_date, 
    85 #                   1: string_to_percent}, 
    86 #       missing_values="nan", 
    87 #     ) 
    88 #     dates, utheos = zip(*data) 
    89  
    90 #     (x1, x2) = (np.nanargmin(utheos), np.nanargmax(utheos)) 
    91  
    92 #     m = np.array([[x1, 1.], [x2, 1.]]) 
    93 #     n = np.array([utheos[x1], utheos[x2]]) 
    94  
    95 #     (a, b) = np.linalg.solve(m, n) 
    96  
    97 #     delta = int(round((-b/a)-x1 + 1)) 
    98  
    99 #     d1 = dates[x1] 
    100 #     self.date_init = d1 + dt.timedelta(days=delta) 
     19from gencmip6_path import * 
    10120 
    10221 
     
    262181  # ... Files and directories ... 
    263182  # ----------------------------- 
    264   dir_data = os.path.join("..", "output") 
    265183  file_pattern = "OUT_CONSO_" 
    266   file_param = get_last_file(dir_data, file_pattern+"PARAM") 
    267   file_utheo = get_last_file(dir_data, file_pattern+"UTHEO") 
    268   file_bilan = get_last_file(dir_data, file_pattern+"BILAN") 
    269   file_login = get_last_file(dir_data, file_pattern+"LOGIN") 
    270   file_store = get_last_file(dir_data, file_pattern+"STORE") 
     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" 
    271190 
    272191  # .. Get project info .. 
     
    324243  # ... Save figure ... 
    325244  # ------------------- 
    326   dirout = "img" 
    327   img_name = "login.pdf" 
    328   plot_save(os.path.join(dirout, img_name)) 
     245  plot_save(os.path.join(DIR["PLOT"], img_name)) 
    329246 
    330247  plt.show() 
Note: See TracChangeset for help on using the changeset viewer.