Example #1
0
def myCalculate(x1, y1, z1):
    x = x1
    y = y1
    z = z1
    tStep = 0.1
    size = 1.0

    myTorus = torus(size)
    myTorus.setMarker(x, y, z)

    for t in range(int(sys.argv[1])):
        vX = dx(x, y, z)
        vY = dy(x, y, z)
        vZ = dz(x, y, z)
        print(vX, vY, vZ)
        x += (vX * tStep)
        y += (vY * tStep)
        z += (vZ * tStep)

        x = round(x, 9)
        y = round(y, 9)
        z = round(z, 9)

        myTorus.setMarker(x, y, z)
        x, y, z = myTorus.getMarker()
    return myTorus.getPath()
Example #2
0
def initialize():
	pl.close('all')
	global info, network, system, traces, torus, sweepingPhasespace
	reload(model)

	info = nf.info()
	network = netw.network(info=info)
	system = sys.system(info=info, network=network)
	traces = tra.traces(system, network, info=info)
	torus = tor.torus(system, network, traces, info=info)
	network.system = system
	system.traces = traces


	## customize system for web
	system.setParams(epsilon=0.3)
	system.ax.set_xlabel(r'Inactivation Variable')
	system.ax.set_ylabel(r'Voltage Variable')
	system.ax.set_title('')
	system.fig.tight_layout()
	plugins.connect(system.fig, DragPlugin(eventHandlerURL="updatesystem", radioButtonID="systemRadio"))

	# customize network
	network.ax.patch.set_facecolor('#777777')
	network.moveText(2, [0.02, -0.1])
	network.moveText(3, [0.02, -0.1])
	network.ax.texts[6].set_text('1')
	network.ax.texts[7].set_text('2')
	network.ax.texts[8].set_text('3')
	plugins.connect(network.fig, DragPlugin(eventHandlerURL="updatenetwork", radioButtonID="networkRadio"))

	# customize traces
	traces.ax.patch.set_facecolor('#777777')
	traces.fig.tight_layout()

	# customize torus
	torus.ax_traces.set_xlabel(r'phase lag: 1-2')
	torus.ax_basins.set_xlabel(r'phase lag: 1-2')
	torus.ax_traces.set_ylabel(r'phase lag: 1-3')
	torus.fig.tight_layout()
	torus.switch_processor()	# switches on the gpu if available
	if torus.USE_GPU: torus.setGridsize(24)
	plugins.connect(torus.fig, ClickPlugin(eventHandlerURL="updatetorus", radioButtonID="torusRadio"))

	# reload timing variable
	sweepingPhasespace = False;
Example #3
0
def stream_torus():
    if 'curl' not in request.headers.get(
            'User-Agent', 'unknown') and 'curl' not in request.args.get(
                'user-agent', 'unknown'):
        return app.send_static_file('ubuntu.html')

    mesh = torus(1, 0.5, 12, 32)
    w, h = parse_resolution(request.args.get('resolution', '80x24'))
    aspect = float(request.args.get('aspect', '0.5'))
    fps = float(request.args.get('fps', 25))
    fov = float(request.args.get('fov', 60))
    d = float(request.args.get('d', 3.2))

    light1 = numgl.normalized(np.array([0, 1, 1]))
    angular_velocity = np.array([1.7, 2, 0])
    projection = Matrix44.perspective_projection(fov, aspect * w / h, 0.1,
                                                 10.0)

    dt = 1 / fps
    beginning = time.time()

    def frames():
        with create_context() as ctx:
            renderer = Renderer(ctx, (w, h), mesh, projection=projection)

            for _ in count():
                t = time.time() - beginning
                theta = t * angular_velocity
                rotation = Matrix44.from_z_rotation(
                    theta[2]) * Matrix44.from_y_rotation(
                        theta[1]) * Matrix44.from_x_rotation(theta[0])
                camera = Matrix44.from_translation(np.array([0, 0, -d
                                                             ])) * rotation
                renderer.render(camera, light1)
                buffer = np.mean(renderer.snapshot2(), axis=-1)
                lines = ascii.shade(buffer)
                text = "resolution: {w}x{h}, fov: {fov:.2f}, fps: {fps:.2f}, d: {d:.2f}, by: vidstige 2020".format(
                    w=w, h=h, fov=fov, fps=fps, d=d)
                lines[-2] = scroller(lines[-2], text, t, w=-12)
                yield b"\033[2J\033[1;1H" + b'\n'.join(lines) + b"\n"
                duration = (time.time() - beginning) - t
                if dt - duration > 0:
                    time.sleep(dt - duration)

    return Response(frames(), mimetype='text/plain;charset=UTF-8')
