Blame view

src/observables.py 14.4 KB
d943e502   Thomas Fitoussi   Update 'analysis'...
1
import matplotlib.cm as colormap
d88319ae   Thomas Fitoussi   Update analysis 2...
2
3
4
5
from matplotlib.pyplot     import figure, show, legend, gca, setp
from matplotlib.gridspec   import GridSpec
from numpy                 import sort, log10, histogram, pi, arange, where, ma, zeros, append
from numpy                 import rot90, flipud, histogram2d, logspace, linspace, size, loadtxt
4d2bede0   Thomas Fitoussi   add script for me...
6
from numpy                 import array, argsort, nditer, mean
188a8c6a   Thomas Fitoussi   Update analysis 2...
7
from mpl_toolkits.mplot3d  import Axes3D
c419cc5a   Thomas Fitoussi   Updated analysis ...
8
from src.read              import select_events, ReadProfile
4d2bede0   Thomas Fitoussi   add script for me...
9
from src.analytic          import degre, yr, Analytic_delay_vs_theta, Analytic_observables_vs_energy
627ed999   Thomas Fitoussi   1. Reorganized fi...
10
11
12
13
14

import matplotlib as mpl
label_size = 20
mpl.rcParams['xtick.labelsize'] = label_size 
mpl.rcParams['ytick.labelsize'] = label_size 
30f3bf5d   Thomas Fitoussi   Adapt reading of ...
15

4d2bede0   Thomas Fitoussi   add script for me...
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def weighted_median(values, weights):
    ''' compute the weighted median of values list. The weighted median is computed as follows:
    1- sort both lists (values and weights) based on values.
    2- select the 0.5 point from the weights and return the corresponding values as results
    e.g. values = [1, 3, 0] and weights=[0.1, 0.3, 0.6] assuming weights are probabilities.
    sorted values = [0, 1, 3] and corresponding sorted weights = [0.6,     0.1, 0.3] the 0.5 point on
    weight corresponds to the first item which is 0. so the weighted     median is 0.'''

    #convert the weights into probabilities
    sum_weights = sum(weights)
    weights = array([(w*1.0)/sum_weights for w in weights])
    #sort values and weights based on values
    values = array(values)
    sorted_indices = argsort(values)
    values_sorted  = values[sorted_indices]
    weights_sorted = weights[sorted_indices]
    #select the median point
    it = nditer(weights_sorted, flags=['f_index'])
    accumulative_probability = 0
    median_index = -1
    while not it.finished:
        accumulative_probability += it[0]
        if accumulative_probability > 0.5:
            median_index = it.index
            return values_sorted[median_index]
        elif accumulative_probability == 0.5:
            median_index = it.index
            it.iternext()
            next_median_index = it.index
            return mean(values_sorted[[median_index, next_median_index]])
        it.iternext()

    return values_sorted[median_index]



30f3bf5d   Thomas Fitoussi   Adapt reading of ...
52
#=========================== CORELATION BETWEEN OBSERVABLES ===========================#
4d2bede0   Thomas Fitoussi   add script for me...
53
def observables_vs_energy(energy,theta,delay,weight,Erange=[1e-3,1e5],median=False,nbBins=-1):#28):
d88319ae   Thomas Fitoussi   Update analysis 2...
54
55
56
57
58
59
60
61
62
63
   # nbBins=16, Erange=[1e-1,1e3] <=> Arlen 2014 (energy binning)
   if (nbBins==-1):
      bins=append(logspace(log10(Erange[0]),log10(0.9),100),logspace(0,log10(Erange[1]),16))
      nbBins=size(bins)-1
   if (nbBins==-2): # <=> Arlen 2014 (energy binning)
      nbBins=16 
      Erange=[1e-1,1e3]
      bins=logspace(log10(Erange[0]),log10(Erange[1]),nbBins+1)
   else:
      bins=logspace(log10(Erange[0]),log10(Erange[1]),nbBins+1)
