#!/usr/bin/env python

import sys

import Ptools as pt

from pNbody import plummer



stats = pt.io.read_hdf5(sys.argv[1])

r = stats['r']
nn = stats['nn']
rho = stats['rho']
phi = stats['phi']
sigma = stats['sigma']
M     = stats['M']
G     = stats['G']
a     = stats['a']
eps   = stats['eps']

###################
# plot
###################


# theorical values
rho_th   = plummer.Density(G,M,a,r)
phi_th   = plummer.Potential(G,M,a,r)
sigma_th = plummer.Sigma(G,M,a,r)


#############
# number per bins
#############
pt.subplot(2,2,1)

pt.plot(r,nn)
pt.semilogx()
pt.semilogy()
pt.xlabel('Radius')
pt.ylabel('Number')

#############
# density
#############
pt.subplot(2,2,2)

pt.plot(r,rho,'b')
pt.plot(r,rho_th,'r--')
pt.semilogx()
#pt.semilogy()
pt.xlabel('Radius')
pt.ylabel('Density')

#############
# potential
#############
pt.subplot(2,2,3)

pt.plot(r,phi,'b')
pt.plot(r,phi_th,'r--')
pt.semilogx()
#pt.semilogy()
pt.xlabel('Radius')
pt.ylabel('Potential')

#############
# sigma
#############
pt.subplot(2,2,4)

pt.plot(r,sigma,'b')
pt.plot(r,sigma_th,'r--')
pt.semilogx()
#pt.semilogy()
pt.xlabel('Radius')
pt.ylabel('Sigma')

pt.show()



