import os
import matplotlib
from matplotlib import pyplot
import matplotlib.pyplot as plt
import numpy
import math
from math import *

from matplotlib.ticker import AutoMinorLocator
XminorLocator = AutoMinorLocator()
YminorLocator = AutoMinorLocator(4)

# LaTeX like fonts in the figure
#plt.rc('text', usetex=True)
plt.rc('font', family='serif')
#plt.rc('font', serif='Palatino')
#plt.rc('font', cursive='Zapf Chancery')
#plt.rc('font', monospace='Courier')


# Change to directory where script is located
abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)


outfile = 'SersicPlot.png'


x = numpy.arange(0.0,10.0,0.001)

fig=pyplot.figure()
fig.set_size_inches(750.0/100.0,750.0/100.0)


def sersic(x):
	Ic = 1.0
	alpha = 1.0
	n = 20.0
			
	sers = Ic*e**(-(x/alpha)**(1.0/n))
	
	#for i in range(len(sers)):
		#sers[i] = math.log10(sers[i])
	
	return sers


pyplot.plot(x,sersic(x), color='black')
			
csfont = {'fontname':'Liberation Serif','fontsize':25}

pyplot.xlabel('Radius', **csfont)
pyplot.ylabel('Surface brightness', **csfont)

plot = fig.add_subplot(111)
plot.tick_params(axis='both', which='major', labelsize=20)
plot.tick_params(axis='both', which='minor', labelsize=20)

axes = plt.gca()
# Uncomment these lines to remove labels
#axes.xaxis.set_ticklabels([])
#axes.yaxis.set_ticklabels([])
axes.xaxis.set_minor_locator(XminorLocator)
axes.yaxis.set_minor_locator(YminorLocator)

pyplot.savefig(outfile,dpi=100,facecolor='white',bbox_inches='tight')
pyplot.close('all')