188a8c6a   Thomas Fitoussi   Update analysis 2...
64
   ener = (bins[1:nbBins+1]*bins[0:nbBins])**0.5
d88319ae   Thomas Fitoussi   Update analysis 2...
65
66
67
68
69
   #dtheta, dE = histogram(energy,bins,weights=weight*theta)
   #dt,     dE = histogram(energy,bins,weights=weight*delay)
   #dN,     dE = histogram(energy,bins,weights=weight)
   dt = zeros(nbBins,dtype="float64")
   dtheta = zeros(nbBins,dtype="float64")
4d2bede0   Thomas Fitoussi   add script for me...
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
   if median==False:
      for i in arange(nbBins):
         mask = (energy >= bins[i]) & (energy < bins[i+1])
         w = sum(weight[mask])
         t = sum(weight[mask]*delay[mask])
         angle = sum(weight[mask]*theta[mask])
         if w !=0:
            dt[i]=t/w
            dtheta[i]=angle/w
   else:
      for i in arange(nbBins):
         mask = (energy >= bins[i]) & (energy < bins[i+1])
         if True in mask:
            dt[i] = weighted_median(delay[mask],weight[mask])
            dtheta[i] = weighted_median(theta[mask],weight[mask])
         else:
            dt[i] = 0
            dtheta[i] = 0
d88319ae   Thomas Fitoussi   Update analysis 2...
88
   return ener, dtheta, dt
188a8c6a   Thomas Fitoussi   Update analysis 2...
89

4d2bede0   Thomas Fitoussi   add script for me...
90
def observables_vs_delay(energy,theta,delay,weight,time_range=[10**-0.5,10**8.5],median=False,nbBins=100):#9): 
188a8c6a   Thomas Fitoussi   Update analysis 2...
91
92
93
   # <=> Taylor 2011 (time binning)
   bins=logspace(log10(time_range[0]),log10(time_range[1]),nbBins+1)
   time = (bins[1:nbBins+1]*bins[0:nbBins])**0.5
d88319ae   Thomas Fitoussi   Update analysis 2...
94
95
   dE = zeros(nbBins,dtype="float64")
   dtheta = zeros(nbBins,dtype="float64")
4d2bede0   Thomas Fitoussi   add script for me...
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
   if median==False:
      for i in arange(nbBins):
         mask = (delay >= bins[i]) & (delay < bins[i+1])
         w = sum(weight[mask])
         E = sum(weight[mask]*energy[mask])
         angle = sum(weight[mask]*theta[mask])
         if w !=0:
            dE[i]=E/w
            dtheta[i]=angle/w
   else:
      for i in arange(nbBins):
         mask = (delay >= bins[i]) & (delay < bins[i+1])
         if True in mask:
            dE[i] = weighted_median(energy[mask],weight[mask])
            dtheta[i] = weighted_median(theta[mask],weight[mask])
         else:
            dE[i] = 0
            dtheta[i] = 0
d88319ae   Thomas Fitoussi   Update analysis 2...
114
115
   return time, dtheta, dE

627ed999   Thomas Fitoussi   1. Reorganized fi...
116
def drawObservables(fileId,psf=180,Nb=28,plot_generation_density=False,plot_others_codes=False,one_figure=True):
188a8c6a   Thomas Fitoussi   Update analysis 2...
117
   #ax = figure(figsize=(12,9)).add_subplot(111,projection='3d')
627ed999   Thomas Fitoussi   1. Reorganized fi...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
   if one_figure:
      fig = figure(figsize=(20,18))
      gs = GridSpec(2, 2, height_ratios=[1,1], width_ratios=[1,1]) 
      fig.subplots_adjust(hspace=0,wspace=0)
      ax0 = fig.add_subplot(gs[0])
      ax2 = fig.add_subplot(gs[2],sharex=ax0)
      ax3 = fig.add_subplot(gs[3],sharey=ax2)
   else:
      fig0 = figure(figsize=(12,9))
      ax0 = fig0.add_subplot(111)
      fig2 = figure(figsize=(12,9))
      ax2 = fig2.add_subplot(111)
      fig3 = figure(figsize=(12,9))
      ax3 = fig3.add_subplot(111)
