Ejemplo n.º 1
0
def main():
    ####
    # Setup Arguments
    config = read_config(CONFIG_FILE)
    arg_parcer = lambda : config_parser(config)
    args = arg_parcer()
    if args.alt_config != "":
        if not os.path.isfile(args.alt_config):
            if not os.path.isfile(args.alt_config):
                print('Invalid inputs: {0} '.format(args.alt_config))
                print('                File not found, exiting script.')
                return ValueError('Invalid file')

        config = read_config(args.alt_config.rstrip())
    data = query_db(config,args)
    build_plots(data,config,args)
Ejemplo n.º 2
0
def main():
    ####
    # Setup Arguments
    config = read_config(CONFIG_FILE)
    arg_parcer = lambda : config_parser(config)
    args = arg_parcer()
    if args.alt_config != "":
        if not os.path.isfile(args.alt_config):
            if not os.path.isfile(args.alt_config):
                print('Invalid inputs: {0} '.format(args.alt_config))
                print('                File not found, exiting script.')
                return ValueError('Invalid file')

        config = read_config(args.alt_config.rstrip())
    models = config["models"]
    scenarios = config["scenarios"]
    mdl_keys = config["models_used"]
    index =config["graph_index"]
    index_name = config["graph_names"]
    data = build_model(args,config)

    copcs = data.index.unique(level='copc')
    mdl = data.index.unique(level='mdl_id')
    for copc in copcs:
        for mdl_ind in mdl:
            if mdl_ind in mdl_keys:

                subset = data.iloc[data.index.get_level_values('mdl_id') == mdl_ind]
                subset = subset.iloc[subset.index.get_level_values('copc') == copc]

                if subset.size and copc=='Tc99':
                    unit = subset['unit_out'].values[0]
                    subset = subset.reset_index(level=['copc','mdl_id'], drop=True)
                    subset.drop(["unit_out"],axis=1, inplace=True)
                    title1 = scenarios[mdl_ind]
                    title2 = "{} ({})".format(copc,models[mdl_ind])
                    title3 = "Concentration"
                    file_name = "{}_{}_{}".format(scenarios[mdl_ind],models[mdl_ind],copc)
                    #quad_plot(args.output.rstrip(),file_name,title1,title2,title3,index,index_name,subset,unit)
                    penta_plot(args.output.rstrip(),file_name,title1,title2,title3,index,index_name,subset,unit)
                    if "max" in subset.columns.values:
                        file_name = "{}_{}_{}_global".format(scenarios[mdl_ind],models[mdl_ind],copc)
                        title1 = ""
                        title2 = "{} ({})".format(copc,models[mdl_ind])
                        title3 = "Concentration"
                        bi_plot(args.output.rstrip(),file_name,title1,title2,title3,'graphs','graphs',build_max_data(subset,index,index_name),unit)
Ejemplo n.º 3
0
""" 
   configure execution of the vzreducer

"""

import sys, os

sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))

import pylib.gwreducer.constants as constants
from pylib.config.config import read_config
from pylib.autoparse.autoparse import config_parser

config = read_config(constants.CONFIG_FILE)
""" contains the results of the config file """
parse_args = lambda: config_parser(config)
""" reads parses the command line args and loads them to a namespace"""
Ejemplo n.º 4
0
def parse_args():
    args = config_parser(config)
    validateArguments(args)
    return args
Ejemplo n.º 5
0
def main():
    ####
    # Setup Arguments
    #parser = argparse.ArgumentParser()
    #parser.add_argument("input", type=str, help="out directory.")
    #parser.add_argument("output", type=str, help="out directory.")
    #parser.add_argument("-startyear", type=int, default=-1, help="start year of graph")
    #parser.add_argument("-endyear", type=int, default=-1, help="end year of graph")
    #parser.add_argument("-single", type=str2bool, nargs='?', const=True, default=False, help="Model all cells for single model.")
    #parser.add_argument("-config", type=str, default=thisdir, help="alternate configuration file")
    #args = parser.parse_args()
    config = read_config(CONFIG_FILE)
    arg_parcer = lambda: config_parser(config)
    args = arg_parcer()
    if args.alt_config != "":
        if not os.path.isfile(args.alt_config):
            if not os.path.isfile(args.alt_config):
                print('Invalid inputs: {0} '.format(args.alt_config))
                print('                File not found, exiting script.')
                return ValueError('Invalid file')

        config = read_config(args.alt_config.rstrip())

    global m_200e
    m_200e = config['m_200e']
    global m_200w
    m_200w = config['m_200w']
    global m_pa
    m_pa = config['m_pa']
    global colors
    colors = config['colors']
    global copcs_chems
    copcs_chems = config['copcs_chems']
    global copcs_rads
    copcs_rads = config['copcs_rads']
    global copcs
    copcs = config['copcs']
    #input_dir = args.input.rstrip()
    #out_dir = args.output.rstrip()
    #end_year = args.endyear
    #start_year = args.startyear
    #print(input_dir)
    #print(out_dir)
    #print(start_year)
    #print(end_year)
    if args.single:
        data, model, copc, unit = build_model(args)
        data.to_csv(os.path.join(args.output.rstrip(),
                                 r'{}_{}_all_cells.csv'.format(model, copc)),
                    header=True)
        plot_model(args, data, model, copc, unit)
    else:
        models = build_data(args)
        for copc in copcs_chems:
            build_plots(args, models, m_200e, '200 East', copc, 'ug')
            build_plots(args, models, m_200w, '200 West', copc, 'ug')
            build_plots(args, models, m_pa, 'PAs', copc, 'ug')
        for copc in copcs_rads:
            build_plots(args, models, m_200e, '200 East', copc, 'pci')
            build_plots(args, models, m_200w, '200 West', copc, 'pci')
            build_plots(args, models, m_pa, 'PAs', copc, 'pci')