Changeset 2421


Ignore:
Timestamp:
03/02/15 14:19:08 (9 years ago)
Author:
labetoulle
Message:

copy plots on dods

Location:
TOOLS/ConsoGENCMIP6/bin
Files:
1 deleted
4 edited

Legend:

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

    r2417 r2421  
    2525  try : 
    2626    res = subprocess.check_output(command) 
    27   except Exception as rc : 
    28     # print(rc) 
     27  except Exception as rc: 
     28    print(rc) 
    2929    res = None 
    3030 
     
    3737  command = ["du", "-sbh", dirname] 
    3838  try : 
    39     res = float(subprocess.check_output(command)) 
     39    res = subprocess.check_output(command) 
     40    res = res.split()[0] 
     41 
    4042  except Exception as rc : 
    4143    print(rc) 
     
    6567      print(rc) 
    6668      exit() 
    67     with open(os.path.join(DIR["DATA"], OUT_CCCMP), "w") as fileout: 
     69    with open(os.path.join(DIR["DATA"], OUT["CCCMP"]), "w") as fileout: 
    6870      fileout.write(res) 
    6971 
     
    259261      igcm_out = os.path.join(storedir, "IGCM_OUT") 
    260262 
    261       for dirname in os.listdir(igcm_out): 
    262         print(dirname, get_dirsize(dirname)) 
    263  
     263      if not os.path.isdir(igcm_out): 
     264        break 
     265 
     266      dirlist = [] 
     267      try: 
     268        dirlist = os.listdir(igcm_out) 
     269      except OSError as rc: 
     270        print("Error on os.listdir({}):\n{}".format(igcm_out, rc)) 
     271 
     272      for dirname in dirlist: 
    264273        result_str = "{:%Y-%m-%d} {:10s} {:>7s} {:s}\n".format( 
    265274                       today, 
    266275                       login, 
    267                        get_dirsize(dirname), 
    268                        dirname 
     276                       get_dirsize(os.path.join(igcm_out, dirname)), 
     277                       os.path.join(igcm_out, dirname) 
    269278                     ) 
    270         if args.dryrun: 
     279 
     280        if args.dryrun or args.verbose: 
    271281          print(result_str.strip()) 
    272         else: 
     282 
     283        if not args.dryrun: 
    273284          fileout.write(result_str) 
    274285 
  • TOOLS/ConsoGENCMIP6/bin/gencmip6.py

    r2420 r2421  
    66 
    77# standard library imports 
    8 # from argparse import ArgumentParser 
    98import socket 
    109import os 
    1110import os.path 
    1211import glob 
     12import shutil 
    1313import datetime as dt 
    1414import numpy as np 
    15 # import matplotlib.pyplot as plt 
    16 # from matplotlib.backends.backend_pdf import PdfPages 
     15 
     16# Application library imports 
     17from gencmip6_path import * 
     18 
     19 
     20######################################## 
     21def dods_cp(filein): 
     22  """ 
     23  """ 
     24  if not DIR["DODS"]: 
     25    print("DODS directory not defined") 
     26    return 
     27 
     28  fileout = os.path.join(DIR["DODS"], os.path.basename(filein)) 
     29  shutil.copy(filein, fileout) 
     30 
     31  return 
    1732 
    1833 
  • TOOLS/ConsoGENCMIP6/bin/gencmip6_path.py.init

    r2417 r2421  
    1515ROOT_DIR = os.getcwd() 
    1616 
     17# Common paths 
    1718DIR = { 
    1819  "ROOT": ROOT_DIR, 
     
    2021  "SAVE": os.path.join(ROOT_DIR, "save"), 
    2122  "PLOT": os.path.join(ROOT_DIR, "plot"), 
     23  "DODS": None, 
     24} 
     25 
     26# Common files 
     27OUT = { 
     28  "PARAM": "OUT_CONSO_PARAM", 
     29  "BILAN": "OUT_CONSO_BILAN", 
     30  "UTHEO": "OUT_CONSO_UTHEO", 
     31  "LOGIN": "OUT_CONSO_LOGIN", 
     32  "STORE": "OUT_CONSO_STORE", 
     33  "CCCMP": "ccc_myproject.dat" 
    2234} 
    2335 
     
    2537if __name__ == "__main__": 
    2638  print(DIR, ) 
    27 2 
     39  print(OUT, ) 
  • TOOLS/ConsoGENCMIP6/bin/plot_bilan.py

    r2420 r2421  
    1111import datetime as dt 
    1212import numpy as np 
    13 import matplotlib.pyplot as plt 
    14 from matplotlib.backends.backend_pdf import PdfPages 
    1513 
    1614# Application library imports 
     
    252250  parser = ArgumentParser() 
    253251  parser.add_argument("-v", "--verbose", action="store_true", 
    254                       help="Verbose mode") 
     252                      help="verbose mode") 
    255253  parser.add_argument("-f", "--full", action="store_true", 
    256254                      help="plot the whole period") 
     
    263261  parser.add_argument("-m", "--max", action="store_true", 
    264262                      help="plot with y_max = allocation") 
     263  parser.add_argument("-s", "--show", action="store_true", 
     264                      help="interactive mode") 
     265  parser.add_argument("-d", "--dods", action="store_true", 
     266                      help="copy output on dods") 
    265267 
    266268  return parser.parse_args() 
     
    272274  # .. Initialization .. 
    273275  # ==================== 
     276 
    274277  # ... Command line arguments ... 
    275278  # ------------------------------ 
    276279  args = get_arguments() 
    277280 
     281  # ... Turn interactive mode off ... 
     282  # --------------------------------- 
     283  if not args.show: 
     284    import matplotlib 
     285    matplotlib.use('Agg') 
     286 
     287  import matplotlib.pyplot as plt 
     288  from matplotlib.backends.backend_pdf import PdfPages 
     289 
     290  if not args.show: 
     291    plt.ioff() 
     292 
    278293  # ... Files and directories ... 
    279294  # ----------------------------- 
    280   file_param = get_last_file(DIR["DATA"], OUT["PARAM"]) 
    281   file_utheo = get_last_file(DIR["DATA"], OUT["UTHEO"]) 
    282   file_bilan = get_last_file(DIR["DATA"], OUT["BILAN"]) 
     295  file_param = get_last_file(DIR["SAVE"], OUT["PARAM"]) 
     296  file_utheo = get_last_file(DIR["SAVE"], OUT["UTHEO"]) 
     297  file_bilan = get_last_file(DIR["SAVE"], OUT["BILAN"]) 
    283298  img_name = "bilan.pdf" 
    284299 
     
    373388  plot_save(os.path.join(DIR["PLOT"], img_name)) 
    374389 
    375   plt.show() 
     390  # ... Publish figure on dods ... 
     391  # ------------------------------ 
     392  if args.dods: 
     393    dods_cp(os.path.join(DIR["PLOT"], img_name)) 
     394 
     395  if args.show: 
     396    plt.show() 
Note: See TracChangeset for help on using the changeset viewer.