30f3bf5d   Thomas Fitoussi   Adapt reading of ...
132
133
134

   fileId = "Simulations/"+fileId

30f3bf5d   Thomas Fitoussi   Adapt reading of ...
135
   i=0
d88319ae   Thomas Fitoussi   Update analysis 2...
136
   nbBins = 250
627ed999   Thomas Fitoussi   1. Reorganized fi...
137
138
139
   theta_range = [1e-5,psf]
   delay_range = [1e-4,5e9]
   energy_range = [1e-3,1e4]
4d2bede0   Thomas Fitoussi   add script for me...
140
   weight,energy,delay,theta,phi,Esource,generation = select_events(fileId,Erange=energy_range)
3c65fe50   Thomas Fitoussi   Modification in t...
141
142
   delay /= yr
   theta /= degre
188a8c6a   Thomas Fitoussi   Update analysis 2...
143

627ed999   Thomas Fitoussi   1. Reorganized fi...
144
   print "theta range:  [",min(theta),", ",max(theta),"] (degre)"
d88319ae   Thomas Fitoussi   Update analysis 2...
145
146
   print "delay range:  [",min(delay),", ",max(delay),"] (yr)"
   print "energy range: [",min(energy),", ",max(energy),"] (GeV)"
627ed999   Thomas Fitoussi   1. Reorganized fi...
147
   print "weight range: [",min(weight),", ",max(weight),"]"
d88319ae   Thomas Fitoussi   Update analysis 2...
148

d88319ae   Thomas Fitoussi   Update analysis 2...
149
150
   colors=['b','g']

4d2bede0   Thomas Fitoussi   add script for me...
151
   cond = (theta>0) & (delay>0)
d88319ae   Thomas Fitoussi   Update analysis 2...
152
   if plot_generation_density: 
188a8c6a   Thomas Fitoussi   Update analysis 2...
153
      cmaps=[colormap.Blues,colormap.Greens,colormap.Reds]
d88319ae   Thomas Fitoussi   Update analysis 2...
154
      for gen in [2,4]:#sort(list(set(generation))):
4d2bede0   Thomas Fitoussi   add script for me...
155
         cond = cond & (generation==gen)
188a8c6a   Thomas Fitoussi   Update analysis 2...
156
157
         H, xedges, yedges = histogram2d(log10(energy[cond]),log10(delay[cond]),bins=nbBins,weights=weight[cond])
         H = flipud(rot90(ma.masked_where(H==0,H)))
d88319ae   Thomas Fitoussi   Update analysis 2...
158
159
         im1 = ax0.pcolormesh(10**xedges,10**yedges,log10(H),cmap=cmaps[i])   

188a8c6a   Thomas Fitoussi   Update analysis 2...
160
161
         H, xedges, yedges = histogram2d(log10(energy[cond]),log10(theta[cond]),bins=nbBins,weights=weight[cond])
         H = flipud(rot90(ma.masked_where(H==0,H)))
d88319ae   Thomas Fitoussi   Update analysis 2...
162
163
         im2 = ax2.pcolormesh(10**xedges,10**yedges,log10(H),cmap=cmaps[i])      

188a8c6a   Thomas Fitoussi   Update analysis 2...
164
165
166
         H, xedges, yedges = histogram2d(log10(delay[cond]),log10(theta[cond]),bins=nbBins,weights=weight[cond])
         H = flipud(rot90(ma.masked_where(H==0,H)))
         im3 = ax3.pcolormesh(10**xedges,10**yedges,log10(H),cmap=cmaps[i])
188a8c6a   Thomas Fitoussi   Update analysis 2...
167

c419cc5a   Thomas Fitoussi   Updated analysis ...
168
         ener,angle,dt = observables_vs_energy(energy[cond],theta[cond],delay[cond],weight[cond],nbBins=Nb,median=False)
