#!/usr/bin/env python

# $Id: pvid.py,v 1.5 2009/04/23 08:50:10 dintrans Exp $
# Plot the time evolution of the hatwave:
# Fig 1: animation, Fig 2: in the plane (x,t)

import numpy as N
import pylab as P
import pencil as pc

f, t = pc.read_slices(field='cc', proc=0)

dim=pc.read_dim()
nt=len(t)
ff=f.reshape(nt, dim.nx)

P.ion()
P.subplot(211)
line, = P.plot(ff[0, :])
P.xlim(xmax=dim.nx-1)
st=P.figtext(0.8, 0.86, 't=%.1f'%t[0])

for i in range(1, nt):
  line.set_ydata(ff[i, :])
  st.set_text('t=%.1f'%t[i])
  P.draw()

P.plot(ff[i, :],'o')
P.xlim(xmax=dim.nx-1)
P.draw()

P.subplot(212)
frame = 0, dim.nx-1, t[0], t[-1]
P.imshow(ff, origin='lower', extent=frame, aspect='auto')
P.ylabel('time')
P.show()

