示例#1
0
def PlotAdiabaticityParameter(param,sparam = PC.PhysicsConstants()):
    """ Plots the adiabaticity parameter from for a given energy range on the sun.
    
    @type   param   :   physicsconstants
    @param  param   :   set of physical parameters used to make the plot.
    @type   sparam  :   physicsconstants
    @param  sparam  :   standard parameters
    
    @rtype          :   plot
    @return         :   generates the spectra plot
    """
    
    import Scientific.Functions.Derivatives as sfd
    
    
    Sun = bd.Sun()
    
    print Sun.rdensity(sfd.DerivVar(0.5))
    
    ## th_24 resonance search
    
    E = np.arange(1.0,1000.0,10.0)
    
    adiabaticity_s1 = (np.sin(2.0*param.th24)**2/np.cos(2.0*param.th24))*(param.dmsq41/(2.0*E*param.GeV))*()
    adiabaticity_s2 = (np.sin(2.0*param.th24)**2/np.cos(2.0*param.th24))*(param.dmsq51/(2.0*E*param.GeV))*()
示例#2
0
def PlotCompareProbabilitiesMC(param,sparam = PC.PhysicsConstants(),plot_path = "../plots/"):
    """ Plot osc. probabilities from MC compared with analitic calculation of probabilities.
    
    @type   param   :   physicsconstants
    @param  param   :   set of physical parameters used to make the plot.
    @type   sparam  :   physicsconstants
    @param  sparam  :   standard parameters
    
    @rtype          :   plot
    @return         :   generates probability comparison plot
    """
    fig = plt.figure()
    
    Enumin  = 1.0
    Enumax  = 1.0e3
    Enustep = 10.0
    
    Enu = np.arange(Enumin,Enumax,Enustep)

    # param1

    param.name  =  "2+3"
    param.neutype = "neutrino"
    datapath = "../data/myMC/"+param.name+"/"+param.neutype+"/"

    inter_nu, inter_anu = DM.DMOscProbabilitiesMC(param,False, datapath = datapath, crosscheck = False)    
    mc_osc_prob  = [float(inter_nu(E)) for E in Enu]
    
    # sparam
    sparam.name = "STD"
    param.neutype = "neutrino"
    sdatapath = "../data/myMC/"+sparam.name+"/"+sparam.neutype+"/"
    
    inter_nu, inter_anu = DM.DMOscProbabilitiesMC(sparam,False, datapath = sdatapath, crosscheck = False)    
    smc_osc_prob  = [float(inter_nu(E)) for E in Enu]
    
    # analitic
    
    ana_osc_prob = [no.AvgNeuProb_RK_STD(0,1,E*param.GeV,param)+no.AvgNeuProb_RK_STD(1,1,E*param.GeV,param)+no.AvgNeuProb_RK_STD(2,1,E*param.GeV,param) for E in Enu]
    
    plt.plot(Enu,mc_osc_prob,label = 'MC-2+3')
    plt.plot(Enu,smc_osc_prob,label = 'MC-STD')
    plt.plot(Enu,ana_osc_prob,label = 'ANA')
    
    plt.legend()
    
#    path = "../plots/"
    filename = "PlotCompareProbabilitiesMC.png"
    plt.savefig(plot_path+filename)                
示例#3
0
    
    + From now on to check or review this code refer to
    
    Neutrino nucleus interaction rates at a low-energy beta beam facility
    Julien Serreau, Cristina Volpe
    Phys.Rev. C70 (2004) 055502
    arXiv : hep-ph/0403293
    