d88319ae   Thomas Fitoussi   Update analysis 2...
169
170
         ax0.plot(ener,dt,color=colors[i],linewidth=2,label="gen = %.0f"%(i+1))
         ax2.plot(ener,angle,color=colors[i],linewidth=2,label="gen = %.0f"%(i+1))
c419cc5a   Thomas Fitoussi   Updated analysis ...
171
         dt,angle,ener = observables_vs_delay(energy[cond],theta[cond],delay[cond],weight[cond],nbBins=Nb,median=False)
d88319ae   Thomas Fitoussi   Update analysis 2...
172
         ax3.plot(dt,angle,color=colors[i],linewidth=2,label="gen = %.0f"%(i+1))
188a8c6a   Thomas Fitoussi   Update analysis 2...
173
         i+=1
d88319ae   Thomas Fitoussi   Update analysis 2...
174
175
            
   else:
4d2bede0   Thomas Fitoussi   add script for me...
176
      H, xedges, yedges = histogram2d(log10(energy[cond]),log10(delay[cond]),bins=nbBins,weights=weight[cond])
d88319ae   Thomas Fitoussi   Update analysis 2...
177
178
179
      H = flipud(rot90(ma.masked_where(H==0,H)))
      im1 = ax0.pcolormesh(10**xedges,10**yedges,log10(H),cmap=colormap.YlOrBr)   

4d2bede0   Thomas Fitoussi   add script for me...
180
      H, xedges, yedges = histogram2d(log10(energy[cond]),log10(theta[cond]),bins=nbBins,weights=weight[cond])
d88319ae   Thomas Fitoussi   Update analysis 2...
181
182
183
      H = flipud(rot90(ma.masked_where(H==0,H)))
      im2 = ax2.pcolormesh(10**xedges,10**yedges,log10(H),cmap=colormap.YlOrBr)      
    
4d2bede0   Thomas Fitoussi   add script for me...
184
      H, xedges, yedges = histogram2d(log10(delay[cond]),log10(theta[cond]),bins=nbBins,weights=weight[cond])
d88319ae   Thomas Fitoussi   Update analysis 2...
185
186
      H = flipud(rot90(ma.masked_where(H==0,H)))
      im3 = ax3.pcolormesh(10**xedges,10**yedges,log10(H),cmap=colormap.YlOrBr)
188a8c6a   Thomas Fitoussi   Update analysis 2...
187

d88319ae   Thomas Fitoussi   Update analysis 2...
188
189
      for gen in [2,4]:#sort(list(set(generation))):
         cond = (generation==gen)
c419cc5a   Thomas Fitoussi   Updated analysis ...
190
         ener,angle,dt = observables_vs_energy(energy[cond],theta[cond],delay[cond],weight[cond],nbBins=Nb,median=False)
d88319ae   Thomas Fitoussi   Update analysis 2...
191
192
         ax0.plot(ener,dt,color=colors[i],linewidth=2,label="gen = %.0f"%(i+1))
         ax2.plot(ener,angle,color=colors[i],linewidth=2,label="gen = %.0f"%(i+1))
c419cc5a   Thomas Fitoussi   Updated analysis ...
193
         dt,angle,ener = observables_vs_delay(energy[cond],theta[cond],delay[cond],weight[cond],nbBins=Nb,median=False)
d88319ae   Thomas Fitoussi   Update analysis 2...
194
195
196
         ax3.plot(dt,angle,color=colors[i],linewidth=2,label="gen = %.0f"%(i+1))
         i+=1       
            
c419cc5a   Thomas Fitoussi   Updated analysis ...
197
   ener,angle,dt = observables_vs_energy(energy,theta,delay,weight,nbBins=Nb,median=False)
627ed999   Thomas Fitoussi   1. Reorganized fi...
198
199
   ax0.plot(ener,dt,color='k',linewidth=2,label="all gen")
   ax2.plot(ener,angle,color='k',linewidth=2,label="all gen")
