#Tasia Raymer
# 250 Project
#This program plots the time series starting from a cluster of initial conditions in order to see the 
#sensitivity to initial conditions

from CpledLogClass import *

#from pylab import *
import pylab as pl
from RandomArray import *
from math import sqrt
from math import log
from Scientific.Geometry import Vector

#set parameter values:
r1=3.7
r2=3.7
d=0.1

#set dynamics equations from the class with the above parameters:
F=CpledLogEqs(r1,r2,d)

# intial conditions are choose randomly from uniform [0,1] distribution:
seed()
# uniform(0,1)
# x1_0=uniform(0,1)
# x2_0=uniform(0,1)

#the  time series starting from each initial condtion will have it's own color:
c=['b.','g.','r.','y.','c.','k.']
cc=['blue','green','red','yellow','cyan','black']

x1_0=[uniform(0,1)]
x2_0=[uniform(0,1)]

for i in range(1,6):
	x1_0.append(x1_0[0]+i*.001)
	x2_0.append(x2_0[0]+.001*i)
nTrans=200
nIterations=500


#sweep over initial conditions:
for i in range(6):
	x1=x1_0[i]
	x2=x2_0[i]
	print cc[i]
	print x1
	print x2
	print '\n'

	for n in range(nTrans):
	#evolve flow:
		x1temp=F.x1dot(x1,x2)
		x2=F.x2dot(x1,x2)
		x1=x1temp
	
	x1vals=[x1]
	x2vals=[x2]
	for n in range(nIterations):
		x1temp=F.x1dot(x1,x2)
		x2=F.x2dot(x1,x2)
		x1=x1temp

		x1vals.append(x1)
		x2vals.append(x2)
		
	pl.title('r1=%g r2=%g d=%g'%(r1,r2,d))
	pl.xlabel('x1(n)')
	pl.ylabel('x2(n)')
	pl.plot(x1vals,x2vals,c[i],label='(%.4f,%.4f)'%(x1_0[i],x2_0[i]))


pl.legend(loc=0)
pl.show()
