def Brems_spec(self,EdNdE_e,Ee,Eg): ''' Calculates the bremsstrahlungs spectrum for given electron spectrum and ambient density ''' dlogEe=np.log(Ee[1]/Ee[0])*np.ones_like(Ee) dNe=EdNdE_e*dlogEe sigma=crs.sigma_brems(Eg,Ee,dNe,self.source.Zeff) dNdE_gamma=self.source.nHeff*const.C*const.m2cm*sigma return dNdE_gamma
def plot_cross(typ=['ic','brems','pp']): Eg=np.logspace(6.,12.,300) Ee=np.logspace(7.,15.,100) Ne=spsh.plcut(Ee,[1.,9.,-3.,14.]) Ne2=spsh.plcut(Ee,[1.,9.,-2.0,11.]) ylist=[] xlist=[] taglist=[] elist=[] if 'brems' in typ: Ee/=10**9 Eg/=10**9 ylist.append(const.C*const.m2cm*crs.sigma_brems(Eg,Ee,Ne)) print const.C*const.m2cm*crs.sigma_brems(Eg,Ee,Ne) #ylist.append(crs.sigma_brems(Eg,Ee,Ne2)) ylist.append(const.C*const.m2cm*crs.sigma_brems_ee(Eg,Ee,Ne)) #ylist.append(crs.sigma_brems_ee(Eg,Ee,Ne2)) ylist.append(const.C*const.m2cm*gs.sigmaB_test(Ne,Eg,Ee)) xlist.append(Eg) xlist.append(Eg) xlist.append(Eg) #xlist.append(Eg) #xlist.append(Eg) for t in['brems_N -1.5','brems_ee -1.5','brems dima']: taglist.append(t) elist.append(0) if 'ic' in typ: Ee/=10**9 Eg/=10**9 #print Ee,Eg source=sed.source() source.set_radiation_densities(0.25,0.84,3.0e-3,0.9)#W51C densities Abdo et al 2009 source.set_radiation_photons(-8.,4.,0.1) ''' print 'CMB: ',source.phCMB print 'Dust : ',source.phDust print 'Star: ',source.phStar print 'tot: ',source.phTot ''' for ph in [source.phTot,source.phCMB,source.phDust,source.phStar]: def sigma_fcn(x): sigma=crs.sigma_ic(x,source.Eph,Ee) #print 'sigma: ',np.size(sigma) return const.C*const.m2cm*np.dot(ph,np.dot(sigma,np.ones_like(Ee))) sigma=np.frompyfunc(sigma_fcn,1,1) ylist.append(sigma(Eg)) xlist.append(Eg) elist.append(0) for t in['IC total','IC CMB','IC Dust','IC Star']: taglist.append(t) plot([source.Eph,source.Eph,source.Eph,source.Eph],[source.phTot,source.phCMB,source.phDust,source.phStar],[],elist,['Tot','CMB','Dust','Star'],r'E [eV]',r'$N_{ph}$') #print ylist plot(xlist,ylist,[],elist,taglist,r'E [eV]',r'$N_{e}\times \sigma_{\mathrm{brems}}$') #plot([source.Eph,source.Eph,source.Eph,source.Eph],[source.phTot,source.phCMB,source.phDust,source.phStar],[],elist,['Tot','CMB','Dust','Star'],r'E [eV]',r'$N_{ph}$') plt.show()