Example #4
0
def torus_image():
    mesh = torus(1, 0.5, 12, 32)
    w, h = parse_resolution(request.args.get('resolution', '80x50'))
    aspect = float(request.args.get('aspect', '1'))
    t = float(request.args.get('t', 0))

    light1 = numgl.normalized(np.array([0, 1, 1]))
    angular_velocity = np.array([1.7, 2, 0])
    projection = Matrix44.perspective_projection(60.0, aspect * w / h, 0.1,
                                                 10.0)
    camera = Matrix44.from_translation(np.array(
        [0, 0, -3])) * Matrix44.from_eulers(t * angular_velocity)

    with create_context() as ctx:
        renderer = Renderer(ctx, (w, h), mesh, projection=projection)
        renderer.render(camera, light1)
        image = renderer.snapshot()
        from io import BytesIO
        with BytesIO() as f:
            image.save(f, 'png')
            return Response(f.getvalue(), mimetype='image/png')
Example #5
0
#!/usr/bin/env python

#import Tkinter
import system as sys
import network as netw
import traces as tra
import info as nf
import torus as tor
import pylab as pl

#root = Tkinter.Tk()
#screen_width = root.winfo_screenwidth()
#screen_height = root.winfo_screenheight()

pos_info = '+0+600'
pos_tra = '+300+600'
pos_net = '+300+0'
pos_sys = '+0+0'
pos_torus = '+800+0'

i = nf.info(position=pos_info)
s = sys.system(info=i, position=pos_sys)
n = netw.network(info=i, position=pos_net)
t = tra.traces(s, n, info=i, position=pos_tra)
tor = tor.torus(s, n, t, info=i, position=pos_torus)

pl.show()
Example #6
0

import system as sys
import network3N as netw
import traces as tra
import info as nf
import torus as tor
import pylab as pl

pos_info = '+0+600'
pos_tra = '+300+600'
pos_net = '+300+0'
pos_sys = '+0+0'
pos_torus = '+800+0'

info = nf.info(position=pos_info)
net = netw.network(g_inh=0.015, info=info, position=pos_net)
system = sys.system(info=info, position=pos_sys, network=net)
traces = tra.traces(system, net, info=info, position=pos_tra)
torus = tor.torus(system, net, traces, info=info, position=pos_torus)

net.system = system
system.traces = traces

if pl.get_backend() == 'TkAgg':
	system.fig.tight_layout()
	traces.fig.tight_layout()
	torus.fig.tight_layout()

pl.show()
Example #7
0
import network as netw
import traces as tra
import info as nf
import torus as tor
import pylab as pl

#root = Tkinter.Tk()
#screen_width = root.winfo_screenwidth()
#screen_height = root.winfo_screenheight() 

pos_info = '+0+600'
pos_tra = '+300+600'
pos_net = '+300+0'
pos_sys = '+0+0'
pos_torus = '+800+0'

i = nf.info(position=pos_info)
n = netw.network(info=i, position=pos_net)
s = sys.system(info=i, position=pos_sys, network=n)
n.system = s
t = tra.traces(s, n, info=i, position=pos_tra)
tor = tor.torus(s, n, t, info=i, position=pos_torus)

if pl.get_backend() == 'TkAgg':
	s.fig.tight_layout()
	#n.fig.tight_layout()
	t.fig.tight_layout()
	tor.fig.tight_layout()