c419cc5a   Thomas Fitoussi   Updated analysis ...
200
   dt,angle,ener = observables_vs_delay(energy,theta,delay,weight,nbBins=Nb,median=False)
627ed999   Thomas Fitoussi   1. Reorganized fi...
201
   ax3.plot(dt,angle,color='k',linewidth=2,label="all gen")
188a8c6a   Thomas Fitoussi   Update analysis 2...
202
203
204
205
206

   nE = 5000 
   Emin = 1.e-3
   Emax = 1e4
   E = Emin*(Emax/Emin)**(arange(nE)/(nE-1.))
627ed999   Thomas Fitoussi   1. Reorganized fi...
207
208
209
210
211
   theta_fit, delay_fit, theta_fit2, delay_fit2 = Analytic_observables_vs_energy(E,"../"+fileId)
   ax0.plot(E,delay_fit/yr,'--b',linewidth=2)
   ax0.plot(E,delay_fit2/yr,'--g',linewidth=2)
   ax2.plot(E,theta_fit,'--b',linewidth=2)
   ax2.plot(E,theta_fit2,'--g',linewidth=2)
4d2bede0   Thomas Fitoussi   add script for me...
212
213
214
   
   ax3.plot(delay_fit[delay_fit.argsort()]/yr,theta_fit[delay_fit.argsort()],'--b',linewidth=2)
   ax3.plot(delay_fit2[delay_fit2.argsort()]/yr,theta_fit2[delay_fit2.argsort()],'--g',linewidth=2)
627ed999   Thomas Fitoussi   1. Reorganized fi...
215
   #ax3.scatter(delay_fit/yr,theta_fit,color='b',marker="+")
188a8c6a   Thomas Fitoussi   Update analysis 2...
216
217
218
219
220
221
222
    
   if plot_others_codes:
      # Results from Arlen 2014 - fig. 2a, 2b
      # =====================================
      #   - binning in energy : log, 16 bins between 1e-1 et 1e3 GeV
      #   - PSF = 10 deg
      data = loadtxt(fileId+'/Arlen2014-fig2a.csv', delimiter=',')
d88319ae   Thomas Fitoussi   Update analysis 2...
223
      ax0.plot(data[:,0],data[:,1],color="m",linestyle='--',linewidth=2,label="Arlen 2014 - no EBL")
188a8c6a   Thomas Fitoussi   Update analysis 2...
224
      data = loadtxt(fileId+'/Arlen2014-fig2b.csv', delimiter=',')
d88319ae   Thomas Fitoussi   Update analysis 2...
225
      ax0.plot(data[:,0],data[:,1],color="m",linestyle='-.',linewidth=2,label="Arlen 2014 - EBL")
188a8c6a   Thomas Fitoussi   Update analysis 2...
226
227
228
229

      # Results from Taylor 2011 - fig. 2
      # =================================
      data = loadtxt(fileId+'/Taylor2011-fig2.csv', delimiter=',')
d88319ae   Thomas Fitoussi   Update analysis 2...
230
      ax0.plot(data[:,0]*1e-9,data[:,1],color="m",linestyle=':',linewidth=2,label="Taylor 2011")  
30f3bf5d   Thomas Fitoussi   Adapt reading of ...
231
232

   #ax.legend(loc="best")
4d2bede0   Thomas Fitoussi   add script for me...
233
   #ax.set_xlabel("$E$ [GeV]")
30f3bf5d   Thomas Fitoussi   Adapt reading of ...
234
   #ax.set_ylabel("$\\theta$ [deg]")
4d2bede0   Thomas Fitoussi   add script for me...
235
   #ax.set_zlabel("$\\Delta t$ [s]")
30f3bf5d   Thomas Fitoussi   Adapt reading of ...
236

d88319ae   Thomas Fitoussi   Update analysis 2...
237
   #ax3.set_title(fileId+" - selection %0.1f"%psf)
627ed999   Thomas Fitoussi   1. Reorganized fi...
238
239
   if one_figure:
      ax0.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
