#!/usr/bin/env python

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

f, t = pc.read_slices(field='uu1', proc=0, extension='xy')

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

y1=ff.min()
y2=ff.max()

P.ion()
for i in range(0, nt):
  P.plot(ff[i, :])

P.ylim(ymin=y1, ymax=y2)
P.show()

line, = P.plot(ff[0, :])
P.xlim(xmax=dim.nx-1)
P.ylim(ymin=y1, ymax=y2)
st=P.figtext(0.8, 0.85, '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.draw()

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

