Example #1
0
def single_orbit(DT_ORBIT=DT_ORBIT,
                 N_ORBIT=N_ORBIT,
                 STRIDE_ORBIT=STRIDE_ORBIT,
                 V_threshold=THRESHOLD,
                 verbose=0):
    X = integrate_one_rk4(
        -0.04346306,
        0.99599451,
        0.02006609,
        dt=DT_ORBIT / float(STRIDE_ORBIT),
        N_integrate=N_ORBIT,
        stride=STRIDE_ORBIT)
    V, h, m = X[0], X[1], X[2]
    Vm, Hm, Mm = tl.splineLS1D(), tl.splineLS1D(), tl.splineLS1D()

    try:
        ni = tl.crossings(V, V_threshold)  # convert to millivolts
        V, h, m = V[ni[-2]:ni[-1]], h[ni[-2]:ni[-1]], m[ni[-2]:ni[-1]]
        t = PI2 * np.arange(V.size) / float(V.size - 1)
        Vm.makeModel(V, t)
        Hm.makeModel(h, t)
        Mm.makeModel(m, t)

    except:
        print '# single_orbit:  No closed orbit found!'
        raise ValueError

    T = DT_ORBIT * V.size

    return Vm, Hm, Mm, T
Example #2
0
	def find_orbit(self, remove=True):

		if self.ORBIT_COMPUTED:
			return

		X = self.integrate(self.model.INITIAL_ORBIT, self.dt/float(self.stride), self.N_integrate, self.stride)
		assert X.shape[0] == self.dimensions
	
		try:
			ni = tl.crossings(X[self.model.IDX_THRESHOLD], self.model.THRESHOLD) # convert to millivolts
			X = X[:, ni[-2]:ni[-1]]
		
			self.period = self.dt*(ni[-1]-ni[-2])
	
			phase = tl.PI2*np.arange(X.shape[1])/float(X.shape[1]-1)
		
			if AUTO_ENABLED: # if enabled, find the exact solution
				t = self.period*np.arange(X.shape[1])/float(X.shape[1]-1)
				self.write_solution(t, X, mode=0)
				phase, X = self.auto_orbit()
				if remove: self.auto_clean()
		
			# splinefit the trajectory
			for i in xrange(self.dimensions):
				self.trajectory[i].makeModel(X[i], phase)
			
			self.ORBIT_COMPUTED = True
		
		except:
			print '# single_orbit:  No closed orbit found!'
			raise ValueError
Example #3
0
def single_orbit(dt=dt,
                 N_integrate=N_integrate,
                 stride=stride,
                 V_threshold=THRESHOLD):
    X = integrate_one_rk4(initial_state,
                          dt=dt / float(stride),
                          N_integrate=N_integrate,
                          stride=stride)
    V, h, n, x, Ca = X[0], X[1], X[2], X[3], X[4]
    V_model, h_model, n_model, x_model, Ca_model = tl.splineLS1D(
    ), tl.splineLS1D(), tl.splineLS1D(), tl.splineLS1D(), tl.splineLS1D()

    try:
        ni = tl.crossings(V, V_threshold)  # convert to millivolts
        V, h, n, x, Ca = V[ni[-2]:ni[-1]], h[ni[-2]:ni[-1]], n[
            ni[-2]:ni[-1]], x[ni[-2]:ni[-1]], Ca[ni[-2]:ni[-1]]
        t = PI2 * np.arange(V.size) / float(V.size - 1)
        V_model.makeModel(V, t)
        h_model.makeModel(h, t)
        n_model.makeModel(n, t)
        x_model.makeModel(x, t)
        Ca_model.makeModel(Ca, t)

    except:
        print '# single_orbit:  No closed orbit found!'
        raise ValueError

    T = dt * V.size

    return V_model, h_model, n_model, x_model, Ca_model, T
Example #4
0
    def find_orbit(self, remove=True):

        if self.ORBIT_COMPUTED:
            return

        X = self.integrate(self.model.INITIAL_ORBIT,
                           self.dt / float(self.stride), self.N_integrate,
                           self.stride)
        assert X.shape[0] == self.dimensions

        try:
            ni = tl.crossings(X[self.model.IDX_THRESHOLD],
                              self.model.THRESHOLD)  # convert to millivolts
            X = X[:, ni[-2]:ni[-1]]

            self.period = self.dt * (ni[-1] - ni[-2])

            phase = tl.PI2 * np.arange(X.shape[1]) / float(X.shape[1] - 1)

            if AUTO_ENABLED:  # if enabled, find the exact solution
                t = self.period * np.arange(X.shape[1]) / float(X.shape[1] - 1)
                self.write_solution(t, X, mode=0)
                phase, X = self.auto_orbit()
                if remove: self.auto_clean()

            # splinefit the trajectory
            for i in xrange(self.dimensions):
                self.trajectory[i].makeModel(X[i], phase)

            self.ORBIT_COMPUTED = True

        except:
            print '# single_orbit:  No closed orbit found!'
            raise ValueError
