def herwigflux(Enu, neuflavor, ch, DMm, wimp_loc='Sun'): flavor = {0: 12, 1: -12, 2: 14, 3: -14, 4: 16, 5: -16} flavor_name = { 0: 'nu_e', 1: 'nu_ebar', 2: 'nu_mu', 3: 'nu_mubar', 4: 'nu_tau', 5: 'nu_taubar' } filedir = '/data/user/qliu/DM/herwig/' if PC.act_channel == ch and PC.act_DM_mass == DMm and PC.act_neuflavor == neuflavor and PC.flag_inter: if Enu / DMm < 0.0025: return 0.0 elif Enu / DMm <= 0.9975: return PC.act_inter(Enu / DMm) elif Enu / DMm > 0.9975: return 0.0 else: print "Interpolation error." quit() else: DMmstring = format(DMm, '.0f') #data = np.load(filedir+ch+'_'+str(DMmstring)+"_"+flavor_name[neuflavor]+".npy") data = np.load(filedir + ch + '-' + str(DMmstring) + "_" + flavor_name[neuflavor] + ".npy") E = np.linspace(0., DMm, 201) #E = np.linspace(0.,DMm,11) #event nunmber #ww evtnum = 127566 #evtnum = 10000 bin_center = (E[1:] + E[:-1]) / 2. bin_width = np.diff(E)[0] weight = 1. / (evtnum * bin_width) nu_hist, _ = np.histogram(data, bins=E, weights=[weight] * len(data)) dNdx = nu_hist * DMm if Enu < bin_center[0]: return 0.0 elif Enu <= bin_center[-1]: inter = sp.interpolate.interp1d(bin_center, dNdx) PC.act_inter = inter PC.flag_inter = True return inter(Enu) elif Enu > bin_center[-1]: return 0.0 else: print "Interpolation Error." quit()
def pythiaflux(Enu, neuflavor, ch, DMm, wimp_loc='Sun'): flavor = {0: 'e', 1: 'ebar', 2: 'mu', 3: 'mubar', 4: 't', 5: 'tbar'} if PC.act_channel == ch and PC.act_DM_mass == DMm and PC.act_neuflavor == neuflavor and PC.flag_inter: if Enu / DMm < 0.0025: return 0.0 elif Enu / DMm <= 0.9975: return PC.act_inter(Enu / DMm) elif Enu / DMm > 0.9975: return 0.0 else: print "Interpolation error." quit() else: if wimp_loc == 'Sun': #filedir = '../../Pythia/no_EW/secluded/Sun/results/' filedir = '/data/user/qliu/DM/DMFlux/Pythia/no_EW/secluded/Sun/results/' #filedir = "/data/user/jlazar/DMFlux/Pythia/no_EW/sun_data/" elif wimp_loc == 'Earth': #filedir = '../../Pythia/no_EW/secluded/Earth/results/' filedir = '/data/user/qliu/DM/DMFlux/Pythia/no_EW/secluded/Earth/results/' elif wimp_loc == 'GC': #filedir = '../../Pythia/no_EW/secluded/Galactic/results/' filedir = '/data/user/qliu/DM/DMFlux/Pythia/no_EW/secluded/Galactic/results/' else: raise Exception( 'WIMP annihilation at {} is not implemented'.format(wimp_loc)) DMmstring = format(DMm, '.0f') if ch == 'ww': filename = 'WW' + '_' + str(DMmstring) + "_{}.dat".format(wimp_loc) else: filename = ch + '_' + str(DMmstring) + "_{}.dat".format(wimp_loc) E = np.genfromtxt(filedir + filename)[:, 0] dNdE = np.genfromtxt(filedir + filename)[:, 1 + neuflavor] if Enu < E[0]: return 0.0 elif Enu <= E[-1]: inter = sp.interpolate.interp1d(E, dNdE) PC.act_inter = inter PC.flag_inter = True return inter(Enu) elif Enu > E[-1]: return 0.0 else: print "Interpolation Error." quit()
def DMSweFluxSun(Enu,neuflavor,ch,DMm,location = 'SunCtr',wimp_loc='Sun'): """ Gets dN/dz(z) using de swedish data set. @type Enu : float @param Enu : neutrino energy [GeV] @type neuflavor : integer @param neuflavor : flavor of the neutrino (0 : nu_e, 1 : anu_e, 2 : nu_mu 0, 3 : anu_mu, 4 : nu_tau, 5 : anu_tau) @type ch : string @param ch : annihilation channel @type DMm : float @param DMm : dark matter mass [GeV] @type location : string @param location : SunCtr line 1-6, SunSrfc 7-12,Sun1Au 13-18, SunSrfc2nd 19-24, Sun1Au2nd 25-30 @rtype : array @return : z = E/DMm, dN/dz(z) arrays at production (??) """ if PC.act_channel == ch and PC.act_DM_mass == DMm and PC.act_neuflavor == neuflavor and PC.flag_inter: if Enu/DMm < 0.0025: return 0.0 elif Enu/DMm <= 0.9975: return PC.act_inter(Enu/DMm) elif Enu/DMm > 0.9975: return 0.0 else : print("Interpolation error.") quit() else: ##print "reloading DM initial flux" DMmstring = format(DMm,'.0f') filename = "wa-m"+str(DMmstring)+"-ch"+str(ch_wimpsim[ch])+"-sun-sum.dat" file = open(datDMFluxSweden + filename,'r') z = np.linspace(0.0,1.,201) z = (z[1:]+z[:-1])/2. if location == 'SunCtr': line = neuflavor elif location == 'SunSrfc': line = neuflavor+6 elif location == 'Sun1AU': line = neuflavor+12 elif location == 'SunSrfc2nd': line = neuflavor+18 elif location == 'Sun1AU2nd': line = neuflavor+24 else: print("No such annihilation location") quit() dn_dz = np.genfromtxt(file)[line,:] if Enu/DMm < z[0]: return 0.0 elif Enu/DMm <= z[-1]: inter = sp.interpolate.interp1d(z,dn_dz) #inter = sp.interpolate.UnivariateSpline(z,dn_dz) PC.act_inter = inter PC.flag_inter = True return inter(Enu/DMm) elif Enu/DMm > z[-1]: return 0.0 else : print("Interpolation Error.") quit() file.close()
def DMSweFluxEarth(Enu,neuflavor,ch,DMm,unit,param,wimp_loc='Earth'): """ Gets dN/dz(z) using de swedish data set. @type Enu : float @param Enu : neutrino energy [GeV] @type neuflavor : integer @param neuflavor : flavor of the neutrino (0 : nu_e, 1 : anu_e, 2 : nu_mu , 3 : anu_mu, 4 : nu_tau, 5 : anu_tau) @type ch : string @param ch : annihilation channel @type DMm : float @param DMm : dark matter mass [GeV] @type unit : string @param unit : 'WimpAnn' or flux @rtype : array @return : z = E/DMm, dN/dz(z) arrays at production (??) """ if PC.act_channel == ch and PC.act_DM_mass == DMm and PC.act_neuflavor == neuflavor and PC.flag_inter: if Enu/DMm < 0.0025: return 0.0 elif Enu/DMm <= 0.9975: return PC.act_inter(Enu/DMm) elif Enu/DMm > 0.9975: return 0.0 else : print("Interpolation error.") quit() else: #print("reloading DM initial flux") DMmstring = format(DMm,'.0f') filename = "wa-m"+str(DMmstring)+"-ch"+str(ch_wimpsim[ch])+"-earth-sum.dat" file = open(datDMFluxSweden + filename,'r') bins = np.linspace(0.0,1.,201,endpoint=True) z = (bins[1:]+bins[:-1])/2. #line = neuflavor+12 line = neuflavor dn_dz = np.genfromtxt(file)[line,:] #print(dn_dz) if unit == 'WimpAnn': if Enu/DMm < z[0]: return 0.0 elif Enu/DMm <= z[-1]: inter = sp.interpolate.interp1d(z,dn_dz) PC.act_inter = inter PC.flag_inter = True return inter(Enu/DMm) elif Enu/DMm > z[-1]: return 0.0 else : print("Interpolation Error.") quit() file.close() elif unit == 'flux': z = z*DMm dn_dz = factor * dn_dz if Enu < z[0]: return 0.0 elif Enu <= z[-1]: inter = sp.interpolate.interp1d(z,dn_dz) #inter = sp.interpolate.UnivariateSpline(z,dn_dz) PC.act_inter = inter PC.flag_inter = True #print(inter(Enu)) return inter(Enu) elif Enu > z[-1]: return 0.0 else : print("Interpolation Error.") quit() file.close() else: print("No such data") quit()