Beispiel #1
0
def aeolis():
    '''aeolis : a process-based model for simulating supply-limited aeolian sediment transport

    Usage:
        aeolis <config> [options]

    Positional arguments:
        config             configuration file

    Options:
        -h, --help         show this help message and exit
        --callback=FUNC    reference to callback function (e.g. example/callback.py:callback)
        --restart=FILE     model restart file
        --verbose=LEVEL    logging verbosity [default: 20]
        --debug            write debug logs

    '''

    print_license()
    
    arguments = docopt.docopt(aeolis.__doc__)

    logger = logging.getLogger('aeolis')
    logger.setLevel(logging.DEBUG)
    
    # initialize file logger
    filehandler = logging.FileHandler('%s.log' % os.path.splitext(arguments['<config>'])[0], mode='w')
    filehandler.setLevel(logging.DEBUG if arguments['--debug'] else logging.INFO)
    filehandler.setFormatter(logging.Formatter('%(asctime)-15s %(name)-8s %(levelname)-8s %(message)s'))
    logger.addHandler(filehandler)

    # initialize console logger
    streamhandler = logging.StreamHandler()
    streamhandler.setLevel(int(arguments['--verbose']))
    streamhandler.setFormatter(StreamFormatter())
    logger.addHandler(streamhandler)

    # start model
    model = AeoLiSRunner(configfile=arguments['<config>'])
    model.run(callback=arguments['--callback'],
              restartfile=arguments['--restart'])
Beispiel #2
0
def aeolis():
    '''aeolis : a process-based model for simulating supply-limited aeolian sediment transport

    Usage:
        aeolis <config> [--callback=FUNC] [--restart=FILE] [--verbose=LEVEL]

    Positional arguments:
        config             configuration file

    Options:
        -h, --help         show this help message and exit
        --callback=FUNC    reference to callback function (e.g. example/callback.py:callback)
        --restart=FILE     model restart file
        --verbose=LEVEL    write logging messages [default: 20]

    '''

    print_license()

    arguments = docopt.docopt(aeolis.__doc__)

    # initialize file logger
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)-15s %(name)-8s %(levelname)-8s %(message)s',
        filename='%s.log' % os.path.splitext(arguments['<config>'])[0])

    # initialize console logger
    console = logging.StreamHandler()
    console.setLevel(int(arguments['--verbose']))
    console.setFormatter(logging.Formatter('%(levelname)-8s %(message)s'))
    logging.getLogger('').addHandler(console)

    # start model
    model = AeoLiSRunner(configfile=arguments['<config>'])
    model.run(callback=arguments['--callback'],
              restartfile=arguments['--restart'])
Beispiel #3
0
def test_integration():

    generate_models()

    for fname in glob.glob(os.path.join(os.path.split(__file__)[0], 'models', '*', 'aeolis.txt')):
        AeoLiSRunner(configfile=fname).run()

        fname1 = '%s.nc' % os.path.splitext(fname)[0]
        fname2 = '%s.json' % os.path.splitext(fname)[0]

        results = check_continuity(fname1)

        with open(fname2, 'r') as fp:
            data = json.load(fp)
            data.update(dict(results=results))
        with open(fname2, 'w') as fp:
            json.dump(data, fp, indent=4)
                
        yield assert_true, results['fraction'] < 0.01 # deficit is smaller than 1%
Beispiel #4
0
from aeolis.model import AeoLiSRunner

for tide_var in [False, True]:
    for wind_var in [False, True]:
        for bar in [False, True]:

            fname = 'aeolis_tide%d_wind%d_bar%d' % (tide_var, wind_var, bar)
            
            model = AeoLiSRunner('aeolis.txt')
            model.set_configfile('%s.txt' % fname)
            model.set_params(output_file='%s.nc' % fname)
            model.set_params(tide_file='tide_sine.txt' if tide_var else 'tide.txt')
            model.set_params(wind_file='wind_random3.txt' if wind_var else 'wind.txt')

            if bar:
                model.run(callback='bar.py:add_bar')
            else:
                model.run()