import numpy as np
import matplotlib.pyplot as plt
import corner

import matplotlib
matplotlib.rcParams.update({'font.size': 16})



def fiveDCorner(data):

    dataMstar = [ np.log10(10.0**(delta+7.0)) for delta in data['delta'] ]


    d2 =  np.atleast_1d([data['logn'],
                         data['beta'],
                         data['gamma'],
                         data['alpha'],
                         dataMstar]).T
    parameterLabels = ([r'$\log_{10}\frac{{\dot n}_0}{{\rm Mpc}^{3}{\rm Gyr}}$',\
                        r'$\beta_z$', r'$z_0$', r'$\alpha_{\mathcal{M}}$',\
                        r'$\log_{10} \frac{\mathcal{M}_*}{ M_{\odot}}$'])

    figure = corner.corner(d2,labels=parameterLabels,
                           quantiles=[0.05, 0.5, 0.95])
    plt.savefig('corner.png')
   
    plt.show()
    return 



posterior = np.genfromtxt('posterior.dat', names=True)
fiveDCorner(posterior)



names = ['logn', 'beta', 'gamma', 'alpha', 'delta']
for i in range(5):

    oneDData = posterior[names[i]]
    
    # percentile:
    
    
    plt.hist(oneDData)
    plt.show()
