#!/usr/bin/python

#
# $Id: init.py,v 1.1 2009/04/29 13:25:49 dintrans Exp $
# Plot the initial setup
#

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

dim=pc.read_dim()
param=pc.read_param(quiet=True)
grid=pc.read_grid(trim=True,param=param,quiet=True)

frame=param.xyz0[0],param.xyz1[0],param.xyz0[1],param.xyz1[1]
qs1=N.random.random_integers(0,dim.nx-1, 1000)
qs2=N.random.random_integers(0,dim.ny-1, 1000)
xx,yy=P.meshgrid(grid.x, grid.y)

var=pc.read_var(ivar=0,quiet=True,param=param,trimall=True,magic=['rho'])
ss=var.ss.reshape(dim.ny, dim.nx)
rho=var.rho.reshape(dim.ny, dim.nx)

P.figure(figsize=(12, 4))
P.subplot(121)
im=P.imshow(ss, extent=frame, origin='lower', aspect='auto')
vel=P.quiver(xx[qs2, qs1], yy[qs2, qs1], var.ux[0, qs2, qs1],
var.uy[0, qs2, qs1], scale=8)

P.xlabel('x')
P.ylabel('y')
P.title('Initial entropy')

P.subplot(122)
im=P.imshow(rho, extent=frame, origin='lower', aspect='auto')
P.xlabel('x')
P.ylabel('y')
P.title('Initial density')

#P.subplots_adjust(hspace=0.25, bottom=0.05, top=0.95, left=0.1, right=0.95)
P.subplots_adjust(left=0.05, right=0.98)
P.show()

