4#Amanda White
#Rec 1 Prog 5

from pylab import *
from prog5_goldberg import *
from prog5_testsub import *
from prog5_boost import *


#time
#t=[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0]
dt = .1
t = [ time*dt for time in xrange(int(10./dt+1)) ]
tm = [ time*-dt for time in xrange(int(10./dt+1)) ] #creates negative time for graphing light  cone.

#Speed of my ship in terms of c
vs = .7

#Calls sub defined in prog5_goldberg
data_g=goldberg_frame(t,vs)

#Placing the data from goldberg_frame in correct variables
xb=data_g[0] #Back of ship
xf=data_g[1] #Front of ship
xl=data_g[2] #Light beam
xp=data_g[3] #Person walking
xs=data_g[4] #Position of my ship

#Calls sub 'getspeed' to determine that the speed of light is one
vtest=getspeed(xl[4],t[4])
print 'Speed of light is ',vtest

#Calls sub 'boost' to transform each variable to the primed frame.
tb=boost(xb,t,vs) #Back of ship transformed
tf=boost(xf,t,vs) #Front of ship transformed
tl=boost(xl,t,vs) #Light beam transformed
tp=boost(xp,t,vs) #Person transformed
ts=boost(xs,t,vs) #My ship transformed

#Calls sub 'getspeed' to determine that the speed of light is still one in the primed frame
vtest2= getspeed(tl[0][2],tl[1][2])
print 'Speed of light is ',vtest2,'(Transformed)'

#Graph
plot (xb,t,'c-',xf,t,'m-',xl,t,'r--',xp,t,'b-',xs,t,'g-',t,t,'y--',tb[0],tb[1],'c-',tf[0],tf[1],'m-',tl[0],tl[1],'r--',tp[0],tp[1],
      'b-',ts[0],ts[1],'g-',tm,t,'y--',t,tm,'y--',tm,tm,'y--')
xlabel('Position (ls)')
xlim(-10,10)
ylabel('Time (t)')
ylim(-10,10)
title('Space Time Diagram')
grid('true')
legend(('Position of Back of Ship','Position of Front of Ship','Position of Light Beam',
        'Position of Walking Person','Position of my Ship','Speed of Light'),'lower right')

text(-9,1,'Shaded Area is not')
text(-9,0,'in Light Cone.')
text(5,1,'Events can not')
text(5,0,'take place here.')

fill([t[0],tm[-1],tm[-1]],[t[0],tm[-1],t[-1]],'y')
fill([t[0],t[-1],t[-1]],[t[0],tm[-1],t[-1]],'y')
show()