"""

import numpy as np
import scipy as sp
import scipy.interpolate as interpolate
import neutrinocommon.physconst.physicsconstants as PC

pc = PC.PhysicsConstants()


def FermiFunction(W, Z=2):
    """ Returns the Fermi function F(+/-Z,W) for Z = 2, evaluated using the	#
    method in the reference, correct to within 1%.			#
    
    Ref.: J. Phys. G: Nucl. Phys. 11, 359 (1985)			  

    @type   W  :  float
    @param  W  :  energy [eV]

    @rtype         :   float
    @return        :   fermi function value [dimensionless?]
    """
    me = pc.electron_mass * pc.GeV
示例#4
0
def PlotSingleNeuCompositionCompare(E,body,param,sparam = PC.PhysicsConstants()):
    """ Plots the composition of a single mass neutrino state.
    
    E        :    neutrino energy [eV]
    body     :    body with the asociated density profile.
    param    :    set of physical parameters used to make the plot. param can be a list.
    sparam   :    standard parameters
    """
    fig = plt.figure()
    ax = plt.subplot(111)
    
    mpl.rcParams['axes.labelsize'] = "x-large"
    mpl.rcParams['xtick.labelsize'] = "x-large"
    mpl.rcParams['legend.fontsize'] = "small"
    
    mpl.rcParams['font.size'] = 18    
    
    colors = ['b', 'g', 'r', 'c', 'm', 'y', 'k']
    linestyles = ['--','-.',':','-','-']
    
    #B Initializing variables
    param.Refresh()
    fM2 = no.flavorM2(param)
    sparam.Refresh()
    fM2STD = no.flavorM2(sparam)
    R = np.arange(1.0,0.01,-0.001)
    Rho = map(lambda r : body.rdensity(r), R)
    #E Initializing variables
    #B Estimating Energy Scale
    if(E/param.MeV <= 500.0) :
        scale =  param.MeV
        scalen = "MeV"
    elif(E/param.GeV <= 500.0) :
        scale =  param.GeV
        scalen = "GeV"
    else :
        scale =  param.TeV
        scalen = "TeV"
    #E Estimating Energy Scale
    
    #B Adding title
    #tit = "Energy : "+str(E/scale)+" "+scalen+ " Parameters :"#+" $\\th_{12}$ = " + str(param.th12) + " $\\th_{23}$ = " + str(param.th23) + " $\\th_{13}$ = "+str(param.th13)
    #atit = []
    #[[ atit.append(" $\\theta_{"+str(j)+str(i)+"}$ = "+format(param.th[j][i],'.4f')) for i in range(1,param.numneu+1) if i>j] for j in range(1,param.numneu+1) ]
    #[[ atit.append(" $\\Delta m^2_{"+str(i)+str(j)+"}$ = "+format(param.dm2[j][i],'.4f')) for i in range(1,param.numneu+1) if i>j and j == 1] for j in range(1,param.numneu+1) ]
    ##[[ atit.append(" $\\Delta m^2_{"+str(j)+str(i)+"}$ = "+format(param.dm2[j][i],'.4f')) for i in range(1,param.numneu+1) if i>j and j == 1] for j in range(1,param.numneu+1) ]
    #for i in range(len(atit)):
    #    tit = tit + atit[i]
    #plt.suptitle(tit,horizontalalignment='center')    
    #E Adding title
    
    ##B PLOTTING MASS BASIS AS FUNCTION OF FLAVOR BASIS
    for i in [1]:
        #fig.add_subplot(2,param.numneu,i+1)
        flavor = False
        NeuComp = map(lambda x : no.NeuComposition(i,E, x, body, fM2, param,flavor),R)
        plt.xlabel(r"$\rho \mathrm{[g/cm^{3}]}$")
        pp = []
        for k in range(param.numneu):
            kNeuComp = map(lambda x: x[k],NeuComp)
            
            # log interpolator
            rholog = gt.LogSpaceEnergies(float(Rho[0]),float(Rho[-1]),100)
            
            #print rholog , float(Rho[0]),float(Rho[-1])
            rholog[-1] = Rho[-1]
            
            inter_neu = interpolate.interp1d(Rho,kNeuComp)
            logkNeuComp = map(inter_neu,rholog)
            
            if k == 3:
                #pp.append(plt.plot(Rho,kNeuComp,'o-',color = 'r',markevery = 10,markeredgewidth = 0.0, ms = 2.0))
                pp.append(plt.plot(rholog,logkNeuComp,'x-',color = 'r',markevery = 10,markeredgewidth = 0.0, ms = 2.0,aa = True,solid_joinstyle = 'bevel'))
            elif k == 4:
                pp.append(plt.plot(Rho,kNeuComp,'o-',color = 'r',markevery = 10,markeredgewidth = 0.0, ms = 2.0))
            else :
                pp.append(plt.plot(Rho,kNeuComp,linestyle = linestyles[k] ,color = 'r'))
        if i<=2 :
            NeuCompSTD = map(lambda x : no.NeuComposition(i,E, x, body, fM2STD, sparam,flavor),R)
            for k in range(sparam.numneu):
                kNeuCompSTD = map(lambda x: x[k],NeuCompSTD)
                plt.plot(Rho,kNeuCompSTD, color = 'k', linestyle = linestyles[k])
        #Solar density
        #ps = plt.vlines(150, 0.0, 1.0, linestyle = "dashed", label = r"$\rho_S$")
        #B plt format
        plt.title(r"Composition of $\nu_"+str(i+1)+"$")
        plt.semilogx()
        plt.ylim(0.0,1.0)
        plt.xlim(1.0,150.0)
        plt.yticks(np.arange(0.0,1.1,0.1))
        xtt = [1.0,5.0,10.0,30.0,100.0]#,150.0]
        #plt.xticks(xtt)
        ax.set_xticks(xtt)
	ax.set_xticklabels(['$1$','$5$','$10$','$30$','$100$'])#,'$\\rho_\\odot = 150$'])
        
        #plt.xscale()
        #B LEGEND
        plots = [] 
        for e in pp :
            plots.append(e[0])
        #plots.append(ps)
        leg = ["$\\nu_e$","$\\nu_\mu$","$\\nu_\\tau$"]
        ss =  ["$\\nu_{s"+str(i)+"}$" for i in np.arange(1,param.numneu-3+1,1)]
        if ss != []:
            leg.extend(ss)
        leg = plt.legend(plots,leg,loc = 6,fancybox=True,bbox_to_anchor = (0.05, 0.75))
        leg.get_frame().set_alpha(0.25)
        #E LEGEND            
        #E plt format
        
        #B EXTRA LEGEND
        box1t = osb.TextArea("STD", textprops=dict(color="k"))
        box1d = osb.DrawingArea(60, 20, 0, 0)
        el1 = ptc.Ellipse((10, 10), width=5, height=5, angle=0, fc="k", edgecolor = 'none')
        box1d.add_artist(el1)
        
        box2t = osb.TextArea("2+3", textprops=dict(color="k"))
        box2d = osb.DrawingArea(60, 20, 0, 0)
        el2 = ptc.Ellipse((10, 10), width=5, height=5, angle=0, fc="r", edgecolor = 'none')
        box2d.add_artist(el2)
        
        box1 = osb.HPacker(children=[box1t, box1d],
                  align="center",
                  pad=0, sep=1)
        
        box2 = osb.HPacker(children=[box2t, box2d],
                  align="center",
                  pad=0, sep=5)
        
        anchored_box1 = osb.AnchoredOffsetbox(loc=9,
                                     child=box1, pad=5.0,
                                     frameon=False,
                                     #bbox_to_anchor=(0., 1.02),
                                     #bbox_transform=ax.transAxes,
                                     borderpad=0.,
                                     )
        
        anchored_box2 = osb.AnchoredOffsetbox(loc=9,
                                     child=box2, pad=6.0,
                                     frameon=False,
                                     #bbox_to_anchor=(0., 1.02),
                                     #bbox_transform=ax.transAxes,
                                     borderpad=0.,
                                     )    
        
        ax.add_artist(anchored_box1)
        ax.add_artist(anchored_box2)
        #E EXTRA LEGEND
        
    ##E PLOTTING MASS BASIS AS FUNCTION OF FLAVOR BASIS

    #plt.suptitle("*Dashed colored lines are 3-flavor standard oscillations.", x = 0.15, y = 0.03)
    path = "../plots/"
    filename = "PlotNeuComposition_E_"+str(E/scale)+"_"+scalen+"_FIG2.eps"
    plt.savefig(path + filename, dpi = 1200)    
示例#5
0
def PlotNeuCompositionCompare(E,body,param,sparam = PC.PhysicsConstants(),plot_path = "../plots/",xlim = None, fmt = "png"):
    """ Plots the composition of neutrinos as a function of mass states, flavors, and density. Compares with STD.
    
    E        :    neutrino energy [eV]
    body     :    body with the asociated density profile.
    param    :    set of physical parameters used to make the plot. param can be a list.
    sparam   :    standard parameters
    """
    fig = plt.figure(figsize = (4*param.numneu,8))
    colors = ['b', 'g', 'r', 'c', 'm', 'y', 'k']
    #B Initializing variables
    param.Refresh()
    fM2 = no.flavorM2(param)
    fM2STD = no.flavorM2(sparam)
    R = np.arange(1.0,0.01,-0.001)
    Rho = map(lambda r : body.rdensity(r), R)
    #E Initializing variables
    #B Estimating Energy Scale
    if(E/param.MeV <= 500.0) :
        scale =  param.MeV
        scalen = "MeV"
    elif(E/param.GeV <= 500.0) :
        scale =  param.GeV
        scalen = "GeV"
    else :
        scale =  param.TeV
        scalen = "TeV"
    #E Estimating Energy Scale
    #B Adding title
    
    tit = "Energy : "+str(E/scale)+" "+scalen+ " Parameters :"#+" $\\th_{12}$ = " + str(param.th12) + " $\\th_{23}$ = " + str(param.th23) + " $\\th_{13}$ = "+str(param.th13)
    atit = []
    try:
        [[ atit.append(" $\\theta_{"+str(j)+str(i)+"}$ = "+format(param.th[j][i],'.4f')) for i in range(1,param.numneu+1) if i>j] for j in range(1,param.numneu+1) ]
        [ atit.append(" $\\Delta m^2_{"+str(j)+str(1)+"}$ = "+format(param.dm2[1][j],'.3e')) for j in range(2,param.numneu+1) ]
    except TypeError:
        [[ atit.append(" $\\theta_{"+str(j)+str(i)+"}$ = "+"{:.4}".format(param.th[j][i])) for i in range(1,param.numneu+1) if i>j] for j in range(1,param.numneu+1) ]
        [ atit.append(" $\\Delta m^2_{"+str(j)+str(1)+"}$ = "+"{:.3}".format(param.dm2[1][j])) for j in range(2,param.numneu+1) ]
        
    for i in range(len(atit)):
        tit = tit + atit[i]
    plt.suptitle(tit,horizontalalignment='center')
    
    #E Adding title
    ##B PLOTTING MASS BASIS AS FUNCTION OF FLAVOR BASIS
    for i in np.arange(0,param.numneu,1):
        fig.add_subplot(2,param.numneu,i+1)
        flavor = False
        NeuComp = map(lambda x : no.NeuComposition(i,E, x, body, fM2, param,flavor),R)
        plt.xlabel(r"$\rho \mathrm{[g/cm^{3}]}$")
        pp = []
        for k in range(param.numneu):
            kNeuComp = map(lambda x: x[k],NeuComp)
            pp.append(plt.plot(Rho,kNeuComp, color = colors[k],lw = 3))
        if i<=2 :
            NeuCompSTD = map(lambda x : no.NeuComposition(i,E, x, body, fM2STD, sparam,flavor),R)
            for k in range(sparam.numneu):
                kNeuCompSTD = map(lambda x: x[k],NeuCompSTD)
                plt.plot(Rho,kNeuCompSTD, color = colors[k], linestyle = 'dashed',lw = 3)
        #Solar density
        ps = plt.vlines(150, 0.0, 1.0, linestyle = "dashed", label = r"$\rho_S$")
        #B plt format
        plt.title(r"Composition of $\nu_"+str(i+1)+"$")
        plt.semilogx()
        plt.ylim(0.0,1.0)
        plt.xlim(0.0,1000.0)
        plt.yticks(np.arange(0.0,1.1,0.1))
        #plt.xscale()
        if xlim == None :
            plt.xlim(Rho[0],Rho[-1])      
        else : 
            plt.xlim(xlim)            
        if i == param.numneu - 1 :
            plots = [] 
            for e in pp :
                plots.append(e[0])
            plots.append(ps)
            leg = ["$\\nu_e$","$\\nu_\mu$","$\\nu_\\tau$"]
            ss =  ["$\\nu_{s"+str(i)+"}$" for i in np.arange(1,param.numneu-3+1,1)]
            if ss != []:
                leg.extend(ss)
            #leg.append("$\\rho_\odot$")
            plt.legend(plots,leg,bbox_to_anchor = (1.5, 0.90))
        fig.subplots_adjust(left=0.05, right=0.85,hspace = 0.35)#,wspace = 0.25, top = 0.95, bottom = 0.05)
        #E plt format
    ##E PLOTTING MASS BASIS AS FUNCTION OF FLAVOR BASIS
    ##B PLOTTING FLAVOR BASIS AS FUNCTION OF MASS BASIS    
    for i in np.arange(param.numneu,2*param.numneu,1):
        fig.add_subplot(2,param.numneu,i+1)
        flavor = True
        NeuComp = map(lambda x : no.NeuComposition(i-param.numneu,E, x, body, fM2, param,flavor),R)
        plt.xlabel(r"$\rho \mathrm{[g/cm^{-3}]}$")
        pp = []
        for k in range(param.numneu):
            kNeuComp = map(lambda x: x[k],NeuComp)
            pp.append(plt.plot(Rho,kNeuComp, color = colors[k],lw = 3))
        if i<=2+param.numneu :
            NeuCompSTD = map(lambda x : no.NeuComposition(i-param.numneu,E, x, body, fM2STD, sparam,flavor),R)
            for k in range(sparam.numneu):
                kNeuCompSTD = map(lambda x: x[k],NeuCompSTD)
                plt.plot(Rho,kNeuCompSTD, color = colors[k], linestyle = 'dashed',lw = 3)
        #Solar density
        ps = plt.vlines(150, 0.0, 1.0, linestyle = "dashed", label = r"$\rho_S$")
        #B plt format
        if i == param.numneu :
            plt.title(r"Composition of $\nu_e$")
        elif i == param.numneu + 1:
            plt.title(r"Composition of $\nu_\mu$")
        elif i == param.numneu + 2:
            plt.title(r"Composition of $\nu_\tau$")
        else : 
            plt.title(r"Composition of $\nu_{s"+str(i+1-param.numneu-3)+"}$")
            
        plt.semilogx()
        plt.ylim(0.0,1.0)
        plt.yticks(np.arange(0.0,1.1,0.1))
        
        if xlim == None :
            plt.xlim(Rho[0],Rho[-1])      
        else : 
            plt.xlim(xlim)    
        #plt.xscale()
        if i == 2*param.numneu - 1 :
            plots = [] 
            for e in pp :
                plots.append(e[0])
            plots.append(ps) 
            leg =  ["$\\nu_{"+str(i)+"}$" for i in np.arange(1,param.numneu+1,1)]
            #leg.append("$\\rho_\odot$")
            plt.legend(plots,leg,bbox_to_anchor = (1.5, 0.90))
        fig.subplots_adjust(left=0.05, right=0.85)#, top = 0.85, bottom = 0.05)        
    ##E PLOTTING FLAVOR BASIS AS FUNCTION OF MASS BASIS
    plt.suptitle("*Dashed colored lines are 3-flavor standard oscillations.", x = 0.15, y = 0.03)

    filename = "PlotNeuComposition_E_"+str(E/scale)+"_"+scalen+"_"+param.name+"."+fmt
    plt.savefig(plot_path + filename)