d88319ae   Thomas Fitoussi   Update analysis 2...
240
241
242
243
244
245

   ax0.grid(b=True,which='major')
   ax0.set_xscale('log')
   ax0.set_yscale('log')
   ax0.set_xlim(energy_range)
   ax0.set_ylim(delay_range)
4d2bede0   Thomas Fitoussi   add script for me...
246
   ax0.set_ylabel("$\\Delta t$ [yrs]",fontsize=label_size)
627ed999   Thomas Fitoussi   1. Reorganized fi...
247
248
249
   if one_figure:
      setp(ax0.get_xticklabels(), visible=False)
   else:
4d2bede0   Thomas Fitoussi   add script for me...
250
251
      ax0.set_xlabel("$E$ [GeV]",fontsize=label_size)
      ax0.legend(loc="best",fontsize=label_size)
627ed999   Thomas Fitoussi   1. Reorganized fi...
252
      cbar1=fig0.colorbar(im1, ax=ax0)
4d2bede0   Thomas Fitoussi   add script for me...
253
      cbar1.ax.set_ylabel("counts [log]",fontsize=label_size)
30f3bf5d   Thomas Fitoussi   Adapt reading of ...
254
255

   ax2.grid(b=True,which='major')
30f3bf5d   Thomas Fitoussi   Adapt reading of ...
256
257
   ax2.set_xscale('log')
   ax2.set_yscale('log')
188a8c6a   Thomas Fitoussi   Update analysis 2...
258
259
   ax2.set_xlim(energy_range)
   ax2.set_ylim(theta_range)
4d2bede0   Thomas Fitoussi   add script for me...
260
261
   ax2.set_xlabel("$E$ [GeV]",fontsize=label_size)
   ax2.set_ylabel("$\\theta$ [deg]",fontsize=label_size)
627ed999   Thomas Fitoussi   1. Reorganized fi...
262
   if not one_figure:
4d2bede0   Thomas Fitoussi   add script for me...
263
      ax2.legend(loc="best",fontsize=label_size)
627ed999   Thomas Fitoussi   1. Reorganized fi...
264
      cbar2=fig2.colorbar(im2, ax=ax2)
4d2bede0   Thomas Fitoussi   add script for me...
265
      cbar2.ax.set_ylabel("counts [log]",fontsize=label_size)
30f3bf5d   Thomas Fitoussi   Adapt reading of ...
266
267

   ax3.grid(b=True,which='major')
30f3bf5d   Thomas Fitoussi   Adapt reading of ...
268
269
   ax3.set_xscale('log')
   ax3.set_yscale('log')
188a8c6a   Thomas Fitoussi   Update analysis 2...
270
271
   ax3.set_xlim(delay_range)
   ax3.set_ylim(theta_range)
4d2bede0   Thomas Fitoussi   add script for me...
272
   ax3.set_xlabel("$\\Delta t$ [yrs]",fontsize=label_size)
627ed999   Thomas Fitoussi   1. Reorganized fi...
273
274
275
   if one_figure:
      setp(ax3.get_yticklabels(), visible=False)
   else:
4d2bede0   Thomas Fitoussi   add script for me...
276
277
      ax3.set_ylabel("$\\theta$ [deg]",fontsize=label_size)
      ax3.legend(loc="best",fontsize=label_size)
627ed999   Thomas Fitoussi   1. Reorganized fi...
278
      cbar3=fig3.colorbar(im3, ax=ax3)
4d2bede0   Thomas Fitoussi   add script for me...
279
      cbar3.ax.set_ylabel("counts [log]",fontsize=label_size)
30f3bf5d   Thomas Fitoussi   Adapt reading of ...
280
281

   show()
188a8c6a   Thomas Fitoussi   Update analysis 2...
282
283
284
285
286
287
288

def drawDelays_vs_energy(files,psf=180,plot_others_codes=False):
   ax1 = figure(figsize=(12,9)).add_subplot(111)
   nbBins = 100

   for fileId0 in files:
      fileId = "Simulations/simple case/"+fileId0