Example #5
0
	def find_orbit(self):
		X = self.integrate(self.initial_state, self.dt/float(self.stride), self.N_integrate, self.stride)
		assert X.shape[0] == self.dimensions
	
		try:
			ni = tl.crossings(X[self.model.IDX_THRESHOLD], self.model.THRESHOLD) # convert to millivolts
			X = X[:, ni[-2]:ni[-1]]
			phase = tl.PI2*np.arange(X.shape[1])/float(X.shape[1]-1)
	
			for i in xrange(self.dimensions):
				self.trajectory[i].makeModel(X[i], phase)
		
		except:
			print '# single_orbit:  No closed orbit found!'
			raise ValueError
	
		self.period = self.dt*X.shape[1]	 # in msec.
Example #6
0
def single_orbit(dt=dt, N_integrate=N_integrate, stride=stride, V_threshold=THRESHOLD):
	X = integrate_one_rk4(initial_state, dt=dt/float(stride), N_integrate=N_integrate, stride=stride)
	V, h, n, x, Ca = X[0], X[1], X[2], X[3], X[4]
	V_model, h_model, n_model, x_model, Ca_model =  tl.splineLS1D(), tl.splineLS1D(), tl.splineLS1D(), tl.splineLS1D(), tl.splineLS1D()

	try:
		ni = tl.crossings(V, V_threshold) # convert to millivolts
		V, h, n, x, Ca = V[ni[-2]:ni[-1]], h[ni[-2]:ni[-1]], n[ni[-2]:ni[-1]], x[ni[-2]:ni[-1]], Ca[ni[-2]:ni[-1]]
		t = PI2*np.arange(V.size)/float(V.size-1)
		V_model.makeModel(V, t); h_model.makeModel(h, t); n_model.makeModel(n, t); x_model.makeModel(x, t); Ca_model.makeModel(Ca, t)

	except:
		print '# single_orbit:  No closed orbit found!'
		raise ValueError

	
	T = dt*V.size

	return V_model, h_model, n_model, x_model, Ca_model, T
Example #7
0
def single_orbit(DT_ORBIT=0.05, N_ORBIT=5*10**4, STRIDE_ORBIT=10, V_threshold=0., verbose=0):

	X = integrate_one_rk4(INITIAL_ORBIT, DT_ORBIT/float(STRIDE_ORBIT), N_ORBIT, STRIDE_ORBIT)
	x_raw, y = X[0], X[1]
	x_m, y_m = tl.splineLS1D(), tl.splineLS1D()

	try:
		ni = tl.crossings(x_raw, V_threshold) # convert to millivolts
		x, y = x_raw[ni[-2]:ni[-1]], y[ni[-2]:ni[-1]]
		t = tl.PI2*np.arange(x.size)/float(x.size-1)
		x_m.makeModel(x, t); y_m.makeModel(y, t)
	
	except:
		print '# single_orbit:  No closed orbit found!'
		raise ValueError

	T = DT_ORBIT*x.size	 # in msec.

	return x_m, y_m, T
Example #8
0
    q = 0.001

    coupling = q * ones((9), float)
    parameters = params_three()

    print step_three_rk4(
        array([0., 1., 0., 0., 1., 0., 0., 1., 0.]),
        parameters,
        coupling=coupling,
        dt=dt / float(stride),
        stride=stride)
    exit(0)

    X = integrate_one_rk4(
        0., 1., 0., dt=dt / float(stride), N_integrate=N, stride=stride)
    ti = tl.crossings(X[0], -0.04)
    #plot(X[0])
    #for t in ti:
    #	axvline(x=t)
    #show()
    #exit(0)
    initial_states = X[:, :ti[0]]
    #plot(initial_states[0])
    #show()

    initial_states = transpose(initial_states).flatten()
    plot(initial_states[::3])
    show()

    X = cuda_relax_one(initial_states, dt / float(stride), N)
    plot(X[:, 0])
Example #9
0
    parameters = params_three()

    print step_three_rk4(array([0., 1., 0., 0., 1., 0., 0., 1., 0.]),
                         parameters,
                         coupling=coupling,
                         dt=dt / float(stride),
                         stride=stride)
    exit(0)

    X = integrate_one_rk4(0.,
                          1.,
                          0.,
                          dt=dt / float(stride),
                          N_integrate=N,
                          stride=stride)
    ti = tl.crossings(X[0], -0.04)
    #plot(X[0])
    #for t in ti:
    #	axvline(x=t)
    #show()
    #exit(0)
    initial_states = X[:, :ti[0]]
    #plot(initial_states[0])
    #show()

    initial_states = transpose(initial_states).flatten()
    plot(initial_states[::3])
    show()

    X = cuda_relax_one(initial_states, dt / float(stride), N)
    plot(X[:, 0])
Example #10
0
    from pylab import *
    import tools
    import time

    dt = 0.05
    stride = 20
    N = 10**6
    N_initials = 100
    coupling = 0.01 * ones((12), float)

    params.update(sigma_0=0.01)
    X = integrate_four_em(randn(8), coupling, dt / float(stride), N, stride)

    recurrences = [
        tools.crossings(X[:, i], threshold=0.) for i in xrange(X.shape[1])
    ]

    t, dphi = tools.unwrapped_phase_differences(recurrences)

    ax = subplot(211)
    plot(X[:, 0], 'b-')
    plot(X[:, 1] - 1., 'g-')
    plot(X[:, 2] - 2., 'r-')
    plot(X[:, 3] - 3., 'y-')

    subplot(212, sharex=ax)
    for i in xrange(3):
        print t, dphi[i]
        plot(t, dphi[i], label='dphi_1%i' % (2 + i))