Changeset 2413 for TOOLS/ConsoGENCMIP6/bin/plot_login.py
- Timestamp:
- 02/10/15 12:25:07 (9 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/ConsoGENCMIP6/bin/plot_login.py
r2411 r2413 9 9 import os 10 10 import os.path 11 import glob12 import datetime as dt11 # import glob 12 # import datetime as dt 13 13 import numpy as np 14 14 import matplotlib.pyplot as plt 15 15 from matplotlib.backends.backend_pdf import PdfPages 16 16 17 # Application library imports 17 18 from 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) 19 from gencmip6_path import * 101 20 102 21 … … 262 181 # ... Files and directories ... 263 182 # ----------------------------- 264 dir_data = os.path.join("..", "output")265 183 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" 271 190 272 191 # .. Get project info .. … … 324 243 # ... Save figure ... 325 244 # ------------------- 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)) 329 246 330 247 plt.show()
Note: See TracChangeset
for help on using the changeset viewer.