#!/usr/bin/env python

#
# $Id: init.py,v 1.2 2018/10/01 12:52:25 dintrans Exp $
# Plot the initial setup
#

import pencil as pc
import pylab as P

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[2],param.xyz1[2]

var=pc.read_var(ivar=0,run2D=True,quiet=True,param=param,trimall=True,
magic=['rho'])

P.subplot(221)
im=P.imshow(var.ss, extent=frame, origin='lower', aspect='auto')
P.ylabel('z')
P.title('Initial entropy field')

P.subplot(222)
im=P.imshow(var.rho, extent=frame, origin='lower', aspect='auto')
P.xlabel('x')
P.ylabel('z')
P.title('Initial density field')

P.subplot(223)
rhom=var.rho.mean(axis=1)
jump=rhom[0]/rhom[-1]
print "density jump=rho_bot/rho_top=%6.2f"%jump
P.plot(grid.z, rhom)
P.title('density')
P.xlabel('z')

P.subplot(224)
ssm=var.ss.mean(axis=1)
P.plot(grid.z, ssm)
P.xlabel('z')
P.title('entropy')

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