pl.show()
Example #8
0
def main():
    mesh = torus(1, 0.4, 8, 8)
    draw((80, 24), mesh, aspect=0.5)
Example #9
0
#!/usr/bin/env python

import system as sys
import network3N as netw
import traces as tra
import info as nf
import torus as tor
import pylab as pl

pos_info = '+0+600'
pos_tra = '+300+600'
pos_net = '+300+0'
pos_sys = '+0+0'
pos_torus = '+800+0'

info = nf.info(position=pos_info)
net = netw.network(g_inh=0.015, info=info, position=pos_net)
system = sys.system(info=info, position=pos_sys, network=net)
traces = tra.traces(system, net, info=info, position=pos_tra)
torus = tor.torus(system, net, traces, info=info, position=pos_torus)

net.system = system
system.traces = traces

if pl.get_backend() == 'TkAgg':
    system.fig.tight_layout()
    traces.fig.tight_layout()
    torus.fig.tight_layout()

pl.show()
Example #10
0
def myCalculate(x1, y1, z1, x2, y2, z2):
    tStep = 0.001
    size = 100.0
    for t in range(100000):
        vXa = dx(x1, y1, z1)
        vYa = dy(x1, y1, z1)
        vZa = dz(x1, y1, z1)

        x1 += (vXa * tStep)
        y1 += (vYa * tStep)
        z1 += (vZa * tStep)

        x1 = round(x1, 9)
        y1 = round(y1, 9)
        z1 = round(z1, 9)
    
    x2 = x1 + pow(10, -8)
    y2 = y1
    z2 = z1

    myTorus = torus(size, x1, y1, z1, x2, y2, z2)
    myTorus.setAMarker(x1, y1, z1)
    myTorus.setBMarker(x2, y2, z2)
    lyapSum = 0
    for t in range(int(sys.argv[1])):

        vXa = dx(x1, y1, z1)
        vYa = dy(x1, y1, z1)
        vZa = dz(x1, y1, z1)
        vXb = dx(x2, y2, z2)
        vYb = dy(x2, y2, z2)
        vZb = dz(x2, y2, z2)

        x1 += (vXa * tStep)
        y1 += (vYa * tStep)
        z1 += (vZa * tStep)
        x2 += (vXb * tStep)
        y2 += (vYb * tStep)
        z2 += (vZb * tStep)

        x1 = round(x1, 9)
        y1 = round(y1, 9)
        z1 = round(z1, 9)
        x2 = round(x2, 9)
        y2 = round(y2, 9)
        z2 = round(z2, 9)

        d00 = myTorus.getAMarker()
        d01 = myTorus.getBMarker()
        d10 = [x1, y1, z1]
        d11 = [x2, y2, z2]
        adjustA, adjustB, adjustC, lyap = lyapCalc(d00, d01, d10, d11)
        if t > 2000:
            lyapSum = lyapSum + lyap
        myTorus.setAMarker(x1, y1, z1)
        myTorus.setBMarker(adjustA, adjustB, adjustC)
        #myTorus.setBMarker(x2, y2, z2)
    print("lyap", (lyapSum / (int(sys.argv[1]) - 2000)) / tStep)
    px1, py1, pz1 = myTorus.getAPath()
    px2, py2, pz2 = myTorus.getBPath()
    return px1, py1, pz1, px2, py2, pz2
Example #11
0
#!/usr/bin/env python



#import Tkinter
import system as sys
import network as netw
import traces as tra
import info as nf
import torus as tor
import pylab as pl

#root = Tkinter.Tk()
#screen_width = root.winfo_screenwidth()
#screen_height = root.winfo_screenheight() 

pos_info = '+0+600'
pos_tra = '+300+600'
pos_net = '+300+0'
pos_sys = '+0+0'
pos_torus = '+800+0'

info = nf.info(position=pos_info)
system = sys.system(info=info, position=pos_sys)
network = netw.network(info=info, position=pos_net)
traces = tra.traces(system, network, info=info, position=pos_tra)
tor = tor.torus(system, network, traces, info=info, position=pos_torus)

pl.show()