#!/usr/bin/python from sys import argv import matplotlib.pyplot as plt from matplotlib import gridspec from Constantes import * if argv[1] == "EGMF": fileName="Results_EGMF" elif argv[1] == "EBL": fileName="Results_EBL" B=10**(-15) Model=["Kneiske and Doll - 'best fit'","Kneiske and Doll - 'lower limit'", "Fraceschini","Finke and Al","Gilmore and Al","Dominguez and Al"] else: print "Used: ./Angle_distribution.py arg1 ind1 ind2 ..." print " arg1 = EGMF or EBL " print " ind1 = file number \n" print "Examples: " print " to study EGMF14: ./Angle_distribution.py EGMF 14 " print " to study EBL1 and EBL2: ./Angle_distribution.py EBL 1 2 \n" exit() nbBins = 100 Eliminf = 1e0 #GeV Elimsup = 1e5 #GeV Esource=100 #TeV Dsource=135 #Mpc delta_to_theta=(lambda_gg/Esource*1e3)/Dsource def fit_theta(E,B): RL0=RL*(Esource/2)*(1e-17/B) Dic0=Dic/(Esource/2) delta=Dic0/(2*RL0)*((Esource/2)**2 *Eic/E-1) return abs(arcsin(delta_to_theta*sin(delta))*degre) fig2 = plt.figure() ax2 = fig2.add_subplot(111) fig1 = plt.figure() gs = gridspec.GridSpec(2, 1, height_ratios=[4,1]) fig1.subplots_adjust(hspace=0.001) ax11 = fig1.add_subplot(gs[0]) ax12 = fig1.add_subplot(gs[1],sharex=ax11) color=['b','r','g','c','m','y'] ind = 0 for fileId in argv[2:]: energy,dirx,diry,dirz = loadtxt(fileName+fileId+"/Results_momentum",unpack=True,usecols=[0,1,2,3]) posx,posy,posz = loadtxt(fileName+fileId+"/Results_position",unpack=True,usecols=[1,2,3]) charge,weight,gen=loadtxt(fileName+fileId+"/Results_extra",unpack=True,usecols=[0,2,3]) hyp=sqrt(posx**2+posy**2+posz**2) posx=posx/hyp posy=posy/hyp posz=posz/hyp hyp=sqrt(dirx**2+diry**2+dirz**2) dirx=dirx/hyp diry=diry/hyp dirz=dirz/hyp costheta=dirx*posx+diry*posy+dirz*posz cond=(costheta<=1)&(costheta>=-1)&(energy>Eliminf)&(energy