How to use the tonic.io.read_config function in tonic

To help you get started, we’ve selected a few tonic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github UW-Hydro / VIC / tests / run_tests.py View on Github external
See Also
    --------
    run_unit_tests
    run_examples
    run_system
    run_release
    '''

    # Print test set welcome
    print('\n-'.ljust(OUTPUT_WIDTH + 1, '-'))
    print('Running Science Tests')
    print('-'.ljust(OUTPUT_WIDTH, '-'))

    # Get setup
    config = read_config(config_file)

    # drop invalid driver tests
    config = drop_tests(config, driver)

    test_results = OrderedDict()

    # Run individual tests
    for i, (testname, test_dict) in enumerate(config.items()):

        # print out status info
        print('Running test {0}/{1}: {2}'.format(i + 1, len(config.items()),
                                                 testname))

        # Setup directories for test
        dirs = setup_test_dirs(testname, out_dir,
                               mkdirs=['results', 'state', 'logs', 'plots'])
github UW-Hydro / VIC / tests / run_tests.py View on Github external
See Also
    --------
    run_unit_tests
    run_system
    run_science
    run_release
    '''

    # Print test set welcome
    print('\n-'.ljust(OUTPUT_WIDTH + 1, '-'))
    print('Running Examples')
    print('-'.ljust(OUTPUT_WIDTH, '-'))

    # Get setup
    config = read_config(config_file)

    # drop invalid driver tests
    config = drop_tests(config, driver)

    test_results = OrderedDict()

    # Run individual examples
    for i, (testname, test_dict) in enumerate(config.items()):

        # print out status info
        print('Running test {0}/{1}: {2}'.format(i + 1, len(config.items()),
                                                 testname))

        # Setup directories for test
        dirs = setup_test_dirs(testname, out_dir,
                               mkdirs=['results', 'state', 'logs', 'plots'])
github UW-Hydro / tonic / tonic / models / vic / vic2netcdf.py View on Github external
def batch(config_file, create_batch, batch_dir):
    """Create a set of batch configuration files"""

    # Read Configuration files
    config_dict = read_config(config_file)
    options = config_dict.pop('OPTIONS')
    global_atts = config_dict.pop('GLOBAL_ATTRIBUTES')
    domain_dict = config_dict.pop('DOMAIN', None)
    fields = config_dict

    config = SafeConfigParser()
    config.optionxform = str

    # Figure out what to call the new files
    nameprefix = os.path.splitext(os.path.split(config_file)[1])[0]

    if create_batch == 'variables':
        # batch by variables
        # options section
        config.add_section('OPTIONS')
        for option, value in options.items():
github UW-Hydro / tonic / tonic / models / vic / vic2netcdf.py View on Github external
def _run(args):
    """Top level driver"""
    print('running now...')

    if args.create_batch:
        # ------------------------------------------------------------ #
        # Create batch files and exit
        batch(args.config_file, args.create_batch, args.batch_dir)
        # ------------------------------------------------------------ #
    else:
        # ------------------------------------------------------------ #
        # Read Configuration files
        config_dict = read_config(args.config_file,
                                  default_config=default_config)
        options = config_dict.pop('OPTIONS')
        global_atts = config_dict.pop('GLOBAL_ATTRIBUTES')
        if not options['regular_grid']:
            domain_dict = config_dict.pop('DOMAIN')
        else:
            domain_dict = None

        # set aside fields dict
        fields = config_dict

        vic2nc(options, global_atts, domain_dict, fields)
        # ------------------------------------------------------------ #
    return
# -------------------------------------------------------------------- #