############################
# Plotting the time series #
############################

# import packages:
import pencil as pc
import matplotlib.pyplot as plt 


# read in time series:
ts=pc.read.ts(datadir='../data')

# pick out some quantities from the time series:
tt=ts.t
ethm=ts.ethm
ekin=ts.ekin
etot=ethm+ekin

#print 'total energy:%9.2e'%etot.mean()
#rap=(etot.max()-etot.min())/etot.mean()
#print 'rel error or total energy:%9.2e'%rap
#print 'last time:%5.2f'%tt[-1]

# plot:
f = plt.figure()

plt.plot(tt,etot,label='$E_\\mathrm{tot}$')
plt.plot(tt,ethm,label='$E_\\mathrm{thm}$')
plt.plot(tt,ekin,label='$E_\\mathrm{kin}$')

plt.legend(loc='best', title='$y=$')
plt.ylabel('$y$')
plt.xlabel('time')

plt.title('Nonlinear sound waves: energies evolution')

f.savefig("plot_ts.pdf" , bbox_inches='tight')