3c65fe50   Thomas Fitoussi   Modification in t...
289
290
      weight, energy, delay, arrival_angle , theta, phi, gen = select_events(fileId)
      #dt,dtheta,ener = observables_vs_delay(energy,arrival_angle/degre,delay/yr,weight)
d88319ae   Thomas Fitoussi   Update analysis 2...
291
      #ax1.plot(ener,dt,marker='*',linestyle=":",linewidth=2) 
3c65fe50   Thomas Fitoussi   Modification in t...
292
      cond = (arrival_angle/degre < psf) & (gen%2==0) #PSF_Taylor2011(energy) 
d88319ae   Thomas Fitoussi   Update analysis 2...
293
294
295
296
      energy = energy[cond]
      arrival_angle = arrival_angle[cond]
      delay = delay[cond]
      weight = weight[cond]
3c65fe50   Thomas Fitoussi   Modification in t...
297
      ener,dtheta,dt = observables_vs_energy(energy,arrival_angle/degre,delay/yr,weight,nbBins=-2)
188a8c6a   Thomas Fitoussi   Update analysis 2...
298
299
300
301
302
303
      p0, =ax1.plot(ener,dt,marker='*',linewidth=2,label=fileId0) 
      
      nth = 5000
      thmin = 0.1
      thmax = 1e4
      E = thmin*(thmax/thmin)**(arange(nth)/(nth-1.))
d88319ae   Thomas Fitoussi   Update analysis 2...
304
      #ax1.plot(E,Analytic_observables_vs_energy(E,fileId)[1]/yr,color=p0.get_color(),linestyle="-")
188a8c6a   Thomas Fitoussi   Update analysis 2...
305
                                                     
d88319ae   Thomas Fitoussi   Update analysis 2...
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
   if plot_others_codes:
      # Results from Arlen 2014 - fig. 2a, 2b
      # =====================================
      #   - binning in energy : log, 16 bins between 1e-1 et 1e3 GeV
      #   - PSF = 10 deg
      data = loadtxt(fileId+'/Arlen2014-fig2a.csv', delimiter=',')
      p1,= ax1.plot(data[:,0],data[:,1],color="r",linestyle='--',linewidth=2,label="Arlen 2014 - fig 2a")
      data = loadtxt(fileId+'/Arlen2014-fig2b.csv', delimiter=',')
      p2,= ax1.plot(data[:,0],data[:,1],color="r",linestyle='-.',linewidth=2,label="Arlen 2014 - fig 2b")
   
      # Results from Taylor 2011 - fig. 2
      # =================================
      #data = loadtxt(fileId+'/Taylor2011-fig2.csv', delimiter=',')
      #p3,= ax1.plot(data[:,0]*1e-9,data[:,1],color=p0.get_color(),linestyle=':',linewidth=2)
   
      #leg1 = legend([p0,p1,p2], ["our code","Arlen 2014 - fig 2a",
      #    "Arlen 2014 - fig 2b"], loc=1)
                                                              
188a8c6a   Thomas Fitoussi   Update analysis 2...
324
325
326
   ax1.grid(b=True,which='major')  
   ax1.set_xscale('log')
   ax1.set_yscale('log')
d88319ae   Thomas Fitoussi   Update analysis 2...
327
328
   #ax1.set_ylim([1,1e8])
   #ax1.set_xlim([1e-1,1e3])
4d2bede0   Thomas Fitoussi   add script for me...
329
330
331
   ax1.set_xlabel("$E$ [GeV]",fontsize=label_size)
   ax1.set_ylabel("$\\Delta t$ [yrs]",fontsize=label_size) 
   ax1.legend(loc="best",fontsize=label_size)#2)
d88319ae   Thomas Fitoussi   Update analysis 2...
332
   #ax1 = gca().add_artist(leg1)
188a8c6a   Thomas Fitoussi   Update analysis 2...
333
334

   show()