#!/usr/bin/python

from numpy import *
from pandas import *
import matplotlib.pyplot as plt

########################
a=104*array(range(24))
b=2*(array(range(24)))
c=array(arange(0,1,0.1))
d=10*array(range(10))
e=array(arange(0,0.4,0.1))
f=10*array(range(4))

##Leer bases de datos######

e1=read_csv("e1.csv")
e2=read_csv("e2.csv")
e3=read_csv("e3.csv")

#########por Run###############
for j in [1,2,3]:
    e1=read_csv("e"+ str(j)+".csv")
    for i in arange(1,10):
        run=e1.loc[e1.run == i]
        run.plot(x='step',y='infected',grid=[])
        plt.title("Experiment "+ str(j)+"  Run " + str(i)) 
        plt.xticks(a,b)
        plt.xlabel("Years")
        plt.yticks(c,d)
        plt.ylabel("HPV Infected (%)")
        plt.savefig("e"+ str(j)+"_infected_run" + str(i)+".pdf") 
        plt.close()
    
        run.plot(x='step',y='sane',grid=[])
        plt.title("Experiment "+ str(j)+"  Run " + str(i)) 
        plt.xticks(a,b)
        plt.xlabel("Years")
        plt.yticks(c,d)
        plt.ylabel("Sane (%)")
        plt.savefig("e"+ str(j) +"_sane_run" + str(i)+".pdf") 
        plt.close()

        run.plot(x='step',y='diagnosed',grid=[])
        plt.title("Experiment "+ str(j)+"  Run " + str(i)) 
        plt.xticks(a,b)
        plt.xlabel("Years")
        plt.yticks(e,f)
        plt.ylabel("HPV Diagnosed (%)")
        plt.savefig("e"+ str(j)+"_diagnosed_run" + str(i)+".pdf") 
        plt.close()

        run.plot(x='step',y='vaccinated',grid=[])
        plt.title("Experiment "+ str(j)+"  Run " + str(i)) 
        plt.xticks(a,b)
        plt.xlabel("Years")
        plt.yticks(e,f)
        plt.ylabel("HPV Vaccinated (%)")
        plt.savefig("e"+ str(j)+"_vaccinated_run" + str(i) + ".pdf") 
        plt.close()


        run.plot(x='step',y=['v0','v1','v2', 'v3'],grid=[])
        plt.title("Experiment "+ str(j)+"  Run " + str(i)) 
        plt.xticks(a,b)
        plt.xlabel("Years")
        plt.yticks(e,f)
        plt.ylabel("HPV Infected by virus type (%)")
        plt.legend(('v0','v1','v2','v3'),loc='upper right', shadow=True, fancybox=True ,framealpha=1,fontsize='small')
        plt.savefig("e"+ str(j)+"_virus_run" + str(i) + ".pdf", transparent = True)
        plt.close()
    

        run.plot(x='step',y=['cin1','cin2','cin3', 'cc'],grid=[])
        plt.title("Experiment "+ str(j)+"  Run " + str(i)) 
        plt.xticks(a,b)
        plt.xlabel("Years")
        plt.yticks(e,f)
        plt.ylabel("HPV Infected by disease stage (%)")
        plt.legend(('Cin 1','Cin 2','Cin 3','CC'),loc='upper right', shadow=True, fancybox=True,framealpha=1,fontsize='small')
        plt.savefig("e"+ str(j)+"_stage_run" + str(i) + ".pdf", transparent = True)
        plt.close()
    
 
        ## run.plot(x='step',y=['vi0','vi1','vi2', 'vi3'],grid=[])
        ## plt.title("Experiment "+ str(j)+"  Run " + str(i)) 
        ## plt.xticks(a,b)
        ## plt.xlabel("Years")
        ## plt.yticks(e,f)
        ## plt.ylabel("HPV vaccinated Infected by virus type (%)")
        ## plt.legend(('v0','v1','v2','v3'),loc='upper right', shadow=True, fancybox=True,framealpha=1,fontsize='small')
        ## plt.savefig("e"+ str(j)+"_vac_inf_run" + str(i) + ".pdf", transparent = True)
        ## plt.close()
    
        run['v0'].hist(alpha=0.5)
        plt.title("v0-type Infected"+"Experiment "+ str(j)+"  Run " + str(i)) 
        #plt.xticks(a,b)
        #plt.xlabel("Years")
        #plt.yticks(e,f)
        #plt.ylabel("HPV vaccinated Infected by virus type (%)")
        #plt.legend(('v0','v1','v2','v3'),loc='upper right', shadow=True, fancybox=True,framealpha=1,fontsize='small')
        plt.savefig("e"+ str(j)+"histogram v0_run" + str(i) + ".pdf", transparent = True)
        plt.close()

        run['v1'].hist(alpha=0.5)
        plt.title("v1-type Infected"+"Experiment "+ str(j)+"  Run " + str(i)) 
        #plt.xticks(a,b)
        #plt.xlabel("Years")
        #plt.yticks(e,f)
        #plt.ylabel("HPV vaccinated Infected by virus type (%)")
        #plt.legend(('v0','v1','v2','v3'),loc='upper right', shadow=True, fancybox=True,framealpha=1,fontsize='small')
        plt.savefig("e"+ str(j)+"histogram v1_run" + str(i) + ".pdf", transparent = True)
        plt.close()
        
        run['v2'].hist(alpha=0.5)
        plt.title("v2-type Infected"+"Experiment "+ str(j)+"  Run " + str(i)) 
        #plt.xticks(a,b)
        #plt.xlabel("Years")
        #plt.yticks(e,f)
        #plt.ylabel("HPV vaccinated Infected by virus type (%)")
        #plt.legend(('v0','v1','v2','v3'),loc='upper right', shadow=True, fancybox=True,framealpha=1,fontsize='small')
        plt.savefig("e"+ str(j)+"histogram v2_run" + str(i) + ".pdf", transparent = True)
        plt.close()

        run['v3'].hist(alpha=0.5)
        plt.title("v3-type Infected"+"Experiment "+ str(j)+"  Run " + str(i)) 
        #plt.xticks(a,b)
        #plt.xlabel("Years")
        #plt.yticks(e,f)
        #plt.ylabel("HPV vaccinated Infected by virus type (%)")
        #plt.legend(('v0','v1','v2','v3'),loc='upper right', shadow=True, fancybox=True,framealpha=1,fontsize='small')
        plt.savefig("e"+ str(j)+"histogram v3_run" + str(i) + ".pdf", transparent = True)
        plt.close()

        run['v0'].plot(kind='density')
        run['v1'].plot(kind='density')
        run['v2'].plot(kind='density')
        run['v3'].plot(kind='density')
        plt.title("virus-type Infected"+"Experiment "+ str(j)+"  Run " + str(i)+ "density plot") 
        #plt.xticks(a,b)
        #plt.xlabel("Years")
        #plt.yticks(e,f)
        #plt.ylabel("HPV vaccinated Infected by virus type (%)")
        plt.legend(loc='upper right', shadow=True, fancybox=True,framealpha=1,fontsize='small')
        plt.savefig("e"+ str(j)+"density_run" + str(i) + ".pdf", transparent = True)
        plt.close()

        run['v0'].cumsum().plot()
        run['v1'].cumsum().plot()
        run['v2'].cumsum().plot()
        run['v3'].cumsum().plot()
        plt.title("virus-type Infected"+"Experiment "+ str(j)+"  Run " + str(i)+ "cummsum") 
        #plt.xticks(a,b)
        #plt.xlabel("Years")
        #plt.yticks(e,f)
        #plt.ylabel("HPV vaccinated Infected by virus type (%)")
        plt.legend(loc='upper right', shadow=True, fancybox=True,framealpha=1,fontsize='small')
        plt.savefig("e"+ str(j)+"cumsum_run" + str(i) + ".pdf", transparent = True)
        plt.close()
