Exemplo n.º 1
0
    out_dir = sys.argv[3]

    with open(os.path.join(in_dir, 'input.json'), 'r') as f:
        params = json.load(f)

    src = expandfilename(('~', 'transims-us101'))
    dst = expandfilename((tmp_dir, 'transims-us101'))

    dirnames = ['control', 'input', 'output', 'ArcGis']
    dirs = dict((name, expandfilename([dst, name])) for name in dirnames)

    os.mkdir(dst)
    for dstdir in dirs.values():
        os.mkdir(dstdir)

    # Set up runtime directories
    copyglob((src, 'control', '*.ctl'), dirs['control'])
    copyglob((src, 'control', '*.sh'), dirs['control'])
    copyglob((src, 'input', '*'), dirs['input'])

    # Run simulation
    os.chdir(dirs['control'])
    subprocess.call(['./RunAll.sh'])

    # Copy output files to output directory
    copyglob((dirs['control'], '*.prn'), out_dir)
    copyglob((dirs['ArcGis'], '*'), out_dir)
    copyglob((dirs['output'], '*'), out_dir)

    print("Done")
Exemplo n.º 2
0
        model = params['model']
    except:
        model = 'tutorial'

    src = expandfilename(['~', 'bangalore-matsim'])

    indir = expandfilename([tmp_dir, 'input'])
    moddir = expandfilename([indir, model])
    outdir = expandfilename([tmp_dir, 'output', model])

    os.mkdir(indir)
    os.mkdir(moddir)
    # don't make output directory

    # Set up runtime directories
    copyglob([src, 'input', model, '*'], moddir)

    # Run simulation
    os.chdir(tmp_dir)
    subprocess.call([expandfilename([src, 'scripts', 'matsim-runner.sh']),
                     model])

    # Copy output files to output directory
    for ftype in ('*.log', '*.gz', '*.png', '*.txt'):
        copyglob(expandfilename([outdir, ftype]), out_dir)

    itersdir = expandfilename([outdir, 'ITERS'])
    for d in listdirs(itersdir):
        iterglob = expandfilename([itersdir, d, '*'])
        copyglob(iterglob, out_dir, prefix="ITER_" + d + "_")