Exemple #1
0
def init(args):

    path = args["root"] if "root" in args else "."
    (rootdir, file) = find("strings.xml", path)

    global root
    root = rootdir

    global resourceFiles
    resourceFiles = {}
Exemple #2
0
def init(args):

	path = args["root"] if "root" in args else "."
	(rootdir, file) = find("strings.xml", path)

	global root
	root = rootdir

	global resourceFiles
	resourceFiles = {}
Exemple #3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import plotting as pl
import numpy as np
import getopt as go
from sys import argv
import files
import yaml

# options parsing
options, args = go.getopt(argv[1:], 's', ['save'])
save = bool(options)

# read npz file
npz_path = files.find(args[0], 'npz')
f = np.load(npz_path)
connections = f['connections'].tolist()
nodes = f['nodes'].tolist()
t = f['t']

# read yml file
yml_path = files.find(args[0], 'yml')
ps = yaml.load(open(yml_path).read())
plmat = ps['plot_matrix'] if 'plot_matrix' in ps else None

if save:
    files.delete_images()

# show/save a graph for every connection
# or a single graph if plot_matrix is specified
Exemple #4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import numpy as np
from sys import argv
import files

# read npz file
npz_path = files.find(argv[1], 'npz')
f = np.load(npz_path)
connections = f['connections'].tolist()
nodes = f['nodes'].tolist()
dt = f['dt']

init_amt  = 0.
final_amt = 0.

print("\n# Connections")
for c in connections:
    init_amt  += np.sum(c.dens[:,0]) * c.dx
    amt = np.sum(c.dens[:,-1]) * c.dx
    final_amt += amt
    print("{0}: {1}".format(c.to_s(), amt))
    print(">1? {0}".format(np.extract(c.dens > 1., c.dens).size))
    print("<0? {0}".format(np.extract(c.dens < 0., c.dens).size))
    print c.dx
    print dt/c.dx*c.max_speed

print("\n# Nodes")
for n in nodes:
    final_amt += n.received()
Exemple #5
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import lwrnetwork as lw
import plotting as pl
import yaml
import files
from sys import argv
import numpy as np

# look for a yml file in the given folder
# (file must have the same name of the folder)
# and parse the simulation parameters
yml_path = files.find(argv[1], 'yml')
ps = yaml.load(open(yml_path).read())

lw.setup(ps['t_max'], ps['t_points_num'])

nodes = {}
connections = {}
for name in ps['nodes']:
    opts = ps['nodes'][name]
    if   opts['type'] == 'sender':
        nodes[name] = lw.SenderNode(name)
    elif opts['type'] == 'receiver':
        nodes[name] = lw.ReceiverNode(name)
    elif opts['type'] == 'matrix_distribution':
        nodes[name] = lw.MatrixDistributionNode(name)
    connections[name] = {}

for name in ps['nodes']: